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(OUString::number(rSplits[i]) + ";");
78 }
79
80 OUString sFixedWidthLists = sSplits.makeStringAndClear();
81 Sequence<Any> aValues;
82 Any *pProperties;
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
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
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 }
150
151 if( nDiff & ScCsvDiff::PosOffset )
153}
154
156{
158 maBackColor = rSett.GetFaceColor();
163}
164
166{
167 mnSplitSize = (GetCharWidth() * 3 / 5) | 1; // make an odd number
168}
169
171{
173
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
186}
187
188void ScCsvRuler::MoveCursor( sal_Int32 nPos, bool bScroll )
189{
191 if( bScroll )
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 )
214 break;
215 case MOVE_NEXT:
216 if( GetRulerCursorPos() < GetPosCount() - 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 }
263}
264
265// split handling -------------------------------------------------------------
266
267sal_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
286void ScCsvRuler::InsertSplit( sal_Int32 nPos )
287{
288 if( maSplits.Insert( nPos ) )
289 {
291 Repaint();
292 }
293}
294
295void ScCsvRuler::RemoveSplit( sal_Int32 nPos )
296{
297 if( maSplits.Remove( nPos ) )
298 {
300 Repaint();
301 }
302}
303
304void 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 {
311 ImplDrawSplit( nNewPos );
312 Repaint();
313 }
314}
315
317{
318 maSplits.Clear();
319 Repaint( true );
320}
321
322sal_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
350void ScCsvRuler::MoveCurrSplit( sal_Int32 nNewPos )
351{
354 MoveCursor( nNewPos );
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{
384}
385
387{
391}
392
394{
395 InitColors();
396 Repaint();
397
399}
400
402{
404 if( !HasFocus() )
405 GrabFocus();
406 if( rMEvt.IsLeft() )
407 {
408 sal_Int32 nPos = GetPosFromX( rMEvt.GetPosPixel().X() );
409 if( IsVisibleSplitPos( nPos ) )
412 }
414 return true;
415}
416
418{
419 if (mbTracking)
420 {
422 mbTracking = false;
423 }
424 return true;
425}
426
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::clamp( nPos, sal_Int32(1), GetPosCount() - 1 );
437 }
438 else
439 {
440 tools::Rectangle aRect( Point(), maWinSize );
441 if( !IsVisibleSplitPos( nPos ) || !aRect.Contains( rMEvt.GetPosPixel() ) )
442 // if focused, keep old cursor position for key input
444 MoveCursor( nPos, false );
445 }
447 }
448 return true;
449}
450
451bool 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
486void ScCsvRuler::StartMouseTracking( sal_Int32 nPos )
487{
489 mbPosMTMoved = false;
492 if( HasSplit( nPos ) )
493 mbTracking = true;
494}
495
496void ScCsvRuler::MoveMouseTracking( sal_Int32 nPos )
497{
498 if( mnPosMTCurr != nPos )
499 {
501 MoveCursor( nPos );
504 else
507 mbPosMTMoved = true;
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
549void 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
604void 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
617void 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
641void 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 ) )
648 }
649}
650
652{
653 SetPointer( HasSplit( nPos ) ? PointerStyle::HSplit : PointerStyle::Arrow );
654}
655
656// accessibility ==============================================================
657
658css::uno::Reference<css::accessibility::XAccessible> ScCsvRuler::CreateAccessible()
659{
661 mxAccessible = xRef;
662 return xRef;
663}
664
665/* 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
constexpr tools::Long X() const
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:549
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:188
void UpdateSplitSize()
Update the split size depending on the last width set by CSVCMD_SETCHARWIDTH.
Definition: csvruler.cxx:165
void MoveMouseTracking(sal_Int32 nPos)
Moves tracking to a new position.
Definition: csvruler.cxx:496
virtual void StyleUpdated() override
Definition: csvruler.cxx:393
void EndMouseTracking()
Applies tracking action for the current tracking position.
Definition: csvruler.cxx:512
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:132
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:322
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:486
void ScrollVertRel(ScMoveMode eDir)
Scrolls data grid vertically.
Definition: csvruler.cxx:248
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:377
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: csvruler.cxx:105
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:629
virtual tools::Rectangle GetFocusRect() override
Definition: csvruler.cxx:541
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:125
void ImplDrawSplit(sal_Int32 nPos)
Draws a split to maRulerDev.
Definition: csvruler.cxx:604
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:451
void MoveCurrSplitRel(ScMoveMode eDir)
Moves split and cursor to the given direction and commits event.
Definition: csvruler.cxx:358
void MoveCursorToSplit(ScMoveMode eDir)
Sets cursor to an existing split, according to eDir.
Definition: csvruler.cxx:226
void ImplRedraw(vcl::RenderContext &rRenderContext)
Redraws the entire ruler.
Definition: csvruler.cxx:527
Size maWinSize
Tracking: Anytime moved to another position?
Definition: csvruler.hxx:53
void RemoveSplit(sal_Int32 nPos)
Removes a split.
Definition: csvruler.cxx:295
void InitColors()
Reads colors from system settings.
Definition: csvruler.cxx:155
ScCsvRuler(const ScCsvLayoutData &rData, ScCsvTableBox *pTableBox)
If currently mouse tracking.
Definition: csvruler.cxx:93
bool mbTracking
Size of a split circle.
Definition: csvruler.hxx:56
virtual bool MouseMove(const MouseEvent &rMEvt) override
Definition: csvruler.cxx:427
void RemoveAllSplits()
Removes all splits of the ruler.
Definition: csvruler.cxx:316
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:286
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: csvruler.cxx:417
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Creates a new accessible object.
Definition: csvruler.cxx:658
virtual void LoseFocus() override
Definition: csvruler.cxx:386
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: csvruler.cxx:522
void ImplEraseSplit(sal_Int32 nPos)
Erases a split from maRulerDev.
Definition: csvruler.cxx:617
void MoveCurrSplit(sal_Int32 nNewPos)
Moves split and cursor to nNewPos and commits event.
Definition: csvruler.cxx:350
void ImplInvertCursor(sal_Int32 nPos)
Inverts the cursor bar at the specified position in maRulerDev.
Definition: csvruler.cxx:641
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
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 MoveSplit(sal_Int32 nPos, sal_Int32 nNewPos)
Moves a split from nPos to nNewPos.
Definition: csvruler.cxx:304
void InitSizeData()
Initializes all data dependent from the control's size.
Definition: csvruler.cxx:170
bool mbPosMTMoved
Current position of mouse tracking.
Definition: csvruler.hxx:51
virtual void Resize() override
Definition: csvruler.cxx:370
ScCsvSplits maSplits
Split area color.
Definition: csvruler.hxx:45
void ImplSetMousePointer(sal_Int32 nPos)
Sets arrow or horizontal split pointer.
Definition: csvruler.cxx:651
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: csvruler.cxx:401
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
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