2015-04-13 04:09:02 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
2015-03-28 06:22:15 -05:00
|
|
|
/*
|
|
|
|
* 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))));
|
2015-07-15 10:31:52 -05:00
|
|
|
long width, height, parts;
|
2015-03-28 06:22:15 -05:00
|
|
|
loKitDocument->pClass->getDocumentSize(loKitDocument, &width, &height);
|
2015-07-15 10:31:52 -05:00
|
|
|
parts = loKitDocument->pClass->getParts(loKitDocument);
|
|
|
|
std::string status =
|
|
|
|
("type=" + typeString + " "
|
|
|
|
"parts=" + std::to_string(parts) + " "
|
2015-03-28 06:22:15 -05:00
|
|
|
"current=" + std::to_string(loKitDocument->pClass->getPart(loKitDocument)) + " "
|
|
|
|
"width=" + std::to_string(width) + " "
|
|
|
|
"height=" + std::to_string(height));
|
2015-07-15 10:31:52 -05:00
|
|
|
if (typeString == "spreadsheet" || typeString == "presentation") {
|
|
|
|
for (int i = 0; i < parts; i++) {
|
|
|
|
status += "\n";
|
|
|
|
status += loKitDocument->pClass->getPartName(loKitDocument, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
2015-03-28 06:22:15 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|