LibreOffice Module sc (master) 1
csvgrid.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 <comphelper/lok.hxx>
21#include <csvgrid.hxx>
22#include <csvtablebox.hxx>
23
24#include <algorithm>
25#include <memory>
26
27#include <svtools/colorcfg.hxx>
28#include <sal/macros.h>
29#include <tools/poly.hxx>
30#include <scmod.hxx>
31#include <asciiopt.hxx>
32#include <impex.hxx>
34
35// *** edit engine ***
36#include <editeng/eeitem.hxx>
37#include <vcl/commandevent.hxx>
38#include <vcl/event.hxx>
39#include <vcl/settings.hxx>
40#include <vcl/svapp.hxx>
41#include <vcl/virdev.hxx>
42#include <vcl/weldutils.hxx>
43
44#include <editeng/colritem.hxx>
45#include <editeng/fhgtitem.hxx>
46#include <editeng/fontitem.hxx>
47#include <editeng/wghtitem.hxx>
48#include <editeng/postitem.hxx>
49#include <editeng/langitem.hxx>
50#include <svl/itempool.hxx>
51#include <svl/itemset.hxx>
52#include <editutil.hxx>
53// *** edit engine ***
54
55namespace {
56
57struct Func_SetType
58{
59 sal_Int32 mnType;
60 explicit Func_SetType( sal_Int32 nType ) : mnType( nType ) {}
61 void operator()( ScCsvColState& rState ) const
62 { rState.mnType = mnType; }
63};
64
65struct Func_Select
66{
67 bool mbSelect;
68 explicit Func_Select( bool bSelect ) : mbSelect( bSelect ) {}
69 void operator()( ScCsvColState& rState ) const
70 { rState.Select( mbSelect ); }
71};
72
73}
74
75ScCsvGrid::ScCsvGrid(const ScCsvLayoutData& rData, std::unique_ptr<weld::Menu> xPopup, ScCsvTableBox* pTableBox)
76 : ScCsvControl(rData)
77 , mpTableBox(pTableBox)
78 , mpBackgrDev( VclPtr<VirtualDevice>::Create() )
79 , mpGridDev( VclPtr<VirtualDevice>::Create() )
80 , mxPopup(std::move(xPopup))
81 , mpColorConfig( nullptr )
82 , mpEditEngine( new ScEditEngineDefaulter( EditEngine::CreatePool().get(), true ) )
83 , maColStates( 1 )
84 , maTypeNames( 1 )
85 , mnFirstImpLine( 0 )
86 , mnRecentSelCol( CSV_COLUMN_INVALID )
87 , mnMTCurrCol( SAL_MAX_UINT32 )
88 , mbTracking( false )
89 , mbMTSelecting( false )
90{
91 mpEditEngine->SetRefDevice( mpBackgrDev.get() );
92 mpEditEngine->SetRefMapMode( MapMode( MapUnit::MapPixel ) );
93 maEdEngSize = mpEditEngine->GetPaperSize();
94}
95
97{
98 OutputDevice& rRefDevice = pDrawingArea->get_ref_device();
100
101 // expand the point size of the desired font to the equivalent pixel size
102 weld::SetPointFont(rRefDevice, maHeaderFont);
103 maHeaderFont = rRefDevice.GetFont();
104
105 // Because this is an always LeftToRight layout widget the initial size of
106 // this widget needs to be smaller than the size of the parent scrolling
107 // window (ScCsvTableBox ctor) because in RTL mode the alignment is against
108 // the right edge of the parent, and if larger than the scrolling window
109 // the left edge will be lost. If this widget is smaller than the scrolling
110 // window it is stretched to fit the parent and the problem doesn't arise.
111 Size aInitialSize(10, 10);
113 aInitialSize = Size(-1, 150);
114 ScCsvControl::SetDrawingArea(pDrawingArea);
115 pDrawingArea->set_size_request(aInitialSize.Width(), aInitialSize.Height());
116 SetOutputSizePixel(aInitialSize);
117
118 EnableRTL( false ); // RTL
119
120 InitFonts();
122}
123
125{
126 OSL_ENSURE(mpColorConfig, "the object hasn't been initialized properly");
127 if (mpColorConfig)
128 mpColorConfig->RemoveListener(this);
131}
132
133void
135{
136 OSL_PRECOND(!mpColorConfig, "the object has already been initialized");
137 mpColorConfig = &SC_MOD()->GetColorConfig();
138 InitColors();
139 mpColorConfig->AddListener(this);
140}
141
142// common grid handling -------------------------------------------------------
143
145{
147 OutputDevice& rRefDevice = GetDrawingArea()->get_ref_device();
148 rRefDevice.SetFont(maMonoFont);
149 Execute(CSVCMD_SETCHARWIDTH, rRefDevice.GetTextWidth(OUString('X')));
150 Execute(CSVCMD_SETLINEHEIGHT, rRefDevice.GetTextHeight() + 1);
151 rRefDevice.SetFont(maHeaderFont);
152 Execute(CSVCMD_SETHDRHEIGHT, rRefDevice.GetTextHeight() + 1);
155}
156
158{
159 sal_Int32 nLastLine = GetLastVisLine() + 1;
160 sal_Int32 nDigits = 2;
161 for (;;)
162 {
163 nLastLine /= 10;
164 if (!nLastLine)
165 break;
166 ++nDigits;
167 }
168 nDigits = std::max( nDigits, sal_Int32( 3 ) );
169 Execute(CSVCMD_SETHDRWIDTH, GetDrawingArea()->get_approximate_digit_width() * nDigits);
170}
171
173{
174 ScCsvDiff nDiff = GetLayoutData().GetDiff( rOldData );
175 if( nDiff == ScCsvDiff::Equal ) return;
176
178
179 if( nDiff & ScCsvDiff::RulerCursor )
180 {
181 ImplInvertCursor( rOldData.mnPosCursor );
183 }
184
185 if( nDiff & ScCsvDiff::PosCount )
186 {
187 if( GetPosCount() < rOldData.mnPosCount )
188 {
189 SelectAll( false );
191 }
192 else
193 maSplits.Remove( rOldData.mnPosCount );
195 maColStates.resize( maSplits.Count() - 1 );
196 }
197
198 if( nDiff & ScCsvDiff::LineOffset )
199 {
202 }
203
205 if( nHVDiff == ScCsvDiff::PosOffset )
207 else if( nHVDiff != ScCsvDiff::Equal )
209
211
214}
215
216void ScCsvGrid::SetFirstImportedLine( sal_Int32 nLine )
217{
218 ImplDrawFirstLineSep( false );
219 mnFirstImpLine = nLine;
220 ImplDrawFirstLineSep( true );
222 Repaint();
223}
224
225sal_Int32 ScCsvGrid::GetNoScrollCol( sal_Int32 nPos ) const
226{
227 sal_Int32 nNewPos = nPos;
228 if( nNewPos != CSV_POS_INVALID )
229 {
230 if( nNewPos < GetFirstVisPos() + CSV_SCROLL_DIST )
231 {
232 sal_Int32 nScroll = (GetFirstVisPos() > 0) ? CSV_SCROLL_DIST : 0;
233 nNewPos = GetFirstVisPos() + nScroll;
234 }
235 else if( nNewPos > GetLastVisPos() - CSV_SCROLL_DIST - 1 )
236 {
237 sal_Int32 nScroll = (GetFirstVisPos() < GetMaxPosOffset()) ? CSV_SCROLL_DIST : 0;
238 nNewPos = GetLastVisPos() - nScroll - 1;
239 }
240 }
241 return nNewPos;
242}
243
245{
246 OSL_PRECOND(mpColorConfig, "the object hasn't been initialized properly");
247 if ( !mpColorConfig )
248 return;
249 maBackColor = mpColorConfig->GetColorValue( ::svtools::DOCCOLOR ).nColor;
250 maGridColor = mpColorConfig->GetColorValue( ::svtools::CALCGRID ).nColor;
251 maGridPBColor = mpColorConfig->GetColorValue( ::svtools::CALCPAGEBREAK ).nColor;
252 maAppBackColor = mpColorConfig->GetColorValue( ::svtools::APPBACKGROUND ).nColor;
253 maTextColor = mpColorConfig->GetColorValue( ::svtools::FONTCOLOR, false ).nColor;
254
255 // tdf#147386 If Automatic font color is used, then check background color and use Black/White as font color
256 if ( maTextColor == COL_AUTO )
257 {
258 if ( maBackColor.IsDark() )
260 else
262 }
263
269
271}
272
274{
275 maMonoFont = OutputDevice::GetDefaultFont( DefaultFontType::FIXED, LANGUAGE_ENGLISH_US, GetDefaultFontFlags::NONE );
277
278 /* *** Set edit engine defaults ***
279 maMonoFont for Latin script, smaller default font for Asian and Complex script. */
280
281 // get default fonts
282 SvxFontItem aLatinItem( EE_CHAR_FONTINFO );
283 SvxFontItem aAsianItem( EE_CHAR_FONTINFO_CJK );
284 SvxFontItem aComplexItem( EE_CHAR_FONTINFO_CTL );
285 ::GetDefaultFonts( aLatinItem, aAsianItem, aComplexItem );
286
287 // create item set for defaults
288 SfxItemSet aDefSet( mpEditEngine->GetEmptyItemSet() );
290 aDefSet.Put( aAsianItem );
291 aDefSet.Put( aComplexItem );
292
293 // set Asian/Complex font size to height of character in Latin font
294 sal_uLong nFontHt = static_cast< sal_uLong >( maMonoFont.GetFontSize().Height() );
295 aDefSet.Put( SvxFontHeightItem( nFontHt, 100, EE_CHAR_FONTHEIGHT_CJK ) );
296 aDefSet.Put( SvxFontHeightItem( nFontHt, 100, EE_CHAR_FONTHEIGHT_CTL ) );
297
298 // copy other items from default font
299 const SfxPoolItem& rWeightItem = aDefSet.Get( EE_CHAR_WEIGHT );
300 std::unique_ptr<SfxPoolItem> pNewItem(rWeightItem.Clone());
301 pNewItem->SetWhich(EE_CHAR_WEIGHT_CJK);
302 aDefSet.Put( *pNewItem );
303 pNewItem->SetWhich(EE_CHAR_WEIGHT_CTL);
304 aDefSet.Put( *pNewItem );
305 const SfxPoolItem& rItalicItem = aDefSet.Get( EE_CHAR_ITALIC );
306 pNewItem.reset(rItalicItem.Clone());
307 pNewItem->SetWhich(EE_CHAR_ITALIC_CJK);
308 aDefSet.Put( *pNewItem );
309 pNewItem->SetWhich(EE_CHAR_ITALIC_CTL);
310 aDefSet.Put( *pNewItem );
311 const SfxPoolItem& rLangItem = aDefSet.Get( EE_CHAR_LANGUAGE );
312 pNewItem.reset(rLangItem.Clone());
314 aDefSet.Put( *pNewItem );
316 aDefSet.Put( *pNewItem );
317
318 mpEditEngine->SetDefaults( aDefSet );
320}
321
323{
325 mpBackgrDev->SetOutputSizePixel( maWinSize );
326 mpGridDev->SetOutputSizePixel( maWinSize );
328}
329
330// split handling -------------------------------------------------------------
331
332void ScCsvGrid::InsertSplit( sal_Int32 nPos )
333{
334 if( ImplInsertSplit( nPos ) )
335 {
339 sal_uInt32 nColIx = GetColumnFromPos( nPos );
340 ImplDrawColumn( nColIx - 1 );
341 ImplDrawColumn( nColIx );
342 ValidateGfx(); // performance: do not redraw all columns
344 }
345}
346
347void ScCsvGrid::RemoveSplit( sal_Int32 nPos )
348{
349 if( ImplRemoveSplit( nPos ) )
350 {
355 ValidateGfx(); // performance: do not redraw all columns
357 }
358}
359
360void ScCsvGrid::MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos )
361{
362 sal_uInt32 nColIx = GetColumnFromPos( nPos );
363 if( nColIx == CSV_COLUMN_INVALID )
364 return;
365
367 if( (GetColumnPos( nColIx - 1 ) < nNewPos) && (nNewPos < GetColumnPos( nColIx + 1 )) )
368 {
369 // move a split in the range between 2 others -> keep selection state of both columns
371 maSplits.Insert( nNewPos );
373 ImplDrawColumn( nColIx - 1 );
374 ImplDrawColumn( nColIx );
375 ValidateGfx(); // performance: do not redraw all columns
376 AccSendTableUpdateEvent( nColIx - 1, nColIx );
377 }
378 else
379 {
381 ImplInsertSplit( nNewPos );
384 }
386}
387
389{
395}
396
397void ScCsvGrid::SetSplits( const ScCsvSplits& rSplits )
398{
401 sal_uInt32 nCount = rSplits.Count();
402 for( sal_uInt32 nIx = 0; nIx < nCount; ++nIx )
403 maSplits.Insert( rSplits[ nIx ] );
404 maColStates.clear();
405 maColStates.resize( maSplits.Count() - 1 );
409}
410
411bool ScCsvGrid::ImplInsertSplit( sal_Int32 nPos )
412{
413 sal_uInt32 nColIx = GetColumnFromPos( nPos );
414 bool bRet = (nColIx < GetColumnCount()) && maSplits.Insert( nPos );
415 if( bRet )
416 {
417 ScCsvColState aState( GetColumnType( nColIx ) );
418 aState.Select( IsSelected( nColIx ) && IsSelected( nColIx + 1 ) );
419 maColStates.insert( maColStates.begin() + nColIx + 1, aState );
420 AccSendInsertColumnEvent( nColIx + 1, nColIx + 1 );
421 AccSendTableUpdateEvent( nColIx, nColIx );
422 }
423 return bRet;
424}
425
426bool ScCsvGrid::ImplRemoveSplit( sal_Int32 nPos )
427{
428 bool bRet = maSplits.Remove( nPos );
429 if( bRet )
430 {
431 sal_uInt32 nColIx = GetColumnFromPos( nPos );
432 bool bSel = IsSelected( nColIx ) || IsSelected( nColIx + 1 );
433 maColStates.erase( maColStates.begin() + nColIx + 1 );
434 maColStates[ nColIx ].Select( bSel );
435 AccSendRemoveColumnEvent( nColIx + 1, nColIx + 1 );
436 AccSendTableUpdateEvent( nColIx, nColIx );
437 }
438 return bRet;
439}
440
442{
443 sal_uInt32 nColumns = GetColumnCount();
444 maSplits.Clear();
445 maSplits.Insert( 0 );
447 maColStates.resize( 1 );
449 AccSendRemoveColumnEvent( 1, nColumns - 1 );
450}
451
452// columns/column types -------------------------------------------------------
453
455{
457}
458
460{
461 return GetColumnFromPos( std::min( GetLastVisPos(), GetPosCount() ) - 1 );
462}
463
464bool ScCsvGrid::IsValidColumn( sal_uInt32 nColIndex ) const
465{
466 return nColIndex < GetColumnCount();
467}
468
469bool ScCsvGrid::IsVisibleColumn( sal_uInt32 nColIndex ) const
470{
471 return IsValidColumn( nColIndex ) &&
472 (GetColumnPos( nColIndex ) < GetLastVisPos()) &&
473 (GetFirstVisPos() < GetColumnPos( nColIndex + 1 ));
474}
475
476sal_Int32 ScCsvGrid::GetColumnX( sal_uInt32 nColIndex ) const
477{
478 return GetX( GetColumnPos( nColIndex ) );
479}
480
481sal_uInt32 ScCsvGrid::GetColumnFromX( sal_Int32 nX ) const
482{
483 sal_Int32 nPos = (nX - GetFirstX()) / GetCharWidth() + GetFirstVisPos();
484 return ((GetFirstVisPos() <= nPos) && (nPos <= GetLastVisPos())) ?
486}
487
488sal_uInt32 ScCsvGrid::GetColumnFromPos( sal_Int32 nPos ) const
489{
490 return maSplits.UpperBound( nPos );
491}
492
493sal_Int32 ScCsvGrid::GetColumnWidth( sal_uInt32 nColIndex ) const
494{
495 return IsValidColumn( nColIndex ) ? (GetColumnPos( nColIndex + 1 ) - GetColumnPos( nColIndex )) : 0;
496}
497
499{
500 maColStates = std::move(rStates);
501 maColStates.resize( maSplits.Count() - 1 );
505}
506
507sal_Int32 ScCsvGrid::GetColumnType( sal_uInt32 nColIndex ) const
508{
509 return IsValidColumn( nColIndex ) ? maColStates[ nColIndex ].mnType : CSV_TYPE_NOSELECTION;
510}
511
512void ScCsvGrid::SetColumnType( sal_uInt32 nColIndex, sal_Int32 nColType )
513{
514 if( IsValidColumn( nColIndex ) )
515 {
516 maColStates[ nColIndex ].mnType = nColType;
517 AccSendTableUpdateEvent( nColIndex, nColIndex, false );
518 }
519}
520
522{
523 sal_uInt32 nColIx = GetFirstSelected();
524 if( nColIx == CSV_COLUMN_INVALID )
526
527 sal_Int32 nType = GetColumnType( nColIx );
528 while( (nColIx != CSV_COLUMN_INVALID) && (nType != CSV_TYPE_MULTI) )
529 {
530 if( nType != GetColumnType( nColIx ) )
532 nColIx = GetNextSelected( nColIx );
533 }
534 return nType;
535}
536
538{
540 {
541 for( sal_uInt32 nColIx = GetFirstSelected(); nColIx != CSV_COLUMN_INVALID; nColIx = GetNextSelected( nColIx ) )
542 SetColumnType( nColIx, nType );
543 Repaint( true );
545 }
546}
547
548void ScCsvGrid::SetTypeNames( std::vector<OUString>&& rTypeNames )
549{
550 OSL_ENSURE( !rTypeNames.empty(), "ScCsvGrid::SetTypeNames - vector is empty" );
551 maTypeNames = std::move(rTypeNames);
552 Repaint( true );
553
554 mxPopup->clear();
555 sal_uInt32 nCount = maTypeNames.size();
556 for (sal_uInt32 nIx = 0; nIx < nCount; ++nIx)
557 mxPopup->append(OUString::number(nIx), maTypeNames[nIx]);
558
559 ::std::for_each( maColStates.begin(), maColStates.end(), Func_SetType( CSV_TYPE_DEFAULT ) );
560}
561
562OUString ScCsvGrid::GetColumnTypeName( sal_uInt32 nColIndex ) const
563{
564 sal_uInt32 nTypeIx = static_cast< sal_uInt32 >( GetColumnType( nColIndex ) );
565 return (nTypeIx < maTypeNames.size()) ? maTypeNames[ nTypeIx ] : OUString();
566}
567
568static sal_uInt8 lcl_GetExtColumnType( sal_Int32 nIntType )
569{
570 static const sal_uInt8 pExtTypes[] =
572 static const sal_Int32 nExtTypeCount = SAL_N_ELEMENTS(pExtTypes);
573 return pExtTypes[ ((0 <= nIntType) && (nIntType < nExtTypeCount)) ? nIntType : 0 ];
574}
575
577{
578 sal_uInt32 nCount = GetColumnCount();
579 ScCsvExpDataVec aDataVec;
580
581 for( sal_uInt32 nColIx = 0; nColIx < nCount; ++nColIx )
582 {
583 if( GetColumnType( nColIx ) != CSV_TYPE_DEFAULT )
584 // 1-based column index
585 aDataVec.emplace_back(
586 static_cast< sal_Int32 >( nColIx + 1 ),
587 lcl_GetExtColumnType( GetColumnType( nColIx ) ) );
588 }
589 rOptions.SetColumnInfo( aDataVec );
590}
591
593{
594 sal_uInt32 nCount = std::min( GetColumnCount(), static_cast<sal_uInt32>(MAXCOLCOUNT) );
595 ScCsvExpDataVec aDataVec( nCount + 1 );
596
597 for( sal_uInt32 nColIx = 0; nColIx < nCount; ++nColIx )
598 {
599 ScCsvExpData& rData = aDataVec[ nColIx ];
600 rData.mnIndex = GetColumnPos( nColIx );
601 rData.mnType = lcl_GetExtColumnType( GetColumnType( nColIx ) );
602 }
603 aDataVec[ nCount ].mnIndex = SAL_MAX_INT32;
604 aDataVec[ nCount ].mnType = SC_COL_SKIP;
605 rOptions.SetColumnInfo( aDataVec );
606}
607
609{
610 sal_Int32 nLine = GetFirstVisLine();
611 switch( eDir )
612 {
613 case MOVE_PREV: --nLine; break;
614 case MOVE_NEXT: ++nLine; break;
615 case MOVE_FIRST: nLine = 0; break;
616 case MOVE_LAST: nLine = GetMaxLineOffset(); break;
617 case MOVE_PREVPAGE: nLine -= GetVisLineCount() - 2; break;
618 case MOVE_NEXTPAGE: nLine += GetVisLineCount() - 2; break;
619 default:
620 {
621 // added to avoid warnings
622 }
623 }
625}
626
627void ScCsvGrid::ExecutePopup( const Point& rPos )
628{
629 OString sItemId = mxPopup->popup_at_rect(GetDrawingArea(), tools::Rectangle(rPos, Size(1, 1)));
630 if (!sItemId.isEmpty()) // empty = cancelled
631 Execute(CSVCMD_SETCOLUMNTYPE, sItemId.toInt32());
632}
633
634// selection handling ---------------------------------------------------------
635
636bool ScCsvGrid::IsSelected( sal_uInt32 nColIndex ) const
637{
638 return IsValidColumn( nColIndex ) && maColStates[ nColIndex ].IsSelected();
639}
640
642{
643 return IsSelected( 0 ) ? 0 : GetNextSelected( 0 );
644}
645
646sal_uInt32 ScCsvGrid::GetNextSelected( sal_uInt32 nFromIndex ) const
647{
648 sal_uInt32 nColCount = GetColumnCount();
649 for( sal_uInt32 nColIx = nFromIndex + 1; nColIx < nColCount; ++nColIx )
650 if( IsSelected( nColIx ) )
651 return nColIx;
652 return CSV_COLUMN_INVALID;
653}
654
655void ScCsvGrid::Select( sal_uInt32 nColIndex, bool bSelect )
656{
657 if( IsValidColumn( nColIndex ) )
658 {
659 maColStates[ nColIndex ].Select( bSelect );
660 ImplDrawColumnSelection( nColIndex );
661 Repaint();
663 if( bSelect )
664 mnRecentSelCol = nColIndex;
666 }
667}
668
669void ScCsvGrid::ToggleSelect( sal_uInt32 nColIndex )
670{
671 Select( nColIndex, !IsSelected( nColIndex ) );
672}
673
674void ScCsvGrid::SelectRange( sal_uInt32 nColIndex1, sal_uInt32 nColIndex2, bool bSelect )
675{
676 if( nColIndex1 == CSV_COLUMN_INVALID )
677 Select( nColIndex2 );
678 else if( nColIndex2 == CSV_COLUMN_INVALID )
679 Select( nColIndex1 );
680 else if( nColIndex1 > nColIndex2 )
681 {
682 SelectRange( nColIndex2, nColIndex1, bSelect );
683 if( bSelect )
684 mnRecentSelCol = nColIndex1;
685 }
686 else if( IsValidColumn( nColIndex1 ) && IsValidColumn( nColIndex2 ) )
687 {
688 for( sal_uInt32 nColIx = nColIndex1; nColIx <= nColIndex2; ++nColIx )
689 {
690 maColStates[ nColIx ].Select( bSelect );
691 ImplDrawColumnSelection( nColIx );
692 }
693 Repaint();
695 if( bSelect )
696 mnRecentSelCol = nColIndex1;
698 }
699}
700
701void ScCsvGrid::SelectAll( bool bSelect )
702{
703 SelectRange( 0, GetColumnCount() - 1, bSelect );
704}
705
706void ScCsvGrid::MoveCursor( sal_uInt32 nColIndex )
707{
709 if( IsValidColumn( nColIndex ) )
710 {
711 sal_Int32 nPosBeg = GetColumnPos( nColIndex );
712 sal_Int32 nPosEnd = GetColumnPos( nColIndex + 1 );
713 sal_Int32 nMinPos = std::max( nPosBeg - CSV_SCROLL_DIST, sal_Int32( 0 ) );
714 sal_Int32 nMaxPos = std::min( nPosEnd - GetVisPosCount() + CSV_SCROLL_DIST + sal_Int32( 1 ), nMinPos );
715 if( nPosBeg - CSV_SCROLL_DIST + 1 <= GetFirstVisPos() )
716 Execute( CSVCMD_SETPOSOFFSET, nMinPos );
717 else if( nPosEnd + CSV_SCROLL_DIST >= GetLastVisPos() )
718 Execute( CSVCMD_SETPOSOFFSET, nMaxPos );
719 }
722}
723
725{
727 return;
728
729 switch( eDir )
730 {
731 case MOVE_FIRST:
732 MoveCursor( 0 );
733 break;
734 case MOVE_LAST:
735 MoveCursor( GetColumnCount() - 1 );
736 break;
737 case MOVE_PREV:
738 if( GetFocusColumn() > 0 )
739 MoveCursor( GetFocusColumn() - 1 );
740 break;
741 case MOVE_NEXT:
742 if( GetFocusColumn() < GetColumnCount() - 1 )
743 MoveCursor( GetFocusColumn() + 1 );
744 break;
745 default:
746 {
747 // added to avoid warnings
748 }
749 }
750}
751
753{
754 ::std::for_each( maColStates.begin(), maColStates.end(), Func_Select( false ) );
756}
757
758void ScCsvGrid::DoSelectAction( sal_uInt32 nColIndex, sal_uInt16 nModifier )
759{
760 if( !(nModifier & KEY_MOD1) )
762 if( nModifier & KEY_SHIFT ) // SHIFT always expands
763 SelectRange( mnRecentSelCol, nColIndex );
764 else if( !(nModifier & KEY_MOD1) ) // no SHIFT/CTRL always selects 1 column
765 Select( nColIndex );
766 else if( mbTracking ) // CTRL in tracking does not toggle
767 Select( nColIndex, mbMTSelecting );
768 else // CTRL only toggles
769 ToggleSelect( nColIndex );
771}
772
773// cell contents --------------------------------------------------------------
774
776 sal_Int32 nLine, const OUString& rTextLine,
777 const OUString& rSepChars, sal_Unicode cTextSep, bool bMergeSep, bool bRemoveSpace )
778{
779 if( nLine < GetFirstVisLine() ) return;
780
781 sal_uInt32 nLineIx = nLine - GetFirstVisLine();
782 while( maTexts.size() <= nLineIx )
783 maTexts.emplace_back( );
784 std::vector<OUString>& rStrVec = maTexts[ nLineIx ];
785 rStrVec.clear();
786
787 // scan for separators
788 OUString aCellText;
789 const sal_Unicode* pSepChars = rSepChars.getStr();
790 const sal_Unicode* pChar = rTextLine.getStr();
791 sal_uInt32 nColIx = 0;
792
793 while( *pChar && (nColIx < sal::static_int_cast<sal_uInt32>(CSV_MAXCOLCOUNT)) )
794 {
795 // scan for next cell text
796 bool bIsQuoted = false;
797 bool bOverflowCell = false;
799 cTextSep, pSepChars, bMergeSep, bIsQuoted, bOverflowCell, bRemoveSpace );
800 /* TODO: signal overflow somewhere in UI */
801
802 // update column width
803 sal_Int32 nWidth = std::max( CSV_MINCOLWIDTH, ScImportExport::CountVisualWidth( aCellText ) + 1 );
804 if( IsValidColumn( nColIx ) )
805 {
806 // expand existing column
807 sal_Int32 nDiff = nWidth - GetColumnWidth( nColIx );
808 if( nDiff > 0 )
809 {
811 for( sal_uInt32 nSplitIx = GetColumnCount() - 1; nSplitIx > nColIx; --nSplitIx )
812 {
813 sal_Int32 nPos = maSplits[ nSplitIx ];
815 maSplits.Insert( nPos + nDiff );
816 }
817 }
818 }
819 else
820 {
821 // append new column
822 sal_Int32 nLastPos = GetPosCount();
823 Execute( CSVCMD_SETPOSCOUNT, nLastPos + nWidth );
824 ImplInsertSplit( nLastPos );
825 }
826
827 if( aCellText.getLength() <= CSV_MAXSTRLEN )
828 rStrVec.push_back( aCellText );
829 else
830 rStrVec.push_back( aCellText.copy( 0, CSV_MAXSTRLEN ) );
831 ++nColIx;
832 }
834}
835
836void ScCsvGrid::ImplSetTextLineFix( sal_Int32 nLine, const OUString& rTextLine )
837{
838 if( nLine < GetFirstVisLine() ) return;
839
840 sal_Int32 nWidth = ScImportExport::CountVisualWidth( rTextLine );
841 if( nWidth > GetPosCount() )
842 Execute( CSVCMD_SETPOSCOUNT, nWidth );
843
844 sal_uInt32 nLineIx = nLine - GetFirstVisLine();
845 while( maTexts.size() <= nLineIx )
846 maTexts.emplace_back( );
847
848 std::vector<OUString>& rStrVec = maTexts[ nLineIx ];
849 rStrVec.clear();
850 sal_uInt32 nColCount = GetColumnCount();
851 sal_Int32 nStrLen = rTextLine.getLength();
852 sal_Int32 nStrIx = 0;
853 for( sal_uInt32 nColIx = 0; (nColIx < nColCount) && (nStrIx < nStrLen); ++nColIx )
854 {
855 sal_Int32 nColWidth = GetColumnWidth( nColIx );
856 sal_Int32 nLastIx = nStrIx;
857 ScImportExport::CountVisualWidth( rTextLine, nLastIx, nColWidth );
858 sal_Int32 nLen = std::min( CSV_MAXSTRLEN, nLastIx - nStrIx );
859 rStrVec.push_back( rTextLine.copy( nStrIx, nLen ) );
860 nStrIx = nStrIx + nLen;
861 }
863}
864
865OUString ScCsvGrid::GetCellText( sal_uInt32 nColIndex, sal_Int32 nLine ) const
866{
867 if( nLine < GetFirstVisLine() ) return OUString();
868
869 sal_uInt32 nLineIx = nLine - GetFirstVisLine();
870 if( nLineIx >= maTexts.size() ) return OUString();
871
872 const std::vector<OUString>& rStrVec = maTexts[ nLineIx ];
873 if( nColIndex >= rStrVec.size() ) return OUString();
874
875 return rStrVec[ nColIndex ];
876}
877
878// event handling -------------------------------------------------------------
879
881{
883
885 InitSizeData();
887}
888
890{
893 Repaint();
894}
895
897{
899 Repaint();
900}
901
903{
905 if( !HasFocus() )
906 GrabFocus();
907
908 Point aPos( rMEvt.GetPosPixel() );
909 sal_uInt32 nColIx = GetColumnFromX( aPos.X() );
910
911 if( rMEvt.IsLeft() )
912 {
913 if( (GetFirstX() > aPos.X()) || (aPos.X() > GetLastX()) ) // in header column
914 {
915 if( aPos.Y() <= GetHdrHeight() )
916 SelectAll();
917 }
918 else if( IsValidColumn( nColIx ) )
919 {
920 DoSelectAction( nColIx, rMEvt.GetModifier() );
921 mnMTCurrCol = nColIx;
922 mbMTSelecting = IsSelected( nColIx );
923 mbTracking = true;
924 }
925 }
927 return true;
928}
929
931{
932 mbTracking = false;
933 return true;
934}
935
937{
938 if (!mbTracking)
939 return true;
940
942
943 sal_Int32 nPos = (rMEvt.GetPosPixel().X() - GetFirstX()) / GetCharWidth() + GetFirstVisPos();
944 // on mouse tracking: keep position valid
945 nPos = std::clamp( nPos, sal_Int32(0), GetPosCount() - 1 );
947
948 sal_uInt32 nColIx = GetColumnFromPos( nPos );
949 if( mnMTCurrCol != nColIx )
950 {
951 DoSelectAction( nColIx, rMEvt.GetModifier() );
952 mnMTCurrCol = nColIx;
953 }
955
956 return true;
957}
958
959bool ScCsvGrid::KeyInput( const KeyEvent& rKEvt )
960{
961 const vcl::KeyCode& rKCode = rKEvt.GetKeyCode();
962 sal_uInt16 nCode = rKCode.GetCode();
963 bool bShift = rKCode.IsShift();
964 bool bMod1 = rKCode.IsMod1();
965
966 if( !rKCode.IsMod2() )
967 {
968 ScMoveMode eHDir = GetHorzDirection( nCode, !bMod1 );
969 ScMoveMode eVDir = GetVertDirection( nCode, bMod1 );
970
971 if( eHDir != MOVE_NONE )
972 {
974 MoveCursorRel( eHDir );
975 if( !bMod1 )
977 if( bShift )
979 else if( !bMod1 )
982 }
983 else if( eVDir != MOVE_NONE )
984 ScrollVertRel( eVDir );
985 else if( nCode == KEY_SPACE )
986 {
987 if( !bMod1 )
989 if( bShift )
991 else if( bMod1 )
993 else
995 }
996 else if( !bShift && bMod1 )
997 {
998 if( nCode == KEY_A )
999 SelectAll();
1000 else if( (KEY_1 <= nCode) && (nCode <= KEY_9) )
1001 {
1002 sal_uInt32 nType = nCode - KEY_1;
1003 if( nType < maTypeNames.size() )
1005 }
1006 }
1007 }
1008
1009 return rKCode.GetGroup() == KEYGROUP_CURSOR;
1010}
1011
1013{
1014 bool bConsumed = true;
1015 switch( rCEvt.GetCommand() )
1016 {
1017 case CommandEventId::ContextMenu:
1018 {
1019 if( rCEvt.IsMouseEvent() )
1020 {
1021 Point aPos( rCEvt.GetMousePosPixel() );
1022 sal_uInt32 nColIx = GetColumnFromX( aPos.X() );
1023 if( IsValidColumn( nColIx ) && (GetFirstX() <= aPos.X()) && (aPos.X() <= GetLastX()) )
1024 {
1025 if( !IsSelected( nColIx ) )
1026 DoSelectAction( nColIx, 0 ); // focus & select
1027 ExecutePopup( aPos );
1028 }
1029 }
1030 else
1031 {
1032 sal_uInt32 nColIx = GetFocusColumn();
1033 if( !IsSelected( nColIx ) )
1034 Select( nColIx );
1035 sal_Int32 nX1 = std::max( GetColumnX( nColIx ), GetFirstX() );
1036 sal_Int32 nX2 = std::min( GetColumnX( nColIx + 1 ), GetWidth() );
1037 ExecutePopup( Point( (nX1 + nX2) / 2, GetHeight() / 2 ) );
1038 }
1039 break;
1040 }
1041 case CommandEventId::Wheel:
1042 {
1043 tools::Rectangle aRect( Point(), maWinSize );
1044 if( aRect.Contains( rCEvt.GetMousePosPixel() ) )
1045 {
1046 const CommandWheelData* pData = rCEvt.GetWheelData();
1047 if( pData && (pData->GetMode() == CommandWheelMode::SCROLL) && !pData->IsHorz() )
1048 Execute( CSVCMD_SETLINEOFFSET, GetFirstVisLine() - pData->GetNotchDelta() );
1049 }
1050 break;
1051 }
1052 default:
1053 bConsumed = false;
1054 break;
1055 }
1056 return bConsumed;
1057}
1058
1060{
1061 InitColors();
1062 InitFonts();
1065
1067}
1068
1070{
1071 InitColors();
1072 Repaint();
1073}
1074
1075// painting -------------------------------------------------------------------
1076
1078{
1079 ImplRedraw(rRenderContext);
1080}
1081
1083{
1084 if( IsVisible() )
1085 {
1086 if( !IsValidGfx() )
1087 {
1088 ValidateGfx();
1091 }
1092 rRenderContext.DrawOutDev( Point(), maWinSize, Point(), maWinSize, *mpGridDev );
1093 }
1094}
1095
1097{
1098 return mpEditEngine.get();
1099}
1100
1101void ScCsvGrid::ImplSetColumnClipRegion( OutputDevice& rOutDev, sal_uInt32 nColIndex )
1102{
1104 std::max( GetColumnX( nColIndex ), GetFirstX() ) + 1, 0,
1105 std::min( GetColumnX( nColIndex + 1 ), GetLastX() ), GetHeight() - 1 ) ) );
1106}
1107
1108void ScCsvGrid::ImplDrawColumnHeader( OutputDevice& rOutDev, sal_uInt32 nColIndex, Color aFillColor )
1109{
1110 sal_Int32 nX1 = GetColumnX( nColIndex ) + 1;
1111 sal_Int32 nX2 = GetColumnX( nColIndex + 1 );
1112 sal_Int32 nHdrHt = GetHdrHeight();
1113
1114 rOutDev.SetLineColor();
1115 rOutDev.SetFillColor( aFillColor );
1116 rOutDev.DrawRect( tools::Rectangle( nX1, 0, nX2, nHdrHt ) );
1117
1118 rOutDev.SetFont( maHeaderFont );
1120 rOutDev.SetTextFillColor();
1121 rOutDev.DrawText( Point( nX1 + 1, 0 ), GetColumnTypeName( nColIndex ) );
1122
1124 rOutDev.DrawLine( Point( nX1, nHdrHt ), Point( nX2, nHdrHt ) );
1125 rOutDev.DrawLine( Point( nX2, 0 ), Point( nX2, nHdrHt ) );
1126}
1127
1128void ScCsvGrid::ImplDrawCellText( const Point& rPos, const OUString& rText )
1129{
1130 OUString aPlainText = rText.replaceAll( "\t", " " );
1131 aPlainText = aPlainText.replaceAll( "\n", " " );
1132 mpEditEngine->SetPaperSize( maEdEngSize );
1133
1134 /* #i60296# If string contains mixed script types, the space character
1135 U+0020 may be drawn with a wrong width (from non-fixed-width Asian or
1136 Complex font). Now we draw every non-space portion separately. */
1137 sal_Int32 nCharIxInt {aPlainText.isEmpty() ? -1 : 0};
1138 while (nCharIxInt>=0)
1139 {
1140 sal_Int32 nBeginIx = nCharIxInt;
1141 const OUString aToken = aPlainText.getToken( 0, ' ', nCharIxInt );
1142 if( !aToken.isEmpty() )
1143 {
1144 sal_Int32 nX = rPos.X() + GetCharWidth() * nBeginIx;
1145 mpEditEngine->SetTextCurrentDefaults( aToken );
1146 mpEditEngine->Draw(*mpBackgrDev, Point(nX, rPos.Y()));
1147 }
1148 }
1149
1150 sal_Int32 nCharIx = 0;
1151 while( (nCharIx = rText.indexOf( '\t', nCharIx )) != -1 )
1152 {
1153 sal_Int32 nX1 = rPos.X() + GetCharWidth() * nCharIx;
1154 sal_Int32 nX2 = nX1 + GetCharWidth() - 2;
1155 sal_Int32 nY = rPos.Y() + GetLineHeight() / 2;
1156 Color aColor( maTextColor );
1157 mpBackgrDev->SetLineColor( aColor );
1158 mpBackgrDev->DrawLine( Point( nX1, nY ), Point( nX2, nY ) );
1159 mpBackgrDev->DrawLine( Point( nX2 - 2, nY - 2 ), Point( nX2, nY ) );
1160 mpBackgrDev->DrawLine( Point( nX2 - 2, nY + 2 ), Point( nX2, nY ) );
1161 ++nCharIx;
1162 }
1163 nCharIx = 0;
1164 while( (nCharIx = rText.indexOf( '\n', nCharIx )) != -1 )
1165 {
1166 sal_Int32 nX1 = rPos.X() + GetCharWidth() * nCharIx;
1167 sal_Int32 nX2 = nX1 + GetCharWidth() - 2;
1168 sal_Int32 nY = rPos.Y() + GetLineHeight() / 2;
1169 Color aColor( maTextColor );
1170 mpBackgrDev->SetLineColor( aColor );
1171 mpBackgrDev->DrawLine( Point( nX1, nY ), Point( nX2, nY ) );
1172 mpBackgrDev->DrawLine( Point( nX1 + 2, nY - 2 ), Point( nX1, nY ) );
1173 mpBackgrDev->DrawLine( Point( nX1 + 2, nY + 2 ), Point( nX1, nY ) );
1174 mpBackgrDev->DrawLine( Point( nX2, nY - 2 ), Point( nX2, nY ) );
1175 ++nCharIx;
1176 }
1177}
1178
1180{
1182 {
1183 sal_Int32 nY = GetY( mnFirstImpLine );
1184 sal_Int32 nX = std::min( GetColumnX( GetLastVisColumn() + 1 ), GetLastX() );
1185 mpBackgrDev->SetLineColor( bSet ? maGridPBColor : maGridColor );
1186 mpBackgrDev->DrawLine( Point( GetFirstX() + 1, nY ), Point( nX, nY ) );
1187 }
1188}
1189
1190void ScCsvGrid::ImplDrawColumnBackgr( sal_uInt32 nColIndex )
1191{
1192 if( !IsVisibleColumn( nColIndex ) )
1193 return;
1194
1195 ImplSetColumnClipRegion( *mpBackgrDev, nColIndex );
1196
1197 // grid
1198 mpBackgrDev->SetLineColor();
1199 mpBackgrDev->SetFillColor( maBackColor );
1200 sal_Int32 nX1 = GetColumnX( nColIndex ) + 1;
1201 sal_Int32 nX2 = GetColumnX( nColIndex + 1 );
1202 sal_Int32 nY2 = GetY( GetLastVisLine() + 1 );
1203 sal_Int32 nHdrHt = GetHdrHeight();
1204 tools::Rectangle aRect( nX1, nHdrHt, nX2, nY2 );
1205 mpBackgrDev->DrawRect( aRect );
1206 mpBackgrDev->SetLineColor( maGridColor );
1207 mpBackgrDev->DrawGrid( aRect, Size( 1, GetLineHeight() ), DrawGridFlags::HorzLines );
1208 mpBackgrDev->DrawLine( Point( nX2, nHdrHt ), Point( nX2, nY2 ) );
1209 ImplDrawFirstLineSep( true );
1210
1211 // cell texts
1212 mpEditEngine->SetDefaultItem( SvxColorItem( maTextColor, EE_CHAR_COLOR ) );
1213 size_t nLineCount = ::std::min( static_cast< size_t >( GetLastVisLine() - GetFirstVisLine() + 1 ), maTexts.size() );
1214 // #i67432# cut string to avoid edit engine performance problems with very large strings
1215 sal_Int32 nFirstVisPos = ::std::max( GetColumnPos( nColIndex ), GetFirstVisPos() );
1216 sal_Int32 nLastVisPos = ::std::min( GetColumnPos( nColIndex + 1 ), GetLastVisPos() );
1217 sal_Int32 nStrPos = nFirstVisPos - GetColumnPos( nColIndex );
1218 sal_Int32 nStrLen = nLastVisPos - nFirstVisPos + 1;
1219 sal_Int32 nStrX = GetX( nFirstVisPos );
1220 for( size_t nLine = 0; nLine < nLineCount; ++nLine )
1221 {
1222 std::vector<OUString>& rStrVec = maTexts[ nLine ];
1223 if( (nColIndex < rStrVec.size()) && (rStrVec[ nColIndex ].getLength() > nStrPos) )
1224 {
1225 const OUString& rStr = rStrVec[ nColIndex ];
1226 OUString aText = rStr.copy( nStrPos, ::std::min( nStrLen, rStr.getLength() - nStrPos) );
1227 ImplDrawCellText( Point( nStrX, GetY( GetFirstVisLine() + nLine ) ), aText );
1228 }
1229 }
1230
1231 // header
1233
1234 mpBackgrDev->SetClipRegion();
1235}
1236
1238{
1239 mpBackgrDev->SetLineColor();
1240 mpBackgrDev->SetFillColor( maAppBackColor );
1241 Point aPoint( GetHdrX(), 0 );
1242 tools::Rectangle aRect( aPoint, Size( GetHdrWidth() + 1, GetHeight() ) );
1243 mpBackgrDev->DrawRect( aRect );
1244
1245 mpBackgrDev->SetFillColor( maHeaderBackColor );
1246 aRect.SetBottom( GetY( GetLastVisLine() + 1 ) );
1247 mpBackgrDev->DrawRect( aRect );
1248
1249 // line numbers
1250 mpBackgrDev->SetFont( maHeaderFont );
1251 mpBackgrDev->SetTextColor( maHeaderTextColor );
1252 mpBackgrDev->SetTextFillColor();
1253 sal_Int32 nLastLine = GetLastVisLine();
1254 for( sal_Int32 nLine = GetFirstVisLine(); nLine <= nLastLine; ++nLine )
1255 {
1256 OUString aText( OUString::number( nLine + 1 ) );
1257 sal_Int32 nX = GetHdrX() + (GetHdrWidth() - mpBackgrDev->GetTextWidth( aText )) / 2;
1258 mpBackgrDev->DrawText( Point( nX, GetY( nLine ) ), aText );
1259 }
1260
1261 // grid
1262 mpBackgrDev->SetLineColor( maHeaderGridColor );
1263 if( IsRTL() )
1264 {
1265 mpBackgrDev->DrawLine( Point( 0, 0 ), Point( 0, GetHeight() - 1 ) );
1266 mpBackgrDev->DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
1267 }
1268 else
1269 mpBackgrDev->DrawLine( aRect.TopRight(), aRect.BottomRight() );
1270 aRect.SetTop( GetHdrHeight() );
1271 mpBackgrDev->DrawGrid( aRect, Size( 1, GetLineHeight() ), DrawGridFlags::HorzLines );
1272}
1273
1275{
1276 mpBackgrDev->SetLineColor();
1277 mpBackgrDev->SetFillColor( maAppBackColor );
1278 mpBackgrDev->DrawRect( tools::Rectangle(
1279 Point( GetFirstX() + 1, 0 ), Size( GetWidth() - GetHdrWidth(), GetHeight() ) ) );
1280
1281 sal_uInt32 nLastCol = GetLastVisColumn();
1282 if (nLastCol == CSV_COLUMN_INVALID)
1283 return;
1284 for( sal_uInt32 nColIx = GetFirstVisColumn(); nColIx <= nLastCol; ++nColIx )
1285 ImplDrawColumnBackgr( nColIx );
1286
1288}
1289
1290void ScCsvGrid::ImplDrawColumnSelection( sal_uInt32 nColIndex )
1291{
1293 ImplSetColumnClipRegion( *mpGridDev, nColIndex );
1294 mpGridDev->DrawOutDev( Point(), maWinSize, Point(), maWinSize, *mpBackgrDev );
1295
1296 if( IsSelected( nColIndex ) )
1297 {
1298 sal_Int32 nX1 = GetColumnX( nColIndex ) + 1;
1299 sal_Int32 nX2 = GetColumnX( nColIndex + 1 );
1300
1301 // header
1302 tools::Rectangle aRect( nX1, 0, nX2, GetHdrHeight() );
1303 mpGridDev->SetLineColor();
1305 // redraw with light gray background in dark mode
1307 else
1308 {
1309 // use transparent active color
1310 mpGridDev->SetFillColor( maSelectColor );
1311 mpGridDev->DrawTransparent( tools::PolyPolygon( tools::Polygon( aRect ) ), CSV_HDR_TRANSPARENCY );
1312 }
1313
1314 // column selection
1315 aRect = tools::Rectangle( nX1, GetHdrHeight() + 1, nX2, GetY( GetLastVisLine() + 1 ) - 1 );
1316 ImplInvertRect( *mpGridDev, aRect );
1317 }
1318
1319 mpGridDev->SetClipRegion();
1321}
1322
1324{
1325 mpGridDev->DrawOutDev( Point(), maWinSize, Point(), maWinSize, *mpBackgrDev );
1326 sal_uInt32 nLastCol = GetLastVisColumn();
1327 if (nLastCol == CSV_COLUMN_INVALID)
1328 return;
1329 for( sal_uInt32 nColIx = GetFirstVisColumn(); nColIx <= nLastCol; ++nColIx )
1330 ImplDrawColumnSelection( nColIx );
1331}
1332
1333void ScCsvGrid::ImplDrawColumn( sal_uInt32 nColIndex )
1334{
1335 ImplDrawColumnBackgr( nColIndex );
1336 ImplDrawColumnSelection( nColIndex );
1337}
1338
1339void ScCsvGrid::ImplDrawHorzScrolled( sal_Int32 nOldPos )
1340{
1341 sal_Int32 nPos = GetFirstVisPos();
1342 if( !IsValidGfx() || (nPos == nOldPos) )
1343 return;
1344 if( std::abs( nPos - nOldPos ) > GetVisPosCount() / 2 )
1345 {
1348 return;
1349 }
1350
1351 Point aSrc, aDest;
1352 sal_uInt32 nFirstColIx, nLastColIx;
1353 if( nPos < nOldPos )
1354 {
1355 aSrc = Point( GetFirstX() + 1, 0 );
1356 aDest = Point( GetFirstX() + GetCharWidth() * (nOldPos - nPos) + 1, 0 );
1357 nFirstColIx = GetColumnFromPos( nPos );
1358 nLastColIx = GetColumnFromPos( nOldPos );
1359 }
1360 else
1361 {
1362 aSrc = Point( GetFirstX() + GetCharWidth() * (nPos - nOldPos) + 1, 0 );
1363 aDest = Point( GetFirstX() + 1, 0 );
1364 nFirstColIx = GetColumnFromPos( std::min( nOldPos + GetVisPosCount(), GetPosCount() ) - 1 );
1365 nLastColIx = GetColumnFromPos( std::min( nPos + GetVisPosCount(), GetPosCount() ) - 1 );
1366 }
1367
1368 ImplInvertCursor( GetRulerCursorPos() + (nPos - nOldPos) );
1369 tools::Rectangle aRectangle( GetFirstX(), 0, GetLastX(), GetHeight() - 1 );
1370 vcl::Region aClipReg( aRectangle );
1371 mpBackgrDev->SetClipRegion( aClipReg );
1372 mpBackgrDev->CopyArea( aDest, aSrc, maWinSize );
1373 mpBackgrDev->SetClipRegion();
1374 mpGridDev->SetClipRegion( aClipReg );
1375 mpGridDev->CopyArea( aDest, aSrc, maWinSize );
1376 mpGridDev->SetClipRegion();
1378
1379 for( sal_uInt32 nColIx = nFirstColIx; nColIx <= nLastColIx; ++nColIx )
1380 ImplDrawColumn( nColIx );
1381
1382 sal_Int32 nLastX = GetX( GetPosCount() ) + 1;
1383 if( nLastX <= GetLastX() )
1384 {
1385 tools::Rectangle aRect( nLastX, 0, GetLastX(), GetHeight() - 1 );
1386 mpBackgrDev->SetLineColor();
1387 mpBackgrDev->SetFillColor( maAppBackColor );
1388 mpBackgrDev->DrawRect( aRect );
1389 mpGridDev->SetLineColor();
1390 mpGridDev->SetFillColor( maAppBackColor );
1391 mpGridDev->DrawRect( aRect );
1392 }
1393}
1394
1395void ScCsvGrid::ImplInvertCursor( sal_Int32 nPos )
1396{
1397 if( IsVisibleSplitPos( nPos ) )
1398 {
1399 sal_Int32 nX = GetX( nPos ) - 1;
1400 tools::Rectangle aRect( Point( nX, 0 ), Size( 3, GetHdrHeight() ) );
1401 ImplInvertRect( *mpGridDev, aRect );
1402 aRect.SetTop( GetHdrHeight() + 1 );
1403 aRect.SetBottom( GetY( GetLastVisLine() + 1 ) );
1404 ImplInvertRect( *mpGridDev, aRect );
1405 }
1406}
1407
1409{
1410 auto nColIndex = GetFocusColumn();
1411 if( HasFocus() && IsVisibleColumn( nColIndex ) )
1412 {
1413 sal_Int32 nX1 = std::max( GetColumnX( nColIndex ), GetFirstX() ) + 1;
1414 sal_Int32 nX2 = std::min( GetColumnX( nColIndex + 1 ) - sal_Int32( 1 ), GetLastX() );
1415 sal_Int32 nY2 = std::min( GetY( GetLastVisLine() + 1 ), GetHeight() ) - 1;
1416 return tools::Rectangle( nX1, 0, nX2, nY2 );
1417 }
1419}
1420
1421// accessibility ==============================================================
1422
1423css::uno::Reference<css::accessibility::XAccessible> ScCsvGrid::CreateAccessible()
1424{
1426 mxAccessible = xRef;
1427 return xRef;
1428}
1429
1430/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SCCOL MAXCOLCOUNT
Definition: address.hxx:63
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
bool IsDark() const
CommandEventId GetCommand() const
const CommandWheelData * GetWheelData() const
const Point & GetMousePosPixel() const
bool IsMouseEvent() const
static void SetFontInfoInItemSet(SfxItemSet &rItemSet, const vcl::Font &rFont)
const vcl::KeyCode & GetKeyCode() const
sal_uInt16 GetModifier() const
const Point & GetPosPixel() const
bool IsLeft() const
const vcl::Font & GetFont() const
void SetFont(const vcl::Font &rNewFont)
void DrawRect(const tools::Rectangle &rRect)
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void SetLineColor()
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void SetTextColor(const Color &rColor)
void SetClipRegion()
void SetFillColor()
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
void SetTextFillColor()
tools::Long GetTextHeight() const
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
Accessible class representing the CSV grid control.
void SetColumnInfo(const ScCsvExpDataVec &rDataVec)
Definition: asciiopt.cxx:48
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
bool IsVisibleLine(sal_Int32 nLine) const
Returns true, if nLine is a valid and visible line index.
Definition: csvcontrol.cxx:225
sal_Int32 GetMaxLineOffset() const
Returns highest possible index for first line.
Definition: csvcontrol.cxx:215
void AccSendSelectionEvent()
Sends a selection changed event to the accessibility object.
Definition: csvcontrol.cxx:104
sal_Int32 GetLastVisLine() const
Returns index of last visible line.
Definition: csvcontrol.cxx:210
sal_Int32 GetRulerCursorPos() const
Returns the ruler cursor position.
Definition: csvcontrol.hxx:356
sal_Int32 GetGridCursorPos() const
Returns the data grid cursor position (not column index!).
Definition: csvcontrol.hxx:358
void InvalidateGfx()
Sets the graphic invalid (next Redraw() will not use cached graphic).
Definition: csvcontrol.hxx:263
bool IsRTL() const
Returns true, if the Right-to-Left layout mode is active.
Definition: csvcontrol.hxx:297
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
void AccSendTableUpdateEvent(sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows=true)
Sends a table model changed event for changed cell contents to the accessibility object.
Definition: csvcontrol.cxx:110
sal_Int32 GetLineHeight() const
Returns the height of one line.
Definition: csvcontrol.hxx:349
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
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
void AccSendRemoveColumnEvent(sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn)
Sends a table model changed event for a removed column to the accessibility object.
Definition: csvcontrol.cxx:122
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
void AccSendInsertColumnEvent(sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn)
Sends a table model changed event for an inserted column to the accessibility object.
Definition: csvcontrol.cxx:116
sal_Int32 GetHdrHeight() const
Returns the height of the header line.
Definition: csvcontrol.hxx:347
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 GetHdrX() const
Returns the start position of the header column.
Definition: csvcontrol.cxx:180
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
sal_Int32 GetVisPosCount() const
Returns the number of visible positions.
Definition: csvcontrol.cxx:160
sal_Int32 GetY(sal_Int32 nLine) const
Returns output Y coordinate of the specified line.
Definition: csvcontrol.cxx:230
virtual bool KeyInput(const KeyEvent &rKEvt) override
Definition: csvgrid.cxx:959
ScCsvGrid(const ScCsvLayoutData &rData, std::unique_ptr< weld::Menu > xPopup, ScCsvTableBox *pTableBox)
Mouse tracking mode: true = select, false = deselect.
Definition: csvgrid.cxx:75
void MoveSplit(sal_Int32 nPos, sal_Int32 nNewPos)
Inserts a new or removes an existing split.
Definition: csvgrid.cxx:360
sal_uInt32 GetLastVisColumn() const
Returns the index of the last visible column.
Definition: csvgrid.cxx:459
sal_Int32 GetNoScrollCol(sal_Int32 nPos) const
Finds a column position nearest to nPos which does not cause scrolling the visible area.
Definition: csvgrid.cxx:225
Color maGridPBColor
Table grid color.
Definition: csvgrid.hxx:68
SAL_DLLPRIVATE void ImplDrawColumnHeader(OutputDevice &rOutDev, sal_uInt32 nColIndex, Color aFillColor)
Draws the header of the specified column to the specified output device.
Definition: csvgrid.cxx:1108
void SetSelColumnType(sal_Int32 nType)
Changes the data type of all selected columns.
Definition: csvgrid.cxx:537
sal_Int32 mnFirstImpLine
2D-vector for cell texts.
Definition: csvgrid.hxx:88
void FillColumnDataSep(ScAsciiOptions &rOptions) const
Fills the options object with column data for separators mode.
Definition: csvgrid.cxx:576
sal_Int32 GetColumnPos(sal_uInt32 nColIndex) const
Returns start position of the column with the specified index.
Definition: csvgrid.hxx:166
SAL_DLLPRIVATE sal_Int32 GetColumnType(sal_uInt32 nColIndex) const
Returns the data type of the specified column.
Definition: csvgrid.cxx:507
SAL_DLLPRIVATE void MoveCursor(sal_uInt32 nColIndex)
Moves column cursor to a new position.
Definition: csvgrid.cxx:706
vcl::Font maMonoFont
Font for column and row headers.
Definition: csvgrid.hxx:79
bool mbTracking
Current column of mouse tracking.
Definition: csvgrid.hxx:91
SAL_DLLPRIVATE void ExecutePopup(const Point &rPos)
Executes the data type popup menu.
Definition: csvgrid.cxx:627
SAL_DLLPRIVATE void ImplDrawFirstLineSep(bool bSet)
Draws the "first imported line" separator to maBackgrDev (or erases, if bSet is false).
Definition: csvgrid.cxx:1179
void SelectAll(bool bSelect=true)
Selects or deselects all columns.
Definition: csvgrid.cxx:701
void RemoveAllSplits()
Removes all splits.
Definition: csvgrid.cxx:388
SAL_DLLPRIVATE void ImplDrawColumnSelection(sal_uInt32 nColIndex)
Draws the column with index nColIndex with its selection state to maGridDev.
Definition: csvgrid.cxx:1290
virtual void GetFocus() override
Definition: csvgrid.cxx:889
Color maHeaderGridColor
Background color for headers.
Definition: csvgrid.hxx:72
void RemoveSplit(sal_Int32 nPos)
Removes a split.
Definition: csvgrid.cxx:347
SAL_DLLPRIVATE void InitSizeData()
Initializes all data dependent from the control's size.
Definition: csvgrid.cxx:322
Size maWinSize
Monospace font for data cells.
Definition: csvgrid.hxx:80
sal_Int32 GetColumnWidth(sal_uInt32 nColIndex) const
Returns the character width of the column with the specified index.
Definition: csvgrid.cxx:493
sal_uInt32 GetColumnFromPos(sal_Int32 nPos) const
Returns column index from position.
Definition: csvgrid.cxx:488
sal_Int32 GetColumnX(sal_uInt32 nColIndex) const
Returns X coordinate of the specified column.
Definition: csvgrid.cxx:476
bool IsValidColumn(sal_uInt32 nColIndex) const
Returns true, if nColIndex points to an existing column.
Definition: csvgrid.cxx:464
virtual void ConfigurationChanged(::utl::ConfigurationBroadcaster *, ConfigurationHints) override
Definition: csvgrid.cxx:1069
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: csvgrid.cxx:930
SAL_DLLPRIVATE void ImplDrawBackgrDev()
Draws all columns and the row headers column to maBackgrDev.
Definition: csvgrid.cxx:1274
SAL_DLLPRIVATE void InitFonts()
Initializes all font settings.
Definition: csvgrid.cxx:273
void FillColumnDataFix(ScAsciiOptions &rOptions) const
Fills the options object with column data for fixed width mode.
Definition: csvgrid.cxx:592
SAL_DLLPRIVATE void ImplDrawCellText(const Point &rPos, const OUString &rText)
Draws the text at the specified position to maBackgrDev.
Definition: csvgrid.cxx:1128
vcl::Font maHeaderFont
For drawing cell texts.
Definition: csvgrid.hxx:78
ScCsvSplits maSplits
Paper size for edit engine.
Definition: csvgrid.hxx:83
sal_uInt32 mnMTCurrCol
Index of most recently selected column.
Definition: csvgrid.hxx:90
SAL_DLLPRIVATE void ImplDrawHorzScrolled(sal_Int32 nOldPos)
Optimized drawing: Scrolls horizontally and redraws only missing parts.
Definition: csvgrid.cxx:1339
bool IsVisibleColumn(sal_uInt32 nColIndex) const
Returns true, if column with index nColIndex is (at least partly) visible.
Definition: csvgrid.cxx:469
SAL_DLLPRIVATE void ImplClearSplits()
Clears the split array and re-inserts boundary splits.
Definition: csvgrid.cxx:441
void SetSplits(const ScCsvSplits &rSplits)
Removes all splits and inserts the splits from rSplits.
Definition: csvgrid.cxx:397
void ApplyLayout(const ScCsvLayoutData &rOldData)
Apply current layout data to the grid control.
Definition: csvgrid.cxx:172
sal_uInt32 GetFocusColumn() const
Returns index of the focused column.
Definition: csvgrid.hxx:219
SAL_DLLPRIVATE void InitColors()
Reads colors from system settings.
Definition: csvgrid.cxx:244
SAL_DLLPRIVATE void ImplDrawColumn(sal_uInt32 nColIndex)
Redraws the entire column (background and selection).
Definition: csvgrid.cxx:1333
sal_uInt32 GetNextSelected(sal_uInt32 nFromIndex) const
Returns index of the first selected column really after nFromIndex.
Definition: csvgrid.cxx:646
SAL_DLLPRIVATE void ImplDrawRowHeaders()
Draws the row headers column to maBackgrDev.
Definition: csvgrid.cxx:1237
std::unique_ptr< weld::Menu > mxPopup
Data grid with selection and cursor.
Definition: csvgrid.hxx:63
void SelectRange(sal_uInt32 nColIndex1, sal_uInt32 nColIndex2, bool bSelect=true)
Selects or deselects the specified column range.
Definition: csvgrid.cxx:674
void ImplRedraw(vcl::RenderContext &rRenderContext)
Redraws the entire data grid.
Definition: csvgrid.cxx:1082
void Select(sal_uInt32 nColIndex, bool bSelect=true)
Selects or deselects the specified column.
Definition: csvgrid.cxx:655
SAL_DLLPRIVATE bool ImplRemoveSplit(sal_Int32 nPos)
Removes a split and adjusts column data.
Definition: csvgrid.cxx:426
void UpdateLayoutData()
Updates layout data dependent from the control's state.
Definition: csvgrid.cxx:144
SAL_DLLPRIVATE void ImplSetColumnClipRegion(OutputDevice &rOutDev, sal_uInt32 nColIndex)
Sets a clip region in the specified output device for the specified column.
Definition: csvgrid.cxx:1101
SAL_DLLPRIVATE void ScrollVertRel(ScMoveMode eDir)
Scrolls data grid vertically.
Definition: csvgrid.cxx:608
EditEngine * GetEditEngine()
Returns a pointer to the used edit engine.
Definition: csvgrid.cxx:1096
void ToggleSelect(sal_uInt32 nColIndex)
Toggles selection of the specified column.
Definition: csvgrid.cxx:669
Color maAppBackColor
Grid color for "first imported line" delimiter.
Definition: csvgrid.hxx:69
SAL_DLLPRIVATE bool ImplInsertSplit(sal_Int32 nPos)
Inserts a split and adjusts column data.
Definition: csvgrid.cxx:411
std::vector< OUString > maTypeNames
State of each column.
Definition: csvgrid.hxx:85
virtual tools::Rectangle GetFocusRect() override
Definition: csvgrid.cxx:1408
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Creates a new accessible object.
Definition: csvgrid.cxx:1423
ScCsvColStateVec maColStates
Vector with split positions.
Definition: csvgrid.hxx:84
virtual void LoseFocus() override
Definition: csvgrid.cxx:896
void InsertSplit(sal_Int32 nPos)
Inserts a split.
Definition: csvgrid.cxx:332
sal_Int32 GetWidth() const
Returns the width of the control.
Definition: csvgrid.hxx:275
SAL_DLLPRIVATE void ImplDrawColumnBackgr(sal_uInt32 nColIndex)
Draws the column with index nColIndex to maBackgrDev.
Definition: csvgrid.cxx:1190
::svtools::ColorConfig * mpColorConfig
Popup menu for column types.
Definition: csvgrid.hxx:65
Color maSelectColor
Text color for headers.
Definition: csvgrid.hxx:74
void UpdateOffsetX()
Updates X coordinate of first visible position dependent from line numbers.
Definition: csvgrid.cxx:157
SAL_DLLPRIVATE void ImplDrawGridDev()
Draws all columns with selection and cursor to maGridDev.
Definition: csvgrid.cxx:1323
VclPtr< VirtualDevice > mpGridDev
Grid background, headers, cell texts.
Definition: csvgrid.hxx:62
virtual bool Command(const CommandEvent &rCEvt) override
Definition: csvgrid.cxx:1012
SAL_DLLPRIVATE void ImplInvertCursor(sal_Int32 nPos)
Inverts the cursor bar at the specified position in maGridDev.
Definition: csvgrid.cxx:1395
void ImplSetTextLineSep(sal_Int32 nLine, const OUString &rTextLine, const OUString &rSepChars, sal_Unicode cTextSep, bool bMergeSep, bool bRemoveSpace=false)
Fills all cells of a line with the passed text (separators mode).
Definition: csvgrid.cxx:775
sal_uInt32 GetFirstSelected() const
Returns index of the first selected column.
Definition: csvgrid.cxx:641
std::unique_ptr< ScEditEngineDefaulter > mpEditEngine
Header color of selected columns.
Definition: csvgrid.hxx:77
Color maBackColor
Application color configuration.
Definition: csvgrid.hxx:66
void SetColumnStates(ScCsvColStateVec &&rColStates)
Sets all column states to the values in the passed vector.
Definition: csvgrid.cxx:498
sal_uInt32 mnRecentSelCol
First imported line (0-based).
Definition: csvgrid.hxx:89
sal_uInt32 GetColumnCount() const
Returns the number of columns.
Definition: csvgrid.hxx:149
SAL_DLLPRIVATE void SetColumnType(sal_uInt32 nColIndex, sal_Int32 nColType)
Sets the data type of the specified column.
Definition: csvgrid.cxx:512
SAL_DLLPRIVATE void MoveCursorRel(ScMoveMode eDir)
Moves column cursor to the given direction.
Definition: csvgrid.cxx:724
Color maHeaderTextColor
Grid color for headers.
Definition: csvgrid.hxx:73
virtual ~ScCsvGrid() override
Definition: csvgrid.cxx:124
bool IsSelected(sal_uInt32 nColIndex) const
Returns true, if the specified column is selected.
Definition: csvgrid.cxx:636
OUString GetCellText(sal_uInt32 nColIndex, sal_Int32 nLine) const
Returns the text of the specified cell.
Definition: csvgrid.cxx:865
VclPtr< VirtualDevice > mpBackgrDev
Grid Parent.
Definition: csvgrid.hxx:61
Color maGridColor
Cell background color.
Definition: csvgrid.hxx:67
bool mbMTSelecting
True if Mouse tracking.
Definition: csvgrid.hxx:92
Color maTextColor
Background color for unused area.
Definition: csvgrid.hxx:70
SAL_DLLPRIVATE void DoSelectAction(sal_uInt32 nColIndex, sal_uInt16 nModifier)
Executes selection action for a specific column.
Definition: csvgrid.cxx:758
Size maEdEngSize
Size of the control.
Definition: csvgrid.hxx:81
OUString GetColumnTypeName(sal_uInt32 nColIndex) const
Returns the UI type name of the specified column.
Definition: csvgrid.cxx:562
virtual void Resize() override
Definition: csvgrid.cxx:880
virtual void StyleUpdated() override
Definition: csvgrid.cxx:1059
Color maHeaderBackColor
Text color for data area.
Definition: csvgrid.hxx:71
sal_Int32 GetSelColumnType() const
Returns the data type of the selected columns.
Definition: csvgrid.cxx:521
virtual bool MouseMove(const MouseEvent &rMEvt) override
Definition: csvgrid.cxx:936
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: csvgrid.cxx:96
sal_uInt32 GetFirstVisColumn() const
Returns the index of the first visible column.
Definition: csvgrid.cxx:454
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: csvgrid.cxx:1077
void SetTypeNames(std::vector< OUString > &&rTypeNames)
Sets new UI data type names.
Definition: csvgrid.cxx:548
std::vector< std::vector< OUString > > maTexts
UI names of data types.
Definition: csvgrid.hxx:86
void ImplSetTextLineFix(sal_Int32 nLine, const OUString &rTextLine)
Fills all cells of a line with the passed text (fixed width mode).
Definition: csvgrid.cxx:836
sal_Int32 GetHeight() const
Returns the height of the control.
Definition: csvgrid.hxx:277
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: csvgrid.cxx:902
void Init()
Finishes initialization.
Definition: csvgrid.cxx:134
void SetFirstImportedLine(sal_Int32 nLine)
Sets the number of the first imported line (for visual feedback).
Definition: csvgrid.cxx:216
ScCsvTableBox * mpTableBox
Definition: csvgrid.hxx:60
SAL_DLLPRIVATE void ImplClearSelection()
Clears the entire selection without notify.
Definition: csvgrid.cxx:752
sal_uInt32 GetColumnFromX(sal_Int32 nX) const
Returns column index from output coordinate.
Definition: csvgrid.cxx:481
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
void RemoveRange(sal_Int32 nPosStart, sal_Int32 nPosEnd)
Removes a range of splits in the given position range.
Definition: csvsplits.cxx:53
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
The control in the CSV import dialog that contains a ruler and a data grid to visualize and modify th...
Definition: csvtablebox.hxx:44
SAL_DLLPRIVATE void InitControls()
Initializes the children controls (pos/size, scroll bars, ...).
static sal_Int32 CountVisualWidth(const OUString &rStr, sal_Int32 &nIdx, sal_Int32 nMaxWidth)
ScImportExport::CountVisualWidth Count the width of string visually ( in multiple of western characte...
Definition: impex.cxx:555
static const sal_Unicode * ScanNextFieldFromString(const sal_Unicode *p, OUString &rField, sal_Unicode cStr, const sal_Unicode *pSeps, bool bMergeSeps, bool &rbIsQuoted, bool &rbOverflowCell, bool bRemoveSpace)
Definition: impex.cxx:1860
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void SetWhich(sal_uInt16 nId)
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const Color & GetDarkShadowColor() const
const Color & GetActiveColor() const
const Color & GetFaceColor() const
const vcl::Font & GetAppFont() const
const Color & GetButtonTextColor() const
void disposeAndClear()
reference_type * get() const
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
bool Contains(const Point &rPOINT) const
constexpr void SetTop(tools::Long v)
constexpr Point TopLeft() const
constexpr void SetBottom(tools::Long v)
constexpr Point BottomRight() const
constexpr Point TopRight() const
constexpr Point BottomLeft() const
void SetFontSize(const Size &)
const Size & GetFontSize() const
sal_uInt16 GetGroup() const
bool IsMod1() const
sal_uInt16 GetCode() const
bool IsShift() const
bool IsMod2() const
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
weld::DrawingArea * GetDrawingArea() const
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_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr ::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
constexpr ::Color COL_BLACK(0x00, 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_TYPE_DEFAULT
Default column data type.
Definition: csvcontrol.hxx:47
::std::vector< ScCsvExpData > ScCsvExpDataVec
Definition: csvcontrol.hxx:73
const sal_Int32 CSV_SCROLL_DIST
Minimum distance to border for auto scroll.
Definition: csvcontrol.hxx:39
const sal_Int32 CSV_TYPE_NOSELECTION
No column selected.
Definition: csvcontrol.hxx:51
const sal_uInt8 SC_COL_TEXT
Definition: csvcontrol.hxx:55
const sal_Int32 CSV_MAXSTRLEN
Maximum length of a cell string.
Definition: csvcontrol.hxx:35
ScCsvDiff
Flags for comparison of old and new control layout data.
Definition: csvcontrol.hxx:88
const sal_Int32 CSV_MAXCOLCOUNT
Maximum count of columns.
Definition: csvcontrol.hxx:44
const sal_uInt8 SC_COL_MDY
Definition: csvcontrol.hxx:56
const sal_Int32 CSV_TYPE_MULTI
Multi selection with different types.
Definition: csvcontrol.hxx:49
const sal_uInt8 SC_COL_YMD
Definition: csvcontrol.hxx:58
const sal_Int32 CSV_MINCOLWIDTH
Minimum character count for a column in separators mode.
Definition: csvcontrol.hxx:33
const sal_uInt8 SC_COL_STANDARD
Definition: csvcontrol.hxx:54
const sal_uInt8 SC_COL_DMY
Definition: csvcontrol.hxx:57
const sal_uInt8 SC_COL_ENGLISH
Definition: csvcontrol.hxx:60
const sal_uInt16 CSV_HDR_TRANSPARENCY
Transparency for header color of selected columns.
Definition: csvcontrol.hxx:37
@ CSVCMD_SETCOLUMNTYPE
Update cell texts with current split settings. [-].
Definition: csvcontrol.hxx:184
@ CSVCMD_SETHDRWIDTH
Change position offset (scroll pos). [position].
Definition: csvcontrol.hxx:167
@ CSVCMD_SETLINEHEIGHT
Change height of top header line. [height in pixel].
Definition: csvcontrol.hxx:174
@ CSVCMD_MOVEGRIDCURSOR
Move ruler cursor to new position. [position].
Definition: csvcontrol.hxx:178
@ CSVCMD_SETPOSCOUNT
Repaint all controls. [-].
Definition: csvcontrol.hxx:165
@ CSVCMD_EXPORTCOLUMNTYPE
Change data type of selected columns. [column type].
Definition: csvcontrol.hxx:185
@ CSVCMD_UPDATECELLTEXTS
Recalculate splits and cell texts. [-].
Definition: csvcontrol.hxx:183
@ CSVCMD_SETPOSOFFSET
Change position/column count. [character count].
Definition: csvcontrol.hxx:166
@ CSVCMD_SETCHARWIDTH
Change width of the header column. [width in pixel].
Definition: csvcontrol.hxx:168
@ CSVCMD_MAKEPOSVISIBLE
Move data grid cursor to new column. [position].
Definition: csvcontrol.hxx:179
@ CSVCMD_SETHDRHEIGHT
Change first visible line. [line index].
Definition: csvcontrol.hxx:173
@ CSVCMD_SETLINEOFFSET
Change number of data lines. [line count].
Definition: csvcontrol.hxx:172
const sal_uInt8 SC_COL_SKIP
Definition: csvcontrol.hxx:59
static sal_uInt8 lcl_GetExtColumnType(sal_Int32 nIntType)
Definition: csvgrid.cxx:568
::std::vector< ScCsvColState > ScCsvColStateVec
Definition: csvgrid.hxx:53
const sal_uInt32 CSV_COLUMN_INVALID
Definition: csvgrid.hxx:38
const sal_Int32 CSV_POS_INVALID
Constant for an invalid ruler position.
Definition: csvsplits.hxx:29
int nCount
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CTL(EE_CHAR_START+16)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CTL(EE_CHAR_START+22)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CJK(EE_CHAR_START+21)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CJK(EE_CHAR_START+15)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CJK(EE_CHAR_START+23)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CTL(EE_CHAR_START+24)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
constexpr sal_uInt16 KEY_MOD1
constexpr sal_uInt16 KEY_1
constexpr sal_uInt16 KEY_9
constexpr sal_uInt16 KEY_A
constexpr sal_uInt16 KEY_SPACE
constexpr sal_uInt16 KEY_SHIFT
constexpr sal_uInt16 KEYGROUP_CURSOR
#define LANGUAGE_ENGLISH_US
sal_uInt16 nPos
#define SAL_N_ELEMENTS(arr)
std::unique_ptr< sal_Int32[]> pData
sal_uInt16 nCode
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
void SetPointFont(OutputDevice &rDevice, const vcl::Font &rFont)
ConfigurationHints
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
sal_Int32 mnType
#define SC_MOD()
Definition: scmod.hxx:249
sal_uIntPtr sal_uLong
This struct contains the state of one table column.
Definition: csvgrid.hxx:42
void Select(bool bSel)
Definition: csvgrid.hxx:50
sal_Int32 mnType
Definition: csvgrid.hxx:43
Exported data of a column (data used in the dialog).
Definition: csvcontrol.hxx:64
sal_uInt8 mnType
Index of a column.
Definition: csvcontrol.hxx:66
sal_Int32 mnIndex
Definition: csvcontrol.hxx:65
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
sal_Int32 mnPosOffset
Number of positions.
Definition: csvcontrol.hxx:115
ScCsvDiff GetDiff(const ScCsvLayoutData &rData) const
Returns differences to rData.
Definition: csvcontrol.cxx:43
sal_Int32 mnPosCount
Definition: csvcontrol.hxx:114
unsigned char sal_uInt8
#define SAL_MAX_INT32
sal_uInt16 sal_Unicode
#define SAL_MAX_UINT32
const char * pChar