13#include <com/sun/star/frame/XLayoutManager.hpp>
14#include <osl/conditn.hxx>
27#include <officecfg/Office/Calc.hxx>
29#include <orcus/csv_parser.hpp>
50 osl_getSystemTime(&now);
51 return static_cast<double>(
now.Seconds) +
static_cast<double>(
now.Nanosec) / 1000000000.0;
56 DataStream::Line& mrLine;
59 const char* mpLineHead;
62 CSVHandler( DataStream::Line& rLine,
size_t nColCount ) :
63 mrLine(rLine), mnColCount(nColCount), mnCols(0), mpLineHead(rLine.
maLine.getStr()) {}
65 static void begin_parse() {}
66 static void end_parse() {}
67 static void begin_row() {}
68 static void end_row() {}
70 void cell(std::string_view s,
bool )
72 if (mnCols >= mnColCount)
75 DataStream::Cell aCell;
82 aCell.mbValue =
false;
83 aCell.maStr.Pos = std::distance(mpLineHead, s.data());
84 aCell.maStr.Size = s.size();
86 mrLine.maCells.push_back(aCell);
94namespace datastreams {
178 std::optional<DataStream::LinesType> oLines;
197 rLine.maCells.clear();
200 orcus::csv_parser<CSVHandler>
parser(rLine.maLine, aHdl,
maConfig);
242 css::uno::Reference< css::frame::XFrame >
xFrame =
247 css::uno::Reference< css::beans::XPropertySet > xPropSet(
xFrame, css::uno::UNO_QUERY);
251 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
252 xPropSet->getPropertyValue(
"LayoutManager") >>= xLayoutManager;
253 if (!xLayoutManager.is())
256 static constexpr OUStringLiteral sResourceURL(
u"private:resource/toolbar/datastreams" );
257 css::uno::Reference< css::ui::XUIElement > xUIElement = xLayoutManager->getElement(sResourceURL);
258 if (!xUIElement.is())
260 xLayoutManager->createElement( sResourceURL );
261 xLayoutManager->showElement( sResourceURL );
267 sal_Int32 nLimit,
MoveType eMove, sal_uInt32 nSettings)
276 sal_Int32 nLimit,
MoveType eMove, sal_uInt32 nSettings) :
295 Decode(rURL, rRange, nLimit, eMove, nSettings);
347 sal_Int32 nLimit,
MoveType eMove,
const sal_uInt32 nSettings)
418 double fStart = getNow();
466 sal_Int32 nStreamTimeout = officecfg::Office::Calc::DataStream::UpdateTimeout::get();
482 double fStart = getNow();
487 const char* pLineHead = aLine.
maLine.getStr();
545 maImportTimer.Start();
basegfx::B2DPolygon maLine
void IncRow(SCROW nDelta=1)
void SetDocumentModified()
const ScDocument & GetDocument() const
static ScViewData * GetViewData()
sc::DocumentLinkManager & GetDocLinkManager()
static bool parseSimpleNumber(const OUString &rStr, sal_Unicode dsep, sal_Unicode gsep, sal_Unicode dsepa, double &rVal, bool bDetectScientificNumber=true)
Check if a given string is a simple decimal number (e.g.
ScTabViewShell * GetViewShell() const
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
SfxFrame & GetFrame() const
SfxViewFrame & GetViewFrame() const
void SetTimeout(sal_uInt64 nTimeoutMs)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
virtual void Start(bool bStartTimer=true) override
size_t mnLinesSinceRefresh
std::vector< Line > LinesType
DocumentStreamAccess maDocAccess
bool mbRefreshOnEmptyLine
static void MakeToolbarVisible()
void Decode(const OUString &rURL, const ScRange &rRange, sal_Int32 nLimit, MoveType eMove, const sal_uInt32 nSettings)
static DataStream * Set(ScDocShell *pShell, const OUString &rURL, const ScRange &rRange, sal_Int32 nLimit, MoveType eMove, sal_uInt32 nSettings)
void SetRefreshOnEmptyLine(bool bVal)
rtl::Reference< datastreams::ReaderThread > mxReaderThread
DataStream(const DataStream &)=delete
std::optional< LinesType > moLines
void setDataStream(DataStream *p)
void reset()
Clear its internal state, and more importantly all the block position hints currently held.
void shiftRangeUp(const ScRange &rRange)
Pop the top row inside specified range, shift all the other rows up by one, then set the bottom row e...
void setStringCell(const ScAddress &rPos, const OUString &rStr)
void setNumericCell(const ScAddress &rPos, double fVal)
void shiftRangeDown(const ScRange &rRange)
Top the bottom row inside specified range, shift all the other rows above downward by one by insertin...
std::atomic< bool > mbTerminate
osl::Condition maCondConsume
std::queue< DataStream::LinesType > maPendingLines
osl::Condition maCondReadStream
bool isTerminateRequested()
virtual void execute() override
std::queue< DataStream::LinesType > maUsedLines
ReaderThread(std::unique_ptr< SvStream > pData, size_t nColCount)
void pushUsedLines(DataStream::LinesType pLines)
std::mutex & getLinesMutex()
orcus::csv::parser_config maConfig
DataStream::LinesType popNewLines()
std::unique_ptr< SvStream > mpStream
#define LINK(Instance, Class, Member)
std::unique_ptr< sal_Int32[]> pData
CAUTION! The following defines must be in the same namespace as the respective type.
IMPL_LINK_NOARG(SharedStringPoolPurge, timerHandler, Timer *, void)
static o3tl::enumarray< DebugTime, double > fTimes
double datastream_get_time(DebugTime nIdx)
std::vector< Cell > maCells
Reference< XFrame > xFrame