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