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