Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / inc / datastream.hxx
blob5600a09c1eb482d256a4ea1c511c95315d53fbbe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #ifndef SC_DATASTREAM_HXX
11 #define SC_DATASTREAM_HXX
13 #include <sal/config.h>
15 #include <rtl/ref.hxx>
16 #include <rtl/ustring.hxx>
17 #include <vcl/timer.hxx>
18 #include <address.hxx>
20 #include <boost/noncopyable.hpp>
21 #include <boost/scoped_ptr.hpp>
22 #include <vector>
24 #include <documentstreamaccess.hxx>
26 class ScDocShell;
27 class ScDocument;
28 class Window;
30 namespace sc {
32 namespace datastreams {
33 class CallerThread;
34 class ReaderThread;
38 class DataStream : boost::noncopyable
40 public:
41 struct Cell
43 struct Str
45 size_t Pos;
46 size_t Size;
49 union
51 Str maStr;
52 double mfValue;
55 bool mbValue;
57 Cell();
58 Cell( const Cell& r );
61 struct Line
63 OString maLine;
64 std::vector<Cell> maCells;
66 typedef std::vector<Line> LinesType;
68 enum MoveType { NO_MOVE, RANGE_DOWN, MOVE_DOWN, MOVE_UP };
69 enum { SCRIPT_STREAM = 1, VALUES_IN_LINE = 2 };
71 static void MakeToolbarVisible();
72 static DataStream* Set(ScDocShell *pShell, const OUString& rURL, const ScRange& rRange,
73 sal_Int32 nLimit, MoveType eMove, sal_uInt32 nSettings);
75 static MoveType ToMoveType( const OUString& rMoveStr );
77 DataStream(
78 ScDocShell *pShell, const OUString& rURL, const ScRange& rRange,
79 sal_Int32 nLimit, MoveType eMove, sal_uInt32 nSettings);
81 ~DataStream();
83 ScRange GetRange() const;
84 const OUString& GetURL() const { return msURL; }
85 const sal_Int32& GetLimit() const { return mnLimit; }
86 MoveType GetMove() const;
87 const sal_uInt32& GetSettings() const { return mnSettings; }
88 bool IsRefreshOnEmptyLine() const;
90 void Decode(
91 const OUString& rURL, const ScRange& rRange, sal_Int32 nLimit,
92 MoveType eMove, const sal_uInt32 nSettings);
94 bool ImportData();
95 void StartImport();
96 void StopImport();
98 void SetRefreshOnEmptyLine( bool bVal );
100 private:
101 Line ConsumeLine();
102 void MoveData();
103 void Text2Doc();
104 void Refresh();
106 DECL_LINK( ImportTimerHdl, void* );
108 private:
109 ScDocShell* mpDocShell;
110 ScDocument* mpDoc;
111 DocumentStreamAccess maDocAccess;
112 OUString msURL;
113 sal_Int32 mnLimit;
114 sal_uInt32 mnSettings;
115 MoveType meOrigMove; // Initial move setting. This one gets saved to file.
116 MoveType meMove; // move setting during streaming, which may change in the middle.
117 bool mbRunning;
118 bool mbValuesInLine;
119 bool mbRefreshOnEmptyLine;
120 LinesType* mpLines;
121 size_t mnLinesCount;
122 size_t mnLinesSinceRefresh;
123 double mfLastRefreshTime;
124 SCROW mnCurRow;
125 ScRange maStartRange;
126 ScRange maEndRange;
128 Timer maImportTimer;
130 rtl::Reference<datastreams::ReaderThread> mxReaderThread;
135 #endif
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */