/src/libreoffice/sc/source/ui/inc/datastream.hxx
Line | Count | Source |
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 | | |
10 | | #pragma once |
11 | | |
12 | | #include <sal/config.h> |
13 | | |
14 | | #include <rtl/ref.hxx> |
15 | | #include <rtl/ustring.hxx> |
16 | | #include <vcl/timer.hxx> |
17 | | #include <address.hxx> |
18 | | #include <optional> |
19 | | #include <vector> |
20 | | |
21 | | #include <documentstreamaccess.hxx> |
22 | | |
23 | | class ScDocShell; |
24 | | |
25 | | namespace sc { |
26 | | |
27 | | namespace datastreams { |
28 | | class ReaderThread; |
29 | | } |
30 | | |
31 | | class DataStream |
32 | | { |
33 | | public: |
34 | | DataStream(const DataStream&) = delete; |
35 | | const DataStream& operator=(const DataStream&) = delete; |
36 | | |
37 | | struct Cell |
38 | | { |
39 | | struct Str |
40 | | { |
41 | | size_t Pos; |
42 | | size_t Size; |
43 | | }; |
44 | | |
45 | | union |
46 | | { |
47 | | Str maStr; |
48 | | double mfValue; |
49 | | }; |
50 | | |
51 | | bool mbValue; |
52 | | |
53 | | Cell(); |
54 | | Cell( const Cell& r ); |
55 | | }; |
56 | | |
57 | | struct Line |
58 | | { |
59 | | OString maLine; |
60 | | std::vector<Cell> maCells; |
61 | | }; |
62 | | typedef std::vector<Line> LinesType; |
63 | | |
64 | | enum MoveType { NO_MOVE, RANGE_DOWN, MOVE_DOWN, MOVE_UP }; |
65 | | |
66 | | static void MakeToolbarVisible(); |
67 | | static DataStream* Set(ScDocShell *pShell, const OUString& rURL, const ScRange& rRange, |
68 | | sal_Int32 nLimit, MoveType eMove); |
69 | | |
70 | | DataStream( |
71 | | ScDocShell *pShell, const OUString& rURL, const ScRange& rRange, |
72 | | sal_Int32 nLimit, MoveType eMove); |
73 | | |
74 | | ~DataStream(); |
75 | | |
76 | | ScRange GetRange() const; |
77 | 0 | const OUString& GetURL() const { return msURL; } |
78 | 0 | MoveType GetMove() const { return meOrigMove;} |
79 | 0 | bool IsRefreshOnEmptyLine() const { return mbRefreshOnEmptyLine;} |
80 | | |
81 | | void Decode( |
82 | | const OUString& rURL, const ScRange& rRange, sal_Int32 nLimit, |
83 | | MoveType eMove); |
84 | | |
85 | | bool ImportData(); |
86 | | void StartImport(); |
87 | | void StopImport(); |
88 | | |
89 | | void SetRefreshOnEmptyLine( bool bVal ); |
90 | | |
91 | | private: |
92 | | Line ConsumeLine(); |
93 | | void MoveData(); |
94 | | void Text2Doc(); |
95 | | void Refresh(); |
96 | | |
97 | | DECL_LINK( ImportTimerHdl, Timer*, void ); |
98 | | |
99 | | private: |
100 | | ScDocShell* mpDocShell; |
101 | | DocumentStreamAccess maDocAccess; |
102 | | OUString msURL; |
103 | | MoveType meOrigMove; // Initial move setting. This one gets saved to file. |
104 | | MoveType meMove; // move setting during streaming, which may change in the middle. |
105 | | bool mbRunning; |
106 | | bool mbValuesInLine; |
107 | | bool mbRefreshOnEmptyLine; |
108 | | std::optional<LinesType> moLines; |
109 | | size_t mnLinesCount; |
110 | | size_t mnLinesSinceRefresh; |
111 | | double mfLastRefreshTime; |
112 | | SCROW mnCurRow; |
113 | | ScRange maStartRange; |
114 | | ScRange maEndRange; |
115 | | |
116 | | Timer maImportTimer; |
117 | | |
118 | | rtl::Reference<datastreams::ReaderThread> mxReaderThread; |
119 | | bool mbIsFirst; |
120 | | bool mbIsUpdate; |
121 | | }; |
122 | | |
123 | | } |
124 | | |
125 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |