LibreOffice Module sc (master)  1
csvtablebox.hxx
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 #pragma once
21 
22 #include <vcl/idle.hxx>
23 #include <vcl/weld.hxx>
24 #include <scdllapi.h>
25 #include "csvcontrol.hxx"
26 #include "csvruler.hxx"
27 #include "csvgrid.hxx"
28 
29 class ScAsciiOptions;
30 namespace weld {
31  class ComboBox;
32 }
33 
34 /* ============================================================================
35 Position: Positions between the characters (the dots in the ruler).
36 Character: The characters (the range from one position to the next).
37 Split: Positions which contain a split to divide characters into groups (columns).
38 Column: The range between two splits.
39 ============================================================================ */
40 
44 {
45 private:
47 
48  std::unique_ptr<ScCsvRuler> mxRuler;
49  std::unique_ptr<ScCsvGrid> mxGrid;
50  std::unique_ptr<weld::ScrolledWindow> mxScroll;
51  std::unique_ptr<weld::CustomWeld> mxRulerWeld;
52  std::unique_ptr<weld::CustomWeld> mxGridWeld;
53 
56 
58 
61 
62  sal_Int32 mnFixedWidth;
63 
64  bool mbFixedMode;
65 
66 public:
67  explicit ScCsvTableBox(weld::Builder& rBuilder);
68  ~ScCsvTableBox();
69 
71  void Init();
72 
73  // common table box handling ----------------------------------------------
74 public:
76  void SetSeparatorsMode();
78  void SetFixedWidthMode();
79 
80  ScCsvRuler& GetRuler() { return *mxRuler; }
81  ScCsvGrid& GetGrid() { return *mxGrid; }
82 
84  SAL_DLLPRIVATE void InitControls();
85 
86 private:
88  SAL_DLLPRIVATE void InitHScrollBar();
90  SAL_DLLPRIVATE void InitVScrollBar();
91 
93  SAL_DLLPRIVATE void ImplSetPosOffset( sal_Int32 nPos )
94  { maData.mnPosOffset = std::clamp( nPos, sal_Int32(0), mxGrid->GetMaxPosOffset() ); }
96  SAL_DLLPRIVATE void ImplSetLineOffset( sal_Int32 nLine )
97  { maData.mnLineOffset = std::clamp( nLine, sal_Int32(0), mxGrid->GetMaxLineOffset() ); }
99  SAL_DLLPRIVATE void MakePosVisible( sal_Int32 nPos );
100 
101  // cell contents ----------------------------------------------------------
102 public:
104  void SetUniStrings(
105  const OUString* pTextLines, const OUString& rSepChars,
106  sal_Unicode cTextSep, bool bMergeSep, bool bRemoveSpace );
107 
108  // column settings --------------------------------------------------------
109 public:
111  void InitTypes(const weld::ComboBox& rListBox);
113  sal_Int32 GetSelColumnType() const { return mxGrid->GetSelColumnType(); }
114 
116  void FillColumnData( ScAsciiOptions& rOptions ) const;
117 
118  // event handling ---------------------------------------------------------
119 public:
121  void SetUpdateTextHdl( const Link<ScCsvTableBox&,void>& rHdl ) { maUpdateTextHdl = rHdl; }
123  void SetColTypeHdl( const Link<ScCsvTableBox&,void>& rHdl ) { maColTypeHdl = rHdl; }
124 
125 private:
126  DECL_DLLPRIVATE_LINK( CsvCmdHdl, ScCsvControl&, void );
127  DECL_DLLPRIVATE_LINK( HScrollHdl, weld::ScrolledWindow&, void );
128  DECL_DLLPRIVATE_LINK( VScrollHdl, weld::ScrolledWindow&, void );
129  DECL_DLLPRIVATE_LINK( ScrollEndHdl, Timer*, void );
130 };
131 
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool mbFixedMode
Cached total width for fixed width mode.
Definition: csvtablebox.hxx:64
sal_Int32 mnPosOffset
Number of positions.
Definition: csvcontrol.hxx:115
std::unique_ptr< ScCsvRuler > mxRuler
Current layout data of the controls.
Definition: csvtablebox.hxx:48
void Init()
std::unique_ptr< weld::CustomWeld > mxGridWeld
Connect the ruler to its drawingarea.
Definition: csvtablebox.hxx:52
void SetColTypeHdl(const Link< ScCsvTableBox &, void > &rHdl)
Sets a new handler for "column selection changed" events.
Base class for the CSV ruler and the data grid control.
Definition: csvcontrol.hxx:222
A ruler control for the CSV import dialog.
Definition: csvruler.hxx:32
sal_uInt16 sal_Unicode
SAL_DLLPRIVATE void ImplSetLineOffset(sal_Int32 nLine)
Calculates and sets valid line offset nearest to nLine.
Definition: csvtablebox.hxx:96
Idle maEndScrollIdle
Handler for exporting the column type.
Definition: csvtablebox.hxx:57
std::unique_ptr< weld::CustomWeld > mxRulerWeld
Scrolled Window.
Definition: csvtablebox.hxx:51
Link< ScCsvTableBox &, void > maColTypeHdl
Updates all cell texts.
Definition: csvtablebox.hxx:55
Link< ScCsvTableBox &, void > maUpdateTextHdl
connect the grid to its drawingarea
Definition: csvtablebox.hxx:54
void SetUpdateTextHdl(const Link< ScCsvTableBox &, void > &rHdl)
Sets a new handler for "update cell texts" requests.
std::unique_ptr< weld::ScrolledWindow > mxScroll
Calc-like data table for fixed width mode.
Definition: csvtablebox.hxx:50
::std::vector< ScCsvColState > ScCsvColStateVec
Definition: csvgrid.hxx:53
sal_Int32 GetSelColumnType() const
Returns the data type of the selected columns.
The control in the CSV import dialog that contains a ruler and a data grid to visualize and modify th...
Definition: csvtablebox.hxx:43
sal_Int32 mnLineOffset
Number of data lines.
Definition: csvcontrol.hxx:123
SAL_DLLPRIVATE void ImplSetPosOffset(sal_Int32 nPos)
Calculates and sets valid position offset nearest to nPos.
Definition: csvtablebox.hxx:93
ScCsvGrid & GetGrid()
Definition: csvtablebox.hxx:81
ScCsvColStateVec maFixColStates
Called when horizontal scrolling has ended.
Definition: csvtablebox.hxx:59
ScCsvRuler & GetRuler()
Definition: csvtablebox.hxx:80
sal_Int32 mnFixedWidth
Column states in separators mode.
Definition: csvtablebox.hxx:62
ScCsvColStateVec maSepColStates
Column states in fixed width mode.
Definition: csvtablebox.hxx:60
ScCsvLayoutData maData
Definition: csvtablebox.hxx:46
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
std::unique_ptr< ScCsvGrid > mxGrid
The ruler for fixed width mode.
Definition: csvtablebox.hxx:49
A data grid control for the CSV import dialog.
Definition: csvgrid.hxx:57
A structure containing all layout data valid for both ruler and data grid (i.e.
Definition: csvcontrol.hxx:111