Add a separate include file for some helper functions
parent
7cb0449b8e
commit
56f3678b36
|
@ -0,0 +1,53 @@
|
|||
/* -*- 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/.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_LOKITHELPER_HPP
|
||||
#define INCLUDED_LOKITHELPER_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#define LOK_USE_UNSTABLE_API
|
||||
#include <LibreOfficeKit/LibreOfficeKit.h>
|
||||
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
||||
|
||||
namespace LOKitHelper
|
||||
{
|
||||
std::string documentTypeToString(LibreOfficeKitDocumentType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case LOK_DOCTYPE_TEXT:
|
||||
return "text";
|
||||
case LOK_DOCTYPE_SPREADSHEET:
|
||||
return "spreadsheet";
|
||||
case LOK_DOCTYPE_PRESENTATION:
|
||||
return "presentation";
|
||||
case LOK_DOCTYPE_DRAWING:
|
||||
return "drawing";
|
||||
default:
|
||||
return "other-" + std::to_string(type);
|
||||
}
|
||||
}
|
||||
|
||||
std::string documentStatus(LibreOfficeKitDocument *loKitDocument)
|
||||
{
|
||||
std::string typeString(documentTypeToString(static_cast<LibreOfficeKitDocumentType>(loKitDocument->pClass->getDocumentType(loKitDocument))));
|
||||
long width, height;
|
||||
loKitDocument->pClass->getDocumentSize(loKitDocument, &width, &height);
|
||||
return ("type=" + typeString + " "
|
||||
"parts=" + std::to_string(loKitDocument->pClass->getParts(loKitDocument)) + " "
|
||||
"current=" + std::to_string(loKitDocument->pClass->getPart(loKitDocument)) + " "
|
||||
"width=" + std::to_string(width) + " "
|
||||
"height=" + std::to_string(height));
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -27,6 +27,7 @@
|
|||
#include <Poco/URI.h>
|
||||
#include <Poco/Util/Application.h>
|
||||
|
||||
#include "LOKitHelper.hpp"
|
||||
#include "LOOLProtocol.hpp"
|
||||
#include "LOOLSession.hpp"
|
||||
#include "LOOLWSD.hpp"
|
||||
|
@ -310,33 +311,7 @@ bool LOOLSession::getStatus(const char *buffer, int length)
|
|||
return true;
|
||||
}
|
||||
|
||||
LibreOfficeKitDocumentType type = (LibreOfficeKitDocumentType) _loKitDocument->pClass->getDocumentType(_loKitDocument);
|
||||
std::string typeString;
|
||||
switch (type)
|
||||
{
|
||||
case LOK_DOCTYPE_TEXT:
|
||||
typeString = "text";
|
||||
break;
|
||||
case LOK_DOCTYPE_SPREADSHEET:
|
||||
typeString = "spreadsheet";
|
||||
break;
|
||||
case LOK_DOCTYPE_PRESENTATION:
|
||||
typeString = "presentation";
|
||||
break;
|
||||
case LOK_DOCTYPE_DRAWING:
|
||||
typeString = "drawing";
|
||||
break;
|
||||
default:
|
||||
typeString = "other";
|
||||
break;
|
||||
}
|
||||
long width, height;
|
||||
_loKitDocument->pClass->getDocumentSize(_loKitDocument, &width, &height);
|
||||
status = ("status: type=" + typeString + " "
|
||||
"parts=" + std::to_string(_loKitDocument->pClass->getParts(_loKitDocument)) + " "
|
||||
"current=" + std::to_string(_loKitDocument->pClass->getPart(_loKitDocument)) + " "
|
||||
"width=" + std::to_string(width) + " "
|
||||
"height=" + std::to_string(height));
|
||||
status = "status: " + LOKitHelper::documentStatus(_loKitDocument);
|
||||
_tileCache->saveStatus(status);
|
||||
|
||||
sendTextFrame(status);
|
||||
|
|
Loading…
Reference in New Issue