2015-09-09 15:08:26 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* 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/.
|
|
|
|
*/
|
2015-09-24 07:39:16 +02:00
|
|
|
|
|
|
|
#ifndef INCLUDED_DESKTOP_INC_LIB_INIT_HXX
|
|
|
|
#define INCLUDED_DESKTOP_INC_LIB_INIT_HXX
|
|
|
|
|
2016-04-19 21:26:42 -04:00
|
|
|
#include <map>
|
2016-09-09 21:55:12 +02:00
|
|
|
#include <unordered_map>
|
2016-04-19 21:26:42 -04:00
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
#include <osl/thread.h>
|
|
|
|
#include <vcl/idle.hxx>
|
2015-09-09 15:08:26 +03:00
|
|
|
#include <LibreOfficeKit/LibreOfficeKit.h>
|
2016-01-26 15:35:42 +01:00
|
|
|
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
2015-09-09 15:08:26 +03:00
|
|
|
#include <com/sun/star/lang/XComponent.hpp>
|
2016-04-19 21:26:42 -04:00
|
|
|
|
2015-11-25 16:50:22 +01:00
|
|
|
#include <desktop/dllapi.h>
|
2015-09-09 15:08:26 +03:00
|
|
|
|
2016-01-25 12:29:16 +01:00
|
|
|
class LOKInteractionHandler;
|
|
|
|
|
2015-09-09 15:08:26 +03:00
|
|
|
namespace desktop {
|
2016-04-19 21:26:42 -04:00
|
|
|
|
2016-06-09 12:17:18 +02:00
|
|
|
class DESKTOP_DLLPUBLIC CallbackFlushHandler : public Idle
|
2016-04-19 21:26:42 -04:00
|
|
|
{
|
|
|
|
public:
|
2016-06-16 15:55:43 +02:00
|
|
|
explicit CallbackFlushHandler(LibreOfficeKitDocument* pDocument, LibreOfficeKitCallback pCallback, void* pData);
|
2016-09-13 13:09:01 +02:00
|
|
|
virtual ~CallbackFlushHandler() override;
|
2016-06-09 12:17:18 +02:00
|
|
|
virtual void Invoke() override;
|
|
|
|
static void callback(const int type, const char* payload, void* data);
|
|
|
|
void queue(const int type, const char* data);
|
2016-08-19 08:28:16 -04:00
|
|
|
|
|
|
|
/// When enabled events are queued but callback not invoked.
|
|
|
|
void setEventLatch(const bool bEventLatch)
|
|
|
|
{
|
|
|
|
m_bEventLatch = bEventLatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isEventLatchOn() const { return m_bEventLatch; }
|
|
|
|
void setPartTilePainting(const bool bPartPainting) { m_bPartTilePainting = bPartPainting; }
|
|
|
|
bool isPartTilePainting() const { return m_bPartTilePainting; }
|
2016-05-06 08:16:00 -04:00
|
|
|
|
2016-09-09 21:55:12 +02:00
|
|
|
void addViewStates(int viewId);
|
|
|
|
void removeViewStates(int viewId);
|
|
|
|
|
2016-09-07 15:56:09 +02:00
|
|
|
typedef std::vector<std::pair<int, std::string>> queue_type;
|
|
|
|
|
2016-04-19 21:26:42 -04:00
|
|
|
private:
|
2016-09-07 15:56:09 +02:00
|
|
|
void removeAll(const std::function<bool (const queue_type::value_type&)>& rTestFunc);
|
2016-04-30 14:29:37 -04:00
|
|
|
|
2016-09-07 15:56:09 +02:00
|
|
|
queue_type m_queue;
|
2016-04-19 21:26:42 -04:00
|
|
|
std::map<int, std::string> m_states;
|
2016-09-09 21:55:12 +02:00
|
|
|
std::unordered_map<int, std::unordered_map<int, std::string>> m_viewStates;
|
2016-06-16 15:55:43 +02:00
|
|
|
LibreOfficeKitDocument* m_pDocument;
|
2016-04-19 21:26:42 -04:00
|
|
|
LibreOfficeKitCallback m_pCallback;
|
|
|
|
void *m_pData;
|
2016-05-06 08:16:00 -04:00
|
|
|
bool m_bPartTilePainting;
|
2016-08-19 08:28:16 -04:00
|
|
|
bool m_bEventLatch;
|
2016-04-19 21:26:42 -04:00
|
|
|
std::mutex m_mutex;
|
|
|
|
};
|
|
|
|
|
2015-09-09 15:08:26 +03:00
|
|
|
struct DESKTOP_DLLPUBLIC LibLODocument_Impl : public _LibreOfficeKitDocument
|
|
|
|
{
|
2015-09-23 07:48:10 +02:00
|
|
|
css::uno::Reference<css::lang::XComponent> mxComponent;
|
2015-09-17 09:21:43 +01:00
|
|
|
std::shared_ptr< LibreOfficeKitDocumentClass > m_pDocumentClass;
|
2016-06-09 14:17:57 +02:00
|
|
|
std::map<size_t, std::shared_ptr<CallbackFlushHandler>> mpCallbackFlushHandlers;
|
2015-09-09 15:08:26 +03:00
|
|
|
|
2015-09-23 07:48:10 +02:00
|
|
|
explicit LibLODocument_Impl(const css::uno::Reference <css::lang::XComponent> &xComponent);
|
2015-09-09 15:08:26 +03:00
|
|
|
~LibLODocument_Impl();
|
|
|
|
};
|
2015-09-25 01:06:31 +02:00
|
|
|
|
|
|
|
struct DESKTOP_DLLPUBLIC LibLibreOffice_Impl : public _LibreOfficeKit
|
|
|
|
{
|
|
|
|
OUString maLastExceptionMsg;
|
|
|
|
std::shared_ptr< LibreOfficeKitClass > m_pOfficeClass;
|
|
|
|
oslThread maThread;
|
|
|
|
LibreOfficeKitCallback mpCallback;
|
|
|
|
void *mpCallbackData;
|
2016-01-26 15:35:42 +01:00
|
|
|
int64_t mOptionalFeatures;
|
2016-01-25 12:29:16 +01:00
|
|
|
std::map<OString, rtl::Reference<LOKInteractionHandler>> mInteractionMap;
|
2015-09-25 01:06:31 +02:00
|
|
|
|
|
|
|
LibLibreOffice_Impl();
|
2016-01-25 12:29:16 +01:00
|
|
|
~LibLibreOffice_Impl();
|
2016-01-26 15:35:42 +01:00
|
|
|
|
|
|
|
bool hasOptionalFeature(LibreOfficeKitOptionalFeatures const feature)
|
|
|
|
{
|
|
|
|
return (mOptionalFeatures & feature) != 0;
|
|
|
|
}
|
2015-09-25 01:06:31 +02:00
|
|
|
};
|
2017-03-23 21:27:18 +01:00
|
|
|
|
|
|
|
/// Helper function to extract the value from parameters delimited by
|
|
|
|
/// comma, like: Name1=Value1,Name2=Value2,Name3=Value3.
|
2017-03-28 23:37:35 +02:00
|
|
|
/// @param rOptions When extracted, the Param=Value is removed from it.
|
2017-03-23 21:27:18 +01:00
|
|
|
DESKTOP_DLLPUBLIC OUString extractParameter(OUString& aOptions, const OUString& rName);
|
2015-09-09 15:08:26 +03:00
|
|
|
}
|
2015-09-23 07:48:10 +02:00
|
|
|
|
2015-09-24 07:39:16 +02:00
|
|
|
#endif
|
|
|
|
|
2015-09-23 07:48:10 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|