2010-12-03 16:17:02 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
2013-04-24 17:14:03 +01:00
|
|
|
* This file is part of the LibreOffice project.
|
2010-12-03 16:17:02 +01:00
|
|
|
*
|
2013-04-24 17:14:03 +01:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2010-12-03 16:17:02 +01:00
|
|
|
*/
|
2013-04-24 17:14:03 +01:00
|
|
|
|
2013-10-23 19:14:56 +02:00
|
|
|
#ifndef INCLUDED_SVTOOLS_FILECHANGEDCHECKER_HXX
|
|
|
|
#define INCLUDED_SVTOOLS_FILECHANGEDCHECKER_HXX
|
2010-12-03 16:17:02 +01:00
|
|
|
|
2013-11-09 15:40:46 -06:00
|
|
|
#include <svtools/svtdllapi.h>
|
2015-07-31 18:28:55 +02:00
|
|
|
|
2010-12-03 16:17:02 +01:00
|
|
|
#include <osl/file.hxx>
|
|
|
|
#include <vcl/timer.hxx>
|
2015-01-14 10:21:20 +01:00
|
|
|
#include <vcl/idle.hxx>
|
2010-12-03 16:17:02 +01:00
|
|
|
|
2015-07-31 18:28:55 +02:00
|
|
|
#include <functional>
|
|
|
|
|
2010-12-03 16:17:02 +01:00
|
|
|
/** Periodically checks if a file has been modified
|
|
|
|
|
|
|
|
Instances of this class setup a vcl timer to occasionally wake up
|
|
|
|
check whether file modification time has changed.
|
|
|
|
*/
|
2010-12-03 21:12:46 +01:00
|
|
|
class SVT_DLLPUBLIC FileChangedChecker
|
2010-12-03 16:17:02 +01:00
|
|
|
{
|
2015-07-17 10:29:59 +02:00
|
|
|
private:
|
2014-11-04 11:51:18 +00:00
|
|
|
Idle mIdle;
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString mFileName;
|
2010-12-03 16:17:02 +01:00
|
|
|
TimeValue mLastModTime;
|
2015-07-31 18:28:55 +02:00
|
|
|
::std::function<void ()> mpCallback;
|
2010-12-03 16:17:02 +01:00
|
|
|
|
2010-12-03 21:12:46 +01:00
|
|
|
bool SVT_DLLPRIVATE getCurrentModTime(TimeValue& o_rValue) const;
|
2017-01-23 19:37:51 +01:00
|
|
|
DECL_LINK(TimerHandler, Timer *, void);
|
2010-12-03 16:17:02 +01:00
|
|
|
|
2015-07-17 10:29:59 +02:00
|
|
|
public:
|
2010-12-03 16:17:02 +01:00
|
|
|
void resetTimer();
|
|
|
|
bool hasFileChanged();
|
2015-07-31 18:28:55 +02:00
|
|
|
FileChangedChecker(const OUString& rFilename,
|
|
|
|
const ::std::function<void ()>& rCallback);
|
2010-12-03 16:17:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|