1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5900e8ecSAndrew Rist * distributed with this work for additional information
6*5900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at
10*5900e8ecSAndrew Rist *
11*5900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5900e8ecSAndrew Rist *
13*5900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist * KIND, either express or implied. See the License for the
17*5900e8ecSAndrew Rist * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist * under the License.
19*5900e8ecSAndrew Rist *
20*5900e8ecSAndrew Rist *************************************************************/
21*5900e8ecSAndrew Rist
22*5900e8ecSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir #include <svtools/brwbox.hxx>
27cdf0e10cSrcweir #include <svtools/brwhead.hxx>
28cdf0e10cSrcweir #include "datwin.hxx"
29cdf0e10cSrcweir #include <tools/debug.hxx>
30cdf0e10cSrcweir #include <tools/stream.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <functional>
33cdf0e10cSrcweir #include <algorithm>
34cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
35cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
36cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
37cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp>
38cdf0e10cSrcweir #include <tools/multisel.hxx>
39cdf0e10cSrcweir #include "brwimpl.hxx"
40cdf0e10cSrcweir
41cdf0e10cSrcweir DBG_NAME(BrowseBox)
42cdf0e10cSrcweir
43cdf0e10cSrcweir extern const char* BrowseBoxCheckInvariants( const void* pVoid );
44cdf0e10cSrcweir
45cdf0e10cSrcweir DECLARE_LIST( BrowserColumns, BrowserColumn* )
46cdf0e10cSrcweir
47cdf0e10cSrcweir #define SCROLL_FLAGS (SCROLL_CLIP | SCROLL_NOCHILDREN)
48cdf0e10cSrcweir #define getDataWindow() ((BrowserDataWin*)pDataWin)
49cdf0e10cSrcweir
50cdf0e10cSrcweir using namespace com::sun::star::accessibility::AccessibleEventId;
51cdf0e10cSrcweir using namespace com::sun::star::accessibility::AccessibleTableModelChangeType;
52cdf0e10cSrcweir using com::sun::star::accessibility::AccessibleTableModelChange;
53cdf0e10cSrcweir using com::sun::star::lang::XComponent;
54cdf0e10cSrcweir using namespace ::com::sun::star::uno;
55cdf0e10cSrcweir using namespace svt;
56cdf0e10cSrcweir
57cdf0e10cSrcweir //-------------------------------------------------------------------
58cdf0e10cSrcweir
59cdf0e10cSrcweir #ifdef DBG_MI
DoLog_Impl(const BrowseBox * pThis,const char * pWhat,const char * pWho)60cdf0e10cSrcweir void DoLog_Impl( const BrowseBox *pThis, const char *pWhat, const char *pWho )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir SvFileStream aLog( "d:\\cursor.log", STREAM_WRITE|STREAM_NOCREATE );
63cdf0e10cSrcweir if ( aLog.IsOpen() )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir aLog.Seek( STREAM_SEEK_TO_END );
66cdf0e10cSrcweir String aEntry( (long) pThis );
67cdf0e10cSrcweir aEntry += "(row=";
68cdf0e10cSrcweir aEntry += pThis->GetCurRow();
69cdf0e10cSrcweir aEntry += "): ";
70cdf0e10cSrcweir aEntry += pWhat;
71cdf0e10cSrcweir aEntry += " from ";
72cdf0e10cSrcweir aEntry += pWho;
73cdf0e10cSrcweir aEntry += " => ";
74cdf0e10cSrcweir aEntry += pThis->GetCursorHideCount();
75cdf0e10cSrcweir aLog.WriteLine( aEntry );
76cdf0e10cSrcweir }
77cdf0e10cSrcweir }
78cdf0e10cSrcweir #endif
79cdf0e10cSrcweir
80cdf0e10cSrcweir namespace
81cdf0e10cSrcweir {
disposeAndClearHeaderCell(::svt::BrowseBoxImpl::THeaderCellMap & _rHeaderCell)82cdf0e10cSrcweir void disposeAndClearHeaderCell(::svt::BrowseBoxImpl::THeaderCellMap& _rHeaderCell)
83cdf0e10cSrcweir {
84cdf0e10cSrcweir ::std::for_each(
85cdf0e10cSrcweir _rHeaderCell.begin(),
86cdf0e10cSrcweir _rHeaderCell.end(),
87cdf0e10cSrcweir ::svt::BrowseBoxImpl::THeaderCellMapFunctorDispose()
88cdf0e10cSrcweir );
89cdf0e10cSrcweir _rHeaderCell.clear();
90cdf0e10cSrcweir }
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir //===================================================================
94cdf0e10cSrcweir
ConstructImpl(BrowserMode nMode)95cdf0e10cSrcweir void BrowseBox::ConstructImpl( BrowserMode nMode )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->ConstructImpl", this );
98cdf0e10cSrcweir bMultiSelection = sal_False;
99cdf0e10cSrcweir pColSel = 0;
100cdf0e10cSrcweir pDataWin = 0;
101cdf0e10cSrcweir pVScroll = 0;
102cdf0e10cSrcweir
103cdf0e10cSrcweir pDataWin = new BrowserDataWin( this );
104cdf0e10cSrcweir pCols = new BrowserColumns;
105cdf0e10cSrcweir m_pImpl.reset( new ::svt::BrowseBoxImpl() );
106cdf0e10cSrcweir
107cdf0e10cSrcweir aGridLineColor = Color( COL_LIGHTGRAY );
108cdf0e10cSrcweir InitSettings_Impl( this );
109cdf0e10cSrcweir InitSettings_Impl( pDataWin );
110cdf0e10cSrcweir
111cdf0e10cSrcweir bBootstrapped = sal_False;
112cdf0e10cSrcweir nDataRowHeight = 0;
113cdf0e10cSrcweir nTitleLines = 1;
114cdf0e10cSrcweir nFirstCol = 0;
115cdf0e10cSrcweir nTopRow = 0;
116cdf0e10cSrcweir nCurRow = BROWSER_ENDOFSELECTION;
117cdf0e10cSrcweir nCurColId = 0;
118cdf0e10cSrcweir bResizing = sal_False;
119cdf0e10cSrcweir bSelect = sal_False;
120cdf0e10cSrcweir bSelecting = sal_False;
121cdf0e10cSrcweir bScrolling = sal_False;
122cdf0e10cSrcweir bSelectionIsVisible = sal_False;
123cdf0e10cSrcweir bNotToggleSel = sal_False;
124cdf0e10cSrcweir bRowDividerDrag = sal_False;
125cdf0e10cSrcweir bHit = sal_False;
126cdf0e10cSrcweir mbInteractiveRowHeight = sal_False;
127cdf0e10cSrcweir bHideSelect = sal_False;
128cdf0e10cSrcweir bHideCursor = NO_CURSOR_HIDE;
129cdf0e10cSrcweir nRowCount = 0;
130cdf0e10cSrcweir m_bFocusOnlyCursor = sal_True;
131cdf0e10cSrcweir m_aCursorColor = COL_TRANSPARENT;
132cdf0e10cSrcweir m_nCurrentMode = 0;
133cdf0e10cSrcweir nControlAreaWidth = USHRT_MAX;
134cdf0e10cSrcweir uRow.nSel = BROWSER_ENDOFSELECTION;
135cdf0e10cSrcweir
136cdf0e10cSrcweir aHScroll.SetLineSize(1);
137cdf0e10cSrcweir aHScroll.SetScrollHdl( LINK( this, BrowseBox, ScrollHdl ) );
138cdf0e10cSrcweir aHScroll.SetEndScrollHdl( LINK( this, BrowseBox, EndScrollHdl ) );
139cdf0e10cSrcweir pDataWin->Show();
140cdf0e10cSrcweir
141cdf0e10cSrcweir SetMode( nMode );
142cdf0e10cSrcweir bSelectionIsVisible = bKeepHighlight;
143cdf0e10cSrcweir bHasFocus = HasChildPathFocus();
144cdf0e10cSrcweir getDataWindow()->nCursorHidden =
145cdf0e10cSrcweir ( bHasFocus ? 0 : 1 ) + ( GetUpdateMode() ? 0 : 1 );
146cdf0e10cSrcweir LOG( this, "ConstructImpl", "*" );
147cdf0e10cSrcweir }
148cdf0e10cSrcweir
149cdf0e10cSrcweir //-------------------------------------------------------------------
150cdf0e10cSrcweir
BrowseBox(Window * pParent,WinBits nBits,BrowserMode nMode)151cdf0e10cSrcweir BrowseBox::BrowseBox( Window* pParent, WinBits nBits, BrowserMode nMode )
152cdf0e10cSrcweir :Control( pParent, nBits | WB_3DLOOK )
153cdf0e10cSrcweir ,DragSourceHelper( this )
154cdf0e10cSrcweir ,DropTargetHelper( this )
155cdf0e10cSrcweir ,aHScroll( this, WinBits( WB_HSCROLL ) )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir DBG_CTOR( BrowseBox, NULL );
158cdf0e10cSrcweir ConstructImpl( nMode );
159cdf0e10cSrcweir }
160cdf0e10cSrcweir
161cdf0e10cSrcweir //-------------------------------------------------------------------
162cdf0e10cSrcweir
BrowseBox(Window * pParent,const ResId & rId,BrowserMode nMode)163cdf0e10cSrcweir BrowseBox::BrowseBox( Window* pParent, const ResId& rId, BrowserMode nMode )
164cdf0e10cSrcweir :Control( pParent, rId )
165cdf0e10cSrcweir ,DragSourceHelper( this )
166cdf0e10cSrcweir ,DropTargetHelper( this )
167cdf0e10cSrcweir ,aHScroll( this, WinBits(WB_HSCROLL) )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir DBG_CTOR( BrowseBox, NULL );
170cdf0e10cSrcweir ConstructImpl(nMode);
171cdf0e10cSrcweir }
172cdf0e10cSrcweir //-------------------------------------------------------------------
173cdf0e10cSrcweir
~BrowseBox()174cdf0e10cSrcweir BrowseBox::~BrowseBox()
175cdf0e10cSrcweir {
176cdf0e10cSrcweir DBG_DTOR(BrowseBox,BrowseBoxCheckInvariants);
177cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p~", this );
178cdf0e10cSrcweir
179cdf0e10cSrcweir if ( m_pImpl->m_pAccessible )
180cdf0e10cSrcweir {
181cdf0e10cSrcweir disposeAndClearHeaderCell(m_pImpl->m_aColHeaderCellMap);
182cdf0e10cSrcweir disposeAndClearHeaderCell(m_pImpl->m_aRowHeaderCellMap);
183cdf0e10cSrcweir m_pImpl->m_pAccessible->dispose();
184cdf0e10cSrcweir }
185cdf0e10cSrcweir
186cdf0e10cSrcweir Hide();
187cdf0e10cSrcweir delete getDataWindow()->pHeaderBar;
188cdf0e10cSrcweir delete getDataWindow()->pCornerWin;
189cdf0e10cSrcweir delete pDataWin;
190cdf0e10cSrcweir delete pVScroll;
191cdf0e10cSrcweir
192cdf0e10cSrcweir // free columns-space
193cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < pCols->Count(); ++n )
194cdf0e10cSrcweir delete pCols->GetObject(n);
195cdf0e10cSrcweir delete pCols;
196cdf0e10cSrcweir delete pColSel;
197cdf0e10cSrcweir if ( bMultiSelection )
198cdf0e10cSrcweir delete uRow.pSel;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
201cdf0e10cSrcweir //-------------------------------------------------------------------
202cdf0e10cSrcweir
GetCursorHideCount() const203cdf0e10cSrcweir short BrowseBox::GetCursorHideCount() const
204cdf0e10cSrcweir {
205cdf0e10cSrcweir return getDataWindow()->nCursorHidden;
206cdf0e10cSrcweir }
207cdf0e10cSrcweir
208cdf0e10cSrcweir //-------------------------------------------------------------------
209cdf0e10cSrcweir
DoShowCursor(const char * pWhoLogs)210cdf0e10cSrcweir void BrowseBox::DoShowCursor( const char *
211cdf0e10cSrcweir #ifdef DBG_MI
212cdf0e10cSrcweir pWhoLogs
213cdf0e10cSrcweir #endif
214cdf0e10cSrcweir )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir short nHiddenCount = --getDataWindow()->nCursorHidden;
217cdf0e10cSrcweir if (PaintCursorIfHiddenOnce())
218cdf0e10cSrcweir {
219cdf0e10cSrcweir if (1 == nHiddenCount)
220cdf0e10cSrcweir DrawCursor();
221cdf0e10cSrcweir }
222cdf0e10cSrcweir else
223cdf0e10cSrcweir {
224cdf0e10cSrcweir if (0 == nHiddenCount)
225cdf0e10cSrcweir DrawCursor();
226cdf0e10cSrcweir }
227cdf0e10cSrcweir LOG( this, "DoShowCursor", pWhoLogs );
228cdf0e10cSrcweir }
229cdf0e10cSrcweir
230cdf0e10cSrcweir //-------------------------------------------------------------------
231cdf0e10cSrcweir
DoHideCursor(const char * pWhoLogs)232cdf0e10cSrcweir void BrowseBox::DoHideCursor( const char *
233cdf0e10cSrcweir #ifdef DBG_MI
234cdf0e10cSrcweir pWhoLogs
235cdf0e10cSrcweir #endif
236cdf0e10cSrcweir )
237cdf0e10cSrcweir {
238cdf0e10cSrcweir short nHiddenCount = ++getDataWindow()->nCursorHidden;
239cdf0e10cSrcweir if (PaintCursorIfHiddenOnce())
240cdf0e10cSrcweir {
241cdf0e10cSrcweir if (2 == nHiddenCount)
242cdf0e10cSrcweir DrawCursor();
243cdf0e10cSrcweir }
244cdf0e10cSrcweir else
245cdf0e10cSrcweir {
246cdf0e10cSrcweir if (1 == nHiddenCount)
247cdf0e10cSrcweir DrawCursor();
248cdf0e10cSrcweir }
249cdf0e10cSrcweir LOG( this, "DoHideCursor", pWhoLogs );
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir //-------------------------------------------------------------------
253cdf0e10cSrcweir
SetRealRowCount(const String & rRealRowCount)254cdf0e10cSrcweir void BrowseBox::SetRealRowCount( const String &rRealRowCount )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir getDataWindow()->aRealRowCount = rRealRowCount;
257cdf0e10cSrcweir }
258cdf0e10cSrcweir
259cdf0e10cSrcweir //-------------------------------------------------------------------
260cdf0e10cSrcweir
SetFont(const Font & rNewFont)261cdf0e10cSrcweir void BrowseBox::SetFont( const Font& rNewFont )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
264cdf0e10cSrcweir pDataWin->SetFont( rNewFont );
265cdf0e10cSrcweir ImpGetDataRowHeight();
266cdf0e10cSrcweir }
267cdf0e10cSrcweir
268cdf0e10cSrcweir //-------------------------------------------------------------------
269cdf0e10cSrcweir
GetDefaultColumnWidth(const String & _rText) const270cdf0e10cSrcweir sal_uLong BrowseBox::GetDefaultColumnWidth( const String& _rText ) const
271cdf0e10cSrcweir {
272cdf0e10cSrcweir return GetDataWindow().GetTextWidth( _rText ) + GetDataWindow().GetTextWidth( '0' ) * 4;
273cdf0e10cSrcweir }
274cdf0e10cSrcweir
275cdf0e10cSrcweir //-------------------------------------------------------------------
276cdf0e10cSrcweir
InsertHandleColumn(sal_uLong nWidth)277cdf0e10cSrcweir void BrowseBox::InsertHandleColumn( sal_uLong nWidth )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
280cdf0e10cSrcweir
281cdf0e10cSrcweir pCols->Insert( new BrowserColumn( 0, Image(), String(), nWidth, GetZoom(), 0 ), (sal_uLong) 0 );
282cdf0e10cSrcweir FreezeColumn( 0 );
283cdf0e10cSrcweir
284cdf0e10cSrcweir // Headerbar anpassen
285cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
286cdf0e10cSrcweir {
287cdf0e10cSrcweir getDataWindow()->pHeaderBar->SetPosSizePixel(
288cdf0e10cSrcweir Point(nWidth, 0),
289cdf0e10cSrcweir Size( GetOutputSizePixel().Width() - nWidth, GetTitleHeight() )
290cdf0e10cSrcweir );
291cdf0e10cSrcweir }
292cdf0e10cSrcweir
293cdf0e10cSrcweir /*if ( getDataWindow()->pHeaderBar )
294cdf0e10cSrcweir getDataWindow()->pHeaderBar->InsertItem( USHRT_MAX - 1,
295cdf0e10cSrcweir "", nWidth, HIB_FIXEDPOS|HIB_FIXED, 0 );*/
296cdf0e10cSrcweir ColumnInserted( 0 );
297cdf0e10cSrcweir }
298cdf0e10cSrcweir
299cdf0e10cSrcweir //-------------------------------------------------------------------
InsertDataColumn(sal_uInt16 nItemId,const Image & rImage,long nWidth,HeaderBarItemBits nBits,sal_uInt16 nPos)300cdf0e10cSrcweir void BrowseBox::InsertDataColumn( sal_uInt16 nItemId, const Image& rImage,
301cdf0e10cSrcweir long nWidth, HeaderBarItemBits nBits, sal_uInt16 nPos )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
304cdf0e10cSrcweir
305cdf0e10cSrcweir pCols->Insert( new BrowserColumn( nItemId, rImage, String(), nWidth, GetZoom(), nBits ),
306cdf0e10cSrcweir Min( nPos, (sal_uInt16)(pCols->Count()) ) );
307cdf0e10cSrcweir if ( nCurColId == 0 )
308cdf0e10cSrcweir nCurColId = nItemId;
309cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir // Handlecolumn nicht in der Headerbar
312cdf0e10cSrcweir sal_uInt16 nHeaderPos = nPos;
313cdf0e10cSrcweir if (nHeaderPos != HEADERBAR_APPEND && !GetColumnId(0))
314cdf0e10cSrcweir nHeaderPos--;
315cdf0e10cSrcweir getDataWindow()->pHeaderBar->InsertItem(
316cdf0e10cSrcweir nItemId, rImage, nWidth, nBits, nHeaderPos );
317cdf0e10cSrcweir }
318cdf0e10cSrcweir ColumnInserted( nPos );
319cdf0e10cSrcweir }
320cdf0e10cSrcweir
321cdf0e10cSrcweir //-------------------------------------------------------------------
322cdf0e10cSrcweir
InsertDataColumn(sal_uInt16 nItemId,const XubString & rText,long nWidth,HeaderBarItemBits nBits,sal_uInt16 nPos)323cdf0e10cSrcweir void BrowseBox::InsertDataColumn( sal_uInt16 nItemId, const XubString& rText,
324cdf0e10cSrcweir long nWidth, HeaderBarItemBits nBits, sal_uInt16 nPos )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
327cdf0e10cSrcweir
328cdf0e10cSrcweir pCols->Insert( new BrowserColumn( nItemId, Image(), rText, nWidth, GetZoom(), nBits ),
329cdf0e10cSrcweir Min( nPos, (sal_uInt16)(pCols->Count()) ) );
330cdf0e10cSrcweir if ( nCurColId == 0 )
331cdf0e10cSrcweir nCurColId = nItemId;
332cdf0e10cSrcweir
333cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir // Handlecolumn nicht in der Headerbar
336cdf0e10cSrcweir sal_uInt16 nHeaderPos = nPos;
337cdf0e10cSrcweir if (nHeaderPos != HEADERBAR_APPEND && !GetColumnId(0))
338cdf0e10cSrcweir nHeaderPos--;
339cdf0e10cSrcweir getDataWindow()->pHeaderBar->InsertItem(
340cdf0e10cSrcweir nItemId, rText, nWidth, nBits, nHeaderPos );
341cdf0e10cSrcweir }
342cdf0e10cSrcweir ColumnInserted( nPos );
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
345cdf0e10cSrcweir //-------------------------------------------------------------------
346cdf0e10cSrcweir
InsertDataColumn(sal_uInt16 nItemId,const Image & rImage,const XubString & rText,long nWidth,HeaderBarItemBits nBits,sal_uInt16 nPos,const String * pHelpText)347cdf0e10cSrcweir void BrowseBox::InsertDataColumn( sal_uInt16 nItemId,
348cdf0e10cSrcweir const Image& rImage, const XubString& rText,
349cdf0e10cSrcweir long nWidth, HeaderBarItemBits nBits, sal_uInt16 nPos,
350cdf0e10cSrcweir const String* pHelpText )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
353cdf0e10cSrcweir
354cdf0e10cSrcweir pCols->Insert( new BrowserColumn( nItemId, rImage, rText, nWidth, GetZoom(), nBits ),
355cdf0e10cSrcweir Min( nPos, (sal_uInt16)(pCols->Count()) ) );
356cdf0e10cSrcweir if ( nCurColId == 0 )
357cdf0e10cSrcweir nCurColId = nItemId;
358cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
359cdf0e10cSrcweir {
360cdf0e10cSrcweir // Handlecolumn nicht in der Headerbar
361cdf0e10cSrcweir sal_uInt16 nHeaderPos = nPos;
362cdf0e10cSrcweir if (nHeaderPos != HEADERBAR_APPEND && !GetColumnId(0))
363cdf0e10cSrcweir nHeaderPos--;
364cdf0e10cSrcweir
365cdf0e10cSrcweir getDataWindow()->pHeaderBar->InsertItem(
366cdf0e10cSrcweir nItemId, rImage, rText, nWidth, nBits, nHeaderPos );
367cdf0e10cSrcweir if( pHelpText && !rText.Len() )
368cdf0e10cSrcweir {
369cdf0e10cSrcweir getDataWindow()->pHeaderBar->SetHelpText(
370cdf0e10cSrcweir nItemId, *pHelpText );
371cdf0e10cSrcweir }
372cdf0e10cSrcweir }
373cdf0e10cSrcweir ColumnInserted( nPos );
374cdf0e10cSrcweir }
375cdf0e10cSrcweir //-------------------------------------------------------------------
ToggleSelectedColumn()376cdf0e10cSrcweir sal_uInt16 BrowseBox::ToggleSelectedColumn()
377cdf0e10cSrcweir {
378cdf0e10cSrcweir sal_uInt16 nSelectedColId = USHRT_MAX;
379cdf0e10cSrcweir if ( pColSel && pColSel->GetSelectCount() )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir DoHideCursor( "ToggleSelectedColumn" );
382cdf0e10cSrcweir ToggleSelection();
383cdf0e10cSrcweir nSelectedColId = pCols->GetObject(pColSel->FirstSelected())->GetId();
384cdf0e10cSrcweir pColSel->SelectAll(sal_False);
385cdf0e10cSrcweir }
386cdf0e10cSrcweir return nSelectedColId;
387cdf0e10cSrcweir }
388cdf0e10cSrcweir // -----------------------------------------------------------------------------
SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId)389cdf0e10cSrcweir void BrowseBox::SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId)
390cdf0e10cSrcweir {
391cdf0e10cSrcweir if ( pColSel && _nSelectedColumnId != USHRT_MAX )
392cdf0e10cSrcweir {
393cdf0e10cSrcweir pColSel->Select( GetColumnPos( _nSelectedColumnId ) );
394cdf0e10cSrcweir ToggleSelection();
395cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->SetToggledSelectedColumn", this );
396cdf0e10cSrcweir DoShowCursor( "SetToggledSelectedColumn" );
397cdf0e10cSrcweir }
398cdf0e10cSrcweir }
399cdf0e10cSrcweir // -----------------------------------------------------------------------------
FreezeColumn(sal_uInt16 nItemId,sal_Bool bFreeze)400cdf0e10cSrcweir void BrowseBox::FreezeColumn( sal_uInt16 nItemId, sal_Bool bFreeze )
401cdf0e10cSrcweir {
402cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
403cdf0e10cSrcweir
404cdf0e10cSrcweir // never unfreeze the handle-column
405cdf0e10cSrcweir if ( nItemId == 0 && !bFreeze )
406cdf0e10cSrcweir return;
407cdf0e10cSrcweir
408cdf0e10cSrcweir // get the position in the current array
409cdf0e10cSrcweir sal_uInt16 nItemPos = GetColumnPos( nItemId );
410cdf0e10cSrcweir if ( nItemPos >= pCols->Count() )
411cdf0e10cSrcweir // not available!
412cdf0e10cSrcweir return;
413cdf0e10cSrcweir
414cdf0e10cSrcweir // doesn't the state change?
415cdf0e10cSrcweir if ( pCols->GetObject(nItemPos)->IsFrozen() == bFreeze )
416cdf0e10cSrcweir return;
417cdf0e10cSrcweir
418cdf0e10cSrcweir // remark the column selection
419cdf0e10cSrcweir sal_uInt16 nSelectedColId = ToggleSelectedColumn();
420cdf0e10cSrcweir
421cdf0e10cSrcweir // freeze or unfreeze?
422cdf0e10cSrcweir if ( bFreeze )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir // to be moved?
425cdf0e10cSrcweir if ( nItemPos != 0 && !pCols->GetObject(nItemPos-1)->IsFrozen() )
426cdf0e10cSrcweir {
427cdf0e10cSrcweir // move to the right of the last frozen column
428cdf0e10cSrcweir sal_uInt16 nFirstScrollable = FrozenColCount();
429cdf0e10cSrcweir BrowserColumn *pColumn = pCols->GetObject(nItemPos);
430cdf0e10cSrcweir pCols->Remove( (sal_uLong) nItemPos );
431cdf0e10cSrcweir nItemPos = nFirstScrollable;
432cdf0e10cSrcweir pCols->Insert( pColumn, (sal_uLong) nItemPos );
433cdf0e10cSrcweir }
434cdf0e10cSrcweir
435cdf0e10cSrcweir // adjust the number of the first scrollable and visible column
436cdf0e10cSrcweir if ( nFirstCol <= nItemPos )
437cdf0e10cSrcweir nFirstCol = nItemPos + 1;
438cdf0e10cSrcweir }
439cdf0e10cSrcweir else
440cdf0e10cSrcweir {
441cdf0e10cSrcweir // to be moved?
442cdf0e10cSrcweir if ( nItemPos != FrozenColCount()-1 )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir // move to the leftmost scrollable colum
445cdf0e10cSrcweir sal_uInt16 nFirstScrollable = FrozenColCount();
446cdf0e10cSrcweir BrowserColumn *pColumn = pCols->GetObject(nItemPos);
447cdf0e10cSrcweir pCols->Remove( (sal_uLong) nItemPos );
448cdf0e10cSrcweir nItemPos = nFirstScrollable;
449cdf0e10cSrcweir pCols->Insert( pColumn, (sal_uLong) nItemPos );
450cdf0e10cSrcweir }
451cdf0e10cSrcweir
452cdf0e10cSrcweir // adjust the number of the first scrollable and visible column
453cdf0e10cSrcweir nFirstCol = nItemPos;
454cdf0e10cSrcweir }
455cdf0e10cSrcweir
456cdf0e10cSrcweir // toggle the freeze-state of the column
457cdf0e10cSrcweir pCols->GetObject(nItemPos)->Freeze( bFreeze );
458cdf0e10cSrcweir
459cdf0e10cSrcweir // align the scrollbar-range
460cdf0e10cSrcweir UpdateScrollbars();
461cdf0e10cSrcweir
462cdf0e10cSrcweir // repaint
463cdf0e10cSrcweir Control::Invalidate();
464cdf0e10cSrcweir getDataWindow()->Invalidate();
465cdf0e10cSrcweir
466cdf0e10cSrcweir // remember the column selection
467cdf0e10cSrcweir SetToggledSelectedColumn(nSelectedColId);
468cdf0e10cSrcweir }
469cdf0e10cSrcweir
470cdf0e10cSrcweir //-------------------------------------------------------------------
471cdf0e10cSrcweir
SetColumnPos(sal_uInt16 nColumnId,sal_uInt16 nPos)472cdf0e10cSrcweir void BrowseBox::SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir // never set pos of the handle-column
475cdf0e10cSrcweir if ( nColumnId == 0 )
476cdf0e10cSrcweir return;
477cdf0e10cSrcweir
478cdf0e10cSrcweir // do not move handle column
479cdf0e10cSrcweir if (nPos == 0 && !pCols->GetObject(0)->GetId())
480cdf0e10cSrcweir return;
481cdf0e10cSrcweir
482cdf0e10cSrcweir // get the position in the current array
483cdf0e10cSrcweir sal_uInt16 nOldPos = GetColumnPos( nColumnId );
484cdf0e10cSrcweir if ( nOldPos >= pCols->Count() )
485cdf0e10cSrcweir // not available!
486cdf0e10cSrcweir return;
487cdf0e10cSrcweir
488cdf0e10cSrcweir // does the state change?
489cdf0e10cSrcweir if (nOldPos != nPos)
490cdf0e10cSrcweir {
491cdf0e10cSrcweir // remark the column selection
492cdf0e10cSrcweir sal_uInt16 nSelectedColId = ToggleSelectedColumn();
493cdf0e10cSrcweir
494cdf0e10cSrcweir // determine old column area
495cdf0e10cSrcweir Size aDataWinSize( pDataWin->GetSizePixel() );
496cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
497cdf0e10cSrcweir aDataWinSize.Height() += getDataWindow()->pHeaderBar->GetSizePixel().Height();
498cdf0e10cSrcweir
499cdf0e10cSrcweir Rectangle aFromRect( GetFieldRect( nColumnId) );
500cdf0e10cSrcweir aFromRect.Right() += 2*MIN_COLUMNWIDTH;
501cdf0e10cSrcweir
502cdf0e10cSrcweir sal_uInt16 nNextPos = nOldPos + 1;
503cdf0e10cSrcweir if ( nOldPos > nPos )
504cdf0e10cSrcweir nNextPos = nOldPos - 1;
505cdf0e10cSrcweir
506cdf0e10cSrcweir BrowserColumn *pNextCol = pCols->GetObject(nNextPos);
507cdf0e10cSrcweir Rectangle aNextRect(GetFieldRect( pNextCol->GetId() ));
508cdf0e10cSrcweir
509cdf0e10cSrcweir // move column internally
510cdf0e10cSrcweir pCols->Insert( pCols->Remove( nOldPos ), nPos );
511cdf0e10cSrcweir
512cdf0e10cSrcweir // determine new column area
513cdf0e10cSrcweir Rectangle aToRect( GetFieldRect( nColumnId ) );
514cdf0e10cSrcweir aToRect.Right() += 2*MIN_COLUMNWIDTH;
515cdf0e10cSrcweir
516cdf0e10cSrcweir // do scroll, let redraw
517cdf0e10cSrcweir if( pDataWin->GetBackground().IsScrollable() )
518cdf0e10cSrcweir {
519cdf0e10cSrcweir long nScroll = -aFromRect.GetWidth();
520cdf0e10cSrcweir Rectangle aScrollArea;
521cdf0e10cSrcweir if ( nOldPos > nPos )
522cdf0e10cSrcweir {
523cdf0e10cSrcweir long nFrozenWidth = GetFrozenWidth();
524cdf0e10cSrcweir if ( aToRect.Left() < nFrozenWidth )
525cdf0e10cSrcweir aToRect.Left() = nFrozenWidth;
526cdf0e10cSrcweir aScrollArea = Rectangle(Point(aToRect.Left(),0),
527cdf0e10cSrcweir Point(aNextRect.Right(),aDataWinSize.Height()));
528cdf0e10cSrcweir nScroll *= -1; // reverse direction
529cdf0e10cSrcweir }
530cdf0e10cSrcweir else
531cdf0e10cSrcweir aScrollArea = Rectangle(Point(aNextRect.Left(),0),
532cdf0e10cSrcweir Point(aToRect.Right(),aDataWinSize.Height()));
533cdf0e10cSrcweir
534cdf0e10cSrcweir pDataWin->Scroll( nScroll, 0, aScrollArea );
535cdf0e10cSrcweir aToRect.Top() = 0;
536cdf0e10cSrcweir aToRect.Bottom() = aScrollArea.Bottom();
537cdf0e10cSrcweir Invalidate( aToRect );
538cdf0e10cSrcweir }
539cdf0e10cSrcweir else
540cdf0e10cSrcweir pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN );
541cdf0e10cSrcweir
542cdf0e10cSrcweir // adjust header bar positions
543cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
544cdf0e10cSrcweir {
545cdf0e10cSrcweir sal_uInt16 nNewPos = nPos;
546cdf0e10cSrcweir if ( !GetColumnId(0) )
547cdf0e10cSrcweir --nNewPos;
548cdf0e10cSrcweir getDataWindow()->pHeaderBar->MoveItem(nColumnId,nNewPos);
549cdf0e10cSrcweir }
550cdf0e10cSrcweir // remember the column selection
551cdf0e10cSrcweir SetToggledSelectedColumn(nSelectedColId);
552cdf0e10cSrcweir
553cdf0e10cSrcweir if ( isAccessibleAlive() )
554cdf0e10cSrcweir {
555cdf0e10cSrcweir commitTableEvent(
556cdf0e10cSrcweir TABLE_MODEL_CHANGED,
557cdf0e10cSrcweir makeAny( AccessibleTableModelChange(
558cdf0e10cSrcweir DELETE,
559cdf0e10cSrcweir 0,
560cdf0e10cSrcweir GetRowCount(),
561cdf0e10cSrcweir nOldPos,
562cdf0e10cSrcweir nOldPos
563cdf0e10cSrcweir )
564cdf0e10cSrcweir ),
565cdf0e10cSrcweir Any()
566cdf0e10cSrcweir );
567cdf0e10cSrcweir
568cdf0e10cSrcweir commitTableEvent(
569cdf0e10cSrcweir TABLE_MODEL_CHANGED,
570cdf0e10cSrcweir makeAny( AccessibleTableModelChange(
571cdf0e10cSrcweir INSERT,
572cdf0e10cSrcweir 0,
573cdf0e10cSrcweir GetRowCount(),
574cdf0e10cSrcweir nPos,
575cdf0e10cSrcweir nPos
576cdf0e10cSrcweir )
577cdf0e10cSrcweir ),
578cdf0e10cSrcweir Any()
579cdf0e10cSrcweir );
580cdf0e10cSrcweir }
581cdf0e10cSrcweir }
582cdf0e10cSrcweir
583cdf0e10cSrcweir }
584cdf0e10cSrcweir
585cdf0e10cSrcweir //-------------------------------------------------------------------
586cdf0e10cSrcweir
SetColumnMode(sal_uInt16 nColumnId,BrowserColumnMode nFlags)587cdf0e10cSrcweir void BrowseBox::SetColumnMode( sal_uInt16 nColumnId, BrowserColumnMode nFlags )
588cdf0e10cSrcweir {
589cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
590cdf0e10cSrcweir
591cdf0e10cSrcweir // never set mode of the handle-column
592cdf0e10cSrcweir if ( nColumnId == 0 )
593cdf0e10cSrcweir return;
594cdf0e10cSrcweir
595cdf0e10cSrcweir // get the position in the current array
596cdf0e10cSrcweir sal_uInt16 nColumnPos = GetColumnPos( nColumnId );
597cdf0e10cSrcweir if ( nColumnPos >= pCols->Count() )
598cdf0e10cSrcweir // not available!
599cdf0e10cSrcweir return;
600cdf0e10cSrcweir
601cdf0e10cSrcweir // does the state change?
602cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nColumnPos);
603cdf0e10cSrcweir if ( pCol->Flags() != nFlags )
604cdf0e10cSrcweir {
605cdf0e10cSrcweir pCol->Flags() = sal::static_int_cast< HeaderBarItemBits >(nFlags);
606cdf0e10cSrcweir
607cdf0e10cSrcweir // redraw visible colums
608cdf0e10cSrcweir if ( GetUpdateMode() && ( pCol->IsFrozen() || nColumnPos > nFirstCol ) )
609cdf0e10cSrcweir Invalidate( Rectangle( Point(0,0),
610cdf0e10cSrcweir Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) );
611cdf0e10cSrcweir }
612cdf0e10cSrcweir }
613cdf0e10cSrcweir
614cdf0e10cSrcweir //-------------------------------------------------------------------
615cdf0e10cSrcweir
SetColumnTitle(sal_uInt16 nItemId,const String & rTitle)616cdf0e10cSrcweir void BrowseBox::SetColumnTitle( sal_uInt16 nItemId, const String& rTitle )
617cdf0e10cSrcweir {
618cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
619cdf0e10cSrcweir
620cdf0e10cSrcweir // never set title of the handle-column
621cdf0e10cSrcweir if ( nItemId == 0 )
622cdf0e10cSrcweir return;
623cdf0e10cSrcweir
624cdf0e10cSrcweir // get the position in the current array
625cdf0e10cSrcweir sal_uInt16 nItemPos = GetColumnPos( nItemId );
626cdf0e10cSrcweir if ( nItemPos >= pCols->Count() )
627cdf0e10cSrcweir // not available!
628cdf0e10cSrcweir return;
629cdf0e10cSrcweir
630cdf0e10cSrcweir // does the state change?
631cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nItemPos);
632cdf0e10cSrcweir if ( pCol->Title() != rTitle )
633cdf0e10cSrcweir {
634cdf0e10cSrcweir ::rtl::OUString sNew(rTitle);
635cdf0e10cSrcweir ::rtl::OUString sOld(pCol->Title());
636cdf0e10cSrcweir
637cdf0e10cSrcweir pCol->Title() = rTitle;
638cdf0e10cSrcweir
639cdf0e10cSrcweir // Headerbar-Column anpassen
640cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
641cdf0e10cSrcweir getDataWindow()->pHeaderBar->SetItemText(
642cdf0e10cSrcweir nItemId ? nItemId : USHRT_MAX - 1, rTitle );
643cdf0e10cSrcweir else
644cdf0e10cSrcweir {
645cdf0e10cSrcweir // redraw visible colums
646cdf0e10cSrcweir if ( GetUpdateMode() && ( pCol->IsFrozen() || nItemPos > nFirstCol ) )
647cdf0e10cSrcweir Invalidate( Rectangle( Point(0,0),
648cdf0e10cSrcweir Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) );
649cdf0e10cSrcweir }
650cdf0e10cSrcweir
651cdf0e10cSrcweir if ( isAccessibleAlive() )
652cdf0e10cSrcweir {
653cdf0e10cSrcweir commitTableEvent( TABLE_COLUMN_DESCRIPTION_CHANGED,
654cdf0e10cSrcweir makeAny( sNew ),
655cdf0e10cSrcweir makeAny( sOld )
656cdf0e10cSrcweir );
657cdf0e10cSrcweir }
658cdf0e10cSrcweir }
659cdf0e10cSrcweir }
660cdf0e10cSrcweir
661cdf0e10cSrcweir //-------------------------------------------------------------------
662cdf0e10cSrcweir
SetColumnWidth(sal_uInt16 nItemId,sal_uLong nWidth)663cdf0e10cSrcweir void BrowseBox::SetColumnWidth( sal_uInt16 nItemId, sal_uLong nWidth )
664cdf0e10cSrcweir {
665cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
666cdf0e10cSrcweir
667cdf0e10cSrcweir // get the position in the current array
668cdf0e10cSrcweir sal_uInt16 nItemPos = GetColumnPos( nItemId );
669cdf0e10cSrcweir if ( nItemPos >= pCols->Count() )
670cdf0e10cSrcweir return;
671cdf0e10cSrcweir
672cdf0e10cSrcweir // does the state change?
673cdf0e10cSrcweir nWidth = QueryColumnResize( nItemId, nWidth );
674cdf0e10cSrcweir if ( nWidth >= LONG_MAX || pCols->GetObject(nItemPos)->Width() != nWidth )
675cdf0e10cSrcweir {
676cdf0e10cSrcweir long nOldWidth = pCols->GetObject(nItemPos)->Width();
677cdf0e10cSrcweir
678cdf0e10cSrcweir // ggf. letzte Spalte anpassen
679cdf0e10cSrcweir if ( IsVisible() && nItemPos == pCols->Count() - 1 )
680cdf0e10cSrcweir {
681cdf0e10cSrcweir long nMaxWidth = pDataWin->GetSizePixel().Width();
682cdf0e10cSrcweir nMaxWidth -= getDataWindow()->bAutoSizeLastCol
683cdf0e10cSrcweir ? GetFieldRect(nItemId).Left()
684cdf0e10cSrcweir : GetFrozenWidth();
685cdf0e10cSrcweir if ( ( (BrowserDataWin*)pDataWin )->bAutoSizeLastCol || nWidth > (sal_uLong)nMaxWidth )
686cdf0e10cSrcweir {
687cdf0e10cSrcweir nWidth = nMaxWidth > 16 ? nMaxWidth : nOldWidth;
688cdf0e10cSrcweir nWidth = QueryColumnResize( nItemId, nWidth );
689cdf0e10cSrcweir }
690cdf0e10cSrcweir }
691cdf0e10cSrcweir
692cdf0e10cSrcweir // OV
693cdf0e10cSrcweir // In AutoSizeLastColumn() wird SetColumnWidth mit nWidth==0xffff
694cdf0e10cSrcweir // gerufen. Deshalb muss hier nochmal geprueft werden, ob sich die
695cdf0e10cSrcweir // Breite tatsaechlich geaendert hat.
696cdf0e10cSrcweir if( (sal_uLong)nOldWidth == nWidth )
697cdf0e10cSrcweir return;
698cdf0e10cSrcweir
699cdf0e10cSrcweir // soll die Aenderung sofort dargestellt werden?
700cdf0e10cSrcweir sal_Bool bUpdate = GetUpdateMode() &&
701cdf0e10cSrcweir ( pCols->GetObject(nItemPos)->IsFrozen() || nItemPos >= nFirstCol );
702cdf0e10cSrcweir
703cdf0e10cSrcweir if ( bUpdate )
704cdf0e10cSrcweir {
705cdf0e10cSrcweir // Selection hiden
706cdf0e10cSrcweir DoHideCursor( "SetColumnWidth" );
707cdf0e10cSrcweir ToggleSelection();
708cdf0e10cSrcweir //!getDataWindow()->Update();
709cdf0e10cSrcweir //!Control::Update();
710cdf0e10cSrcweir }
711cdf0e10cSrcweir
712cdf0e10cSrcweir // Breite setzen
713cdf0e10cSrcweir pCols->GetObject(nItemPos)->SetWidth(nWidth, GetZoom());
714cdf0e10cSrcweir #if 0
715cdf0e10cSrcweir if ( nItemPos != pCols->Count() - 1 )
716cdf0e10cSrcweir {
717cdf0e10cSrcweir long nLastColMaxWidth = pDataWin->GetSizePixel().Width() -
718cdf0e10cSrcweir GetFieldRect(GetColumnId(pCols->Count()-1)).Left();
719cdf0e10cSrcweir pCols->GetObject(pCols->Count()-1)->Width() = nLastColMaxWidth;
720cdf0e10cSrcweir }
721cdf0e10cSrcweir #endif
722cdf0e10cSrcweir
723cdf0e10cSrcweir // scroll and invalidate
724cdf0e10cSrcweir if ( bUpdate )
725cdf0e10cSrcweir {
726cdf0e10cSrcweir // X-Pos der veraenderten Spalte ermitteln
727cdf0e10cSrcweir long nX = 0;
728cdf0e10cSrcweir for ( sal_uInt16 nCol = 0; nCol < nItemPos; ++nCol )
729cdf0e10cSrcweir {
730cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nCol);
731cdf0e10cSrcweir if ( pCol->IsFrozen() || nCol >= nFirstCol )
732cdf0e10cSrcweir nX += pCol->Width();
733cdf0e10cSrcweir }
734cdf0e10cSrcweir
735cdf0e10cSrcweir // eigentliches scroll+invalidate
736cdf0e10cSrcweir pDataWin->SetClipRegion();
737cdf0e10cSrcweir sal_Bool bSelVis = bSelectionIsVisible;
738cdf0e10cSrcweir bSelectionIsVisible = sal_False;
739cdf0e10cSrcweir if( GetBackground().IsScrollable() )
740cdf0e10cSrcweir {
741cdf0e10cSrcweir
742cdf0e10cSrcweir Rectangle aScrRect( nX + std::min( (sal_uLong)nOldWidth, nWidth ), 0,
743cdf0e10cSrcweir GetSizePixel().Width() , // the header is longer than the datawin
744cdf0e10cSrcweir pDataWin->GetPosPixel().Y() - 1 );
745cdf0e10cSrcweir Control::Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS );
746cdf0e10cSrcweir aScrRect.Bottom() = pDataWin->GetSizePixel().Height();
747cdf0e10cSrcweir getDataWindow()->Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS );
748cdf0e10cSrcweir Rectangle aInvRect( nX, 0, nX + std::max( nWidth, (sal_uLong)nOldWidth ), USHRT_MAX );
749cdf0e10cSrcweir Control::Invalidate( aInvRect, INVALIDATE_NOCHILDREN );
750cdf0e10cSrcweir ( (BrowserDataWin*)pDataWin )->Invalidate( aInvRect );
751cdf0e10cSrcweir }
752cdf0e10cSrcweir else
753cdf0e10cSrcweir {
754cdf0e10cSrcweir Control::Invalidate( INVALIDATE_NOCHILDREN );
755cdf0e10cSrcweir getDataWindow()->Window::Invalidate( INVALIDATE_NOCHILDREN );
756cdf0e10cSrcweir }
757cdf0e10cSrcweir
758cdf0e10cSrcweir
759cdf0e10cSrcweir //!getDataWindow()->Update();
760cdf0e10cSrcweir //!Control::Update();
761cdf0e10cSrcweir bSelectionIsVisible = bSelVis;
762cdf0e10cSrcweir ToggleSelection();
763cdf0e10cSrcweir DoShowCursor( "SetColumnWidth" );
764cdf0e10cSrcweir }
765cdf0e10cSrcweir UpdateScrollbars();
766cdf0e10cSrcweir
767cdf0e10cSrcweir // Headerbar-Column anpassen
768cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
769cdf0e10cSrcweir getDataWindow()->pHeaderBar->SetItemSize(
770cdf0e10cSrcweir nItemId ? nItemId : USHRT_MAX - 1, nWidth );
771cdf0e10cSrcweir
772cdf0e10cSrcweir // adjust last column
773cdf0e10cSrcweir if ( nItemPos != pCols->Count() - 1 )
774cdf0e10cSrcweir AutoSizeLastColumn();
775cdf0e10cSrcweir
776cdf0e10cSrcweir }
777cdf0e10cSrcweir }
778cdf0e10cSrcweir
779cdf0e10cSrcweir //-------------------------------------------------------------------
780cdf0e10cSrcweir
AutoSizeLastColumn()781cdf0e10cSrcweir void BrowseBox::AutoSizeLastColumn()
782cdf0e10cSrcweir {
783cdf0e10cSrcweir if ( getDataWindow()->bAutoSizeLastCol &&
784cdf0e10cSrcweir getDataWindow()->GetUpdateMode() )
785cdf0e10cSrcweir {
786cdf0e10cSrcweir sal_uInt16 nId = GetColumnId( (sal_uInt16)pCols->Count() - 1 );
787cdf0e10cSrcweir SetColumnWidth( nId, LONG_MAX );
788cdf0e10cSrcweir ColumnResized( nId );
789cdf0e10cSrcweir }
790cdf0e10cSrcweir }
791cdf0e10cSrcweir
792cdf0e10cSrcweir //-------------------------------------------------------------------
793cdf0e10cSrcweir
RemoveColumn(sal_uInt16 nItemId)794cdf0e10cSrcweir void BrowseBox::RemoveColumn( sal_uInt16 nItemId )
795cdf0e10cSrcweir {
796cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
797cdf0e10cSrcweir
798cdf0e10cSrcweir // Spaltenposition ermitteln
799cdf0e10cSrcweir sal_uInt16 nPos = GetColumnPos(nItemId);
800cdf0e10cSrcweir if ( nPos >= ColCount() )
801cdf0e10cSrcweir // nicht vorhanden
802cdf0e10cSrcweir return;
803cdf0e10cSrcweir
804cdf0e10cSrcweir // Spaltenselektion korrigieren
805cdf0e10cSrcweir if ( pColSel )
806cdf0e10cSrcweir pColSel->Remove( nPos );
807cdf0e10cSrcweir
808cdf0e10cSrcweir // Spaltencursor korrigieren
809cdf0e10cSrcweir if ( nCurColId == nItemId )
810cdf0e10cSrcweir nCurColId = 0;
811cdf0e10cSrcweir
812cdf0e10cSrcweir // Spalte entfernen
813cdf0e10cSrcweir delete( pCols->Remove( (sal_uLong) nPos ));
814cdf0e10cSrcweir // OJ #93534#
815cdf0e10cSrcweir if ( nFirstCol >= nPos && nFirstCol > FrozenColCount() )
816cdf0e10cSrcweir {
817cdf0e10cSrcweir OSL_ENSURE(nFirstCol > 0,"FirstCol must be greater zero!");
818cdf0e10cSrcweir --nFirstCol;
819cdf0e10cSrcweir }
820cdf0e10cSrcweir
821cdf0e10cSrcweir // Handlecolumn nicht in der Headerbar
822cdf0e10cSrcweir if (nItemId)
823cdf0e10cSrcweir {
824cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
825cdf0e10cSrcweir getDataWindow()->pHeaderBar->RemoveItem( nItemId );
826cdf0e10cSrcweir }
827cdf0e10cSrcweir else
828cdf0e10cSrcweir {
829cdf0e10cSrcweir // Headerbar anpassen
830cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
831cdf0e10cSrcweir {
832cdf0e10cSrcweir getDataWindow()->pHeaderBar->SetPosSizePixel(
833cdf0e10cSrcweir Point(0, 0),
834cdf0e10cSrcweir Size( GetOutputSizePixel().Width(), GetTitleHeight() )
835cdf0e10cSrcweir );
836cdf0e10cSrcweir }
837cdf0e10cSrcweir }
838cdf0e10cSrcweir
839cdf0e10cSrcweir // vertikalen Scrollbar korrigieren
840cdf0e10cSrcweir UpdateScrollbars();
841cdf0e10cSrcweir
842cdf0e10cSrcweir // ggf. Repaint ausl"osen
843cdf0e10cSrcweir if ( GetUpdateMode() )
844cdf0e10cSrcweir {
845cdf0e10cSrcweir getDataWindow()->Invalidate();
846cdf0e10cSrcweir Control::Invalidate();
847cdf0e10cSrcweir if ( getDataWindow()->bAutoSizeLastCol && nPos ==ColCount() )
848cdf0e10cSrcweir SetColumnWidth( GetColumnId( nPos - 1 ), LONG_MAX );
849cdf0e10cSrcweir }
850cdf0e10cSrcweir
851cdf0e10cSrcweir if ( isAccessibleAlive() )
852cdf0e10cSrcweir {
853cdf0e10cSrcweir commitTableEvent(
854cdf0e10cSrcweir TABLE_MODEL_CHANGED,
855cdf0e10cSrcweir makeAny( AccessibleTableModelChange( DELETE,
856cdf0e10cSrcweir 0,
857cdf0e10cSrcweir GetRowCount(),
858cdf0e10cSrcweir nPos,
859cdf0e10cSrcweir nPos
860cdf0e10cSrcweir )
861cdf0e10cSrcweir ),
862cdf0e10cSrcweir Any()
863cdf0e10cSrcweir );
864cdf0e10cSrcweir
865cdf0e10cSrcweir commitHeaderBarEvent(
866cdf0e10cSrcweir CHILD,
867cdf0e10cSrcweir Any(),
868cdf0e10cSrcweir makeAny( CreateAccessibleColumnHeader( nPos ) ),
869cdf0e10cSrcweir sal_True
870cdf0e10cSrcweir );
871cdf0e10cSrcweir }
872cdf0e10cSrcweir }
873cdf0e10cSrcweir
874cdf0e10cSrcweir //-------------------------------------------------------------------
875cdf0e10cSrcweir
RemoveColumns()876cdf0e10cSrcweir void BrowseBox::RemoveColumns()
877cdf0e10cSrcweir {
878cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
879cdf0e10cSrcweir
880cdf0e10cSrcweir unsigned int nOldCount = pCols->Count();
881cdf0e10cSrcweir // alle Spalten entfernen
882cdf0e10cSrcweir while ( pCols->Count() )
883cdf0e10cSrcweir delete ( pCols->Remove( (sal_uLong) 0 ));
884cdf0e10cSrcweir
885cdf0e10cSrcweir // Spaltenselektion korrigieren
886cdf0e10cSrcweir if ( pColSel )
887cdf0e10cSrcweir {
888cdf0e10cSrcweir pColSel->SelectAll(sal_False);
889cdf0e10cSrcweir pColSel->SetTotalRange( Range( 0, 0 ) );
890cdf0e10cSrcweir }
891cdf0e10cSrcweir
892cdf0e10cSrcweir // Spaltencursor korrigieren
893cdf0e10cSrcweir nCurColId = 0;
894cdf0e10cSrcweir nFirstCol = 0;
895cdf0e10cSrcweir
896cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
897cdf0e10cSrcweir getDataWindow()->pHeaderBar->Clear( );
898cdf0e10cSrcweir
899cdf0e10cSrcweir // vertikalen Scrollbar korrigieren
900cdf0e10cSrcweir UpdateScrollbars();
901cdf0e10cSrcweir
902cdf0e10cSrcweir // ggf. Repaint ausl"osen
903cdf0e10cSrcweir if ( GetUpdateMode() )
904cdf0e10cSrcweir {
905cdf0e10cSrcweir getDataWindow()->Invalidate();
906cdf0e10cSrcweir Control::Invalidate();
907cdf0e10cSrcweir }
908cdf0e10cSrcweir
909cdf0e10cSrcweir if ( isAccessibleAlive() )
910cdf0e10cSrcweir {
911cdf0e10cSrcweir if ( pCols->Count() != nOldCount )
912cdf0e10cSrcweir {
913cdf0e10cSrcweir // all columns should be removed, so we remove the column header bar and append it again
914cdf0e10cSrcweir // to avoid to notify every column remove
915cdf0e10cSrcweir commitBrowseBoxEvent(
916cdf0e10cSrcweir CHILD,
917cdf0e10cSrcweir Any(),
918cdf0e10cSrcweir makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_COLUMNHEADERBAR))
919cdf0e10cSrcweir );
920cdf0e10cSrcweir
921cdf0e10cSrcweir // and now append it again
922cdf0e10cSrcweir commitBrowseBoxEvent(
923cdf0e10cSrcweir CHILD,
924cdf0e10cSrcweir makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_COLUMNHEADERBAR)),
925cdf0e10cSrcweir Any()
926cdf0e10cSrcweir );
927cdf0e10cSrcweir
928cdf0e10cSrcweir // notify a table model change
929cdf0e10cSrcweir commitTableEvent(
930cdf0e10cSrcweir TABLE_MODEL_CHANGED,
931cdf0e10cSrcweir makeAny ( AccessibleTableModelChange( DELETE,
932cdf0e10cSrcweir 0,
933cdf0e10cSrcweir GetRowCount(),
934cdf0e10cSrcweir 0,
935cdf0e10cSrcweir nOldCount
936cdf0e10cSrcweir )
937cdf0e10cSrcweir ),
938cdf0e10cSrcweir Any()
939cdf0e10cSrcweir );
940cdf0e10cSrcweir }
941cdf0e10cSrcweir }
942cdf0e10cSrcweir }
943cdf0e10cSrcweir
944cdf0e10cSrcweir //-------------------------------------------------------------------
945cdf0e10cSrcweir
GetColumnTitle(sal_uInt16 nId) const946cdf0e10cSrcweir String BrowseBox::GetColumnTitle( sal_uInt16 nId ) const
947cdf0e10cSrcweir {
948cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
949cdf0e10cSrcweir
950cdf0e10cSrcweir sal_uInt16 nItemPos = GetColumnPos( nId );
951cdf0e10cSrcweir if ( nItemPos >= pCols->Count() )
952cdf0e10cSrcweir return String();
953cdf0e10cSrcweir return pCols->GetObject(nItemPos)->Title();
954cdf0e10cSrcweir }
955cdf0e10cSrcweir
956cdf0e10cSrcweir //-------------------------------------------------------------------
957cdf0e10cSrcweir
GetRowCount() const958cdf0e10cSrcweir long BrowseBox::GetRowCount() const
959cdf0e10cSrcweir {
960cdf0e10cSrcweir return nRowCount;
961cdf0e10cSrcweir }
962cdf0e10cSrcweir
963cdf0e10cSrcweir //-------------------------------------------------------------------
964cdf0e10cSrcweir
ColCount() const965cdf0e10cSrcweir sal_uInt16 BrowseBox::ColCount() const
966cdf0e10cSrcweir {
967cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
968cdf0e10cSrcweir
969cdf0e10cSrcweir return (sal_uInt16) pCols->Count();
970cdf0e10cSrcweir }
971cdf0e10cSrcweir
972cdf0e10cSrcweir //-------------------------------------------------------------------
973cdf0e10cSrcweir
ImpGetDataRowHeight() const974cdf0e10cSrcweir long BrowseBox::ImpGetDataRowHeight() const
975cdf0e10cSrcweir {
976cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
977cdf0e10cSrcweir
978cdf0e10cSrcweir BrowseBox *pThis = (BrowseBox*)this;
979cdf0e10cSrcweir pThis->nDataRowHeight = pThis->CalcReverseZoom(pDataWin->GetTextHeight() + 2);
980cdf0e10cSrcweir pThis->Resize();
981cdf0e10cSrcweir getDataWindow()->Invalidate();
982cdf0e10cSrcweir return nDataRowHeight;
983cdf0e10cSrcweir }
984cdf0e10cSrcweir
985cdf0e10cSrcweir //-------------------------------------------------------------------
986cdf0e10cSrcweir
SetDataRowHeight(long nPixel)987cdf0e10cSrcweir void BrowseBox::SetDataRowHeight( long nPixel )
988cdf0e10cSrcweir {
989cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
990cdf0e10cSrcweir
991cdf0e10cSrcweir nDataRowHeight = CalcReverseZoom(nPixel);
992cdf0e10cSrcweir Resize();
993cdf0e10cSrcweir getDataWindow()->Invalidate();
994cdf0e10cSrcweir }
995cdf0e10cSrcweir
996cdf0e10cSrcweir //-------------------------------------------------------------------
997cdf0e10cSrcweir
SetTitleLines(sal_uInt16 nLines)998cdf0e10cSrcweir void BrowseBox::SetTitleLines( sal_uInt16 nLines )
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1001cdf0e10cSrcweir
1002cdf0e10cSrcweir nTitleLines = nLines;
1003cdf0e10cSrcweir }
1004cdf0e10cSrcweir
1005cdf0e10cSrcweir //-------------------------------------------------------------------
1006cdf0e10cSrcweir
ScrollColumns(long nCols)1007cdf0e10cSrcweir long BrowseBox::ScrollColumns( long nCols )
1008cdf0e10cSrcweir {
1009cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1010cdf0e10cSrcweir
1011cdf0e10cSrcweir if ( nFirstCol + nCols < 0 ||
1012cdf0e10cSrcweir nFirstCol + nCols >= (long)pCols->Count() )
1013cdf0e10cSrcweir //?MI: pCols->GetObject( nFirstCol + nCols )->IsFrozen() )
1014cdf0e10cSrcweir return 0;
1015cdf0e10cSrcweir
1016cdf0e10cSrcweir // implicitly hides cursor while scrolling
1017cdf0e10cSrcweir StartScroll();
1018cdf0e10cSrcweir bScrolling = sal_True;
1019cdf0e10cSrcweir sal_Bool bScrollable = pDataWin->GetBackground().IsScrollable();
1020cdf0e10cSrcweir sal_Bool bInvalidateView = sal_False;
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir // scrolling one column to the right?
1023cdf0e10cSrcweir if ( nCols == 1 )
1024cdf0e10cSrcweir {
1025cdf0e10cSrcweir // update internal value and scrollbar
1026cdf0e10cSrcweir ++nFirstCol;
1027cdf0e10cSrcweir aHScroll.SetThumbPos( nFirstCol - FrozenColCount() );
1028cdf0e10cSrcweir
1029cdf0e10cSrcweir if ( !bScrollable )
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir bInvalidateView = sal_True;
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir else
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir long nDelta = pCols->GetObject(nFirstCol-1)->Width();
1036cdf0e10cSrcweir long nFrozenWidth = GetFrozenWidth();
1037cdf0e10cSrcweir
1038cdf0e10cSrcweir Rectangle aScrollRect( Point( nFrozenWidth + nDelta, 0 ),
1039cdf0e10cSrcweir Size ( GetOutputSizePixel().Width() - nFrozenWidth - nDelta,
1040cdf0e10cSrcweir GetTitleHeight() - 1
1041cdf0e10cSrcweir ) );
1042cdf0e10cSrcweir
1043cdf0e10cSrcweir // scroll the header bar area (if there is no dedicated HeaderBar control)
1044cdf0e10cSrcweir if ( !getDataWindow()->pHeaderBar && nTitleLines )
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir // actually scroll
1047cdf0e10cSrcweir Scroll( -nDelta, 0, aScrollRect, SCROLL_FLAGS );
1048cdf0e10cSrcweir
1049cdf0e10cSrcweir // invalidate the area of the column which was scrolled out to the left hand side
1050cdf0e10cSrcweir Rectangle aInvalidateRect( aScrollRect );
1051cdf0e10cSrcweir aInvalidateRect.Left() = nFrozenWidth;
1052cdf0e10cSrcweir aInvalidateRect.Right() = nFrozenWidth + nDelta - 1;
1053cdf0e10cSrcweir Invalidate( aInvalidateRect );
1054cdf0e10cSrcweir }
1055cdf0e10cSrcweir
1056cdf0e10cSrcweir // scroll the data-area
1057cdf0e10cSrcweir aScrollRect.Bottom() = pDataWin->GetOutputSizePixel().Height();
1058cdf0e10cSrcweir
1059cdf0e10cSrcweir // actually scroll
1060cdf0e10cSrcweir pDataWin->Scroll( -nDelta, 0, aScrollRect, SCROLL_FLAGS );
1061cdf0e10cSrcweir
1062cdf0e10cSrcweir // invalidate the area of the column which was scrolled out to the left hand side
1063cdf0e10cSrcweir aScrollRect.Left() = nFrozenWidth;
1064cdf0e10cSrcweir aScrollRect.Right() = nFrozenWidth + nDelta - 1;
1065cdf0e10cSrcweir getDataWindow()->Invalidate( aScrollRect );
1066cdf0e10cSrcweir }
1067cdf0e10cSrcweir }
1068cdf0e10cSrcweir
1069cdf0e10cSrcweir // scrolling one column to the left?
1070cdf0e10cSrcweir else if ( nCols == -1 )
1071cdf0e10cSrcweir {
1072cdf0e10cSrcweir --nFirstCol;
1073cdf0e10cSrcweir aHScroll.SetThumbPos( nFirstCol - FrozenColCount() );
1074cdf0e10cSrcweir
1075cdf0e10cSrcweir if ( !bScrollable )
1076cdf0e10cSrcweir {
1077cdf0e10cSrcweir bInvalidateView = sal_True;
1078cdf0e10cSrcweir }
1079cdf0e10cSrcweir else
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir long nDelta = pCols->GetObject(nFirstCol)->Width();
1082cdf0e10cSrcweir long nFrozenWidth = GetFrozenWidth();
1083cdf0e10cSrcweir
1084cdf0e10cSrcweir Rectangle aScrollRect( Point( nFrozenWidth, 0 ),
1085cdf0e10cSrcweir Size ( GetOutputSizePixel().Width() - nFrozenWidth,
1086cdf0e10cSrcweir GetTitleHeight() - 1
1087cdf0e10cSrcweir ) );
1088cdf0e10cSrcweir
1089cdf0e10cSrcweir // scroll the header bar area (if there is no dedicated HeaderBar control)
1090cdf0e10cSrcweir if ( !getDataWindow()->pHeaderBar && nTitleLines )
1091cdf0e10cSrcweir {
1092cdf0e10cSrcweir Scroll( nDelta, 0, aScrollRect, SCROLL_FLAGS );
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir
1095cdf0e10cSrcweir // scroll the data-area
1096cdf0e10cSrcweir aScrollRect.Bottom() = pDataWin->GetOutputSizePixel().Height();
1097cdf0e10cSrcweir pDataWin->Scroll( nDelta, 0, aScrollRect, SCROLL_FLAGS );
1098cdf0e10cSrcweir }
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir else
1101cdf0e10cSrcweir {
1102cdf0e10cSrcweir if ( GetUpdateMode() )
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir Invalidate( Rectangle(
1105cdf0e10cSrcweir Point( GetFrozenWidth(), 0 ),
1106cdf0e10cSrcweir Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) );
1107cdf0e10cSrcweir getDataWindow()->Invalidate( Rectangle(
1108cdf0e10cSrcweir Point( GetFrozenWidth(), 0 ),
1109cdf0e10cSrcweir pDataWin->GetSizePixel() ) );
1110cdf0e10cSrcweir }
1111cdf0e10cSrcweir
1112cdf0e10cSrcweir nFirstCol = nFirstCol + (sal_uInt16)nCols;
1113cdf0e10cSrcweir aHScroll.SetThumbPos( nFirstCol - FrozenColCount() );
1114cdf0e10cSrcweir }
1115cdf0e10cSrcweir
1116cdf0e10cSrcweir // ggf. externe Headerbar anpassen
1117cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir long nWidth = 0;
1120cdf0e10cSrcweir for ( sal_uInt16 nCol = 0;
1121cdf0e10cSrcweir nCol < pCols->Count() && nCol < nFirstCol;
1122cdf0e10cSrcweir ++nCol )
1123cdf0e10cSrcweir {
1124cdf0e10cSrcweir // HandleColumn nicht
1125cdf0e10cSrcweir if ( pCols->GetObject(nCol)->GetId() )
1126cdf0e10cSrcweir nWidth += pCols->GetObject(nCol)->Width();
1127cdf0e10cSrcweir }
1128cdf0e10cSrcweir
1129cdf0e10cSrcweir getDataWindow()->pHeaderBar->SetOffset( nWidth );
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir
1132cdf0e10cSrcweir if( bInvalidateView )
1133cdf0e10cSrcweir {
1134cdf0e10cSrcweir Control::Invalidate( INVALIDATE_NOCHILDREN );
1135cdf0e10cSrcweir pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN );
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir
1138cdf0e10cSrcweir // implicitly show cursor after scrolling
1139cdf0e10cSrcweir if ( nCols )
1140cdf0e10cSrcweir {
1141cdf0e10cSrcweir getDataWindow()->Update();
1142cdf0e10cSrcweir Update();
1143cdf0e10cSrcweir }
1144cdf0e10cSrcweir bScrolling = sal_False;
1145cdf0e10cSrcweir EndScroll();
1146cdf0e10cSrcweir
1147cdf0e10cSrcweir return nCols;
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir //-------------------------------------------------------------------
1151cdf0e10cSrcweir
ScrollRows(long nRows)1152cdf0e10cSrcweir long BrowseBox::ScrollRows( long nRows )
1153cdf0e10cSrcweir {
1154cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1155cdf0e10cSrcweir
1156cdf0e10cSrcweir // out of range?
1157cdf0e10cSrcweir if ( getDataWindow()->bNoScrollBack && nRows < 0 )
1158cdf0e10cSrcweir return 0;
1159cdf0e10cSrcweir
1160cdf0e10cSrcweir // compute new top row
1161cdf0e10cSrcweir long nTmpMin = Min( (long)(nTopRow + nRows), (long)(nRowCount - 1) );
1162cdf0e10cSrcweir
1163cdf0e10cSrcweir long nNewTopRow = Max( (long)nTmpMin, (long)0 );
1164cdf0e10cSrcweir
1165cdf0e10cSrcweir if ( nNewTopRow == nTopRow )
1166cdf0e10cSrcweir return 0;
1167cdf0e10cSrcweir
1168cdf0e10cSrcweir sal_uInt16 nVisibleRows =
1169cdf0e10cSrcweir (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
1170cdf0e10cSrcweir
1171cdf0e10cSrcweir VisibleRowsChanged(nNewTopRow, nVisibleRows);
1172cdf0e10cSrcweir
1173cdf0e10cSrcweir // compute new top row again (nTopRow might have changed!)
1174cdf0e10cSrcweir nTmpMin = Min( (long)(nTopRow + nRows), (long)(nRowCount - 1) );
1175cdf0e10cSrcweir
1176cdf0e10cSrcweir nNewTopRow = Max( (long)nTmpMin, (long)0 );
1177cdf0e10cSrcweir
1178cdf0e10cSrcweir StartScroll();
1179cdf0e10cSrcweir
1180cdf0e10cSrcweir // scroll area on screen and/or repaint
1181cdf0e10cSrcweir long nDeltaY = GetDataRowHeight() * ( nNewTopRow - nTopRow );
1182cdf0e10cSrcweir long nOldTopRow = nTopRow;
1183cdf0e10cSrcweir nTopRow = nNewTopRow;
1184cdf0e10cSrcweir
1185cdf0e10cSrcweir if ( GetUpdateMode() )
1186cdf0e10cSrcweir {
1187cdf0e10cSrcweir pVScroll->SetRange( Range( 0L, nRowCount ) );
1188cdf0e10cSrcweir pVScroll->SetThumbPos( nTopRow );
1189cdf0e10cSrcweir
1190cdf0e10cSrcweir if( pDataWin->GetBackground().IsScrollable() &&
1191cdf0e10cSrcweir Abs( nDeltaY ) > 0 &&
1192cdf0e10cSrcweir Abs( nDeltaY ) < pDataWin->GetSizePixel().Height() )
1193cdf0e10cSrcweir {
1194cdf0e10cSrcweir pDataWin->Scroll( 0, (short)-nDeltaY, SCROLL_FLAGS );
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir else
1197cdf0e10cSrcweir getDataWindow()->Invalidate();
1198cdf0e10cSrcweir
1199cdf0e10cSrcweir if ( nTopRow - nOldTopRow )
1200cdf0e10cSrcweir getDataWindow()->Update();
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir
1203cdf0e10cSrcweir EndScroll();
1204cdf0e10cSrcweir
1205cdf0e10cSrcweir return nTopRow - nOldTopRow;
1206cdf0e10cSrcweir }
1207cdf0e10cSrcweir
1208cdf0e10cSrcweir //-------------------------------------------------------------------
1209cdf0e10cSrcweir
ScrollPages(long)1210cdf0e10cSrcweir long BrowseBox::ScrollPages( long )
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir return ScrollRows( pDataWin->GetSizePixel().Height() / GetDataRowHeight() );
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir
1217cdf0e10cSrcweir //-------------------------------------------------------------------
1218cdf0e10cSrcweir
RowModified(long nRow,sal_uInt16 nColId)1219cdf0e10cSrcweir void BrowseBox::RowModified( long nRow, sal_uInt16 nColId )
1220cdf0e10cSrcweir {
1221cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1222cdf0e10cSrcweir
1223cdf0e10cSrcweir if ( !GetUpdateMode() )
1224cdf0e10cSrcweir return;
1225cdf0e10cSrcweir
1226cdf0e10cSrcweir Rectangle aRect;
1227cdf0e10cSrcweir if ( nColId == USHRT_MAX )
1228cdf0e10cSrcweir // invalidate the whole row
1229cdf0e10cSrcweir aRect = Rectangle( Point( 0, (nRow-nTopRow) * GetDataRowHeight() ),
1230cdf0e10cSrcweir Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) );
1231cdf0e10cSrcweir else
1232cdf0e10cSrcweir {
1233cdf0e10cSrcweir // invalidate the specific field
1234cdf0e10cSrcweir aRect = GetFieldRectPixel( nRow, nColId, sal_False );
1235cdf0e10cSrcweir }
1236cdf0e10cSrcweir getDataWindow()->Invalidate( aRect );
1237cdf0e10cSrcweir }
1238cdf0e10cSrcweir
1239cdf0e10cSrcweir //-------------------------------------------------------------------
1240cdf0e10cSrcweir
Clear()1241cdf0e10cSrcweir void BrowseBox::Clear()
1242cdf0e10cSrcweir {
1243cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1244cdf0e10cSrcweir
1245cdf0e10cSrcweir // adjust the total number of rows
1246cdf0e10cSrcweir DoHideCursor( "Clear" );
1247cdf0e10cSrcweir long nOldRowCount = nRowCount;
1248cdf0e10cSrcweir nRowCount = 0;
1249cdf0e10cSrcweir nCurRow = BROWSER_ENDOFSELECTION;
1250cdf0e10cSrcweir nTopRow = 0;
1251cdf0e10cSrcweir nCurColId = 0;
1252cdf0e10cSrcweir
1253cdf0e10cSrcweir // nFirstCol darf nicht zurueckgesetzt werden, da ansonsten das Scrollen
1254cdf0e10cSrcweir // total durcheinander kommt
1255cdf0e10cSrcweir // nFirstCol darf nur beim Hinzufuegen oder Loeschen von Spalten geaendert werden
1256cdf0e10cSrcweir // nFirstCol = 0; ->Falsch!!!!
1257cdf0e10cSrcweir aHScroll.SetThumbPos( 0 );
1258cdf0e10cSrcweir pVScroll->SetThumbPos( 0 );
1259cdf0e10cSrcweir
1260cdf0e10cSrcweir Invalidate();
1261cdf0e10cSrcweir UpdateScrollbars();
1262cdf0e10cSrcweir SetNoSelection();
1263cdf0e10cSrcweir DoShowCursor( "Clear" );
1264cdf0e10cSrcweir CursorMoved();
1265cdf0e10cSrcweir
1266cdf0e10cSrcweir if ( isAccessibleAlive() )
1267cdf0e10cSrcweir {
1268cdf0e10cSrcweir // all rows should be removed, so we remove the row header bar and append it again
1269cdf0e10cSrcweir // to avoid to notify every row remove
1270cdf0e10cSrcweir if ( nOldRowCount != nRowCount )
1271cdf0e10cSrcweir {
1272cdf0e10cSrcweir commitBrowseBoxEvent(
1273cdf0e10cSrcweir CHILD,
1274cdf0e10cSrcweir Any(),
1275cdf0e10cSrcweir makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) )
1276cdf0e10cSrcweir );
1277cdf0e10cSrcweir
1278cdf0e10cSrcweir // and now append it again
1279cdf0e10cSrcweir commitBrowseBoxEvent(
1280cdf0e10cSrcweir CHILD,
1281cdf0e10cSrcweir makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) ),
1282cdf0e10cSrcweir Any()
1283cdf0e10cSrcweir );
1284cdf0e10cSrcweir
1285cdf0e10cSrcweir // notify a table model change
1286cdf0e10cSrcweir commitTableEvent(
1287cdf0e10cSrcweir TABLE_MODEL_CHANGED,
1288cdf0e10cSrcweir makeAny( AccessibleTableModelChange( DELETE,
1289cdf0e10cSrcweir 0,
1290cdf0e10cSrcweir nOldRowCount,
1291cdf0e10cSrcweir 0,
1292cdf0e10cSrcweir GetColumnCount())
1293cdf0e10cSrcweir ),
1294cdf0e10cSrcweir Any()
1295cdf0e10cSrcweir );
1296cdf0e10cSrcweir }
1297cdf0e10cSrcweir }
1298cdf0e10cSrcweir }
1299cdf0e10cSrcweir // -----------------------------------------------------------------------------
RowInserted(long nRow,long nNumRows,sal_Bool bDoPaint,sal_Bool bKeepSelection)1300cdf0e10cSrcweir void BrowseBox::RowInserted( long nRow, long nNumRows, sal_Bool bDoPaint, sal_Bool bKeepSelection )
1301cdf0e10cSrcweir {
1302cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1303cdf0e10cSrcweir
1304cdf0e10cSrcweir if (nRow < 0)
1305cdf0e10cSrcweir nRow = 0;
1306cdf0e10cSrcweir else if (nRow > nRowCount) // maximal = nRowCount
1307cdf0e10cSrcweir nRow = nRowCount;
1308cdf0e10cSrcweir
1309cdf0e10cSrcweir if ( nNumRows <= 0 )
1310cdf0e10cSrcweir return;
1311cdf0e10cSrcweir
1312cdf0e10cSrcweir #if 0
1313cdf0e10cSrcweir // Zerlegung in einzelne RowInserted-Aufrufe:
1314cdf0e10cSrcweir if (nNumRows > 1)
1315cdf0e10cSrcweir {
1316cdf0e10cSrcweir for (long i = 0; i < nNumRows; i++)
1317cdf0e10cSrcweir RowInserted(nRow + i,1,bDoPaint);
1318cdf0e10cSrcweir return;
1319cdf0e10cSrcweir }
1320cdf0e10cSrcweir #endif
1321cdf0e10cSrcweir
1322cdf0e10cSrcweir // adjust total row count
1323cdf0e10cSrcweir sal_Bool bLastRow = nRow >= nRowCount;
1324cdf0e10cSrcweir nRowCount += nNumRows;
1325cdf0e10cSrcweir
1326cdf0e10cSrcweir DoHideCursor( "RowInserted" );
1327cdf0e10cSrcweir
1328cdf0e10cSrcweir // must we paint the new rows?
1329cdf0e10cSrcweir long nOldCurRow = nCurRow;
1330cdf0e10cSrcweir Size aSz = pDataWin->GetOutputSizePixel();
1331cdf0e10cSrcweir if ( bDoPaint && nRow >= nTopRow &&
1332cdf0e10cSrcweir nRow <= nTopRow + aSz.Height() / GetDataRowHeight() )
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir long nY = (nRow-nTopRow) * GetDataRowHeight();
1335cdf0e10cSrcweir if ( !bLastRow )
1336cdf0e10cSrcweir {
1337cdf0e10cSrcweir // scroll down the rows behind the new row
1338cdf0e10cSrcweir pDataWin->SetClipRegion();
1339cdf0e10cSrcweir if( pDataWin->GetBackground().IsScrollable() )
1340cdf0e10cSrcweir {
1341cdf0e10cSrcweir pDataWin->Scroll( 0, GetDataRowHeight() * nNumRows,
1342cdf0e10cSrcweir Rectangle( Point( 0, nY ),
1343cdf0e10cSrcweir Size( aSz.Width(), aSz.Height() - nY ) ),
1344cdf0e10cSrcweir SCROLL_FLAGS );
1345cdf0e10cSrcweir }
1346cdf0e10cSrcweir else
1347cdf0e10cSrcweir pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN );
1348cdf0e10cSrcweir }
1349cdf0e10cSrcweir else
1350cdf0e10cSrcweir // scroll would cause a repaint, so we must explicitly invalidate
1351cdf0e10cSrcweir pDataWin->Invalidate( Rectangle( Point( 0, nY ),
1352cdf0e10cSrcweir Size( aSz.Width(), nNumRows * GetDataRowHeight() ) ) );
1353cdf0e10cSrcweir }
1354cdf0e10cSrcweir
1355cdf0e10cSrcweir // ggf. Top-Row korrigieren
1356cdf0e10cSrcweir if ( nRow < nTopRow )
1357cdf0e10cSrcweir nTopRow += nNumRows;
1358cdf0e10cSrcweir
1359cdf0e10cSrcweir // adjust the selection
1360cdf0e10cSrcweir if ( bMultiSelection )
1361cdf0e10cSrcweir uRow.pSel->Insert( nRow, nNumRows );
1362cdf0e10cSrcweir else if ( uRow.nSel != BROWSER_ENDOFSELECTION && nRow <= uRow.nSel )
1363cdf0e10cSrcweir uRow.nSel += nNumRows;
1364cdf0e10cSrcweir
1365cdf0e10cSrcweir // adjust the cursor
1366cdf0e10cSrcweir if ( nCurRow == BROWSER_ENDOFSELECTION )
1367cdf0e10cSrcweir GoToRow( 0, sal_False, bKeepSelection );
1368cdf0e10cSrcweir else if ( nRow <= nCurRow )
1369cdf0e10cSrcweir GoToRow( nCurRow += nNumRows, sal_False, bKeepSelection );
1370cdf0e10cSrcweir
1371cdf0e10cSrcweir // adjust the vertical scrollbar
1372cdf0e10cSrcweir if ( bDoPaint )
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir UpdateScrollbars();
1375cdf0e10cSrcweir AutoSizeLastColumn();
1376cdf0e10cSrcweir }
1377cdf0e10cSrcweir
1378cdf0e10cSrcweir DoShowCursor( "RowInserted" );
1379cdf0e10cSrcweir // notify accessible that rows were inserted
1380cdf0e10cSrcweir if ( isAccessibleAlive() )
1381cdf0e10cSrcweir {
1382cdf0e10cSrcweir commitTableEvent(
1383cdf0e10cSrcweir TABLE_MODEL_CHANGED,
1384cdf0e10cSrcweir makeAny( AccessibleTableModelChange(
1385cdf0e10cSrcweir INSERT,
1386cdf0e10cSrcweir nRow,
1387cdf0e10cSrcweir nRow + nNumRows,
1388cdf0e10cSrcweir 0,
1389cdf0e10cSrcweir GetColumnCount()
1390cdf0e10cSrcweir )
1391cdf0e10cSrcweir ),
1392cdf0e10cSrcweir Any()
1393cdf0e10cSrcweir );
1394cdf0e10cSrcweir
1395cdf0e10cSrcweir for (sal_Int32 i = nRow+1 ; i <= nRowCount ; ++i)
1396cdf0e10cSrcweir {
1397cdf0e10cSrcweir commitHeaderBarEvent(
1398cdf0e10cSrcweir CHILD,
1399cdf0e10cSrcweir makeAny( CreateAccessibleRowHeader( i ) ),
1400cdf0e10cSrcweir Any(),
1401cdf0e10cSrcweir sal_False
1402cdf0e10cSrcweir );
1403cdf0e10cSrcweir }
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir
1406cdf0e10cSrcweir if ( nCurRow != nOldCurRow )
1407cdf0e10cSrcweir CursorMoved();
1408cdf0e10cSrcweir
1409cdf0e10cSrcweir DBG_ASSERT(nRowCount > 0,"BrowseBox: nRowCount <= 0");
1410cdf0e10cSrcweir DBG_ASSERT(nCurRow >= 0,"BrowseBox: nCurRow < 0");
1411cdf0e10cSrcweir DBG_ASSERT(nCurRow < nRowCount,"nCurRow >= nRowCount");
1412cdf0e10cSrcweir }
1413cdf0e10cSrcweir
1414cdf0e10cSrcweir //-------------------------------------------------------------------
1415cdf0e10cSrcweir
RowRemoved(long nRow,long nNumRows,sal_Bool bDoPaint)1416cdf0e10cSrcweir void BrowseBox::RowRemoved( long nRow, long nNumRows, sal_Bool bDoPaint )
1417cdf0e10cSrcweir {
1418cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1419cdf0e10cSrcweir
1420cdf0e10cSrcweir if ( nRow < 0 )
1421cdf0e10cSrcweir nRow = 0;
1422cdf0e10cSrcweir else if ( nRow >= nRowCount )
1423cdf0e10cSrcweir nRow = nRowCount - 1;
1424cdf0e10cSrcweir
1425cdf0e10cSrcweir if ( nNumRows <= 0 )
1426cdf0e10cSrcweir return;
1427cdf0e10cSrcweir
1428cdf0e10cSrcweir if ( nRowCount <= 0 )
1429cdf0e10cSrcweir return;
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir if ( bDoPaint )
1432cdf0e10cSrcweir {
1433cdf0e10cSrcweir // hide cursor and selection
1434cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
1435cdf0e10cSrcweir ToggleSelection();
1436cdf0e10cSrcweir DoHideCursor( "RowRemoved" );
1437cdf0e10cSrcweir }
1438cdf0e10cSrcweir
1439cdf0e10cSrcweir // adjust total row count
1440cdf0e10cSrcweir nRowCount -= nNumRows;
1441cdf0e10cSrcweir if (nRowCount < 0) nRowCount = 0;
1442cdf0e10cSrcweir long nOldCurRow = nCurRow;
1443cdf0e10cSrcweir
1444cdf0e10cSrcweir // adjust the selection
1445cdf0e10cSrcweir if ( bMultiSelection )
1446cdf0e10cSrcweir // uRow.pSel->Remove( nRow, nNumRows );
1447cdf0e10cSrcweir for ( long i = 0; i < nNumRows; i++ )
1448cdf0e10cSrcweir uRow.pSel->Remove( nRow );
1449cdf0e10cSrcweir else if ( nRow < uRow.nSel && uRow.nSel >= nNumRows )
1450cdf0e10cSrcweir uRow.nSel -= nNumRows;
1451cdf0e10cSrcweir else if ( nRow <= uRow.nSel )
1452cdf0e10cSrcweir uRow.nSel = BROWSER_ENDOFSELECTION;
1453cdf0e10cSrcweir
1454cdf0e10cSrcweir // adjust the cursor
1455cdf0e10cSrcweir if ( nRowCount == 0 ) // don't compare nRowCount with nNumRows as nNumRows already was subtracted from nRowCount
1456cdf0e10cSrcweir nCurRow = BROWSER_ENDOFSELECTION;
1457cdf0e10cSrcweir else if ( nRow < nCurRow )
1458cdf0e10cSrcweir {
1459cdf0e10cSrcweir nCurRow -= Min( nCurRow - nRow, nNumRows );
1460cdf0e10cSrcweir // with the above nCurRow points a) to the first row after the removed block or b) to the same line
1461cdf0e10cSrcweir // as before, but moved up nNumRows
1462cdf0e10cSrcweir // case a) needs an additional correction if the last n lines were deleted, as 'the first row after the
1463cdf0e10cSrcweir // removed block' is an invalid position then
1464cdf0e10cSrcweir // FS - 09/28/99 - 68429
1465cdf0e10cSrcweir if (nCurRow == nRowCount)
1466cdf0e10cSrcweir --nCurRow;
1467cdf0e10cSrcweir }
1468cdf0e10cSrcweir else if( nRow == nCurRow && nCurRow == nRowCount )
1469cdf0e10cSrcweir nCurRow = nRowCount-1;
1470cdf0e10cSrcweir
1471cdf0e10cSrcweir // is the deleted row visible?
1472cdf0e10cSrcweir Size aSz = pDataWin->GetOutputSizePixel();
1473cdf0e10cSrcweir if ( nRow >= nTopRow &&
1474cdf0e10cSrcweir nRow <= nTopRow + aSz.Height() / GetDataRowHeight() )
1475cdf0e10cSrcweir {
1476cdf0e10cSrcweir if ( bDoPaint )
1477cdf0e10cSrcweir {
1478cdf0e10cSrcweir // scroll up the rows behind the deleted row
1479cdf0e10cSrcweir // if there are Rows behind
1480cdf0e10cSrcweir if (nRow < nRowCount)
1481cdf0e10cSrcweir {
1482cdf0e10cSrcweir long nY = (nRow-nTopRow) * GetDataRowHeight();
1483cdf0e10cSrcweir pDataWin->SetClipRegion();
1484cdf0e10cSrcweir if( pDataWin->GetBackground().IsScrollable() )
1485cdf0e10cSrcweir {
1486cdf0e10cSrcweir pDataWin->Scroll( 0, - (short) GetDataRowHeight() * nNumRows,
1487cdf0e10cSrcweir Rectangle( Point( 0, nY ), Size( aSz.Width(),
1488cdf0e10cSrcweir aSz.Height() - nY + nNumRows*GetDataRowHeight() ) ),
1489cdf0e10cSrcweir SCROLL_FLAGS );
1490cdf0e10cSrcweir }
1491cdf0e10cSrcweir else
1492cdf0e10cSrcweir pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN );
1493cdf0e10cSrcweir }
1494cdf0e10cSrcweir else
1495cdf0e10cSrcweir {
1496cdf0e10cSrcweir // Repaint the Rect of the deleted row
1497cdf0e10cSrcweir Rectangle aRect(
1498cdf0e10cSrcweir Point( 0, (nRow-nTopRow)*GetDataRowHeight() ),
1499cdf0e10cSrcweir Size( pDataWin->GetSizePixel().Width(),
1500cdf0e10cSrcweir nNumRows * GetDataRowHeight() ) );
1501cdf0e10cSrcweir pDataWin->Invalidate( aRect );
1502cdf0e10cSrcweir }
1503cdf0e10cSrcweir }
1504cdf0e10cSrcweir }
1505cdf0e10cSrcweir // is the deleted row above of the visible area?
1506cdf0e10cSrcweir else if ( nRow < nTopRow )
1507cdf0e10cSrcweir nTopRow = nTopRow >= nNumRows ? nTopRow-nNumRows : 0;
1508cdf0e10cSrcweir
1509cdf0e10cSrcweir if ( bDoPaint )
1510cdf0e10cSrcweir {
1511cdf0e10cSrcweir // reshow cursor and selection
1512cdf0e10cSrcweir ToggleSelection();
1513cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
1514cdf0e10cSrcweir DoShowCursor( "RowRemoved" );
1515cdf0e10cSrcweir
1516cdf0e10cSrcweir // adjust the vertical scrollbar
1517cdf0e10cSrcweir UpdateScrollbars();
1518cdf0e10cSrcweir AutoSizeLastColumn();
1519cdf0e10cSrcweir }
1520cdf0e10cSrcweir
1521cdf0e10cSrcweir if ( isAccessibleAlive() )
1522cdf0e10cSrcweir {
1523cdf0e10cSrcweir if ( nRowCount == 0 )
1524cdf0e10cSrcweir {
1525cdf0e10cSrcweir // all columns should be removed, so we remove the column header bar and append it again
1526cdf0e10cSrcweir // to avoid to notify every column remove
1527cdf0e10cSrcweir commitBrowseBoxEvent(
1528cdf0e10cSrcweir CHILD,
1529cdf0e10cSrcweir Any(),
1530cdf0e10cSrcweir makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) )
1531cdf0e10cSrcweir );
1532cdf0e10cSrcweir
1533cdf0e10cSrcweir // and now append it again
1534cdf0e10cSrcweir commitBrowseBoxEvent(
1535cdf0e10cSrcweir CHILD,
1536cdf0e10cSrcweir makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_ROWHEADERBAR)),
1537cdf0e10cSrcweir Any()
1538cdf0e10cSrcweir );
1539cdf0e10cSrcweir commitBrowseBoxEvent(
1540cdf0e10cSrcweir CHILD,
1541cdf0e10cSrcweir Any(),
1542cdf0e10cSrcweir makeAny( m_pImpl->getAccessibleTable() )
1543cdf0e10cSrcweir );
1544cdf0e10cSrcweir
1545cdf0e10cSrcweir // and now append it again
1546cdf0e10cSrcweir commitBrowseBoxEvent(
1547cdf0e10cSrcweir CHILD,
1548cdf0e10cSrcweir makeAny( m_pImpl->getAccessibleTable() ),
1549cdf0e10cSrcweir Any()
1550cdf0e10cSrcweir );
1551cdf0e10cSrcweir }
1552cdf0e10cSrcweir else
1553cdf0e10cSrcweir {
1554cdf0e10cSrcweir commitTableEvent(
1555cdf0e10cSrcweir TABLE_MODEL_CHANGED,
1556cdf0e10cSrcweir makeAny( AccessibleTableModelChange(
1557cdf0e10cSrcweir DELETE,
1558cdf0e10cSrcweir nRow,
1559cdf0e10cSrcweir nRow + nNumRows,
1560cdf0e10cSrcweir 0,
1561cdf0e10cSrcweir GetColumnCount()
1562cdf0e10cSrcweir )
1563cdf0e10cSrcweir ),
1564cdf0e10cSrcweir Any()
1565cdf0e10cSrcweir );
1566cdf0e10cSrcweir
1567cdf0e10cSrcweir for (sal_Int32 i = nRow+1 ; i <= (nRow+nNumRows) ; ++i)
1568cdf0e10cSrcweir {
1569cdf0e10cSrcweir commitHeaderBarEvent(
1570cdf0e10cSrcweir CHILD,
1571cdf0e10cSrcweir Any(),
1572cdf0e10cSrcweir makeAny( CreateAccessibleRowHeader( i ) ),
1573cdf0e10cSrcweir sal_False
1574cdf0e10cSrcweir );
1575cdf0e10cSrcweir }
1576cdf0e10cSrcweir }
1577cdf0e10cSrcweir }
1578cdf0e10cSrcweir
1579cdf0e10cSrcweir if ( nOldCurRow != nCurRow )
1580cdf0e10cSrcweir CursorMoved();
1581cdf0e10cSrcweir
1582cdf0e10cSrcweir DBG_ASSERT(nRowCount >= 0,"BrowseBox: nRowCount < 0");
1583cdf0e10cSrcweir DBG_ASSERT(nCurRow >= 0 || nRowCount == 0,"BrowseBox: nCurRow < 0 && nRowCount != 0");
1584cdf0e10cSrcweir DBG_ASSERT(nCurRow < nRowCount,"nCurRow >= nRowCount");
1585cdf0e10cSrcweir }
1586cdf0e10cSrcweir
1587cdf0e10cSrcweir //-------------------------------------------------------------------
1588cdf0e10cSrcweir
GoToRow(long nRow)1589cdf0e10cSrcweir sal_Bool BrowseBox::GoToRow( long nRow)
1590cdf0e10cSrcweir {
1591cdf0e10cSrcweir return GoToRow(nRow, sal_False, sal_False);
1592cdf0e10cSrcweir }
1593cdf0e10cSrcweir
1594cdf0e10cSrcweir //-------------------------------------------------------------------
1595cdf0e10cSrcweir
GoToRowAndDoNotModifySelection(long nRow)1596cdf0e10cSrcweir sal_Bool BrowseBox::GoToRowAndDoNotModifySelection( long nRow )
1597cdf0e10cSrcweir {
1598cdf0e10cSrcweir return GoToRow( nRow, sal_False, sal_True );
1599cdf0e10cSrcweir }
1600cdf0e10cSrcweir
1601cdf0e10cSrcweir //-------------------------------------------------------------------
GoToRow(long nRow,sal_Bool bRowColMove,sal_Bool bKeepSelection)1602cdf0e10cSrcweir sal_Bool BrowseBox::GoToRow( long nRow, sal_Bool bRowColMove, sal_Bool bKeepSelection )
1603cdf0e10cSrcweir {
1604cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1605cdf0e10cSrcweir
1606cdf0e10cSrcweir long nOldCurRow = nCurRow;
1607cdf0e10cSrcweir
1608cdf0e10cSrcweir // nothing to do?
1609cdf0e10cSrcweir if ( nRow == nCurRow && ( bMultiSelection || uRow.nSel == nRow ) )
1610cdf0e10cSrcweir return sal_True;
1611cdf0e10cSrcweir
1612cdf0e10cSrcweir // out of range?
1613cdf0e10cSrcweir if ( nRow < 0 || nRow >= nRowCount )
1614cdf0e10cSrcweir return sal_False;
1615cdf0e10cSrcweir
1616cdf0e10cSrcweir // nicht erlaubt?
1617cdf0e10cSrcweir if ( ( !bRowColMove && !IsCursorMoveAllowed( nRow, nCurColId ) ) )
1618cdf0e10cSrcweir return sal_False;
1619cdf0e10cSrcweir
1620cdf0e10cSrcweir if ( getDataWindow()->bNoScrollBack && nRow < nTopRow )
1621cdf0e10cSrcweir nRow = nTopRow;
1622cdf0e10cSrcweir
1623cdf0e10cSrcweir // compute the last visible row
1624cdf0e10cSrcweir Size aSz( pDataWin->GetSizePixel() );
1625cdf0e10cSrcweir sal_uInt16 nVisibleRows = sal_uInt16( aSz.Height() / GetDataRowHeight() - 1 );
1626cdf0e10cSrcweir long nLastRow = nTopRow + nVisibleRows;
1627cdf0e10cSrcweir
1628cdf0e10cSrcweir // suspend Updates
1629cdf0e10cSrcweir getDataWindow()->EnterUpdateLock();
1630cdf0e10cSrcweir
1631cdf0e10cSrcweir // ggf. altes Highlight weg
1632cdf0e10cSrcweir if ( !bMultiSelection && !bKeepSelection )
1633cdf0e10cSrcweir ToggleSelection();
1634cdf0e10cSrcweir DoHideCursor( "GoToRow" );
1635cdf0e10cSrcweir
1636cdf0e10cSrcweir // must we scroll?
1637cdf0e10cSrcweir sal_Bool bWasVisible = bSelectionIsVisible;
1638cdf0e10cSrcweir if (! bMultiSelection)
1639cdf0e10cSrcweir {
1640cdf0e10cSrcweir if( !bKeepSelection )
1641cdf0e10cSrcweir bSelectionIsVisible = sal_False;
1642cdf0e10cSrcweir }
1643cdf0e10cSrcweir if ( nRow < nTopRow )
1644cdf0e10cSrcweir ScrollRows( nRow - nTopRow );
1645cdf0e10cSrcweir else if ( nRow > nLastRow )
1646cdf0e10cSrcweir ScrollRows( nRow - nLastRow );
1647cdf0e10cSrcweir bSelectionIsVisible = bWasVisible;
1648cdf0e10cSrcweir
1649cdf0e10cSrcweir // adjust cursor (selection) and thumb
1650cdf0e10cSrcweir if ( GetUpdateMode() )
1651cdf0e10cSrcweir pVScroll->SetThumbPos( nTopRow );
1652cdf0e10cSrcweir
1653cdf0e10cSrcweir // relative positioning (because nCurRow might have changed in the meantime)!
1654cdf0e10cSrcweir if (nCurRow != BROWSER_ENDOFSELECTION )
1655cdf0e10cSrcweir nCurRow = nCurRow + (nRow - nOldCurRow);
1656cdf0e10cSrcweir
1657cdf0e10cSrcweir // make sure that the current position is valid
1658cdf0e10cSrcweir if (nCurRow == BROWSER_ENDOFSELECTION && nRowCount > 0)
1659cdf0e10cSrcweir nCurRow = 0;
1660cdf0e10cSrcweir else if ( nCurRow >= nRowCount )
1661cdf0e10cSrcweir nCurRow = nRowCount - 1;
1662cdf0e10cSrcweir aSelRange = Range( nCurRow, nCurRow );
1663cdf0e10cSrcweir
1664cdf0e10cSrcweir // ggf. neues Highlight anzeigen
1665cdf0e10cSrcweir if ( !bMultiSelection && !bKeepSelection )
1666cdf0e10cSrcweir uRow.nSel = nRow;
1667cdf0e10cSrcweir
1668cdf0e10cSrcweir // resume Updates
1669cdf0e10cSrcweir getDataWindow()->LeaveUpdateLock();
1670cdf0e10cSrcweir
1671cdf0e10cSrcweir // Cursor+Highlight
1672cdf0e10cSrcweir if ( !bMultiSelection && !bKeepSelection)
1673cdf0e10cSrcweir ToggleSelection();
1674cdf0e10cSrcweir DoShowCursor( "GoToRow" );
1675cdf0e10cSrcweir if ( !bRowColMove && nOldCurRow != nCurRow )
1676cdf0e10cSrcweir CursorMoved();
1677cdf0e10cSrcweir
1678cdf0e10cSrcweir if ( !bMultiSelection && !bKeepSelection )
1679cdf0e10cSrcweir {
1680cdf0e10cSrcweir if ( !bSelecting )
1681cdf0e10cSrcweir Select();
1682cdf0e10cSrcweir else
1683cdf0e10cSrcweir bSelect = sal_True;
1684cdf0e10cSrcweir }
1685cdf0e10cSrcweir return sal_True;
1686cdf0e10cSrcweir }
1687cdf0e10cSrcweir
1688cdf0e10cSrcweir //-------------------------------------------------------------------
1689cdf0e10cSrcweir
GoToColumnId(sal_uInt16 nColId)1690cdf0e10cSrcweir sal_Bool BrowseBox::GoToColumnId( sal_uInt16 nColId)
1691cdf0e10cSrcweir {
1692cdf0e10cSrcweir return GoToColumnId(nColId,sal_True,sal_False);
1693cdf0e10cSrcweir }
1694cdf0e10cSrcweir
1695cdf0e10cSrcweir
GoToColumnId(sal_uInt16 nColId,sal_Bool bMakeVisible,sal_Bool bRowColMove)1696cdf0e10cSrcweir sal_Bool BrowseBox::GoToColumnId( sal_uInt16 nColId, sal_Bool bMakeVisible, sal_Bool bRowColMove)
1697cdf0e10cSrcweir {
1698cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1699cdf0e10cSrcweir
1700cdf0e10cSrcweir if (!bColumnCursor)
1701cdf0e10cSrcweir return sal_False;
1702cdf0e10cSrcweir
1703cdf0e10cSrcweir // erlaubt?
1704cdf0e10cSrcweir if (!bRowColMove && !IsCursorMoveAllowed( nCurRow, nColId ) )
1705cdf0e10cSrcweir return sal_False;
1706cdf0e10cSrcweir
1707cdf0e10cSrcweir if ( nColId != nCurColId || (bMakeVisible && !IsFieldVisible(nCurRow, nColId, sal_True)))
1708cdf0e10cSrcweir {
1709cdf0e10cSrcweir sal_uInt16 nNewPos = GetColumnPos(nColId);
1710cdf0e10cSrcweir BrowserColumn* pColumn = pCols->GetObject( nNewPos );
1711cdf0e10cSrcweir DBG_ASSERT( pColumn, "no column object - invalid id?" );
1712cdf0e10cSrcweir if ( !pColumn )
1713cdf0e10cSrcweir return sal_False;
1714cdf0e10cSrcweir
1715cdf0e10cSrcweir DoHideCursor( "GoToColumnId" );
1716cdf0e10cSrcweir nCurColId = nColId;
1717cdf0e10cSrcweir
1718cdf0e10cSrcweir sal_uInt16 nFirstPos = nFirstCol;
1719cdf0e10cSrcweir sal_uInt16 nWidth = (sal_uInt16)pColumn->Width();
1720cdf0e10cSrcweir sal_uInt16 nLastPos = GetColumnAtXPosPixel(
1721cdf0e10cSrcweir pDataWin->GetSizePixel().Width()-nWidth, sal_False );
1722cdf0e10cSrcweir sal_uInt16 nFrozen = FrozenColCount();
1723cdf0e10cSrcweir if ( bMakeVisible && nLastPos &&
1724cdf0e10cSrcweir nNewPos >= nFrozen && ( nNewPos < nFirstPos || nNewPos > nLastPos ) )
1725cdf0e10cSrcweir {
1726cdf0e10cSrcweir if ( nNewPos < nFirstPos )
1727cdf0e10cSrcweir ScrollColumns( nNewPos-nFirstPos );
1728cdf0e10cSrcweir else if ( nNewPos > nLastPos )
1729cdf0e10cSrcweir ScrollColumns( nNewPos-nLastPos );
1730cdf0e10cSrcweir }
1731cdf0e10cSrcweir
1732cdf0e10cSrcweir DoShowCursor( "GoToColumnId" );
1733cdf0e10cSrcweir if (!bRowColMove)
1734cdf0e10cSrcweir CursorMoved();
1735cdf0e10cSrcweir return sal_True;
1736cdf0e10cSrcweir }
1737cdf0e10cSrcweir return sal_True;
1738cdf0e10cSrcweir }
1739cdf0e10cSrcweir
1740cdf0e10cSrcweir //-------------------------------------------------------------------
1741cdf0e10cSrcweir
GoToRowColumnId(long nRow,sal_uInt16 nColId)1742cdf0e10cSrcweir sal_Bool BrowseBox::GoToRowColumnId( long nRow, sal_uInt16 nColId )
1743cdf0e10cSrcweir {
1744cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1745cdf0e10cSrcweir
1746cdf0e10cSrcweir // out of range?
1747cdf0e10cSrcweir if ( nRow < 0 || nRow >= nRowCount )
1748cdf0e10cSrcweir return sal_False;
1749cdf0e10cSrcweir
1750cdf0e10cSrcweir if (!bColumnCursor)
1751cdf0e10cSrcweir return sal_False;
1752cdf0e10cSrcweir
1753cdf0e10cSrcweir // nothing to do ?
1754cdf0e10cSrcweir if ( nRow == nCurRow && ( bMultiSelection || uRow.nSel == nRow ) &&
1755cdf0e10cSrcweir nColId == nCurColId && IsFieldVisible(nCurRow, nColId, sal_True))
1756cdf0e10cSrcweir return sal_True;
1757cdf0e10cSrcweir
1758cdf0e10cSrcweir // erlaubt?
1759cdf0e10cSrcweir if (!IsCursorMoveAllowed(nRow, nColId))
1760cdf0e10cSrcweir return sal_False;
1761cdf0e10cSrcweir
1762cdf0e10cSrcweir DoHideCursor( "GoToRowColumnId" );
1763cdf0e10cSrcweir sal_Bool bMoved = GoToRow(nRow, sal_True) && GoToColumnId(nColId, sal_True, sal_True);
1764cdf0e10cSrcweir DoShowCursor( "GoToRowColumnId" );
1765cdf0e10cSrcweir
1766cdf0e10cSrcweir if (bMoved)
1767cdf0e10cSrcweir CursorMoved();
1768cdf0e10cSrcweir
1769cdf0e10cSrcweir return bMoved;
1770cdf0e10cSrcweir }
1771cdf0e10cSrcweir
1772cdf0e10cSrcweir //-------------------------------------------------------------------
1773cdf0e10cSrcweir
SetNoSelection()1774cdf0e10cSrcweir void BrowseBox::SetNoSelection()
1775cdf0e10cSrcweir {
1776cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1777cdf0e10cSrcweir
1778cdf0e10cSrcweir // is there no selection
1779cdf0e10cSrcweir if ( ( !pColSel || !pColSel->GetSelectCount() ) &&
1780cdf0e10cSrcweir ( ( !bMultiSelection && uRow.nSel == BROWSER_ENDOFSELECTION ) ||
1781cdf0e10cSrcweir ( bMultiSelection && !uRow.pSel->GetSelectCount() ) ) )
1782cdf0e10cSrcweir // nothing to do
1783cdf0e10cSrcweir return;
1784cdf0e10cSrcweir
1785cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
1786cdf0e10cSrcweir ToggleSelection();
1787cdf0e10cSrcweir
1788cdf0e10cSrcweir // unselect all
1789cdf0e10cSrcweir if ( bMultiSelection )
1790cdf0e10cSrcweir uRow.pSel->SelectAll(sal_False);
1791cdf0e10cSrcweir else
1792cdf0e10cSrcweir uRow.nSel = BROWSER_ENDOFSELECTION;
1793cdf0e10cSrcweir if ( pColSel )
1794cdf0e10cSrcweir pColSel->SelectAll(sal_False);
1795cdf0e10cSrcweir if ( !bSelecting )
1796cdf0e10cSrcweir Select();
1797cdf0e10cSrcweir else
1798cdf0e10cSrcweir bSelect = sal_True;
1799cdf0e10cSrcweir
1800cdf0e10cSrcweir // restore screen
1801cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
1802cdf0e10cSrcweir
1803cdf0e10cSrcweir if ( isAccessibleAlive() )
1804cdf0e10cSrcweir {
1805cdf0e10cSrcweir commitTableEvent(
1806cdf0e10cSrcweir SELECTION_CHANGED,
1807cdf0e10cSrcweir Any(),
1808cdf0e10cSrcweir Any()
1809cdf0e10cSrcweir );
1810cdf0e10cSrcweir }
1811cdf0e10cSrcweir }
1812cdf0e10cSrcweir
1813cdf0e10cSrcweir //-------------------------------------------------------------------
1814cdf0e10cSrcweir
SetSelection(const MultiSelection & rSel)1815cdf0e10cSrcweir void BrowseBox::SetSelection( const MultiSelection &rSel )
1816cdf0e10cSrcweir {
1817cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1818cdf0e10cSrcweir DBG_ASSERT( bMultiSelection, "SetSelection only allowed with Multi-Selection-Mode" );
1819cdf0e10cSrcweir
1820cdf0e10cSrcweir // prepare inverted areas
1821cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
1822cdf0e10cSrcweir ToggleSelection();
1823cdf0e10cSrcweir
1824cdf0e10cSrcweir // assign Selection
1825cdf0e10cSrcweir *uRow.pSel = rSel;
1826cdf0e10cSrcweir
1827cdf0e10cSrcweir // only highlight painted areas
1828cdf0e10cSrcweir pDataWin->Update();
1829cdf0e10cSrcweir
1830cdf0e10cSrcweir // notify derived class
1831cdf0e10cSrcweir if ( !bSelecting )
1832cdf0e10cSrcweir Select();
1833cdf0e10cSrcweir else
1834cdf0e10cSrcweir bSelect = sal_True;
1835cdf0e10cSrcweir
1836cdf0e10cSrcweir // restore screen
1837cdf0e10cSrcweir ToggleSelection();
1838cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
1839cdf0e10cSrcweir
1840cdf0e10cSrcweir if ( isAccessibleAlive() )
1841cdf0e10cSrcweir {
1842cdf0e10cSrcweir commitTableEvent(
1843cdf0e10cSrcweir SELECTION_CHANGED,
1844cdf0e10cSrcweir Any(),
1845cdf0e10cSrcweir Any()
1846cdf0e10cSrcweir );
1847cdf0e10cSrcweir }
1848cdf0e10cSrcweir }
1849cdf0e10cSrcweir
1850cdf0e10cSrcweir //-------------------------------------------------------------------
1851cdf0e10cSrcweir
SelectAll()1852cdf0e10cSrcweir void BrowseBox::SelectAll()
1853cdf0e10cSrcweir {
1854cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1855cdf0e10cSrcweir
1856cdf0e10cSrcweir if ( !bMultiSelection )
1857cdf0e10cSrcweir return;
1858cdf0e10cSrcweir
1859cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
1860cdf0e10cSrcweir ToggleSelection();
1861cdf0e10cSrcweir
1862cdf0e10cSrcweir // select all rows
1863cdf0e10cSrcweir if ( pColSel )
1864cdf0e10cSrcweir pColSel->SelectAll(sal_False);
1865cdf0e10cSrcweir uRow.pSel->SelectAll(sal_True);
1866cdf0e10cSrcweir
1867cdf0e10cSrcweir // Handle-Column nicht highlighten
1868cdf0e10cSrcweir BrowserColumn *pFirstCol = pCols->GetObject(0);
1869cdf0e10cSrcweir long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width();
1870cdf0e10cSrcweir
1871cdf0e10cSrcweir // highlight the row selection
1872cdf0e10cSrcweir if ( !bHideSelect )
1873cdf0e10cSrcweir {
1874cdf0e10cSrcweir Rectangle aHighlightRect;
1875cdf0e10cSrcweir sal_uInt16 nVisibleRows =
1876cdf0e10cSrcweir (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
1877cdf0e10cSrcweir for ( long nRow = Max( nTopRow, uRow.pSel->FirstSelected() );
1878cdf0e10cSrcweir nRow != BROWSER_ENDOFSELECTION && nRow < nTopRow + nVisibleRows;
1879cdf0e10cSrcweir nRow = uRow.pSel->NextSelected() )
1880cdf0e10cSrcweir aHighlightRect.Union( Rectangle(
1881cdf0e10cSrcweir Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ),
1882cdf0e10cSrcweir Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) ) );
1883cdf0e10cSrcweir pDataWin->Invalidate( aHighlightRect );
1884cdf0e10cSrcweir }
1885cdf0e10cSrcweir
1886cdf0e10cSrcweir if ( !bSelecting )
1887cdf0e10cSrcweir Select();
1888cdf0e10cSrcweir else
1889cdf0e10cSrcweir bSelect = sal_True;
1890cdf0e10cSrcweir
1891cdf0e10cSrcweir // restore screen
1892cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
1893cdf0e10cSrcweir
1894cdf0e10cSrcweir if ( isAccessibleAlive() )
1895cdf0e10cSrcweir {
1896cdf0e10cSrcweir commitTableEvent(
1897cdf0e10cSrcweir SELECTION_CHANGED,
1898cdf0e10cSrcweir Any(),
1899cdf0e10cSrcweir Any()
1900cdf0e10cSrcweir );
1901cdf0e10cSrcweir commitHeaderBarEvent(
1902cdf0e10cSrcweir SELECTION_CHANGED,
1903cdf0e10cSrcweir Any(),
1904cdf0e10cSrcweir Any(),
1905cdf0e10cSrcweir sal_True
1906cdf0e10cSrcweir ); // column header event
1907cdf0e10cSrcweir
1908cdf0e10cSrcweir commitHeaderBarEvent(
1909cdf0e10cSrcweir SELECTION_CHANGED,
1910cdf0e10cSrcweir Any(),
1911cdf0e10cSrcweir Any(),
1912cdf0e10cSrcweir sal_False
1913cdf0e10cSrcweir ); // row header event
1914cdf0e10cSrcweir }
1915cdf0e10cSrcweir }
1916cdf0e10cSrcweir
1917cdf0e10cSrcweir //-------------------------------------------------------------------
1918cdf0e10cSrcweir
SelectRow(long nRow,sal_Bool _bSelect,sal_Bool bExpand)1919cdf0e10cSrcweir void BrowseBox::SelectRow( long nRow, sal_Bool _bSelect, sal_Bool bExpand )
1920cdf0e10cSrcweir {
1921cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1922cdf0e10cSrcweir
1923cdf0e10cSrcweir if ( !bMultiSelection )
1924cdf0e10cSrcweir {
1925cdf0e10cSrcweir // deselecting is impossible, selecting via cursor
1926cdf0e10cSrcweir if ( _bSelect )
1927cdf0e10cSrcweir GoToRow(nRow, sal_False);
1928cdf0e10cSrcweir return;
1929cdf0e10cSrcweir }
1930cdf0e10cSrcweir
1931cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
1932cdf0e10cSrcweir
1933cdf0e10cSrcweir // remove old selection?
1934cdf0e10cSrcweir if ( !bExpand || !bMultiSelection )
1935cdf0e10cSrcweir {
1936cdf0e10cSrcweir ToggleSelection();
1937cdf0e10cSrcweir if ( bMultiSelection )
1938cdf0e10cSrcweir uRow.pSel->SelectAll(sal_False);
1939cdf0e10cSrcweir else
1940cdf0e10cSrcweir uRow.nSel = BROWSER_ENDOFSELECTION;
1941cdf0e10cSrcweir if ( pColSel )
1942cdf0e10cSrcweir pColSel->SelectAll(sal_False);
1943cdf0e10cSrcweir }
1944cdf0e10cSrcweir
1945cdf0e10cSrcweir // set new selection
1946cdf0e10cSrcweir if ( !bHideSelect
1947cdf0e10cSrcweir && ( ( bMultiSelection
1948cdf0e10cSrcweir && uRow.pSel->GetTotalRange().Max() >= nRow
1949cdf0e10cSrcweir && uRow.pSel->Select( nRow, _bSelect )
1950cdf0e10cSrcweir )
1951cdf0e10cSrcweir || ( !bMultiSelection
1952cdf0e10cSrcweir && ( uRow.nSel = nRow ) != BROWSER_ENDOFSELECTION )
1953cdf0e10cSrcweir )
1954cdf0e10cSrcweir )
1955cdf0e10cSrcweir {
1956cdf0e10cSrcweir // Handle-Column nicht highlighten
1957cdf0e10cSrcweir BrowserColumn *pFirstCol = pCols->GetObject(0);
1958cdf0e10cSrcweir long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width();
1959cdf0e10cSrcweir
1960cdf0e10cSrcweir // highlight only newly selected part
1961cdf0e10cSrcweir Rectangle aRect(
1962cdf0e10cSrcweir Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ),
1963cdf0e10cSrcweir Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) );
1964cdf0e10cSrcweir pDataWin->Invalidate( aRect );
1965cdf0e10cSrcweir }
1966cdf0e10cSrcweir
1967cdf0e10cSrcweir if ( !bSelecting )
1968cdf0e10cSrcweir Select();
1969cdf0e10cSrcweir else
1970cdf0e10cSrcweir bSelect = sal_True;
1971cdf0e10cSrcweir
1972cdf0e10cSrcweir // restore screen
1973cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
1974cdf0e10cSrcweir
1975cdf0e10cSrcweir if ( isAccessibleAlive() )
1976cdf0e10cSrcweir {
1977cdf0e10cSrcweir commitTableEvent(
1978cdf0e10cSrcweir SELECTION_CHANGED,
1979cdf0e10cSrcweir Any(),
1980cdf0e10cSrcweir Any()
1981cdf0e10cSrcweir );
1982cdf0e10cSrcweir commitHeaderBarEvent(
1983cdf0e10cSrcweir SELECTION_CHANGED,
1984cdf0e10cSrcweir Any(),
1985cdf0e10cSrcweir Any(),
1986cdf0e10cSrcweir sal_False
1987cdf0e10cSrcweir ); // row header event
1988cdf0e10cSrcweir }
1989cdf0e10cSrcweir }
1990cdf0e10cSrcweir
1991cdf0e10cSrcweir //-------------------------------------------------------------------
1992cdf0e10cSrcweir
GetSelectRowCount() const1993cdf0e10cSrcweir long BrowseBox::GetSelectRowCount() const
1994cdf0e10cSrcweir {
1995cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1996cdf0e10cSrcweir
1997cdf0e10cSrcweir return bMultiSelection ? uRow.pSel->GetSelectCount() :
1998cdf0e10cSrcweir uRow.nSel == BROWSER_ENDOFSELECTION ? 0 : 1;
1999cdf0e10cSrcweir }
2000cdf0e10cSrcweir
2001cdf0e10cSrcweir //-------------------------------------------------------------------
2002cdf0e10cSrcweir
SelectColumnPos(sal_uInt16 nNewColPos,sal_Bool _bSelect,sal_Bool bMakeVisible)2003cdf0e10cSrcweir void BrowseBox::SelectColumnPos( sal_uInt16 nNewColPos, sal_Bool _bSelect, sal_Bool bMakeVisible )
2004cdf0e10cSrcweir {
2005cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2006cdf0e10cSrcweir
2007cdf0e10cSrcweir if ( !bColumnCursor || nNewColPos == BROWSER_INVALIDID )
2008cdf0e10cSrcweir return;
2009cdf0e10cSrcweir
2010cdf0e10cSrcweir if ( !bMultiSelection )
2011cdf0e10cSrcweir {
2012cdf0e10cSrcweir if ( _bSelect )
2013cdf0e10cSrcweir GoToColumnId( pCols->GetObject(nNewColPos)->GetId(), bMakeVisible );
2014cdf0e10cSrcweir return;
2015cdf0e10cSrcweir }
2016cdf0e10cSrcweir else
2017cdf0e10cSrcweir {
2018cdf0e10cSrcweir if ( !GoToColumnId( pCols->GetObject( nNewColPos )->GetId(), bMakeVisible ) )
2019cdf0e10cSrcweir return;
2020cdf0e10cSrcweir }
2021cdf0e10cSrcweir
2022cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
2023cdf0e10cSrcweir ToggleSelection();
2024cdf0e10cSrcweir if ( bMultiSelection )
2025cdf0e10cSrcweir uRow.pSel->SelectAll(sal_False);
2026cdf0e10cSrcweir else
2027cdf0e10cSrcweir uRow.nSel = BROWSER_ENDOFSELECTION;
2028cdf0e10cSrcweir pColSel->SelectAll(sal_False);
2029cdf0e10cSrcweir
2030cdf0e10cSrcweir if ( pColSel->Select( nNewColPos, _bSelect ) )
2031cdf0e10cSrcweir {
2032cdf0e10cSrcweir // GoToColumnId( pCols->GetObject(nNewColPos)->GetId(), bMakeVisible );
2033cdf0e10cSrcweir
2034cdf0e10cSrcweir // only highlight painted areas
2035cdf0e10cSrcweir pDataWin->Update();
2036cdf0e10cSrcweir Rectangle aFieldRectPix( GetFieldRectPixel( nCurRow, nCurColId, sal_False ) );
2037cdf0e10cSrcweir Rectangle aRect(
2038cdf0e10cSrcweir Point( aFieldRectPix.Left() - MIN_COLUMNWIDTH, 0 ),
2039cdf0e10cSrcweir Size( pCols->GetObject(nNewColPos)->Width(),
2040cdf0e10cSrcweir pDataWin->GetOutputSizePixel().Height() ) );
2041cdf0e10cSrcweir pDataWin->Invalidate( aRect );
2042cdf0e10cSrcweir if ( !bSelecting )
2043cdf0e10cSrcweir Select();
2044cdf0e10cSrcweir else
2045cdf0e10cSrcweir bSelect = sal_True;
2046cdf0e10cSrcweir
2047cdf0e10cSrcweir if ( isAccessibleAlive() )
2048cdf0e10cSrcweir {
2049cdf0e10cSrcweir commitTableEvent(
2050cdf0e10cSrcweir SELECTION_CHANGED,
2051cdf0e10cSrcweir Any(),
2052cdf0e10cSrcweir Any()
2053cdf0e10cSrcweir );
2054cdf0e10cSrcweir commitHeaderBarEvent(
2055cdf0e10cSrcweir SELECTION_CHANGED,
2056cdf0e10cSrcweir Any(),
2057cdf0e10cSrcweir Any(),
2058cdf0e10cSrcweir sal_True
2059cdf0e10cSrcweir ); // column header event
2060cdf0e10cSrcweir }
2061cdf0e10cSrcweir }
2062cdf0e10cSrcweir
2063cdf0e10cSrcweir // restore screen
2064cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
2065cdf0e10cSrcweir }
2066cdf0e10cSrcweir
2067cdf0e10cSrcweir //-------------------------------------------------------------------
2068cdf0e10cSrcweir
GetSelectColumnCount() const2069cdf0e10cSrcweir sal_uInt16 BrowseBox::GetSelectColumnCount() const
2070cdf0e10cSrcweir {
2071cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2072cdf0e10cSrcweir
2073cdf0e10cSrcweir // while bAutoSelect (==!pColSel), 1 if any rows (yes rows!) else none
2074cdf0e10cSrcweir return pColSel ? (sal_uInt16) pColSel->GetSelectCount() :
2075cdf0e10cSrcweir nCurRow >= 0 ? 1 : 0;
2076cdf0e10cSrcweir }
2077cdf0e10cSrcweir
2078cdf0e10cSrcweir //-------------------------------------------------------------------
FirstSelectedColumn() const2079cdf0e10cSrcweir long BrowseBox::FirstSelectedColumn( ) const
2080cdf0e10cSrcweir {
2081cdf0e10cSrcweir return pColSel ? pColSel->FirstSelected() : BROWSER_ENDOFSELECTION;
2082cdf0e10cSrcweir }
2083cdf0e10cSrcweir
2084cdf0e10cSrcweir //-------------------------------------------------------------------
NextSelectedColumn() const2085cdf0e10cSrcweir long BrowseBox::NextSelectedColumn( ) const
2086cdf0e10cSrcweir {
2087cdf0e10cSrcweir return pColSel ? pColSel->NextSelected() : BROWSER_ENDOFSELECTION;
2088cdf0e10cSrcweir }
2089cdf0e10cSrcweir
2090cdf0e10cSrcweir //-------------------------------------------------------------------
2091cdf0e10cSrcweir
FirstSelectedRow(sal_Bool bInverse)2092cdf0e10cSrcweir long BrowseBox::FirstSelectedRow( sal_Bool bInverse )
2093cdf0e10cSrcweir {
2094cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2095cdf0e10cSrcweir
2096cdf0e10cSrcweir return bMultiSelection ? uRow.pSel->FirstSelected(bInverse) : uRow.nSel;
2097cdf0e10cSrcweir }
2098cdf0e10cSrcweir
2099cdf0e10cSrcweir //-------------------------------------------------------------------
2100cdf0e10cSrcweir
NextSelectedRow()2101cdf0e10cSrcweir long BrowseBox::NextSelectedRow()
2102cdf0e10cSrcweir {
2103cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2104cdf0e10cSrcweir
2105cdf0e10cSrcweir return bMultiSelection ? uRow.pSel->NextSelected() : BROWSER_ENDOFSELECTION;
2106cdf0e10cSrcweir }
2107cdf0e10cSrcweir
2108cdf0e10cSrcweir //-------------------------------------------------------------------
2109cdf0e10cSrcweir
PrevSelectedRow()2110cdf0e10cSrcweir long BrowseBox::PrevSelectedRow()
2111cdf0e10cSrcweir {
2112cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2113cdf0e10cSrcweir
2114cdf0e10cSrcweir return bMultiSelection ? uRow.pSel->PrevSelected() : BROWSER_ENDOFSELECTION;
2115cdf0e10cSrcweir }
2116cdf0e10cSrcweir
2117cdf0e10cSrcweir //-------------------------------------------------------------------
2118cdf0e10cSrcweir
LastSelectedRow()2119cdf0e10cSrcweir long BrowseBox::LastSelectedRow()
2120cdf0e10cSrcweir {
2121cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2122cdf0e10cSrcweir
2123cdf0e10cSrcweir return bMultiSelection ? uRow.pSel->LastSelected() : uRow.nSel;
2124cdf0e10cSrcweir }
2125cdf0e10cSrcweir
2126cdf0e10cSrcweir //-------------------------------------------------------------------
2127cdf0e10cSrcweir
IsRowSelected(long nRow) const2128cdf0e10cSrcweir bool BrowseBox::IsRowSelected( long nRow ) const
2129cdf0e10cSrcweir {
2130cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2131cdf0e10cSrcweir
2132cdf0e10cSrcweir return bMultiSelection ? uRow.pSel->IsSelected(nRow) : nRow == uRow.nSel;
2133cdf0e10cSrcweir }
2134cdf0e10cSrcweir
2135cdf0e10cSrcweir //-------------------------------------------------------------------
2136cdf0e10cSrcweir
IsColumnSelected(sal_uInt16 nColumnId) const2137cdf0e10cSrcweir bool BrowseBox::IsColumnSelected( sal_uInt16 nColumnId ) const
2138cdf0e10cSrcweir {
2139cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2140cdf0e10cSrcweir
2141cdf0e10cSrcweir return pColSel ? pColSel->IsSelected( GetColumnPos(nColumnId) ) :
2142cdf0e10cSrcweir nCurColId == nColumnId;
2143cdf0e10cSrcweir }
2144cdf0e10cSrcweir
2145cdf0e10cSrcweir //-------------------------------------------------------------------
2146cdf0e10cSrcweir
IsAllSelected() const2147cdf0e10cSrcweir sal_Bool BrowseBox::IsAllSelected() const
2148cdf0e10cSrcweir {
2149cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2150cdf0e10cSrcweir
2151cdf0e10cSrcweir return bMultiSelection && uRow.pSel->IsAllSelected();
2152cdf0e10cSrcweir }
2153cdf0e10cSrcweir
2154cdf0e10cSrcweir //-------------------------------------------------------------------
2155cdf0e10cSrcweir
MakeFieldVisible(long nRow,sal_uInt16 nColId,sal_Bool bComplete)2156cdf0e10cSrcweir sal_Bool BrowseBox::MakeFieldVisible
2157cdf0e10cSrcweir (
2158cdf0e10cSrcweir long nRow, // Zeilen-Nr des Feldes (beginnend mit 0)
2159cdf0e10cSrcweir sal_uInt16 nColId, // Spalten-Id des Feldes
2160cdf0e10cSrcweir sal_Bool bComplete // (== sal_False), sal_True => vollst"andig sichtbar machen
2161cdf0e10cSrcweir )
2162cdf0e10cSrcweir
2163cdf0e10cSrcweir /* [Beschreibung]
2164cdf0e10cSrcweir
2165cdf0e10cSrcweir Macht das durch 'nRow' und 'nColId' beschriebene Feld durch
2166cdf0e10cSrcweir entsprechendes scrollen sichtbar. Ist 'bComplete' gesetzt, dann wird
2167cdf0e10cSrcweir gefordert, da\s das Feld ganz sichtbar wird.
2168cdf0e10cSrcweir
2169cdf0e10cSrcweir [R"uckgabewert]
2170cdf0e10cSrcweir
2171cdf0e10cSrcweir sal_Bool sal_True
2172cdf0e10cSrcweir Das angegebene Feld wurde sichtbar gemacht, bzw. war
2173cdf0e10cSrcweir bereits sichtbar.
2174cdf0e10cSrcweir
2175cdf0e10cSrcweir sal_False
2176cdf0e10cSrcweir Das angegebene Feld konnte nicht sichtbar bzw. bei
2177cdf0e10cSrcweir 'bComplete' nicht vollst"andig sichtbar gemacht werden.
2178cdf0e10cSrcweir */
2179cdf0e10cSrcweir
2180cdf0e10cSrcweir {
2181cdf0e10cSrcweir Size aTestSize = pDataWin->GetSizePixel();
2182cdf0e10cSrcweir
2183cdf0e10cSrcweir if ( !bBootstrapped ||
2184cdf0e10cSrcweir ( aTestSize.Width() == 0 && aTestSize.Height() == 0 ) )
2185cdf0e10cSrcweir return sal_False;
2186cdf0e10cSrcweir
2187cdf0e10cSrcweir // ist es schon sichtbar?
2188cdf0e10cSrcweir sal_Bool bVisible = IsFieldVisible( nRow, nColId, bComplete );
2189cdf0e10cSrcweir if ( bVisible )
2190cdf0e10cSrcweir return sal_True;
2191cdf0e10cSrcweir
2192cdf0e10cSrcweir // Spaltenposition und Feld-Rechteck und Ausgabebereich berechnen
2193cdf0e10cSrcweir sal_uInt16 nColPos = GetColumnPos( nColId );
2194cdf0e10cSrcweir Rectangle aFieldRect = GetFieldRectPixel( nRow, nColId, sal_False );
2195cdf0e10cSrcweir Rectangle aDataRect = Rectangle( Point(0, 0), pDataWin->GetSizePixel() );
2196cdf0e10cSrcweir
2197cdf0e10cSrcweir // links au\serhalb?
2198cdf0e10cSrcweir if ( nColPos >= FrozenColCount() && nColPos < nFirstCol )
2199cdf0e10cSrcweir // => nach rechts scrollen
2200cdf0e10cSrcweir ScrollColumns( nColPos - nFirstCol );
2201cdf0e10cSrcweir
2202cdf0e10cSrcweir // solange rechts au\serhalb
2203cdf0e10cSrcweir while ( aDataRect.Right() < ( bComplete
2204cdf0e10cSrcweir ? aFieldRect.Right()
2205cdf0e10cSrcweir : aFieldRect.Left()+aFieldRect.GetWidth()/2 ) )
2206cdf0e10cSrcweir {
2207cdf0e10cSrcweir // => nach links scrollen
2208cdf0e10cSrcweir if ( ScrollColumns( 1 ) != 1 )
2209cdf0e10cSrcweir // nichts mehr zu scrollen
2210cdf0e10cSrcweir break;
2211cdf0e10cSrcweir aFieldRect = GetFieldRectPixel( nRow, nColId, sal_False );
2212cdf0e10cSrcweir }
2213cdf0e10cSrcweir
2214cdf0e10cSrcweir // oben au\serhalb?
2215cdf0e10cSrcweir if ( nRow < nTopRow )
2216cdf0e10cSrcweir // nach unten scrollen
2217cdf0e10cSrcweir ScrollRows( nRow - nTopRow );
2218cdf0e10cSrcweir
2219cdf0e10cSrcweir // unten au\serhalb?
2220cdf0e10cSrcweir long nBottomRow = nTopRow + GetVisibleRows();
2221cdf0e10cSrcweir // OV: damit nBottomRow die Nummer der letzten sichtbaren Zeile ist
2222cdf0e10cSrcweir // (Zaehlung ab Null!), muss sie dekrementiert werden.
2223cdf0e10cSrcweir // Beispiel: BrowseBox enthaelt genau einen Eintrag. nBottomRow := 0 + 1 - 1
2224cdf0e10cSrcweir if( nBottomRow )
2225cdf0e10cSrcweir nBottomRow--;
2226cdf0e10cSrcweir
2227cdf0e10cSrcweir if ( nRow > nBottomRow )
2228cdf0e10cSrcweir // nach oben scrollen
2229cdf0e10cSrcweir ScrollRows( nRow - nBottomRow );
2230cdf0e10cSrcweir
2231cdf0e10cSrcweir // jetzt kann es immer noch nicht passen, z.B. weil Window zu klein
2232cdf0e10cSrcweir return IsFieldVisible( nRow, nColId, bComplete );
2233cdf0e10cSrcweir }
2234cdf0e10cSrcweir
2235cdf0e10cSrcweir //-------------------------------------------------------------------
2236cdf0e10cSrcweir
IsFieldVisible(long nRow,sal_uInt16 nColumnId,sal_Bool bCompletely) const2237cdf0e10cSrcweir sal_Bool BrowseBox::IsFieldVisible( long nRow, sal_uInt16 nColumnId,
2238cdf0e10cSrcweir sal_Bool bCompletely ) const
2239cdf0e10cSrcweir {
2240cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2241cdf0e10cSrcweir
2242cdf0e10cSrcweir // durch frozen-Column verdeckt?
2243cdf0e10cSrcweir sal_uInt16 nColPos = GetColumnPos( nColumnId );
2244cdf0e10cSrcweir if ( nColPos >= FrozenColCount() && nColPos < nFirstCol )
2245cdf0e10cSrcweir return sal_False;
2246cdf0e10cSrcweir
2247cdf0e10cSrcweir Rectangle aRect( ImplFieldRectPixel( nRow, nColumnId ) );
2248cdf0e10cSrcweir if ( aRect.IsEmpty() )
2249cdf0e10cSrcweir return sal_False;
2250cdf0e10cSrcweir
2251cdf0e10cSrcweir // get the visible area
2252cdf0e10cSrcweir Rectangle aOutRect( Point(0, 0), pDataWin->GetOutputSizePixel() );
2253cdf0e10cSrcweir
2254cdf0e10cSrcweir if ( bCompletely )
2255cdf0e10cSrcweir // test if the field is completely visible
2256cdf0e10cSrcweir return aOutRect.IsInside( aRect );
2257cdf0e10cSrcweir else
2258cdf0e10cSrcweir // test if the field is partly of completely visible
2259cdf0e10cSrcweir return !aOutRect.Intersection( aRect ).IsEmpty();
2260cdf0e10cSrcweir }
2261cdf0e10cSrcweir
2262cdf0e10cSrcweir //-------------------------------------------------------------------
2263cdf0e10cSrcweir
GetFieldRectPixel(long nRow,sal_uInt16 nColumnId,sal_Bool bRelToBrowser) const2264cdf0e10cSrcweir Rectangle BrowseBox::GetFieldRectPixel( long nRow, sal_uInt16 nColumnId,
2265cdf0e10cSrcweir sal_Bool bRelToBrowser) const
2266cdf0e10cSrcweir {
2267cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2268cdf0e10cSrcweir
2269cdf0e10cSrcweir // get the rectangle relative to DataWin
2270cdf0e10cSrcweir Rectangle aRect( ImplFieldRectPixel( nRow, nColumnId ) );
2271cdf0e10cSrcweir if ( aRect.IsEmpty() )
2272cdf0e10cSrcweir return aRect;
2273cdf0e10cSrcweir
2274cdf0e10cSrcweir // adjust relative to BrowseBox's output area
2275cdf0e10cSrcweir Point aTopLeft( aRect.TopLeft() );
2276cdf0e10cSrcweir if ( bRelToBrowser )
2277cdf0e10cSrcweir {
2278cdf0e10cSrcweir aTopLeft = pDataWin->OutputToScreenPixel( aTopLeft );
2279cdf0e10cSrcweir aTopLeft = ScreenToOutputPixel( aTopLeft );
2280cdf0e10cSrcweir }
2281cdf0e10cSrcweir
2282cdf0e10cSrcweir return Rectangle( aTopLeft, aRect.GetSize() );
2283cdf0e10cSrcweir }
2284cdf0e10cSrcweir
2285cdf0e10cSrcweir //-------------------------------------------------------------------
2286cdf0e10cSrcweir
GetRowRectPixel(long nRow,sal_Bool bRelToBrowser) const2287cdf0e10cSrcweir Rectangle BrowseBox::GetRowRectPixel( long nRow, sal_Bool bRelToBrowser ) const
2288cdf0e10cSrcweir {
2289cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2290cdf0e10cSrcweir
2291cdf0e10cSrcweir // get the rectangle relative to DataWin
2292cdf0e10cSrcweir Rectangle aRect;
2293cdf0e10cSrcweir if ( nTopRow > nRow )
2294cdf0e10cSrcweir // row is above visible area
2295cdf0e10cSrcweir return aRect;
2296cdf0e10cSrcweir aRect = Rectangle(
2297cdf0e10cSrcweir Point( 0, GetDataRowHeight() * (nRow-nTopRow) ),
2298cdf0e10cSrcweir Size( pDataWin->GetOutputSizePixel().Width(), GetDataRowHeight() ) );
2299cdf0e10cSrcweir if ( aRect.TopLeft().Y() > pDataWin->GetOutputSizePixel().Height() )
2300cdf0e10cSrcweir // row is below visible area
2301cdf0e10cSrcweir return aRect;
2302cdf0e10cSrcweir
2303cdf0e10cSrcweir // adjust relative to BrowseBox's output area
2304cdf0e10cSrcweir Point aTopLeft( aRect.TopLeft() );
2305cdf0e10cSrcweir if ( bRelToBrowser )
2306cdf0e10cSrcweir {
2307cdf0e10cSrcweir aTopLeft = pDataWin->OutputToScreenPixel( aTopLeft );
2308cdf0e10cSrcweir aTopLeft = ScreenToOutputPixel( aTopLeft );
2309cdf0e10cSrcweir }
2310cdf0e10cSrcweir
2311cdf0e10cSrcweir return Rectangle( aTopLeft, aRect.GetSize() );
2312cdf0e10cSrcweir }
2313cdf0e10cSrcweir
2314cdf0e10cSrcweir //-------------------------------------------------------------------
2315cdf0e10cSrcweir
ImplFieldRectPixel(long nRow,sal_uInt16 nColumnId) const2316cdf0e10cSrcweir Rectangle BrowseBox::ImplFieldRectPixel( long nRow, sal_uInt16 nColumnId ) const
2317cdf0e10cSrcweir {
2318cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2319cdf0e10cSrcweir
2320cdf0e10cSrcweir // compute the X-coordinte realtiv to DataWin by accumulation
2321cdf0e10cSrcweir long nColX = 0;
2322cdf0e10cSrcweir sal_uInt16 nFrozenCols = FrozenColCount();
2323cdf0e10cSrcweir sal_uInt16 nCol;
2324cdf0e10cSrcweir for ( nCol = 0;
2325cdf0e10cSrcweir nCol < pCols->Count() && pCols->GetObject(nCol)->GetId() != nColumnId;
2326cdf0e10cSrcweir ++nCol )
2327cdf0e10cSrcweir if ( pCols->GetObject(nCol)->IsFrozen() || nCol >= nFirstCol )
2328cdf0e10cSrcweir nColX += pCols->GetObject(nCol)->Width();
2329cdf0e10cSrcweir
2330cdf0e10cSrcweir if ( nCol >= pCols->Count() || ( nCol >= nFrozenCols && nCol < nFirstCol ) )
2331cdf0e10cSrcweir return Rectangle();
2332cdf0e10cSrcweir
2333cdf0e10cSrcweir // compute the Y-coordinate relative to DataWin
2334cdf0e10cSrcweir long nRowY = GetDataRowHeight();
2335cdf0e10cSrcweir if ( nRow != BROWSER_ENDOFSELECTION ) // #105497# OJ
2336cdf0e10cSrcweir nRowY = ( nRow - nTopRow ) * GetDataRowHeight();
2337cdf0e10cSrcweir
2338cdf0e10cSrcweir // assemble the Rectangle relative to DataWin
2339cdf0e10cSrcweir return Rectangle(
2340cdf0e10cSrcweir Point( nColX + MIN_COLUMNWIDTH, nRowY ),
2341cdf0e10cSrcweir Size( pCols->GetObject(nCol)->Width() - 2*MIN_COLUMNWIDTH,
2342cdf0e10cSrcweir GetDataRowHeight() - 1 ) );
2343cdf0e10cSrcweir }
2344cdf0e10cSrcweir
2345cdf0e10cSrcweir //-------------------------------------------------------------------
2346cdf0e10cSrcweir
GetRowAtYPosPixel(long nY,sal_Bool bRelToBrowser) const2347cdf0e10cSrcweir long BrowseBox::GetRowAtYPosPixel( long nY, sal_Bool bRelToBrowser ) const
2348cdf0e10cSrcweir {
2349cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2350cdf0e10cSrcweir
2351cdf0e10cSrcweir // compute the Y-coord
2352cdf0e10cSrcweir if ( bRelToBrowser )
2353cdf0e10cSrcweir {
2354cdf0e10cSrcweir Point aDataTopLeft = pDataWin->OutputToScreenPixel( Point(0, 0) );
2355cdf0e10cSrcweir Point aTopLeft = OutputToScreenPixel( Point(0, 0) );
2356cdf0e10cSrcweir nY -= aDataTopLeft.Y() - aTopLeft.Y();
2357cdf0e10cSrcweir }
2358cdf0e10cSrcweir
2359cdf0e10cSrcweir // no row there (e.g. in the header)
2360cdf0e10cSrcweir if ( nY < 0 || nY >= pDataWin->GetOutputSizePixel().Height() )
2361cdf0e10cSrcweir return -1;
2362cdf0e10cSrcweir
2363cdf0e10cSrcweir return nY / GetDataRowHeight() + nTopRow;
2364cdf0e10cSrcweir }
2365cdf0e10cSrcweir
2366cdf0e10cSrcweir //-------------------------------------------------------------------
2367cdf0e10cSrcweir
GetFieldRect(sal_uInt16 nColumnId) const2368cdf0e10cSrcweir Rectangle BrowseBox::GetFieldRect( sal_uInt16 nColumnId ) const
2369cdf0e10cSrcweir {
2370cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2371cdf0e10cSrcweir
2372cdf0e10cSrcweir return GetFieldRectPixel( nCurRow, nColumnId );
2373cdf0e10cSrcweir }
2374cdf0e10cSrcweir
2375cdf0e10cSrcweir //-------------------------------------------------------------------
2376cdf0e10cSrcweir
GetColumnAtXPosPixel(long nX,sal_Bool) const2377cdf0e10cSrcweir sal_uInt16 BrowseBox::GetColumnAtXPosPixel( long nX, sal_Bool ) const
2378cdf0e10cSrcweir {
2379cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2380cdf0e10cSrcweir
2381cdf0e10cSrcweir // accumulate the withds of the visible columns
2382cdf0e10cSrcweir long nColX = 0;
2383cdf0e10cSrcweir sal_uInt16 nCol;
2384cdf0e10cSrcweir for ( nCol = 0; nCol < sal_uInt16(pCols->Count()); ++nCol )
2385cdf0e10cSrcweir {
2386cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nCol);
2387cdf0e10cSrcweir if ( pCol->IsFrozen() || nCol >= nFirstCol )
2388cdf0e10cSrcweir nColX += pCol->Width();
2389cdf0e10cSrcweir
2390cdf0e10cSrcweir if ( nColX > nX )
2391cdf0e10cSrcweir return nCol;
2392cdf0e10cSrcweir }
2393cdf0e10cSrcweir
2394cdf0e10cSrcweir return BROWSER_INVALIDID;
2395cdf0e10cSrcweir }
2396cdf0e10cSrcweir
2397cdf0e10cSrcweir //-------------------------------------------------------------------
2398cdf0e10cSrcweir
ReserveControlArea(sal_uInt16 nWidth)2399cdf0e10cSrcweir void BrowseBox::ReserveControlArea( sal_uInt16 nWidth )
2400cdf0e10cSrcweir {
2401cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2402cdf0e10cSrcweir
2403cdf0e10cSrcweir if ( nWidth != nControlAreaWidth )
2404cdf0e10cSrcweir {
2405cdf0e10cSrcweir OSL_ENSURE(nWidth,"Control aera of 0 is not allowed, Use USHRT_MAX instead!");
2406cdf0e10cSrcweir nControlAreaWidth = nWidth;
2407cdf0e10cSrcweir UpdateScrollbars();
2408cdf0e10cSrcweir }
2409cdf0e10cSrcweir }
2410cdf0e10cSrcweir
2411cdf0e10cSrcweir //-------------------------------------------------------------------
2412cdf0e10cSrcweir
GetControlArea() const2413cdf0e10cSrcweir Rectangle BrowseBox::GetControlArea() const
2414cdf0e10cSrcweir {
2415cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2416cdf0e10cSrcweir
2417cdf0e10cSrcweir return Rectangle(
2418cdf0e10cSrcweir Point( 0, GetOutputSizePixel().Height() - aHScroll.GetSizePixel().Height() ),
2419cdf0e10cSrcweir Size( GetOutputSizePixel().Width() - aHScroll.GetSizePixel().Width(),
2420cdf0e10cSrcweir aHScroll.GetSizePixel().Height() ) );
2421cdf0e10cSrcweir }
2422cdf0e10cSrcweir
2423cdf0e10cSrcweir //-------------------------------------------------------------------
2424cdf0e10cSrcweir
SetMode(BrowserMode nMode)2425cdf0e10cSrcweir void BrowseBox::SetMode( BrowserMode nMode )
2426cdf0e10cSrcweir {
2427cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2428cdf0e10cSrcweir
2429cdf0e10cSrcweir #ifdef DBG_MIx
2430cdf0e10cSrcweir Sound::Beep();
2431cdf0e10cSrcweir nMode =
2432cdf0e10cSrcweir // BROWSER_COLUMNSELECTION |
2433cdf0e10cSrcweir // BROWSER_MULTISELECTION |
2434cdf0e10cSrcweir BROWSER_THUMBDRAGGING |
2435cdf0e10cSrcweir BROWSER_KEEPHIGHLIGHT |
2436cdf0e10cSrcweir BROWSER_HLINES |
2437cdf0e10cSrcweir BROWSER_VLINES |
2438cdf0e10cSrcweir // BROWSER_HIDECURSOR |
2439cdf0e10cSrcweir // BROWSER_NO_HSCROLL |
2440cdf0e10cSrcweir // BROWSER_NO_SCROLLBACK |
2441cdf0e10cSrcweir BROWSER_AUTO_VSCROLL |
2442cdf0e10cSrcweir BROWSER_AUTO_HSCROLL |
2443cdf0e10cSrcweir BROWSER_TRACKING_TIPS |
2444cdf0e10cSrcweir // BROWSER_HIGHLIGHT_NONE |
2445cdf0e10cSrcweir BROWSER_HEADERBAR_NEW |
2446cdf0e10cSrcweir // BROWSER_AUTOSIZE_LASTCOL |
2447cdf0e10cSrcweir 0;
2448cdf0e10cSrcweir #endif
2449cdf0e10cSrcweir
2450cdf0e10cSrcweir getDataWindow()->bAutoHScroll = BROWSER_AUTO_HSCROLL == ( nMode & BROWSER_AUTO_HSCROLL );
2451cdf0e10cSrcweir getDataWindow()->bAutoVScroll = BROWSER_AUTO_VSCROLL == ( nMode & BROWSER_AUTO_VSCROLL );
2452cdf0e10cSrcweir getDataWindow()->bNoHScroll = BROWSER_NO_HSCROLL == ( nMode & BROWSER_NO_HSCROLL );
2453cdf0e10cSrcweir getDataWindow()->bNoVScroll = BROWSER_NO_VSCROLL == ( nMode & BROWSER_NO_VSCROLL );
2454cdf0e10cSrcweir
2455cdf0e10cSrcweir DBG_ASSERT( !( getDataWindow()->bAutoHScroll && getDataWindow()->bNoHScroll ),
2456cdf0e10cSrcweir "BrowseBox::SetMode: AutoHScroll *and* NoHScroll?" );
2457cdf0e10cSrcweir DBG_ASSERT( !( getDataWindow()->bAutoVScroll && getDataWindow()->bNoVScroll ),
2458cdf0e10cSrcweir "BrowseBox::SetMode: AutoVScroll *and* NoVScroll?" );
2459cdf0e10cSrcweir if ( getDataWindow()->bAutoHScroll )
2460cdf0e10cSrcweir getDataWindow()->bNoHScroll = sal_False;
2461cdf0e10cSrcweir if ( getDataWindow()->bAutoVScroll )
2462cdf0e10cSrcweir getDataWindow()->bNoVScroll = sal_False;
2463cdf0e10cSrcweir
2464cdf0e10cSrcweir if ( getDataWindow()->bNoHScroll )
2465cdf0e10cSrcweir aHScroll.Hide();
2466cdf0e10cSrcweir
2467cdf0e10cSrcweir nControlAreaWidth = USHRT_MAX;
2468cdf0e10cSrcweir
2469cdf0e10cSrcweir getDataWindow()->bNoScrollBack =
2470cdf0e10cSrcweir BROWSER_NO_SCROLLBACK == ( nMode & BROWSER_NO_SCROLLBACK);
2471cdf0e10cSrcweir
2472cdf0e10cSrcweir long nOldRowSel = bMultiSelection ? uRow.pSel->FirstSelected() : uRow.nSel;
2473cdf0e10cSrcweir MultiSelection *pOldRowSel = bMultiSelection ? uRow.pSel : 0;
2474cdf0e10cSrcweir MultiSelection *pOldColSel = pColSel;
2475cdf0e10cSrcweir
2476cdf0e10cSrcweir delete pVScroll;
2477cdf0e10cSrcweir
2478cdf0e10cSrcweir bThumbDragging = ( nMode & BROWSER_THUMBDRAGGING ) == BROWSER_THUMBDRAGGING;
2479cdf0e10cSrcweir bMultiSelection = ( nMode & BROWSER_MULTISELECTION ) == BROWSER_MULTISELECTION;
2480cdf0e10cSrcweir bColumnCursor = ( nMode & BROWSER_COLUMNSELECTION ) == BROWSER_COLUMNSELECTION;
2481cdf0e10cSrcweir bKeepHighlight = ( nMode & BROWSER_KEEPSELECTION ) == BROWSER_KEEPSELECTION;
2482cdf0e10cSrcweir
2483cdf0e10cSrcweir bHideSelect = ((nMode & BROWSER_HIDESELECT) == BROWSER_HIDESELECT);
2484cdf0e10cSrcweir // default: do not hide the cursor at all (untaken scrolling and such)
2485cdf0e10cSrcweir bHideCursor = NO_CURSOR_HIDE;
2486cdf0e10cSrcweir
2487cdf0e10cSrcweir if ( BROWSER_SMART_HIDECURSOR == ( nMode & BROWSER_SMART_HIDECURSOR ) )
2488cdf0e10cSrcweir { // smart cursor hide overrules hard cursor hide
2489cdf0e10cSrcweir bHideCursor = SMART_CURSOR_HIDE;
2490cdf0e10cSrcweir }
2491cdf0e10cSrcweir else if ( BROWSER_HIDECURSOR == ( nMode & BROWSER_HIDECURSOR ) )
2492cdf0e10cSrcweir {
2493cdf0e10cSrcweir bHideCursor = HARD_CURSOR_HIDE;
2494cdf0e10cSrcweir }
2495cdf0e10cSrcweir
2496cdf0e10cSrcweir m_bFocusOnlyCursor = ((nMode & BROWSER_CURSOR_WO_FOCUS) == 0);
2497cdf0e10cSrcweir
2498cdf0e10cSrcweir bHLines = ( nMode & BROWSER_HLINESFULL ) == BROWSER_HLINESFULL;
2499cdf0e10cSrcweir bVLines = ( nMode & BROWSER_VLINESFULL ) == BROWSER_VLINESFULL;
2500cdf0e10cSrcweir bHDots = ( nMode & BROWSER_HLINESDOTS ) == BROWSER_HLINESDOTS;
2501cdf0e10cSrcweir bVDots = ( nMode & BROWSER_VLINESDOTS ) == BROWSER_VLINESDOTS;
2502cdf0e10cSrcweir
2503cdf0e10cSrcweir WinBits nVScrollWinBits =
2504cdf0e10cSrcweir WB_VSCROLL | ( ( nMode & BROWSER_THUMBDRAGGING ) ? WB_DRAG : 0 );
2505cdf0e10cSrcweir pVScroll = ( nMode & BROWSER_TRACKING_TIPS ) == BROWSER_TRACKING_TIPS
2506cdf0e10cSrcweir ? new BrowserScrollBar( this, nVScrollWinBits,
2507cdf0e10cSrcweir (BrowserDataWin*) pDataWin )
2508cdf0e10cSrcweir : new ScrollBar( this, nVScrollWinBits );
2509cdf0e10cSrcweir pVScroll->SetLineSize( 1 );
2510cdf0e10cSrcweir pVScroll->SetPageSize(1);
2511cdf0e10cSrcweir pVScroll->SetScrollHdl( LINK( this, BrowseBox, ScrollHdl ) );
2512cdf0e10cSrcweir pVScroll->SetEndScrollHdl( LINK( this, BrowseBox, EndScrollHdl ) );
2513cdf0e10cSrcweir
2514cdf0e10cSrcweir getDataWindow()->bAutoSizeLastCol =
2515cdf0e10cSrcweir BROWSER_AUTOSIZE_LASTCOL == ( nMode & BROWSER_AUTOSIZE_LASTCOL );
2516cdf0e10cSrcweir getDataWindow()->bOwnDataChangedHdl =
2517cdf0e10cSrcweir BROWSER_OWN_DATACHANGED == ( nMode & BROWSER_OWN_DATACHANGED );
2518cdf0e10cSrcweir
2519cdf0e10cSrcweir // Headerbar erzeugen, was passiert, wenn eine erzeugt werden mu� und schon Spalten bestehen ?
2520cdf0e10cSrcweir if ( BROWSER_HEADERBAR_NEW == ( nMode & BROWSER_HEADERBAR_NEW ) )
2521cdf0e10cSrcweir {
2522cdf0e10cSrcweir if (!getDataWindow()->pHeaderBar)
2523cdf0e10cSrcweir getDataWindow()->pHeaderBar = CreateHeaderBar( this );
2524cdf0e10cSrcweir }
2525cdf0e10cSrcweir else
2526cdf0e10cSrcweir {
2527cdf0e10cSrcweir DELETEZ(getDataWindow()->pHeaderBar);
2528cdf0e10cSrcweir }
2529cdf0e10cSrcweir
2530cdf0e10cSrcweir
2531cdf0e10cSrcweir
2532cdf0e10cSrcweir if ( bColumnCursor )
2533cdf0e10cSrcweir {
2534cdf0e10cSrcweir pColSel = pOldColSel ? pOldColSel : new MultiSelection;
2535cdf0e10cSrcweir pColSel->SetTotalRange( Range( 0, pCols->Count()-1 ) );
2536cdf0e10cSrcweir }
2537cdf0e10cSrcweir else
2538cdf0e10cSrcweir {
2539cdf0e10cSrcweir pColSel = 0;
2540cdf0e10cSrcweir delete pColSel;
2541cdf0e10cSrcweir }
2542cdf0e10cSrcweir
2543cdf0e10cSrcweir if ( bMultiSelection )
2544cdf0e10cSrcweir {
2545cdf0e10cSrcweir if ( pOldRowSel )
2546cdf0e10cSrcweir uRow.pSel = pOldRowSel;
2547cdf0e10cSrcweir else
2548cdf0e10cSrcweir uRow.pSel = new MultiSelection;
2549cdf0e10cSrcweir }
2550cdf0e10cSrcweir else
2551cdf0e10cSrcweir {
2552cdf0e10cSrcweir uRow.nSel = nOldRowSel;
2553cdf0e10cSrcweir delete pOldRowSel;
2554cdf0e10cSrcweir }
2555cdf0e10cSrcweir
2556cdf0e10cSrcweir if ( bBootstrapped )
2557cdf0e10cSrcweir {
2558cdf0e10cSrcweir StateChanged( STATE_CHANGE_INITSHOW );
2559cdf0e10cSrcweir if ( bMultiSelection && !pOldRowSel &&
2560cdf0e10cSrcweir nOldRowSel != BROWSER_ENDOFSELECTION )
2561cdf0e10cSrcweir uRow.pSel->Select( nOldRowSel );
2562cdf0e10cSrcweir }
2563cdf0e10cSrcweir
2564cdf0e10cSrcweir if ( pDataWin )
2565cdf0e10cSrcweir pDataWin->Invalidate();
2566cdf0e10cSrcweir
2567cdf0e10cSrcweir // kein Cursor auf Handle-Column
2568cdf0e10cSrcweir if ( nCurColId == 0 )
2569cdf0e10cSrcweir nCurColId = GetColumnId( 1 );
2570cdf0e10cSrcweir
2571cdf0e10cSrcweir m_nCurrentMode = nMode;
2572cdf0e10cSrcweir }
2573cdf0e10cSrcweir
2574cdf0e10cSrcweir //-------------------------------------------------------------------
2575cdf0e10cSrcweir
VisibleRowsChanged(long,sal_uInt16)2576cdf0e10cSrcweir void BrowseBox::VisibleRowsChanged( long, sal_uInt16 )
2577cdf0e10cSrcweir {
2578cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2579cdf0e10cSrcweir
2580cdf0e10cSrcweir // Das alte Verhalten: NumRows automatisch korrigieren:
2581cdf0e10cSrcweir if ( nRowCount < GetRowCount() )
2582cdf0e10cSrcweir {
2583cdf0e10cSrcweir RowInserted(nRowCount,GetRowCount() - nRowCount,sal_False);
2584cdf0e10cSrcweir }
2585cdf0e10cSrcweir else if ( nRowCount > GetRowCount() )
2586cdf0e10cSrcweir {
2587cdf0e10cSrcweir RowRemoved(nRowCount-(nRowCount - GetRowCount()),nRowCount - GetRowCount(),sal_False);
2588cdf0e10cSrcweir }
2589cdf0e10cSrcweir }
2590cdf0e10cSrcweir
2591cdf0e10cSrcweir //-------------------------------------------------------------------
2592cdf0e10cSrcweir
IsCursorMoveAllowed(long,sal_uInt16) const2593cdf0e10cSrcweir sal_Bool BrowseBox::IsCursorMoveAllowed( long, sal_uInt16 ) const
2594cdf0e10cSrcweir
2595cdf0e10cSrcweir /* [Beschreibung]
2596cdf0e10cSrcweir
2597cdf0e10cSrcweir Diese virtuelle Methode wird immer gerufen bevor der Cursor direkt
2598cdf0e10cSrcweir bewegt werden soll. Durch 'return sal_False' kann verhindert werden, da\s
2599cdf0e10cSrcweir dies geschieht, wenn z.B. ein Datensatz irgendwelchen Rules widerspricht.
2600cdf0e10cSrcweir
2601cdf0e10cSrcweir Diese Methode wird nicht gerufen, wenn die Cursorbewegung durch
2602cdf0e10cSrcweir ein L"oschen oder Einf"ugen (einer Zeile/Spalte) ausgel"ost wird, also
2603cdf0e10cSrcweir genaugenommen nur eine Cursor-Korrektur vorliegt.
2604cdf0e10cSrcweir
2605cdf0e10cSrcweir Die Basisimplementierung liefert derzeit immer sal_True.
2606cdf0e10cSrcweir */
2607cdf0e10cSrcweir
2608cdf0e10cSrcweir {
2609cdf0e10cSrcweir return sal_True;
2610cdf0e10cSrcweir }
2611cdf0e10cSrcweir
2612cdf0e10cSrcweir //-------------------------------------------------------------------
2613cdf0e10cSrcweir
GetDataRowHeight() const2614cdf0e10cSrcweir long BrowseBox::GetDataRowHeight() const
2615cdf0e10cSrcweir {
2616cdf0e10cSrcweir return CalcZoom(nDataRowHeight ? nDataRowHeight : ImpGetDataRowHeight());
2617cdf0e10cSrcweir }
2618cdf0e10cSrcweir
2619cdf0e10cSrcweir //-------------------------------------------------------------------
2620cdf0e10cSrcweir
GetEventWindow() const2621cdf0e10cSrcweir Window& BrowseBox::GetEventWindow() const
2622cdf0e10cSrcweir {
2623cdf0e10cSrcweir return *getDataWindow()->pEventWin;
2624cdf0e10cSrcweir }
2625cdf0e10cSrcweir
2626cdf0e10cSrcweir //-------------------------------------------------------------------
2627cdf0e10cSrcweir
CreateHeaderBar(BrowseBox * pParent)2628cdf0e10cSrcweir BrowserHeader* BrowseBox::CreateHeaderBar( BrowseBox* pParent )
2629cdf0e10cSrcweir {
2630cdf0e10cSrcweir BrowserHeader* pNewBar = new BrowserHeader( pParent );
2631cdf0e10cSrcweir pNewBar->SetStartDragHdl( LINK( this, BrowseBox, StartDragHdl ) );
2632cdf0e10cSrcweir return pNewBar;
2633cdf0e10cSrcweir }
2634cdf0e10cSrcweir
SetHeaderBar(BrowserHeader * pHeaderBar)2635cdf0e10cSrcweir void BrowseBox::SetHeaderBar( BrowserHeader* pHeaderBar )
2636cdf0e10cSrcweir {
2637cdf0e10cSrcweir delete ( (BrowserDataWin*)pDataWin )->pHeaderBar;
2638cdf0e10cSrcweir ( (BrowserDataWin*)pDataWin )->pHeaderBar = pHeaderBar;
2639cdf0e10cSrcweir ( (BrowserDataWin*)pDataWin )->pHeaderBar->SetStartDragHdl( LINK( this, BrowseBox, StartDragHdl ) );
2640cdf0e10cSrcweir }
2641cdf0e10cSrcweir //-------------------------------------------------------------------
2642cdf0e10cSrcweir
2643cdf0e10cSrcweir #ifdef DBG_UTIL
BrowseBoxCheckInvariants(const void * pVoid)2644cdf0e10cSrcweir const char* BrowseBoxCheckInvariants( const void * pVoid )
2645cdf0e10cSrcweir {
2646cdf0e10cSrcweir const BrowseBox * p = (const BrowseBox *)pVoid;
2647cdf0e10cSrcweir
2648cdf0e10cSrcweir if (p->nRowCount < 0) return "BrowseBox: nRowCount < 0";
2649cdf0e10cSrcweir if (p->nTopRow < 0) return "BrowseBox: nTopRow < 0";
2650cdf0e10cSrcweir if (p->nTopRow >= p->nRowCount && p->nRowCount != 0) return "BrowseBox: nTopRow >= nRowCount && nRowCount != 0";
2651cdf0e10cSrcweir if (p->nCurRow < -1) return "BrowseBox: nCurRow < -1";
2652cdf0e10cSrcweir if (p->nCurRow > p->nRowCount) return "BrowseBox: nCurRow > nRowCount";
2653cdf0e10cSrcweir
2654cdf0e10cSrcweir // Leider waehrend der Bearbeitung nicht immer der Fall:
2655cdf0e10cSrcweir //if (p->nCurRow < 0 && p->nRowCount != 0) return "nCurRow < 0 && nRowCount != 0";
2656cdf0e10cSrcweir //if (p->nCurRow >= p->nRowCount && p->nRowCount != 0) return "nCurRow >= nRowCount && nRowCount != 0";
2657cdf0e10cSrcweir
2658cdf0e10cSrcweir return NULL;
2659cdf0e10cSrcweir }
2660cdf0e10cSrcweir #endif
2661cdf0e10cSrcweir
2662cdf0e10cSrcweir //-------------------------------------------------------------------
GetTitleHeight() const2663cdf0e10cSrcweir long BrowseBox::GetTitleHeight() const
2664cdf0e10cSrcweir {
2665cdf0e10cSrcweir long nHeight;
2666cdf0e10cSrcweir // ask the header bar for the text height (if possible), as the header bar's font is adjusted with
2667cdf0e10cSrcweir // our (and the header's) zoom factor
2668cdf0e10cSrcweir HeaderBar* pHeaderBar = ( (BrowserDataWin*)pDataWin )->pHeaderBar;
2669cdf0e10cSrcweir if ( pHeaderBar )
2670cdf0e10cSrcweir nHeight = pHeaderBar->GetTextHeight();
2671cdf0e10cSrcweir else
2672cdf0e10cSrcweir nHeight = GetTextHeight();
2673cdf0e10cSrcweir
2674cdf0e10cSrcweir return nTitleLines ? nTitleLines * nHeight + 4 : 0;
2675cdf0e10cSrcweir }
2676cdf0e10cSrcweir
2677cdf0e10cSrcweir //-------------------------------------------------------------------
CalcReverseZoom(long nVal)2678cdf0e10cSrcweir long BrowseBox::CalcReverseZoom(long nVal)
2679cdf0e10cSrcweir {
2680cdf0e10cSrcweir if (IsZoom())
2681cdf0e10cSrcweir {
2682cdf0e10cSrcweir const Fraction& rZoom = GetZoom();
2683cdf0e10cSrcweir double n = (double)nVal;
2684cdf0e10cSrcweir n *= (double)rZoom.GetDenominator();
2685cdf0e10cSrcweir n /= (double)rZoom.GetNumerator();
2686cdf0e10cSrcweir nVal = n>0 ? (long)(n + 0.5) : -(long)(-n + 0.5);
2687cdf0e10cSrcweir }
2688cdf0e10cSrcweir
2689cdf0e10cSrcweir return nVal;
2690cdf0e10cSrcweir }
2691cdf0e10cSrcweir
2692cdf0e10cSrcweir //-------------------------------------------------------------------
GetHeaderBar() const2693cdf0e10cSrcweir HeaderBar* BrowseBox::GetHeaderBar() const
2694cdf0e10cSrcweir {
2695cdf0e10cSrcweir return getDataWindow()->pHeaderBar;
2696cdf0e10cSrcweir }
2697cdf0e10cSrcweir //-------------------------------------------------------------------
2698cdf0e10cSrcweir
CursorMoved()2699cdf0e10cSrcweir void BrowseBox::CursorMoved()
2700cdf0e10cSrcweir {
2701cdf0e10cSrcweir // before implementing more here, please adjust the EditBrowseBox
2702cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2703cdf0e10cSrcweir
2704cdf0e10cSrcweir if ( isAccessibleAlive() && HasFocus() )
2705cdf0e10cSrcweir commitTableEvent(
2706cdf0e10cSrcweir ACTIVE_DESCENDANT_CHANGED,
2707cdf0e10cSrcweir makeAny( CreateAccessibleCell( GetCurRow(),GetColumnPos( GetCurColumnId() ) ) ),
2708cdf0e10cSrcweir Any()
2709cdf0e10cSrcweir );
2710cdf0e10cSrcweir }
2711cdf0e10cSrcweir
2712cdf0e10cSrcweir //-------------------------------------------------------------------
2713cdf0e10cSrcweir
LoseFocus()2714cdf0e10cSrcweir void BrowseBox::LoseFocus()
2715cdf0e10cSrcweir {
2716cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2717cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->LoseFocus", this );
2718cdf0e10cSrcweir
2719cdf0e10cSrcweir if ( bHasFocus )
2720cdf0e10cSrcweir {
2721cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
2722cdf0e10cSrcweir DoHideCursor( "LoseFocus" );
2723cdf0e10cSrcweir
2724cdf0e10cSrcweir if ( !bKeepHighlight )
2725cdf0e10cSrcweir {
2726cdf0e10cSrcweir ToggleSelection();
2727cdf0e10cSrcweir bSelectionIsVisible = sal_False;
2728cdf0e10cSrcweir }
2729cdf0e10cSrcweir
2730cdf0e10cSrcweir bHasFocus = sal_False;
2731cdf0e10cSrcweir }
2732cdf0e10cSrcweir Control::LoseFocus();
2733cdf0e10cSrcweir }
2734cdf0e10cSrcweir
2735cdf0e10cSrcweir //-------------------------------------------------------------------
2736cdf0e10cSrcweir
GetFocus()2737cdf0e10cSrcweir void BrowseBox::GetFocus()
2738cdf0e10cSrcweir {
2739cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2740cdf0e10cSrcweir DBG_TRACE1( "BrowseBox: %p->GetFocus", this );
2741cdf0e10cSrcweir
2742cdf0e10cSrcweir if ( !bHasFocus )
2743cdf0e10cSrcweir {
2744cdf0e10cSrcweir if ( !bSelectionIsVisible )
2745cdf0e10cSrcweir {
2746cdf0e10cSrcweir bSelectionIsVisible = sal_True;
2747cdf0e10cSrcweir if ( bBootstrapped )
2748cdf0e10cSrcweir ToggleSelection();
2749cdf0e10cSrcweir }
2750cdf0e10cSrcweir
2751cdf0e10cSrcweir bHasFocus = sal_True;
2752cdf0e10cSrcweir DoShowCursor( "GetFocus" );
2753cdf0e10cSrcweir }
2754cdf0e10cSrcweir Control::GetFocus();
2755cdf0e10cSrcweir }
2756cdf0e10cSrcweir
2757cdf0e10cSrcweir
2758