LibreOffice Module sc (master)  1
csvruler.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <csvruler.hxx>
21 #include <AccessibleCsvControl.hxx>
22 
23 #include <optutil.hxx>
24 #include <com/sun/star/uno/Any.hxx>
25 #include <com/sun/star/uno/Sequence.hxx>
26 #include <vcl/event.hxx>
27 #include <vcl/settings.hxx>
28 #include <vcl/ptrstyle.hxx>
29 #include <vcl/svapp.hxx>
30 #include <vcl/virdev.hxx>
31 
32 using namespace com::sun::star::uno;
33 
34 #define SEP_PATH "Office.Calc/Dialogs/CSVImport"
35 #define FIXED_WIDTH_LIST "FixedWidthList"
36 
37 static void load_FixedWidthList(ScCsvSplits &rSplits)
38 {
39  Sequence<Any>aValues;
40  const Any *pProperties;
42  ScLinkConfigItem aItem( SEP_PATH );
43 
44  aValues = aItem.GetProperties( aNames );
45  pProperties = aValues.getConstArray();
46 
47  if( !pProperties[0].hasValue() )
48  return;
49 
50  rSplits.Clear();
51 
52  OUString sFixedWidthLists;
53  pProperties[0] >>= sFixedWidthLists;
54 
55  sal_Int32 nIdx {0};
56  for(;;)
57  {
58  const sal_Int32 n {sFixedWidthLists.getToken(0, ';', nIdx).toInt32()};
59  if (nIdx<0)
60  {
61  // String ends with a semi-colon so there
62  // is no useful 'int' after the last one.
63  // This also works in case of empty string
64  break;
65  }
66  rSplits.Insert(n);
67  }
68 }
69 static void save_FixedWidthList(const ScCsvSplits& rSplits)
70 {
71  OUStringBuffer sSplits;
72  // Create a semi-colon separated string to save the splits
73  sal_uInt32 n = rSplits.Count();
74  for (sal_uInt32 i = 0; i < n; ++i)
75  {
76  sSplits.append(OUString::number(rSplits[i]));
77  sSplits.append(";");
78  }
79 
80  OUString sFixedWidthLists = sSplits.makeStringAndClear();
81  Sequence<Any> aValues;
82  Any *pProperties;
84  ScLinkConfigItem aItem( SEP_PATH );
85 
86  aValues = aItem.GetProperties( aNames );
87  pProperties = aValues.getArray();
88  pProperties[0] <<= sFixedWidthLists;
89 
90  aItem.PutProperties(aNames, aValues);
91 }
92 
94  : ScCsvControl(rData)
95  , mpTableBox(pTableBox)
96  , mnPosCursorLast(1)
97  , mnPosMTStart(0)
98  , mnPosMTCurr(0)
99  , mbPosMTMoved(false)
100  , mnSplitSize(0)
101  , mbTracking(false)
102 {
103 }
104 
106 {
107  ScCsvControl::SetDrawingArea(pDrawingArea);
108 
109  UpdateSplitSize();
110 
111  Size aSize(1, GetTextHeight() + mnSplitSize + 2);
112  pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
113  SetOutputSizePixel(aSize);
114 
115  EnableRTL( false ); // RTL
116  InitColors();
117  InitSizeData();
118 
119  OutputDevice& rRefDevice = pDrawingArea->get_ref_device();
120  maBackgrDev->SetFont( rRefDevice.GetFont() );
121  maRulerDev->SetFont( rRefDevice.GetFont() );
123 }
124 
126 {
128 }
129 
130 // common ruler handling ------------------------------------------------------
131 
133 {
135  if( nDiff == ScCsvDiff::Equal ) return;
136 
137  DisableRepaint();
138  if( nDiff & ScCsvDiff::HorizontalMask )
139  {
140  InitSizeData();
141  if( GetRulerCursorPos() >= GetPosCount() )
142  MoveCursor( GetPosCount() - 1 );
143  }
144  if( nDiff & ScCsvDiff::RulerCursor )
145  {
146  ImplInvertCursor( rOldData.mnPosCursor );
148  }
149  EnableRepaint();
150 
151  if( nDiff & ScCsvDiff::PosOffset )
153 }
154 
156 {
158  maBackColor = rSett.GetFaceColor();
159  maActiveColor = rSett.GetWindowColor();
160  maTextColor = rSett.GetLabelTextColor();
162  InvalidateGfx();
163 }
164 
166 {
167  mnSplitSize = (GetCharWidth() * 3 / 5) | 1; // make an odd number
168 }
169 
171 {
173 
174  UpdateSplitSize();
175 
176  sal_Int32 nActiveWidth = std::min( GetWidth() - GetHdrWidth(), GetPosCount() * GetCharWidth() );
177  sal_Int32 nActiveHeight = GetTextHeight();
178 
179  maActiveRect.SetPos( Point( GetFirstX(), (GetHeight() - nActiveHeight - 1) / 2 ) );
180  maActiveRect.SetSize( Size( nActiveWidth, nActiveHeight ) );
181 
182  maBackgrDev->SetOutputSizePixel( maWinSize );
183  maRulerDev->SetOutputSizePixel( maWinSize );
184 
185  InvalidateGfx();
186 }
187 
188 void ScCsvRuler::MoveCursor( sal_Int32 nPos, bool bScroll )
189 {
190  DisableRepaint();
191  if( bScroll )
194  EnableRepaint();
196 }
197 
199 {
201  return;
202 
203  switch( eDir )
204  {
205  case MOVE_FIRST:
206  MoveCursor( 1 );
207  break;
208  case MOVE_LAST:
209  MoveCursor( GetPosCount() - 1 );
210  break;
211  case MOVE_PREV:
212  if( GetRulerCursorPos() > 1 )
213  MoveCursor( GetRulerCursorPos() - 1 );
214  break;
215  case MOVE_NEXT:
216  if( GetRulerCursorPos() < GetPosCount() - 1 )
217  MoveCursor( GetRulerCursorPos() + 1 );
218  break;
219  default:
220  {
221  // added to avoid warnings
222  }
223  }
224 }
225 
227 {
229  return;
230 
231  sal_uInt32 nIndex = CSV_VEC_NOTFOUND;
232  switch( eDir )
233  {
234  case MOVE_FIRST: nIndex = maSplits.LowerBound( 0 ); break;
235  case MOVE_LAST: nIndex = maSplits.UpperBound( GetPosCount() ); break;
236  case MOVE_PREV: nIndex = maSplits.UpperBound( GetRulerCursorPos() - 1 ); break;
237  case MOVE_NEXT: nIndex = maSplits.LowerBound( GetRulerCursorPos() + 1 ); break;
238  default:
239  {
240  // added to avoid warnings
241  }
242  }
243  sal_Int32 nPos = maSplits[ nIndex ];
244  if( nPos != CSV_POS_INVALID )
245  MoveCursor( nPos );
246 }
247 
249 {
250  sal_Int32 nLine = GetFirstVisLine();
251  switch( eDir )
252  {
253  case MOVE_PREV: --nLine; break;
254  case MOVE_NEXT: ++nLine; break;
255  case MOVE_PREVPAGE: nLine -= GetVisLineCount() - 1; break;
256  case MOVE_NEXTPAGE: nLine += GetVisLineCount() - 1; break;
257  default:
258  {
259  // added to avoid warnings
260  }
261  }
262  Execute( CSVCMD_SETLINEOFFSET, nLine );
263 }
264 
265 // split handling -------------------------------------------------------------
266 
267 sal_Int32 ScCsvRuler::GetNoScrollPos( sal_Int32 nPos ) const
268 {
269  sal_Int32 nNewPos = nPos;
270  if( nNewPos != CSV_POS_INVALID )
271  {
272  if( nNewPos < GetFirstVisPos() + CSV_SCROLL_DIST )
273  {
274  sal_Int32 nScroll = (GetFirstVisPos() > 0) ? CSV_SCROLL_DIST : 0;
275  nNewPos = std::max( nPos, GetFirstVisPos() + nScroll );
276  }
277  else if( nNewPos > GetLastVisPos() - CSV_SCROLL_DIST - 1 )
278  {
279  sal_Int32 nScroll = (GetFirstVisPos() < GetMaxPosOffset()) ? CSV_SCROLL_DIST : 0;
280  nNewPos = std::min( nNewPos, GetLastVisPos() - nScroll - sal_Int32( 1 ) );
281  }
282  }
283  return nNewPos;
284 }
285 
286 void ScCsvRuler::InsertSplit( sal_Int32 nPos )
287 {
288  if( maSplits.Insert( nPos ) )
289  {
290  ImplDrawSplit( nPos );
291  Repaint();
292  }
293 }
294 
295 void ScCsvRuler::RemoveSplit( sal_Int32 nPos )
296 {
297  if( maSplits.Remove( nPos ) )
298  {
299  ImplEraseSplit( nPos );
300  Repaint();
301  }
302 }
303 
304 void ScCsvRuler::MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos )
305 {
306  bool bRemove = maSplits.Remove( nPos );
307  bool bInsert = maSplits.Insert( nNewPos );
308  if( bRemove || bInsert )
309  {
310  ImplEraseSplit( nPos );
311  ImplDrawSplit( nNewPos );
312  Repaint();
313  }
314 }
315 
317 {
318  maSplits.Clear();
319  Repaint( true );
320 }
321 
322 sal_Int32 ScCsvRuler::FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const
323 {
324  sal_Int32 nNewPos = nPos;
325  if( nNewPos != CSV_POS_INVALID )
326  {
327  switch( eDir )
328  {
329  case MOVE_FIRST:
330  nNewPos = std::min( nPos, FindEmptyPos( 0, MOVE_NEXT ) );
331  break;
332  case MOVE_LAST:
333  nNewPos = std::max( nPos, FindEmptyPos( GetPosCount(), MOVE_PREV ) );
334  break;
335  case MOVE_PREV:
336  while( HasSplit( --nNewPos ) ) ;
337  break;
338  case MOVE_NEXT:
339  while( HasSplit( ++nNewPos ) ) ;
340  break;
341  default:
342  {
343  // added to avoid warnings
344  }
345  }
346  }
347  return IsValidSplitPos( nNewPos ) ? nNewPos : CSV_POS_INVALID;
348 }
349 
350 void ScCsvRuler::MoveCurrSplit( sal_Int32 nNewPos )
351 {
352  DisableRepaint();
354  MoveCursor( nNewPos );
355  EnableRepaint();
356 }
357 
359 {
360  if( HasSplit( GetRulerCursorPos() ) )
361  {
362  sal_Int32 nNewPos = FindEmptyPos( GetRulerCursorPos(), eDir );
363  if( nNewPos != CSV_POS_INVALID )
364  MoveCurrSplit( nNewPos );
365  }
366 }
367 
368 // event handling -------------------------------------------------------------
369 
371 {
373  InitSizeData();
374  Repaint();
375 }
376 
378 {
380  DisableRepaint();
383  EnableRepaint();
384 }
385 
387 {
391 }
392 
394 {
395  InitColors();
396  Repaint();
397 
399 }
400 
402 {
403  DisableRepaint();
404  if( !HasFocus() )
405  GrabFocus();
406  if( rMEvt.IsLeft() )
407  {
408  sal_Int32 nPos = GetPosFromX( rMEvt.GetPosPixel().X() );
409  if( IsVisibleSplitPos( nPos ) )
410  StartMouseTracking( nPos );
411  ImplSetMousePointer( nPos );
412  }
413  EnableRepaint();
414  return true;
415 }
416 
418 {
419  if (mbTracking)
420  {
422  mbTracking = false;
423  }
424  return true;
425 }
426 
427 bool ScCsvRuler::MouseMove( const MouseEvent& rMEvt )
428 {
429  if( !rMEvt.IsModifierChanged() )
430  {
431  sal_Int32 nPos = GetPosFromX( rMEvt.GetPosPixel().X() );
432  if( mbTracking )
433  {
434  // on mouse tracking: keep position valid
435  nPos = std::max( std::min( nPos, GetPosCount() - sal_Int32( 1 ) ), sal_Int32( 1 ) );
436  MoveMouseTracking( nPos );
437  }
438  else
439  {
440  tools::Rectangle aRect( Point(), maWinSize );
441  if( !IsVisibleSplitPos( nPos ) || !aRect.IsInside( rMEvt.GetPosPixel() ) )
442  // if focused, keep old cursor position for key input
444  MoveCursor( nPos, false );
445  }
446  ImplSetMousePointer( nPos );
447  }
448  return true;
449 }
450 
451 bool ScCsvRuler::KeyInput( const KeyEvent& rKEvt )
452 {
453  const vcl::KeyCode& rKCode = rKEvt.GetKeyCode();
454  sal_uInt16 nCode = rKCode.GetCode();
455  bool bNoMod = !rKCode.GetModifier();
456  bool bShift = (rKCode.GetModifier() == KEY_SHIFT);
457  bool bJump = (rKCode.GetModifier() == KEY_MOD1);
458  bool bMove = (rKCode.GetModifier() == (KEY_MOD1 | KEY_SHIFT));
459 
460  ScMoveMode eHDir = GetHorzDirection( nCode, true );
461  ScMoveMode eVDir = GetVertDirection( nCode, false );
462 
463  if( bNoMod )
464  {
465  if( eHDir != MOVE_NONE )
466  MoveCursorRel( eHDir );
467  else if( eVDir != MOVE_NONE )
468  ScrollVertRel( eVDir );
469  else switch( nCode )
470  {
474  }
475  }
476  else if( bJump && (eHDir != MOVE_NONE) )
477  MoveCursorToSplit( eHDir );
478  else if( bMove && (eHDir != MOVE_NONE) )
479  MoveCurrSplitRel( eHDir );
480  else if( bShift && (nCode == KEY_DELETE) )
482 
483  return rKCode.GetGroup() == KEYGROUP_CURSOR;
484 }
485 
486 void ScCsvRuler::StartMouseTracking( sal_Int32 nPos )
487 {
488  mnPosMTStart = mnPosMTCurr = nPos;
489  mbPosMTMoved = false;
491  Execute( CSVCMD_INSERTSPLIT, nPos );
492  if( HasSplit( nPos ) )
493  mbTracking = true;
494 }
495 
496 void ScCsvRuler::MoveMouseTracking( sal_Int32 nPos )
497 {
498  if( mnPosMTCurr != nPos )
499  {
500  DisableRepaint();
501  MoveCursor( nPos );
503  Execute( CSVCMD_INSERTSPLIT, nPos );
504  else
506  mnPosMTCurr = nPos;
507  mbPosMTMoved = true;
508  EnableRepaint();
509  }
510 }
511 
513 {
514  // remove on simple click on an existing split
518 }
519 
520 // painting -------------------------------------------------------------------
521 
523 {
524  ImplRedraw(rRenderContext);
525 }
526 
528 {
529  if( IsVisible() )
530  {
531  if( !IsValidGfx() )
532  {
533  ValidateGfx();
536  }
537  rRenderContext.DrawOutDev( Point(), maWinSize, Point(), maWinSize, *maRulerDev );
538  }
539 }
540 
542 {
543  /* Draws directly tracking rectangle to the column with the specified index. */
544  if(HasFocus())
545  return tools::Rectangle(0, 0, GetWidth() - 1, GetHeight() - 2);
547 }
548 
549 void ScCsvRuler::ImplDrawArea( sal_Int32 nPosX, sal_Int32 nWidth )
550 {
551  maBackgrDev->SetLineColor();
552  tools::Rectangle aRect( Point( nPosX, 0 ), Size( nWidth, GetHeight() ) );
553  maBackgrDev->SetFillColor( maBackColor );
554  maBackgrDev->DrawRect( aRect );
555 
556  aRect = maActiveRect;
557  aRect.SetLeft( std::max( GetFirstX(), nPosX ) );
558  aRect.SetRight( std::min( std::min( GetX( GetPosCount() ), GetLastX() ), nPosX + nWidth - sal_Int32( 1 ) ) );
559  if( aRect.Left() <= aRect.Right() )
560  {
561  maBackgrDev->SetFillColor( maActiveColor );
562  maBackgrDev->DrawRect( aRect );
563  }
564 
565  maBackgrDev->SetLineColor( maTextColor );
566  sal_Int32 nY = GetHeight() - 1;
567  maBackgrDev->DrawLine( Point( nPosX, nY ), Point( nPosX + nWidth - 1, nY ) );
568 }
569 
571 {
572  ImplDrawArea( 0, GetWidth() );
573 
574  // scale
575  maBackgrDev->SetLineColor( maTextColor );
576  maBackgrDev->SetFillColor();
577  sal_Int32 nPos;
578 
579  sal_Int32 nFirstPos = std::max( GetPosFromX( 0 ) - 1, sal_Int32(0) );
580  sal_Int32 nLastPos = GetPosFromX( GetWidth() );
581  sal_Int32 nY = (maActiveRect.Top() + maActiveRect.Bottom()) / 2;
582  for( nPos = nFirstPos; nPos <= nLastPos; ++nPos )
583  {
584  sal_Int32 nX = GetX( nPos );
585  if( nPos % 5 )
586  maBackgrDev->DrawPixel( Point( nX, nY ) );
587  else
588  maBackgrDev->DrawLine( Point( nX, nY - 1 ), Point( nX, nY + 1 ) );
589  }
590 
591  // texts
592  maBackgrDev->SetTextColor( maTextColor );
593  maBackgrDev->SetTextFillColor();
594  for( nPos = ((nFirstPos + 9) / 10) * 10; nPos <= nLastPos; nPos += 10 )
595  {
596  OUString aText( OUString::number( nPos ) );
597  sal_Int32 nTextWidth = maBackgrDev->GetTextWidth( aText );
598  sal_Int32 nTextX = GetX( nPos ) - nTextWidth / 2;
599  ImplDrawArea( nTextX - 1, nTextWidth + 2 );
600  maBackgrDev->DrawText( Point( nTextX, maActiveRect.Top() ), aText );
601  }
602 }
603 
604 void ScCsvRuler::ImplDrawSplit( sal_Int32 nPos )
605 {
606  if( IsVisibleSplitPos( nPos ) )
607  {
608  Point aPos( GetX( nPos ) - mnSplitSize / 2, GetHeight() - mnSplitSize - 2 );
609  Size aSize( mnSplitSize, mnSplitSize );
610  maRulerDev->SetLineColor( maTextColor );
611  maRulerDev->SetFillColor( maSplitColor );
612  maRulerDev->DrawEllipse( tools::Rectangle( aPos, aSize ) );
613  maRulerDev->DrawPixel( Point( GetX( nPos ), GetHeight() - 2 ) );
614  }
615 }
616 
617 void ScCsvRuler::ImplEraseSplit( sal_Int32 nPos )
618 {
619  if( IsVisibleSplitPos( nPos ) )
620  {
622  Point aPos( GetX( nPos ) - mnSplitSize / 2, 0 );
623  Size aSize( mnSplitSize, GetHeight() );
624  maRulerDev->DrawOutDev( aPos, aSize, aPos, aSize, *maBackgrDev );
626  }
627 }
628 
630 {
631  maRulerDev->DrawOutDev( Point(), maWinSize, Point(), maWinSize, *maBackgrDev );
633 
634  sal_uInt32 nFirst = maSplits.LowerBound( GetFirstVisPos() );
635  sal_uInt32 nLast = maSplits.UpperBound( GetLastVisPos() );
636  if( (nFirst != CSV_VEC_NOTFOUND) && (nLast != CSV_VEC_NOTFOUND) )
637  for( sal_uInt32 nIndex = nFirst; nIndex <= nLast; ++nIndex )
639 }
640 
641 void ScCsvRuler::ImplInvertCursor( sal_Int32 nPos )
642 {
643  if( IsVisibleSplitPos( nPos ) )
644  {
645  ImplInvertRect( *maRulerDev, tools::Rectangle( Point( GetX( nPos ) - 1, 0 ), Size( 3, GetHeight() - 1 ) ) );
646  if( HasSplit( nPos ) )
647  ImplDrawSplit( nPos );
648  }
649 }
650 
651 void ScCsvRuler::ImplSetMousePointer( sal_Int32 nPos )
652 {
653  SetPointer( HasSplit( nPos ) ? PointerStyle::HSplit : PointerStyle::Arrow );
654 }
655 
656 // accessibility ==============================================================
657 
658 css::uno::Reference<css::accessibility::XAccessible> ScCsvRuler::CreateAccessible()
659 {
661  mxAccessible.set(xRef.get());
662  return css::uno::Reference<css::accessibility::XAccessible>(xRef.get());
663 }
664 
665 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScCsvDiff GetDiff(const ScCsvLayoutData &rData) const
Returns differences to rData.
Definition: csvcontrol.cxx:43
Change data line pixel height. [height in pixel}.
Definition: csvcontrol.hxx:179
long Width() const
void ScrollVertRel(ScMoveMode eDir)
Scrolls data grid vertically.
Definition: csvruler.cxx:248
void SetPos(const Point &rPoint)
static void ImplInvertRect(OutputDevice &rOutDev, const tools::Rectangle &rRect)
Inverts a rectangle in the specified output device.
Definition: csvcontrol.cxx:242
sal_uInt32 UpperBound(sal_Int32 nPos) const
Returns index of the last split less than or equal to nPos.
Definition: csvsplits.cxx:82
Color maActiveColor
Background color.
Definition: csvruler.hxx:43
Color maTextColor
Color for active part of ruler.
Definition: csvruler.hxx:44
sal_Int32 nIndex
void InsertSplit(sal_Int32 nPos)
Inserts a split.
Definition: csvruler.cxx:286
void EnableRepaint()
Decreases no-repaint counter and repaints if counter reaches 0.
Definition: csvcontrol.cxx:143
constexpr sal_uInt16 KEY_MOD1
const sal_Int32 CSV_POS_INVALID
Constant for an invalid ruler position.
Definition: csvsplits.hxx:30
void InitSizeData()
Initializes all data dependent from the control's size.
Definition: csvruler.cxx:170
sal_Int32 GetPosCount() const
Returns the number of available positions.
Definition: csvcontrol.hxx:302
void ImplRedraw(vcl::RenderContext &rRenderContext)
Redraws the entire ruler.
Definition: csvruler.cxx:527
const ScCsvLayoutData & GetLayoutData() const
Returns a reference to the current layout data.
Definition: csvcontrol.hxx:297
long Height() const
ScMoveMode
Specifies which element should be used to perform an action.
Definition: csvcontrol.hxx:78
Set number of first imported line. [line index].
Definition: csvcontrol.hxx:191
sal_Int32 GetX(sal_Int32 nPos) const
Returns output X coordinate of the specified position.
Definition: csvcontrol.cxx:195
void StartMouseTracking(sal_Int32 nPos)
Starts tracking at the specified position.
Definition: csvruler.cxx:486
void AccSendVisibleEvent()
Sends a visible area changed event to the accessibility object.
Definition: csvcontrol.cxx:98
sal_uInt32 LowerBound(sal_Int32 nPos) const
Returns index of the first split greater than or equal to nPos.
Definition: csvsplits.cxx:77
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
const Color & GetFaceColor() const
static ScMoveMode GetHorzDirection(sal_uInt16 nCode, bool bHomeEnd)
Returns direction code for the keys LEFT, RIGHT, HOME, END.
Definition: csvcontrol.cxx:252
sal_Int64 n
#define SEP_PATH
Definition: csvruler.cxx:34
sal_uInt16 GetGroup() const
sal_uInt16 GetCode() const
bool IsValidGfx() const
Returns true, if cached graphic is valid.
Definition: csvcontrol.hxx:269
const Color & GetLabelTextColor() const
virtual bool KeyInput(const KeyEvent &rKEvt) override
Definition: csvruler.cxx:451
bool mbTracking
Size of a split circle.
Definition: csvruler.hxx:58
constexpr sal_uInt16 KEY_SPACE
virtual void StyleUpdated() override
Definition: csvruler.cxx:393
ScCsvRuler(const ScCsvLayoutData &rData, ScCsvTableBox *pTableBox)
If currently mouse tracking.
Definition: csvruler.cxx:93
static void load_FixedWidthList(ScCsvSplits &rSplits)
Definition: csvruler.cxx:37
Base class for the CSV ruler and the data grid control.
Definition: csvcontrol.hxx:224
bool mbPosMTMoved
Current position of mouse tracking.
Definition: csvruler.hxx:53
Size const & GetOutputSizePixel() const
void RemoveSplit(sal_Int32 nPos)
Removes a split.
Definition: csvruler.cxx:295
void ImplDrawBackgrDev()
Draws the entire ruler background with scaling to maBackgrDev.
Definition: csvruler.cxx:570
void MoveCursorRel(ScMoveMode eDir)
Moves cursor to the given direction.
Definition: csvruler.cxx:198
void ImplSetMousePointer(sal_Int32 nPos)
Sets arrow or horizontal split pointer.
Definition: csvruler.cxx:651
Predecessor of current element in current context.
Definition: csvcontrol.hxx:84
virtual void GetFocus() override
Definition: csvcontrol.cxx:74
long Right() const
sal_Int32 GetLastX() const
Returns the X position of the last pixel of the data area.
Definition: csvcontrol.cxx:190
const sal_Int32 CSV_SCROLL_DIST
Minimum distance to border for auto scroll.
Definition: csvcontrol.hxx:41
sal_Int32 GetCharWidth() const
Returns the width of one character column.
Definition: csvcontrol.hxx:320
const vcl::Font & GetFont() const
void AccSendCaretEvent()
Sends a caret changed event to the accessibility object.
Definition: csvcontrol.cxx:92
bool Remove(sal_Int32 nPos)
Removes a split by position.
Definition: csvsplits.cxx:43
sal_Int32 mnPosCursorLast
Old state for cancellation.
Definition: csvruler.hxx:50
ScCsvSplits maSplits
Split area color.
Definition: csvruler.hxx:47
Inserts or removes a split. [position].
Definition: csvcontrol.hxx:194
sal_uInt16 GetModifier() const
constexpr sal_uInt16 KEYGROUP_CURSOR
long Top() const
virtual OutputDevice & get_ref_device()=0
static void save_FixedWidthList(const ScCsvSplits &rSplits)
Definition: csvruler.cxx:69
sal_Int32 GetFirstX() const
Returns the X position of the first pixel of the data area.
Definition: csvcontrol.cxx:185
const sal_uInt32 CSV_VEC_NOTFOUND
Constant for an invalid vector index.
Definition: csvsplits.hxx:28
sal_uInt16 nCode
void MoveSplit(sal_Int32 nPos, sal_Int32 nNewPos)
Moves a split from nPos to nNewPos.
Definition: csvruler.cxx:304
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_LIGHTRED
Change number of data lines. [line count].
Definition: csvcontrol.hxx:174
Remove a split. [position].
Definition: csvcontrol.hxx:193
sal_Int32 GetSplitPos(sal_uInt32 nIndex) const
Returns the position of the specified split.
Definition: csvruler.hxx:95
void Repaint(bool bInvalidate=false)
Repaints all controls.
Definition: csvcontrol.cxx:130
sal_Int32 GetLastVisPos() const
Returns the last visible position.
Definition: csvcontrol.hxx:308
void ImplEraseSplit(sal_Int32 nPos)
Erases a split from maRulerDev.
Definition: csvruler.cxx:617
bool HasSplit(sal_Int32 nPos) const
Returns true if at position nPos is a split.
Definition: csvsplits.cxx:66
void ImplInvertCursor(sal_Int32 nPos)
Inverts the cursor bar at the specified position in maRulerDev.
Definition: csvruler.cxx:641
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Creates a new accessible object.
Definition: csvruler.cxx:658
virtual void GetFocus() override
Definition: csvruler.cxx:377
Last element in current context.
Definition: csvcontrol.hxx:83
Successor of current element in current context.
Definition: csvcontrol.hxx:85
int i
Color maBackColor
Ruler with splits and cursor.
Definition: csvruler.hxx:42
bool IsDark() const
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: csvruler.cxx:417
ScCsvSplits maOldSplits
Vector with split positions.
Definition: csvruler.hxx:48
virtual tools::Rectangle GetFocusRect() override
Definition: csvruler.cxx:541
void Clear()
Removes all elements from the vector.
Definition: csvsplits.cxx:61
static ScMoveMode GetVertDirection(sal_uInt16 nCode, bool bHomeEnd)
Returns direction code for the keys UP, DOWN, HOME, END, PAGE UP, PAGE DOWN.
Definition: csvcontrol.cxx:267
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: csvruler.cxx:105
void SetSize(const Size &rSize)
sal_Int32 GetPosFromX(sal_Int32 nX) const
Returns position from output coordinate.
Definition: csvcontrol.cxx:200
void SetRight(long v)
virtual ~ScCsvRuler() override
Definition: csvruler.cxx:125
Move data grid cursor to new column. [position].
Definition: csvcontrol.hxx:181
virtual tools::Rectangle GetFocusRect()
virtual void LoseFocus() override
Definition: csvruler.cxx:386
A vector of column splits that supports inserting, removing and moving splits.
Definition: csvsplits.hxx:33
long Bottom() const
sal_Int32 GetFirstVisLine() const
Returns index of first visible line.
Definition: csvcontrol.hxx:337
sal_Int32 GetVisLineCount() const
Returns the number of visible lines (including partly visible bottom line).
Definition: csvcontrol.cxx:205
rtl::Reference< ScAccessibleCsvControl > mxAccessible
Content of virtual devices valid?
Definition: csvcontrol.hxx:234
bool IsVisibleSplitPos(sal_Int32 nPos) const
Returns true, if nPos is an allowed AND visible split position.
Definition: csvcontrol.cxx:175
bool HasSplit(sal_Int32 nPos) const
Returns true if at position nPos is a split.
Definition: csvruler.hxx:101
bool IsInside(const Point &rPOINT) const
#define FIXED_WIDTH_LIST
Definition: csvruler.cxx:35
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: csvruler.cxx:401
void MoveCursor(sal_Int32 nPos, bool bScroll=true)
Moves cursor to a new position.
Definition: csvruler.cxx:188
void RemoveAllSplits()
Removes all splits of the ruler.
Definition: csvruler.cxx:316
void ValidateGfx()
Sets the graphic valid (next Redraw() will use cached graphic).
Definition: csvcontrol.hxx:267
void MoveCurrSplitRel(ScMoveMode eDir)
Moves split and cursor to the given direction and commits event.
Definition: csvruler.cxx:358
void MoveCurrSplit(sal_Int32 nNewPos)
Moves split and cursor to nNewPos and commits event.
Definition: csvruler.cxx:350
void MoveCursorToSplit(ScMoveMode eDir)
Sets cursor to an existing split, according to eDir.
Definition: csvruler.cxx:226
void ImplDrawSplit(sal_Int32 nPos)
Draws a split to maRulerDev.
Definition: csvruler.cxx:604
First element in current context.
Definition: csvcontrol.hxx:82
void SetOutputSizePixel(const Size &rSize)
sal_Int32 GetMaxPosOffset() const
Returns highest possible position for first visible character.
Definition: csvcontrol.cxx:165
No action.
Definition: csvcontrol.hxx:81
ScopedVclPtrInstance< VirtualDevice > maBackgrDev
Grid Parent.
Definition: csvruler.hxx:39
sal_Int32 mnPosCursor
Height of a data line.
Definition: csvcontrol.hxx:132
void PutProperties(const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues)
Definition: optutil.hxx:54
The control in the CSV import dialog that contains a ruler and a data grid to visualize and modify th...
Definition: csvtablebox.hxx:44
Accessible class representing the CSV ruler control.
bool IsModifierChanged() const
sal_Int32 FindEmptyPos(sal_Int32 nPos, ScMoveMode eDir) const
Finds next position without a split.
Definition: csvruler.cxx:322
const vcl::KeyCode & GetKeyCode() const
virtual void LoseFocus() override
Definition: csvcontrol.cxx:80
sal_Int32 GetRulerCursorPos() const
Returns the ruler cursor position.
Definition: csvcontrol.hxx:358
void Execute(ScCsvCmdType eType, sal_Int32 nParam1=CSV_POS_INVALID, sal_Int32 nParam2=CSV_POS_INVALID)
Executes a command by calling command handler.
Definition: csvcontrol.cxx:152
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: csvruler.cxx:522
virtual void Resize() override
Definition: csvruler.cxx:370
void ApplyLayout(const ScCsvLayoutData &rOldData)
Apply current layout data to the ruler.
Definition: csvruler.cxx:132
bool IsLeft() const
void MoveMouseTracking(sal_Int32 nPos)
Moves tracking to a new position.
Definition: csvruler.cxx:496
Size maWinSize
Tracking: Anytime moved to another position?
Definition: csvruler.hxx:55
sal_Int32 GetHdrWidth() const
Returns the width of the header column.
Definition: csvcontrol.hxx:318
sal_Int32 mnSplitSize
The active area of the ruler.
Definition: csvruler.hxx:57
ScCsvDiff
Flags for comparison of old and new control layout data.
Definition: csvcontrol.hxx:90
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
Color maSplitColor
Text and scale color.
Definition: csvruler.hxx:45
bool IsValidSplitPos(sal_Int32 nPos) const
Returns true, if it is allowed to set a split at nPos.
Definition: csvcontrol.cxx:170
const Color & GetWindowColor() const
const Point & GetPosPixel() const
Previous page relative to current context.
Definition: csvcontrol.hxx:86
long Left() const
void DisableRepaint()
Increases no-repaint counter (controls do not repaint until the last EnableRepaint()).
Definition: csvcontrol.cxx:138
void InvalidateGfx()
Sets the graphic invalid (next Redraw() will not use cached graphic).
Definition: csvcontrol.hxx:265
void SetLeft(long v)
bool Insert(sal_Int32 nPos)
The split container.
Definition: csvsplits.cxx:26
Insert a split. [position].
Definition: csvcontrol.hxx:192
constexpr sal_uInt16 KEY_DELETE
void UpdateSplitSize()
Update the split size depending on the last width set by CSVCMD_SETCHARWIDTH.
Definition: csvruler.cxx:165
sal_Int32 GetNoScrollPos(sal_Int32 nPos) const
Finds a position nearest to nPos which does not cause scrolling the visible area. ...
Definition: csvruler.cxx:267
virtual bool MouseMove(const MouseEvent &rMEvt) override
Definition: csvruler.cxx:427
tools::Rectangle maActiveRect
Size of the control.
Definition: csvruler.hxx:56
constexpr sal_uInt16 KEY_INSERT
ScopedVclPtrInstance< VirtualDevice > maRulerDev
Ruler background, scaling.
Definition: csvruler.hxx:40
constexpr sal_uInt16 KEY_SHIFT
void EndMouseTracking()
Applies tracking action for the current tracking position.
Definition: csvruler.cxx:512
virtual void set_size_request(int nWidth, int nHeight)=0
void SetPointer(PointerStyle ePointerStyle)
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
Definition: optutil.hxx:52
Move a split. [old position, new position].
Definition: csvcontrol.hxx:195
void ImplDrawArea(sal_Int32 nPosX, sal_Int32 nWidth)
Draws the background and active area to maBackgrDev (only the given X range).
Definition: csvruler.cxx:549
sal_Int32 GetFirstVisPos() const
Returns the first visible position.
Definition: csvcontrol.hxx:306
sal_Int32 mnPosMTCurr
Start position of mouse tracking.
Definition: csvruler.hxx:52
sal_uInt32 Count() const
Returns the number of splits.
Definition: csvsplits.hxx:69
sal_Int32 GetWidth() const
Returns the width of the control.
Definition: csvruler.hxx:153
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
sal_Int32 mnPosMTStart
Last valid position of cursor.
Definition: csvruler.hxx:51
sal_uInt16 nPos
void InitColors()
Reads colors from system settings.
Definition: csvruler.cxx:155
void EnableRTL(bool bEnable)
void ImplDrawRulerDev()
Draws the ruler background, all splits and the cursor to maRulerDev.
Definition: csvruler.cxx:629
A structure containing all layout data valid for both ruler and data grid (i.e.
Definition: csvcontrol.hxx:113
sal_Int32 GetHeight() const
Returns the height of the control.
Definition: csvruler.hxx:155