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
29class ScAsciiOptions;
30namespace weld {
31 class ComboBox;
32}
33
34/* ============================================================================
35Position: Positions between the characters (the dots in the ruler).
36Character: The characters (the range from one position to the next).
37Split: Positions which contain a split to divide characters into groups (columns).
38Column: The range between two splits.
39============================================================================ */
40
44{
45private:
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
65
66public:
67 explicit ScCsvTableBox(weld::Builder& rBuilder);
69
71 void Init();
72
73 // common table box handling ----------------------------------------------
74public:
76 void SetSeparatorsMode();
78 void SetFixedWidthMode();
79
80 ScCsvRuler& GetRuler() { return *mxRuler; }
81 ScCsvGrid& GetGrid() { return *mxGrid; }
82
84 SAL_DLLPRIVATE void InitControls();
85
86private:
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 ----------------------------------------------------------
102public:
104 void SetUniStrings(
105 const OUString* pTextLines, const OUString& rSepChars,
106 sal_Unicode cTextSep, bool bMergeSep, bool bRemoveSpace );
107
108 // column settings --------------------------------------------------------
109public:
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 ---------------------------------------------------------
119public:
121 void SetUpdateTextHdl( const Link<ScCsvTableBox&,void>& rHdl ) { maUpdateTextHdl = rHdl; }
123 void SetColTypeHdl( const Link<ScCsvTableBox&,void>& rHdl ) { maColTypeHdl = rHdl; }
124
125private:
126 DECL_DLLPRIVATE_LINK( CsvCmdHdl, ScCsvControl&, void );
129 DECL_DLLPRIVATE_LINK( ScrollEndHdl, Timer*, void );
130};
131
132/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class for the CSV ruler and the data grid control.
Definition: csvcontrol.hxx:223
A data grid control for the CSV import dialog.
Definition: csvgrid.hxx:58
A ruler control for the CSV import dialog.
Definition: csvruler.hxx:33
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 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 > mxGridWeld
Connect the ruler to its drawingarea.
Definition: csvtablebox.hxx:52
DECL_DLLPRIVATE_LINK(VScrollHdl, weld::ScrolledWindow &, void)
std::unique_ptr< weld::CustomWeld > mxRulerWeld
Scrolled Window.
Definition: csvtablebox.hxx:51
sal_Int32 GetSelColumnType() const
Returns the data type of the selected columns.
Link< ScCsvTableBox &, void > maUpdateTextHdl
connect the grid to its drawingarea
Definition: csvtablebox.hxx:54
bool mbFixedMode
Cached total width for fixed width mode.
Definition: csvtablebox.hxx:64
sal_Int32 mnFixedWidth
Column states in separators mode.
Definition: csvtablebox.hxx:62
DECL_DLLPRIVATE_LINK(CsvCmdHdl, ScCsvControl &, void)
SAL_DLLPRIVATE void ImplSetPosOffset(sal_Int32 nPos)
Calculates and sets valid position offset nearest to nPos.
Definition: csvtablebox.hxx:93
ScCsvColStateVec maFixColStates
Called when horizontal scrolling has ended.
Definition: csvtablebox.hxx:59
std::unique_ptr< ScCsvRuler > mxRuler
Current layout data of the controls.
Definition: csvtablebox.hxx:48
ScCsvColStateVec maSepColStates
Column states in fixed width mode.
Definition: csvtablebox.hxx:60
DECL_DLLPRIVATE_LINK(ScrollEndHdl, Timer *, void)
ScCsvLayoutData maData
Definition: csvtablebox.hxx:46
ScCsvGrid & GetGrid()
Definition: csvtablebox.hxx:81
std::unique_ptr< ScCsvGrid > mxGrid
The ruler for fixed width mode.
Definition: csvtablebox.hxx:49
DECL_DLLPRIVATE_LINK(HScrollHdl, weld::ScrolledWindow &, void)
void SetColTypeHdl(const Link< ScCsvTableBox &, void > &rHdl)
Sets a new handler for "column selection changed" events.
void SetUpdateTextHdl(const Link< ScCsvTableBox &, void > &rHdl)
Sets a new handler for "update cell texts" requests.
Link< ScCsvTableBox &, void > maColTypeHdl
Updates all cell texts.
Definition: csvtablebox.hxx:55
std::unique_ptr< weld::ScrolledWindow > mxScroll
Calc-like data table for fixed width mode.
Definition: csvtablebox.hxx:50
ScCsvRuler & GetRuler()
Definition: csvtablebox.hxx:80
void Init()
::std::vector< ScCsvColState > ScCsvColStateVec
Definition: csvgrid.hxx:53
sal_uInt16 nPos
std::vector< sal_Int8, boost::noinit_adaptor< std::allocator< sal_Int8 > > > maData
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
A structure containing all layout data valid for both ruler and data grid (i.e.
Definition: csvcontrol.hxx:112
sal_uInt16 sal_Unicode