10#include <config_buildconfig.h>
11#include <config_features.h>
20#include <unicode/udata.h>
21#include <unicode/ucnv.h>
23#import <Foundation/Foundation.h>
24#import <CoreGraphics/CoreGraphics.h>
29#include <osl/detail/android-bootstrap.h>
33#include <osl/detail/emscripten-bootstrap.h>
41#include <boost/property_tree/json_parser.hpp>
42#include <boost/algorithm/string.hpp>
44#include <LibreOfficeKit/LibreOfficeKit.h>
45#include <LibreOfficeKit/LibreOfficeKitEnums.h>
54#include <osl/file.hxx>
55#include <osl/process.h>
56#include <osl/thread.h>
57#include <rtl/bootstrap.hxx>
58#include <rtl/strbuf.hxx>
74#include <com/sun/star/document/MacroExecMode.hpp>
75#include <com/sun/star/beans/XPropertySet.hpp>
76#include <com/sun/star/container/XNameAccess.hpp>
77#include <com/sun/star/frame/Desktop.hpp>
78#include <com/sun/star/frame/DispatchResultEvent.hpp>
79#include <com/sun/star/frame/DispatchResultState.hpp>
80#include <com/sun/star/frame/XDispatchProvider.hpp>
81#include <com/sun/star/frame/XDispatchResultListener.hpp>
82#include <com/sun/star/frame/XSynchronousDispatch.hpp>
83#include <com/sun/star/frame/XStorable.hpp>
84#include <com/sun/star/lang/Locale.hpp>
85#include <com/sun/star/lang/XComponent.hpp>
86#include <com/sun/star/lang/XMultiServiceFactory.hpp>
87#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
88#include <com/sun/star/util/URLTransformer.hpp>
89#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
90#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp>
91#include <com/sun/star/datatransfer/XTransferable2.hpp>
92#include <com/sun/star/text/TextContentAnchorType.hpp>
93#include <com/sun/star/document/XRedlinesSupplier.hpp>
94#include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
96#include <com/sun/star/xml/crypto/SEInitializer.hpp>
97#include <com/sun/star/xml/crypto/XSEInitializer.hpp>
98#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
99#include <com/sun/star/xml/crypto/XCertificateCreator.hpp>
100#include <com/sun/star/security/XCertificate.hpp>
102#include <com/sun/star/linguistic2/LinguServiceManager.hpp>
103#include <com/sun/star/linguistic2/XSpellChecker.hpp>
104#include <com/sun/star/i18n/LocaleCalendar2.hpp>
105#include <com/sun/star/i18n/ScriptType.hpp>
106#include <com/sun/star/lang/DisposedException.hpp>
125#include <svx/strings.hrc>
127#include <svx/svxids.hrc>
149#include <unicode/uchar.h>
157#include <osl/module.hxx>
170#include <com/sun/star/document/XUndoManager.hpp>
171#include <com/sun/star/document/XUndoManagerSupplier.hpp>
178#include "../app/cmdlineargs.hxx"
180#include "../app/sofficemain.h"
181#include "../app/officeipcthread.hxx"
186#include <officecfg/Office/Common.hxx>
187#include <officecfg/Office/Impress.hxx>
216 SAL_WARN_IF(!s.isEmpty(),
"lok",
"lok exception '" + s +
"'");
226 const char *filterName;
231 static const int dumpTimeoutMS = 5000;
234 TraceEventDumper() :
AutoTimer(
"Trace Event dumper" )
240 virtual void Invoke()
override
245 static void flushRecordings()
247 const css::uno::Sequence<OUString> aEvents =
249 OStringBuffer aOutput;
250 for (
const auto &s : aEvents)
253 aOutput.append(
"\n");
255 if (aOutput.getLength() > 0)
257 OString aChunk = aOutput.makeStringAndClear();
270 {
"doc",
"MS Word 97" },
271 {
"docm",
"MS Word 2007 XML VBA" },
272 {
"docx",
"MS Word 2007 XML" },
273 {
"fodt",
"OpenDocument Text Flat XML" },
274 {
"html",
"HTML (StarWriter)" },
275 {
"odt",
"writer8" },
276 {
"ott",
"writer8_template" },
277 {
"pdf",
"writer_pdf_Export" },
279 {
"rtf",
"Rich Text Format" },
281 {
"xhtml",
"XHTML Writer File" },
282 {
"png",
"writer_png_Export" },
283 {
"xml",
"writer_indexing_export" },
289 {
"csv",
"Text - txt - csv (StarCalc)" },
290 {
"fods",
"OpenDocument Spreadsheet Flat XML" },
291 {
"html",
"HTML (StarCalc)" },
293 {
"ots",
"calc8_template" },
294 {
"pdf",
"calc_pdf_Export" },
295 {
"xhtml",
"XHTML Calc File" },
296 {
"xls",
"MS Excel 97" },
297 {
"xlsm",
"Calc MS Excel 2007 VBA XML" },
298 {
"xlsx",
"Calc MS Excel 2007 XML" },
299 {
"png",
"calc_png_Export" },
305 {
"fodp",
"OpenDocument Presentation Flat XML" },
306 {
"html",
"impress_html_Export" },
307 {
"odg",
"impress8_draw" },
308 {
"odp",
"impress8" },
309 {
"otp",
"impress8_template" },
310 {
"pdf",
"impress_pdf_Export" },
311 {
"potm",
"Impress MS PowerPoint 2007 XML Template" },
312 {
"pot",
"MS PowerPoint 97 Vorlage" },
313 {
"pptm",
"Impress MS PowerPoint 2007 XML VBA" },
314 {
"pptx",
"Impress MS PowerPoint 2007 XML" },
315 {
"pps",
"MS PowerPoint 97 Autoplay" },
316 {
"ppt",
"MS PowerPoint 97" },
317 {
"svg",
"impress_svg_Export" },
318 {
"xhtml",
"XHTML Impress File" },
319 {
"png",
"impress_png_Export"},
325 {
"fodg",
"draw_ODG_FlatXML" },
326 {
"html",
"draw_html_Export" },
328 {
"pdf",
"draw_pdf_Export" },
329 {
"svg",
"draw_svg_Export" },
330 {
"xhtml",
"XHTML Draw File" },
331 {
"png",
"draw_png_Export"},
337 if (pString ==
nullptr)
340 OString sString(pString, strlen(pString));
341 return OStringToOUString(sString, RTL_TEXTENCODING_UTF8);
347 char* pMemory =
static_cast<char*
>(malloc(rStr.getLength() + 1));
349 memcpy(pMemory, rStr.getStr(), rStr.getLength() + 1);
366 OUString aWorkingDir;
367 osl_getProcessWorkingDir(&aWorkingDir.pData);
368 if (!aWorkingDir.endsWith(
"/"))
373 return rtl::Uri::convertRelToAbs(aWorkingDir,
aURL);
375 catch (
const rtl::MalformedUriException &)
385 if (pJSON && pJSON[0] !=
'\0')
395 OUString aType = anyItem.getValueTypeName();
396 rJson.
put(
"type", aType.toUtf8().getStr());
398 if (aType ==
"string")
399 rJson.
put(
"value", anyItem.get<OUString>().toUtf8().getStr());
400 else if (aType ==
"unsigned long")
401 rJson.
put(
"value", OString::number(anyItem.get<sal_uInt32>()).getStr());
402 else if (aType ==
"long")
403 rJson.
put(
"value", OString::number(anyItem.get<sal_Int32>()).getStr());
404 else if (aType ==
"[]any")
407 if (anyItem >>=
aSeq)
409 auto valueNode = rJson.
startNode(
"value");
411 for (
auto i = 0;
i <
aSeq.getLength(); ++
i)
426 if (rPayload.compare(0, 5,
"EMPTY") == 0)
431 int nSeparatorPos = rPayload.find(
',', 6);
432 bool bHasMode = nSeparatorPos > 0;
435 aRet.
m_nPart = std::stol(rPayload.substr(6, nSeparatorPos - 6));
437 aRet.
m_nMode = std::stol(rPayload.substr(nSeparatorPos + 1));
441 aRet.
m_nPart = std::stol(rPayload.substr(6));
450 const char*
pos = rPayload.c_str();
451 const char*
end = rPayload.c_str() + rPayload.size();
476 nPart = rtl_str_toInt64_WithLength(
pos, 10,
end -
pos);
478 while( *
pos && *
pos !=
',' )
484 nMode = rtl_str_toInt64_WithLength(
pos, 10,
end -
pos);
496 if (nWidth <= 0 || nHeight <= 0)
513 if (nWidth > 0 && nHeight > 0)
538 PayloadObject = rRectAndPart;
539 PayloadString.clear();
546 if(PayloadObject.which() != 1)
548 return boost::get<RectangleAndPart>(PayloadObject);
553 boost::property_tree::ptree aTree;
554 std::stringstream aStream(payload);
555 boost::property_tree::read_json(aStream, aTree);
561 return boost::get<boost::property_tree::ptree>(PayloadObject);
566 std::stringstream aJSONStream;
567 constexpr bool bPretty =
false;
568 boost::property_tree::write_json(aJSONStream, rTree, bPretty);
569 PayloadString = boost::trim_copy(aJSONStream.str());
571 PayloadObject = rTree;
576 assert(PayloadObject.which() == 2);
577 return boost::get<boost::property_tree::ptree>(PayloadObject);
584 assert(PayloadObject.which() == 3);
585 return boost::get<int>(PayloadObject);
592 switch (PayloadObject.which())
600 return getRectangleAndPart().toString().getStr() == getPayload();
605 std::stringstream aJSONStream;
606 boost::property_tree::write_json(aJSONStream, getJson(),
false);
607 const std::string aExpected = boost::trim_copy(aJSONStream.str());
608 return aExpected == getPayload();
616 assert(!
"Unknown variant type; please add an entry to validate.");
628 case LOK_CALLBACK_CELL_VIEW_CURSOR:
629 case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
630 case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
631 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
632 case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
644 case LOK_CALLBACK_TEXT_SELECTION:
645 case LOK_CALLBACK_TEXT_SELECTION_START:
646 case LOK_CALLBACK_TEXT_SELECTION_END:
657 case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
658 case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
659 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
670 size_t viewIdPos = payload.find(
"viewId");
671 if (viewIdPos == std::string::npos)
674 size_t numberPos = payload.find(
":", viewIdPos + 6);
675 if (numberPos == std::string::npos)
678 for (++numberPos; numberPos < payload.length(); ++numberPos)
680 if (payload[numberPos] ==
',' || payload[numberPos] ==
'}' || (payload[numberPos] >=
'0' && payload[numberPos] <=
'9'))
684 if (numberPos < payload.length() && payload[numberPos] >=
'0' && payload[numberPos] <=
'9')
685 return strtol(payload.substr(numberPos).c_str(),
nullptr, 10);
692std::string extractCertificate(
const std::string & certificate)
694 const std::string
header(
"-----BEGIN CERTIFICATE-----");
695 const std::string footer(
"-----END CERTIFICATE-----");
699 size_t pos1 = certificate.find(header);
700 if (pos1 == std::string::npos)
703 size_t pos2 = certificate.find(footer, pos1 + 1);
704 if (pos2 == std::string::npos)
707 pos1 = pos1 +
header.length();
710 return certificate.substr(pos1, pos2);
713std::string extractPrivateKey(
const std::string & privateKey)
715 const std::string
header(
"-----BEGIN PRIVATE KEY-----");
716 const std::string footer(
"-----END PRIVATE KEY-----");
720 size_t pos1 = privateKey.find(header);
721 if (pos1 == std::string::npos)
724 size_t pos2 = privateKey.find(footer, pos1 + 1);
725 if (pos2 == std::string::npos)
728 pos1 = pos1 +
header.length();
731 return privateKey.substr(pos1, pos2);
752 return pFilter->GetMimeType();
756css::uno::Reference< css::document::XUndoManager > getUndoManager(
const css::uno::Reference< css::frame::XFrame >& rxFrame )
758 const css::uno::Reference< css::frame::XController >&
xController = rxFrame->getController();
761 const css::uno::Reference< css::frame::XModel >&
xModel =
xController->getModel();
764 const css::uno::Reference< css::document::XUndoManagerSupplier > xSuppUndo( xModel, css::uno::UNO_QUERY_THROW );
765 return css::uno::Reference< css::document::XUndoManager >( xSuppUndo->getUndoManager(), css::uno::UNO_SET_THROW );
769 return css::uno::Reference< css::document::XUndoManager > ();
773void ExecuteMarginLRChange(
778 pPageLRMarginItem->
SetLeft( nPageLeftMargin );
779 pPageLRMarginItem->
SetRight( nPageRightMargin );
781 SfxCallMode::RECORD, { pPageLRMarginItem });
785void ExecuteMarginULChange(
790 pPageULMarginItem->
SetUpper( nPageTopMargin );
791 pPageULMarginItem->
SetLower( nPageBottomMargin );
793 SfxCallMode::RECORD, { pPageULMarginItem });
797void ExecuteOrientationChange()
803 std::unique_ptr<SvxPageItem> pPageItem(
new SvxPageItem(SID_ATTR_PAGE));
809 css::uno::Reference< css::document::XUndoManager > mxUndoManager(
812 if ( mxUndoManager.is() )
813 mxUndoManager->enterUndoContext(
"" );
818 std::unique_ptr<SvxSizeItem> pPageSizeItem(pSizeItem->
Clone());
822 std::unique_ptr<SvxLongLRSpaceItem> pPageLRMarginItem(pLRSpaceItem->
Clone());
826 std::unique_ptr<SvxLongULSpaceItem> pPageULMarginItem(pULSpaceItem->
Clone());
829 bool bIsLandscape =
false;
830 if ( pPageSizeItem->GetSize().Width() > pPageSizeItem->GetSize().Height())
834 pPageItem->SetLandscape(!bIsLandscape);
838 const tools::Long nRotatedWidth = pPageSizeItem->GetSize().Height();
839 const tools::Long nRotatedHeight = pPageSizeItem->GetSize().Width();
840 pPageSizeItem->SetSize(
Size(nRotatedWidth, nRotatedHeight));
847 SfxCallMode::RECORD, { pPageSizeItem.get(), pPageItem.get() });
859 const tools::Long nPW = pPageSizeItem->GetSize().Width();
865 ExecuteMarginLRChange( pPageLRMarginItem->
GetLeft(), nMR - (nTmpPW - nPW ), pPageLRMarginItem.get() );
869 ExecuteMarginLRChange( nML - (nTmpPW - nPW ), pPageLRMarginItem->
GetRight(), pPageLRMarginItem.get() );
877 const tools::Long nPH = pPageSizeItem->GetSize().Height();
883 ExecuteMarginULChange( pPageULMarginItem->
GetUpper(), nMB - ( nTmpPH - nPH ), pPageULMarginItem.get() );
887 ExecuteMarginULChange( nMT - ( nTmpPH - nPH ), pPageULMarginItem->
GetLower(), pPageULMarginItem.get() );
892 if ( mxUndoManager.is() )
893 mxUndoManager->leaveUndoContext();
896void setupSidebar(std::u16string_view sidebarDeckId = u
"")
919 = pDockingWin->GetOrCreateSidebarController();
924 if (!sidebarDeckId.empty())
933 pDockingWin->SyncUpdate();
957 OUString aNameEquals(OUString::Concat(rName) +
"=");
958 OUString aCommaNameEquals(OUString::Concat(
",") + rName +
"=");
961 if (rOptions.startsWith(aNameEquals))
963 size_t nLen = aNameEquals.getLength();
964 int nComma = rOptions.indexOf(
",", nLen);
967 aValue = rOptions.copy(nLen, nComma - nLen);
968 rOptions = rOptions.copy(nComma + 1);
972 aValue = rOptions.copy(nLen);
976 else if ((
nIndex = rOptions.indexOf(aCommaNameEquals)) >= 0)
978 size_t nLen = aCommaNameEquals.getLength();
979 int nComma = rOptions.indexOf(
",",
nIndex + nLen);
982 aValue = rOptions.copy(
nIndex + nLen, nComma -
nIndex - nLen);
983 rOptions = OUString::Concat(rOptions.subView(0,
nIndex)) + rOptions.subView(nComma);
987 aValue = rOptions.copy(
nIndex + nLen);
988 rOptions = rOptions.copy(0,
nIndex);
998static void doc_destroy(LibreOfficeKitDocument* pThis);
999static int doc_saveAs(LibreOfficeKitDocument* pThis,
const char* pUrl,
const char* pFormat,
const char* pFilterOptions);
1003static int doc_getPart(LibreOfficeKitDocument* pThis);
1004static void doc_setPart(LibreOfficeKitDocument* pThis,
int nPart);
1005static void doc_selectPart(LibreOfficeKitDocument* pThis,
int nPart,
int nSelect);
1007static char*
doc_getPartName(LibreOfficeKitDocument* pThis,
int nPart);
1008static void doc_setPartMode(LibreOfficeKitDocument* pThis,
int nPartMode);
1011 unsigned char* pBuffer,
1012 const int nCanvasWidth,
const int nCanvasHeight,
1013 const int nTilePosX,
const int nTilePosY,
1014 const int nTileWidth,
const int nTileHeight);
1016static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis,
1018 const int nCanvasWidth,
const int nCanvasHeight,
1019 const int nTilePosX,
const int nTilePosY,
1020 const int nTileWidth,
const int nTileHeight);
1023 unsigned char* pBuffer,
1026 const int nCanvasWidth,
const int nCanvasHeight,
1027 const int nTilePosX,
const int nTilePosY,
1028 const int nTileWidth,
const int nTileHeight);
1038 const char* pArguments);
1041 LibreOfficeKitCallback pCallback,
1049 const char* blockedCommandList);
1056 unsigned nLOKWindowId,
1060 unsigned long long int nLOKWindowId,
1061 const char* pArguments);
1063 unsigned nLOKWindowId,
1075 unsigned nLOKWindowId,
1083 unsigned nLOKWindowId,
1089 const char* pCommand,
1090 const char* pArguments,
1091 bool bNotifyWhenFinished);
1093 unsigned nLOKWindowId,
1102 const char* pMimeType,
1103 char** pUsedMimeType);
1106 const char* pMimeType,
1108 char** pUsedMimeType);
1110 const char **pMimeTypes,
1112 char ***pOutMimeTypes,
1114 char ***pOutStreams);
1116 const size_t nInCount,
1117 const char **pInMimeTypes,
1118 const size_t *pInSizes,
1119 const char **pInStreams);
1120static bool doc_paste(LibreOfficeKitDocument* pThis,
1121 const char* pMimeType,
1131 int nTilePixelWidth,
1132 int nTilePixelHeight,
1134 int nTileTwipHeight);
1136static void doc_setOutlineState(LibreOfficeKitDocument* pThis,
bool bColumn,
int nLevel,
int nIndex,
bool bHidden);
1146 const char *pFontName,
1151static unsigned char*
doc_renderFont(LibreOfficeKitDocument* pThis,
1152 const char *pFontName,
1156static char*
doc_getPartHash(LibreOfficeKitDocument* pThis,
int nPart);
1158static void doc_paintWindow(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
unsigned char* pBuffer,
1159 const int nX,
const int nY,
1160 const int nWidth,
const int nHeight);
1162static void doc_paintWindowDPI(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
unsigned char* pBuffer,
1163 const int nX,
const int nY,
1164 const int nWidth,
const int nHeight,
1165 const double fDPIScale);
1167static void doc_paintWindowForView(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
unsigned char* pBuffer,
1168 const int nX,
const int nY,
1169 const int nWidth,
const int nHeight,
1170 const double fDPIScale,
int viewId);
1172static void doc_postWindow(LibreOfficeKitDocument* pThis,
unsigned
1173 nLOKWindowId,
int nAction,
const char* pData);
1175static char*
doc_getPartInfo(LibreOfficeKitDocument* pThis,
int nPart);
1178 const unsigned char* pCertificateBinary,
1179 const int nCertificateBinarySize,
1180 const unsigned char* pPrivateKeyBinary,
1181 const int nPrivateKeyBinarySize);
1184 const unsigned char* pCertificateBinary,
1185 const int nCertificateBinarySize);
1191static void doc_resizeWindow(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
1192 const int nWidth,
const int nHeight);
1198 const char* pArguments);
1201 const char* pSearchResult,
unsigned char** pBitmapBuffer,
1202 int* pWidth,
int* pHeight,
size_t* pByteSize);
1209ITiledRenderable* getTiledRenderable(LibreOfficeKitDocument* pThis)
1212 return dynamic_cast<ITiledRenderable*
>(pDocument->
mxComponent.get());
1224 ITiledRenderable* pDoc = getTiledRenderable(pThis);
1227 SAL_INFO(
"lok",
"Set to clipboard for view " << xClip.get());
1236const vcl::Font* FindFont(std::u16string_view rFontName)
1244 if (pList && !rFontName.empty())
1250vcl::Font FindFont_FallbackToDefault(std::u16string_view rFontName)
1252 if (
auto pFound = FindFont(rFontName))
1256 GetDefaultFontFlags::NONE);
1261 : mxComponent(
std::move(xComponent))
1262 , mnDocumentId(nDocumentId)
1264 assert(nDocumentId != -1 &&
"Cannot set mnDocumentId to -1");
1361 forceSetClipboardForCurrentView(
this);
1371 catch (
const css::lang::DisposedException&)
1379 OUString sGenerator(
1381 OUString os(
"$_OS");
1382 ::rtl::Bootstrap::expandMacros(os);
1383 return sGenerator.replaceFirst(
"%1", os);
1389 :
Timer(
"lokit timer callback" )
1390 , mHandler( handler )
1405 :
Idle(
"lokit idle callback" ),
1416 m_states.emplace(LOK_CALLBACK_TEXT_SELECTION,
"NIL");
1417 m_states.emplace(LOK_CALLBACK_GRAPHIC_SELECTION,
"NIL");
1418 m_states.emplace(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR,
"NIL");
1419 m_states.emplace(LOK_CALLBACK_STATE_CHANGED,
"NIL");
1420 m_states.emplace(LOK_CALLBACK_MOUSE_POINTER,
"NIL");
1421 m_states.emplace(LOK_CALLBACK_CELL_CURSOR,
"NIL");
1422 m_states.emplace(LOK_CALLBACK_CELL_FORMULA,
"NIL");
1423 m_states.emplace(LOK_CALLBACK_CELL_ADDRESS,
"NIL");
1424 m_states.emplace(LOK_CALLBACK_CURSOR_VISIBLE,
"NIL");
1425 m_states.emplace(LOK_CALLBACK_SET_PART,
"NIL");
1426 m_states.emplace(LOK_CALLBACK_TABLE_SELECTED,
"NIL");
1427 m_states.emplace(LOK_CALLBACK_TAB_STOP_LIST,
"NIL");
1428 m_states.emplace(LOK_CALLBACK_RULER_UPDATE,
"NIL");
1429 m_states.emplace(LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE,
"NIL");
1439 int delta = std::distance(
m_queue1.begin(), pos);
1445 int delta = std::distance(
m_queue1.rbegin(), pos);
1469 types.resize(
nType + 1 );
1478 bool allViewIds =
false;
1489 std::vector<PerViewIdData>& types = it.second;
1491 types[
nType ].set =
false;
1510 queue(LOK_CALLBACK_INVALIDATE_TILES, callbackData);
1516 std::unique_lock<std::recursive_mutex>
lock(
m_mutex);
1524 std::unique_lock<std::recursive_mutex>
lock(
m_mutex);
1532 rState.append(
"\nView:\t");
1533 rState.append(
static_cast<sal_Int32
>(
m_viewId));
1534 rState.append(
"\n\tDisableCallbacks:\t");
1536 rState.append(
"\n\tStates:\n");
1539 rState.append(
"\n\t\t");
1540 rState.append(
static_cast<sal_Int32
>(
i.first));
1541 rState.append(
"\t");
1542 rState.append(
i.second);
1564 bool bIsChartActive =
false;
1565 bool bIsComment =
false;
1566 if (
type == LOK_CALLBACK_GRAPHIC_SELECTION)
1569 bIsChartActive = aChartHelper.
GetWindow() !=
nullptr;
1571 else if (
type == LOK_CALLBACK_COMMENT)
1585 if (
type != LOK_CALLBACK_STATE_CHANGED &&
1586 type != LOK_CALLBACK_INVALIDATE_TILES &&
1587 type != LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR &&
1588 type != LOK_CALLBACK_CURSOR_VISIBLE &&
1589 type != LOK_CALLBACK_VIEW_CURSOR_VISIBLE &&
1590 type != LOK_CALLBACK_TEXT_SELECTION &&
1591 type != LOK_CALLBACK_TEXT_SELECTION_START &&
1592 type != LOK_CALLBACK_TEXT_SELECTION_END &&
1593 type != LOK_CALLBACK_MEDIA_SHAPE &&
1594 type != LOK_CALLBACK_REFERENCE_MARKS)
1606 if (
type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR &&
1607 aCallbackData.
getPayload().find(
", 0, 0, ") != std::string::npos &&
1608 aCallbackData.
getPayload().find(
"\"hyperlink\":\"\"") == std::string::npos &&
1609 aCallbackData.
getPayload().find(
"\"hyperlink\": {}") == std::string::npos)
1619 std::unique_lock<std::recursive_mutex>
lock(
m_mutex);
1626 SAL_INFO(
"lok",
"Received event with updated type [" <<
type <<
"] as normal callback");
1631 SAL_INFO(
"lok",
"Received event with updated type [" <<
type <<
"] as normal callback");
1638 case LOK_CALLBACK_TEXT_SELECTION_START:
1639 case LOK_CALLBACK_TEXT_SELECTION_END:
1640 case LOK_CALLBACK_TEXT_SELECTION:
1641 case LOK_CALLBACK_GRAPHIC_SELECTION:
1642 case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
1643 case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
1644 case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
1645 case LOK_CALLBACK_STATE_CHANGED:
1646 case LOK_CALLBACK_MOUSE_POINTER:
1647 case LOK_CALLBACK_CELL_CURSOR:
1648 case LOK_CALLBACK_CELL_VIEW_CURSOR:
1649 case LOK_CALLBACK_CELL_FORMULA:
1650 case LOK_CALLBACK_CELL_ADDRESS:
1651 case LOK_CALLBACK_CELL_SELECTION_AREA:
1652 case LOK_CALLBACK_CURSOR_VISIBLE:
1653 case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
1654 case LOK_CALLBACK_SET_PART:
1655 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
1656 case LOK_CALLBACK_INVALIDATE_HEADER:
1657 case LOK_CALLBACK_WINDOW:
1658 case LOK_CALLBACK_CALC_FUNCTION_LIST:
1659 case LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY:
1660 case LOK_CALLBACK_REFERENCE_MARKS:
1661 case LOK_CALLBACK_CELL_AUTO_FILL_AREA:
1674 if (
type == LOK_CALLBACK_TEXT_SELECTION && aCallbackData.
isEmpty())
1676 const auto& posStart = std::find(
m_queue1.rbegin(),
m_queue1.rend(), LOK_CALLBACK_TEXT_SELECTION_START);
1677 auto posStart2 =
toQueue2(posStart);
1681 const auto& posEnd = std::find(
m_queue1.rbegin(),
m_queue1.rend(), LOK_CALLBACK_TEXT_SELECTION_END);
1692 case LOK_CALLBACK_TEXT_SELECTION_START:
1693 case LOK_CALLBACK_TEXT_SELECTION_END:
1694 case LOK_CALLBACK_TEXT_SELECTION:
1695 case LOK_CALLBACK_GRAPHIC_SELECTION:
1696 case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
1697 case LOK_CALLBACK_INVALIDATE_TILES:
1709 case LOK_CALLBACK_TEXT_SELECTION_START:
1710 case LOK_CALLBACK_TEXT_SELECTION_END:
1711 case LOK_CALLBACK_TEXT_SELECTION:
1712 case LOK_CALLBACK_MOUSE_POINTER:
1713 case LOK_CALLBACK_CELL_CURSOR:
1714 case LOK_CALLBACK_CELL_FORMULA:
1715 case LOK_CALLBACK_CELL_ADDRESS:
1716 case LOK_CALLBACK_CURSOR_VISIBLE:
1717 case LOK_CALLBACK_SET_PART:
1718 case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
1719 case LOK_CALLBACK_RULER_UPDATE:
1729 case LOK_CALLBACK_CELL_VIEW_CURSOR:
1730 case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
1731 case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
1732 case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
1733 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
1734 case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
1735 case LOK_CALLBACK_CALC_FUNCTION_LIST:
1736 case LOK_CALLBACK_FORM_FIELD_BUTTON:
1740 const bool hyperLinkException =
type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR &&
1741 aCallbackData.
getPayload().find(
"\"hyperlink\":\"\"") == std::string::npos &&
1742 aCallbackData.
getPayload().find(
"\"hyperlink\": {}") == std::string::npos;
1743 if(!hyperLinkException)
1745 const int nViewId = aCallbackData.
getViewId();
1747 return (nViewId == elemData.
getViewId());
1754 case LOK_CALLBACK_INVALIDATE_TILES:
1761 case LOK_CALLBACK_STATE_CHANGED:
1765 if (
pos != std::string::npos)
1770 if (
name !=
".uno:ModifiedStatus=")
1781 case LOK_CALLBACK_WINDOW:
1786 case LOK_CALLBACK_GRAPHIC_SELECTION:
1791 {
return (elemData.
getPayload().find(
"INPLACE") == std::string::npos); });
1798 assert(aCallbackData.
validate() &&
"Cached callback payload object and string mismatch!");
1800 m_queue2.emplace_back(aCallbackData);
1808 std::ostringstream oss;
1812 oss <<
m_queue1.size() <<
" items\n";
1815 for (; it1 !=
m_queue1.end(); ++it1, ++it2)
1816 oss <<
i++ <<
": [" << *it1 <<
"] [" << it2->getPayload() <<
"].\n";
1817 SAL_INFO(
"lok",
"Current Queue: " << oss.str());
1841 = std::find(
m_queue1.rbegin(),
m_queue1.rend(), LOK_CALLBACK_INVALIDATE_TILES);
1850 <<
"] since all tiles need to be invalidated.");
1860 <<
"] since overlaps existing all-parts.");
1869 <<
"] so removing all with part " << rcNew.
m_nPart <<
".");
1878 const auto rcOrig = rcNew;
1880 SAL_INFO(
"lok",
"Have [" <<
type <<
"]: [" << aCallbackData.
getPayload() <<
"] so merging overlapping.");
1886 SAL_INFO(
"lok",
"Nothing to merge between new: "
1887 << rcNew.toString() <<
", and old: " << rcOld.toString());
1894 SAL_INFO(
"lok",
"New " << rcNew.toString() <<
" has " << rcOld.toString()
1896 if (rcNew.m_aRectangle.Contains(rcOld.m_aRectangle) && rcOld.m_nMode == rcNew.m_nMode)
1898 SAL_INFO(
"lok",
"New " << rcNew.toString() <<
" engulfs old "
1899 << rcOld.toString() <<
".");
1903 else if (rcOld.m_nPart == -1)
1906 SAL_INFO(
"lok",
"Old " << rcOld.toString() <<
" has " << rcNew.toString()
1908 if (rcOld.m_aRectangle.Contains(rcNew.m_aRectangle) && rcOld.m_nMode == rcNew.m_nMode)
1910 SAL_INFO(
"lok",
"New " << rcNew.toString() <<
" engulfs old "
1911 << rcOld.toString() <<
".");
1919 const bool bOverlap = !rcOverlap.
IsEmpty() && rcOld.m_nMode == rcNew.
m_nMode;
1920 SAL_INFO(
"lok",
"Merging " << rcNew.
toString() <<
" & " << rcOld.toString()
1922 <<
" Overlap: " << bOverlap);
1935 if (rcNew.m_aRectangle != rcOrig.m_aRectangle)
1937 SAL_INFO(
"lok",
"Replacing: " << rcOrig.toString() <<
" by " << rcNew.toString());
1938 if (rcNew.m_aRectangle.GetWidth() < rcOrig.m_aRectangle.GetWidth()
1939 || rcNew.m_aRectangle.GetHeight() < rcOrig.m_aRectangle.GetHeight())
1941 SAL_WARN(
"lok",
"Error: merged rect smaller.");
1946 aCallbackData.updateRectangleAndPart(rcNew);
1953 const std::string& payload = aCallbackData.
getPayload();
1955 boost::property_tree::ptree& aTree = aCallbackData.
setJson(payload);
1956 const unsigned nLOKWindowId = aTree.get<
unsigned>(
"id", 0);
1957 const std::string aAction = aTree.get<std::string>(
"action",
"");
1958 if (aAction ==
"invalidate")
1960 std::string aRectStr = aTree.get<std::string>(
"rectangle",
"");
1963 if (aRectStr.empty())
1966 const boost::property_tree::ptree& aOldTree = elemData.
getJson();
1967 if (nLOKWindowId == aOldTree.get<
unsigned>(
"id", 0)
1968 && aOldTree.get<std::string>(
"action",
"") ==
"invalidate")
1979 bool invAllExist =
false;
1982 for (;it1 !=
m_queue1.rend(); ++it1, ++it2)
1984 if (*it1 != LOK_CALLBACK_WINDOW)
1986 const boost::property_tree::ptree& aOldTree = it2->getJson();
1987 if (nLOKWindowId == aOldTree.get<
unsigned>(
"id", 0)
1988 && aOldTree.get<std::string>(
"action",
"") ==
"invalidate"
1989 && aOldTree.get<std::string>(
"rectangle",
"").empty())
1999 SAL_INFO(
"lok.dialog",
"Skipping queue ["
2000 <<
type <<
"]: [" << payload
2001 <<
"] since whole window needs to be invalidated.");
2005 std::istringstream aRectStream(aRectStr);
2008 aRectStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight;
2010 bool currentIsRedundant =
false;
2011 removeAll(LOK_CALLBACK_WINDOW, [&aNewRect, &nLOKWindowId,
2013 const boost::property_tree::ptree& aOldTree = elemData.
getJson();
2014 if (aOldTree.get<std::string>(
"action",
"") ==
"invalidate")
2017 std::istringstream aOldRectStream(aOldTree.get<std::string>(
"rectangle",
""));
2018 tools::Long nOldLeft, nOldTop, nOldWidth, nOldHeight;
2020 aOldRectStream >> nOldLeft >> nOldComma >> nOldTop >> nOldComma >> nOldWidth
2021 >> nOldComma >> nOldHeight;
2022 const tools::Rectangle aOldRect = tools::Rectangle(
2023 nOldLeft, nOldTop, nOldLeft + nOldWidth, nOldTop + nOldHeight);
2025 if (nLOKWindowId == aOldTree.get<unsigned>(
"id", 0))
2027 if (aNewRect == aOldRect)
2029 SAL_INFO(
"lok.dialog",
"Duplicate rect [" << aNewRect.toString()
2030 <<
"]. Skipping new.");
2032 currentIsRedundant = true;
2036 else if (aNewRect.Contains(aOldRect))
2038 SAL_INFO(
"lok.dialog",
2039 "New rect [" << aNewRect.toString() <<
"] engulfs old ["
2040 << aOldRect.toString() <<
"]. Replacing old.");
2044 else if (aOldRect.Contains(aNewRect))
2046 SAL_INFO(
"lok.dialog",
2047 "Old rect [" << aOldRect.toString() <<
"] engulfs new ["
2048 << aNewRect.toString() <<
"]. Skipping new.");
2050 currentIsRedundant = true;
2056 const tools::Rectangle aPreMergeRect = aNewRect;
2057 aNewRect.Union(aOldRect);
2058 SAL_INFO(
"lok.dialog",
"Merging rects ["
2059 << aPreMergeRect.toString() <<
"] & ["
2060 << aOldRect.toString() <<
"] = ["
2061 << aNewRect.toString()
2062 <<
"]. Replacing old.");
2073 if (currentIsRedundant)
2076 aTree.put(
"rectangle", aNewRect.toString().getStr());
2078 assert(aCallbackData.
validate() &&
"Validation after setJson failed!");
2081 else if (aAction ==
"created")
2084 removeAll(LOK_CALLBACK_WINDOW,[&nLOKWindowId](
const CallbackData& elemData) {
2085 const boost::property_tree::ptree& aOldTree = elemData.getJson();
2086 if (nLOKWindowId == aOldTree.get<
unsigned>(
"id", 0))
2099 auto xClip = forceSetClipboardForCurrentView(m_pDocument);
2102 pWindow->SetClipboard(xClipboard);
2105 else if (aAction ==
"size_changed")
2109 removeAll(LOK_CALLBACK_WINDOW, [&nLOKWindowId](
const CallbackData& elemData) {
2110 const boost::property_tree::ptree& aOldTree = elemData.getJson();
2111 if (nLOKWindowId == aOldTree.get<
unsigned>(
"id", 0))
2113 const std::string aOldAction = aOldTree.get<std::string>(
"action",
"");
2114 if (aOldAction ==
"invalidate")
2132 assert(viewShell !=
nullptr);
2135 std::vector<bool> updatedTypes;
2137 boost::container::flat_map<int, std::vector<PerViewIdData>> updatedTypesPerViewId;
2144 static const int orderedUpdatedTypes[] = {
2145 LOK_CALLBACK_TEXT_SELECTION_START, LOK_CALLBACK_TEXT_SELECTION_END, LOK_CALLBACK_TEXT_SELECTION };
2148 static const int orderedUpdatedTypesPerViewId[] = {
2149 LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR,
2150 LOK_CALLBACK_INVALIDATE_VIEW_CURSOR,
2151 LOK_CALLBACK_TEXT_VIEW_SELECTION };
2153 for(
int type : orderedUpdatedTypes )
2160 for(
const auto& it : updatedTypesPerViewId )
2162 int viewId = it.first;
2163 const std::vector<PerViewIdData>& types = it.second;
2164 for(
int type : orderedUpdatedTypesPerViewId )
2169 const int sourceViewId = types[
type ].sourceViewId;
2172 assert(sourceViewId >= 0);
2176 if(sourceViewShell ==
nullptr)
2178 SAL_INFO(
"lok",
"View #" << sourceViewId <<
" no longer found for updated event [" <<
type <<
"]");
2189 if (
type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR)
2192 viewShell = viewShell2;
2199 m_queue2.emplace_back(callbackData);
2201 <<
"] to have " <<
m_queue1.size() <<
" entries.");
2217 viewShell->flushPendingLOKInvalidateTiles();
2220 std::unique_lock<std::recursive_mutex>
lock(
m_mutex);
2228 for (; it1 !=
m_queue1.end(); ++it1, ++it2)
2230 const int type = *it1;
2231 const auto& payload = it2->getPayload();
2234 SAL_INFO(
"lok",
"processing event: [" <<
type <<
',' << viewId <<
"]: [" << payload <<
"].");
2241 if (
type == LOK_CALLBACK_STATE_CHANGED &&
2242 (
idx = payload.find(
'=')) != std::string::npos)
2244 std::string key = payload.substr(0,
idx);
2245 std::string
value = payload.substr(
idx+1);
2250 if (stateIt->second ==
value)
2252 SAL_INFO(
"lok",
"Skipping new state duplicate: [" <<
type <<
"]: [" << payload <<
"].");
2255 SAL_INFO(
"lok",
"Replacing a state element [" <<
type <<
"]: [" << payload <<
"].");
2256 stateIt->second =
value;
2260 SAL_INFO(
"lok",
"Inserted a new state element: [" <<
type <<
"]: [" << payload <<
"]");
2270 if (stateIt->second == payload)
2272 SAL_INFO(
"lok",
"Skipping duplicate [" <<
type <<
"]: [" << payload <<
"].");
2275 stateIt->second = payload;
2284 auto& states = statesIt->second;
2285 const auto stateIt = states.find(
type);
2286 if (stateIt != states.end())
2289 if (stateIt->second == payload)
2291 SAL_INFO(
"lok",
"Skipping view duplicate [" <<
type <<
',' << viewId <<
"]: [" << payload <<
"].");
2295 SAL_INFO(
"lok",
"Replacing an element in view states [" <<
type <<
',' << viewId <<
"]: [" << payload <<
"].");
2296 stateIt->second = payload;
2300 SAL_INFO(
"lok",
"Inserted a new element in view states: [" <<
type <<
',' << viewId <<
"]: [" << payload <<
"]");
2301 states.emplace(
type, payload);
2326 bool bErased =
false;
2342 bool bErased =
false;
2350 if (rTestFunc(*it2))
2367 result.first->second.clear();
2391static void lo_destroy (LibreOfficeKit* pThis);
2392static int lo_initialize (LibreOfficeKit* pThis,
const char* pInstallPath,
const char* pUserProfilePath);
2393static LibreOfficeKitDocument*
lo_documentLoad (LibreOfficeKit* pThis,
const char* pURL);
2398 const char* pOptions);
2400 LibreOfficeKitCallback pCallback,
2406 const char* pPassword);
2408static int lo_runMacro (LibreOfficeKit* pThis,
const char* pURL);
2412 const unsigned char* pCertificateBinary,
2413 const int nCertificateBinarySize,
2414 const unsigned char* pPrivateKeyBinary,
2415 const int nPrivateKeyBinarySize);
2418 LibreOfficeKitPollCallback pPollCallback,
2419 LibreOfficeKitWakeCallback pWakeCallback,
2423 unsigned long long int nLOKWindowId,
2424 const char* pArguments);
2426static void lo_setOption(LibreOfficeKit* pThis,
const char* pOption,
const char* pValue);
2428static void lo_dumpState(LibreOfficeKit* pThis,
const char* pOptions,
char** pState);
2433 , mpCallback(nullptr)
2434 , mpCallbackData(nullptr)
2435 , mOptionalFeatures(0)
2472void paintTileToCGContext(ITiledRenderable* pDocument,
2473 void* rCGContext,
const Size nCanvasSize,
2474 const int nTilePosX,
const int nTilePosY,
2475 const int nTileWidth,
const int nTileHeight)
2478 aData.rCGContext =
reinterpret_cast<CGContextRef
>(rCGContext);
2481 pDevice->SetBackground(
Wallpaper(COL_TRANSPARENT));
2482 pDevice->SetOutputSizePixel(nCanvasSize);
2483 pDocument->paintTile(*pDevice, nCanvasSize.
Width(), nCanvasSize.
Height(),
2484 nTilePosX, nTilePosY, nTileWidth, nTileHeight);
2487void paintTileIOS(LibreOfficeKitDocument* pThis,
2488 unsigned char* pBuffer,
2489 const int nCanvasWidth,
const int nCanvasHeight,
const double fDPIScale,
2490 const int nTilePosX,
const int nTilePosY,
2491 const int nTileWidth,
const int nTileHeight)
2493 CGContextRef pCGContext = CGBitmapContextCreate(pBuffer, nCanvasWidth, nCanvasHeight, 8,
2494 nCanvasWidth * 4, CGColorSpaceCreateDeviceRGB(),
2495 kCGImageAlphaPremultipliedFirst | kCGImageByteOrder32Little);
2497 CGContextTranslateCTM(pCGContext, 0, nCanvasHeight);
2498 CGContextScaleCTM(pCGContext, fDPIScale, -fDPIScale);
2500 doc_paintTileToCGContext(pThis, (
void*) pCGContext, nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
2502 CGContextRelease(pCGContext);
2506void setLanguageAndLocale(OUString
const & aLangISO)
2516 if (sFormat == u
"pdf")
2519 rFilterDataMap[
"ExportBookmarks"] <<=
true;
2541 static int nDocumentIdCounter = 0;
2544 pLib->maLastExceptionMsg.clear();
2549 pLib->maLastExceptionMsg =
"Filename to load was not provided.";
2550 SAL_INFO(
"lok",
"URL for load is empty");
2554 pLib->maLastExceptionMsg.clear();
2558 pLib->maLastExceptionMsg =
"ComponentContext is not available";
2559 SAL_INFO(
"lok",
"ComponentContext is not available");
2565 if (!xComponentLoader.is())
2567 pLib->maLastExceptionMsg =
"ComponentLoader is not available";
2568 SAL_INFO(
"lok",
"ComponentLoader is not available");
2580 if (!aLanguage.isEmpty() && isValidLangTag)
2582 static bool isLoading =
true;
2595 SAL_INFO(
"lok",
"Set document language to " << aLanguage);
2598 setLanguageAndLocale(aLanguage);
2603 const OUString aDeviceFormFactor =
extractParameter(aOptions,
u"DeviceFormFactor");
2607 if (!aBatch.isEmpty())
2612 const OUString sFilterOptions = aOptions;
2616 auto const pair(
pLib->mInteractionMap.insert(std::make_pair(
aURL.toUtf8(), pInteraction)));
2620 pLib->mInteractionMap.erase(aURL.toUtf8());
2625 int nMacroSecurityLevel = 1;
2626 const OUString aMacroSecurityLevel =
extractParameter(aOptions,
u"MacroSecurityLevel");
2627 if (!aMacroSecurityLevel.isEmpty())
2630 sal_uInt32 nFormat = 1;
2632 if (aFormatter.
IsNumberFormat(aMacroSecurityLevel, nFormat, nNumber))
2633 nMacroSecurityLevel =
static_cast<int>(nNumber);
2637#if defined(ANDROID) && HAVE_FEATURE_ANDROID_LOK
2638 sal_Int16 nMacroExecMode = document::MacroExecMode::USE_CONFIG;
2640 const OUString aEnableMacrosExecution =
extractParameter(aOptions,
u"EnableMacrosExecution");
2641 sal_Int16 nMacroExecMode = aEnableMacrosExecution ==
"true" ? document::MacroExecMode::USE_CONFIG :
2642 document::MacroExecMode::NEVER_EXECUTE;
2664 const int nThisDocumentId = nDocumentIdCounter++;
2670 assert(!xComponent.is() || pair.second);
2672 if (!xComponent.is())
2674 pLib->maLastExceptionMsg =
"loadComponentFromURL returned an empty reference";
2675 SAL_INFO(
"lok",
"Document can't be loaded - " <<
pLib->maLastExceptionMsg);
2682 if (
pLib->mpCallback)
2685 pLib->mpCallback(LOK_CALLBACK_SIGNATURE_STATUS, OString::number(
nState).getStr(),
pLib->mpCallbackData);
2690 if (aFontMappingUseData.size() > 0)
2692 SAL_INFO(
"lok.fontsubst",
"================ Original substitutions:");
2693 for (
const auto &
i : aFontMappingUseData)
2695 SAL_INFO(
"lok.fontsubst",
i.mOriginalFont);
2696 for (
const auto &j :
i.mUsedFonts)
2697 SAL_INFO(
"lok.fontsubst",
" " << j);
2705 aFontMappingUseData.erase
2706 (std::remove_if(aFontMappingUseData.begin(), aFontMappingUseData.end(),
2718 if (x.mOriginalFont.indexOf(
'/') == -1)
2719 for (const auto &j : x.mUsedFonts)
2720 if (j == x.mOriginalFont ||
2721 j.startsWith(Concat2View(x.mOriginalFont +
"/")))
2726 aFontMappingUseData.end());
2732 aFontMappingUseData.erase
2733 (std::remove_if(aFontMappingUseData.begin(), aFontMappingUseData.end(),
2740 if (x.mOriginalFont.indexOf(
'/') == -1)
2741 for (const auto &j : x.mUsedFonts)
2742 if ((x.mOriginalFont ==
"Arial" &&
2743 j.startsWith(
"Liberation Sans/")) ||
2744 (x.mOriginalFont ==
"Times New Roman" &&
2745 j.startsWith(
"Liberation Serif/")) ||
2746 (x.mOriginalFont ==
"Courier New" &&
2747 j.startsWith(
"Liberation Mono/")) ||
2748 (x.mOriginalFont ==
"Arial Narrow" &&
2749 j.startsWith(
"Liberation Sans Narrow/")) ||
2750 (x.mOriginalFont ==
"Cambria" &&
2751 j.startsWith(
"Caladea/")) ||
2752 (x.mOriginalFont ==
"Calibri" &&
2753 j.startsWith(
"Carlito/")) ||
2754 (x.mOriginalFont ==
"Palatino Linotype" &&
2755 j.startsWith(
"P052/")) ||
2759 (x.mOriginalFont ==
"Symbol" &&
2760 j.startsWith(
"OpenSymbol/")))
2767 aFontMappingUseData.end());
2769 if (aFontMappingUseData.size() > 0)
2771 SAL_INFO(
"lok.fontsubst",
"================ Pruned substitutions:");
2772 for (
const auto &
i : aFontMappingUseData)
2774 SAL_INFO(
"lok.fontsubst",
i.mOriginalFont);
2775 for (
const auto &j :
i.mUsedFonts)
2776 SAL_INFO(
"lok.fontsubst",
" " << j);
2780 for (std::size_t
i = 0;
i < aFontMappingUseData.size(); ++
i)
2782 pDocument->maFontsMissing.insert(aFontMappingUseData[
i].mOriginalFont);
2787 catch (
const uno::Exception& exception)
2789 pLib->maLastExceptionMsg = exception.Message;
2803 pLib->maLastExceptionMsg.clear();
2805 OUString sURL( pURL, strlen(pURL), RTL_TEXTENCODING_UTF8 );
2808 pLib->maLastExceptionMsg =
"Macro to run was not provided.";
2809 SAL_INFO(
"lok",
"Macro URL is empty");
2813 if (!sURL.startsWith(
"macro://"))
2815 pLib->maLastExceptionMsg =
"This doesn't look like macro URL";
2816 SAL_INFO(
"lok",
"Macro URL is invalid");
2820 pLib->maLastExceptionMsg.clear();
2824 pLib->maLastExceptionMsg =
"ComponentContext is not available";
2825 SAL_INFO(
"lok",
"ComponentContext is not available");
2830 aURL.Complete = sURL;
2835 xParser->parseStrict(
aURL );
2839 if (!xComponentLoader.is())
2841 pLib->maLastExceptionMsg =
"ComponentLoader is not available";
2842 SAL_INFO(
"lok",
"ComponentLoader is not available");
2853 xDP.set(
xSFactory->createInstance(
"com.sun.star.comp.sfx2.SfxMacroLoader"), uno::UNO_QUERY );
2858 pLib->maLastExceptionMsg =
"Macro loader is not available";
2859 SAL_INFO(
"lok",
"Macro loader is not available");
2865 css::beans::PropertyValue aErr;
2866 uno::Any aRet = xSyncDisp->dispatchWithReturnValue(
aURL, aEmpty );
2869 if (aErr.Name ==
"ErrorCode")
2871 sal_uInt32 nErrCode = 0;
2872 aErr.
Value >>= nErrCode;
2874 pLib->maLastExceptionMsg =
"An error occurred running macro (error code: " + OUString::number( nErrCode ) +
")";
2875 SAL_INFO(
"lok",
"Macro execution terminated with error code " << nErrCode);
2885 const unsigned char* pCertificateBinary,
2886 const int nCertificateBinarySize,
2887 const unsigned char* pPrivateKeyBinary,
2888 const int nPrivateKeyBinarySize)
2901 std::string aCertificateString(
reinterpret_cast<const char*
>(pCertificateBinary), nCertificateBinarySize);
2902 std::string aCertificateBase64String = extractCertificate(aCertificateString);
2903 if (!aCertificateBase64String.empty())
2905 OUString aBase64OUString = OUString::createFromAscii(aCertificateBase64String.c_str());
2910 aCertificateSequence.realloc(nCertificateBinarySize);
2911 std::copy(pCertificateBinary, pCertificateBinary + nCertificateBinarySize, aCertificateSequence.getArray());
2915 std::string aPrivateKeyString(
reinterpret_cast<const char*
>(pPrivateKeyBinary), nPrivateKeyBinarySize);
2916 std::string aPrivateKeyBase64String = extractPrivateKey(aPrivateKeyString);
2917 if (!aPrivateKeyBase64String.empty())
2919 OUString aBase64OUString = OUString::createFromAscii(aPrivateKeyBase64String.c_str());
2924 aPrivateKeySequence.realloc(nPrivateKeyBinarySize);
2925 std::copy(pPrivateKeyBinary, pPrivateKeyBinary + nPrivateKeyBinarySize, aPrivateKeySequence.getArray());
2930 if (!xSecurityContext.is())
2936 if (!xCertificateCreator.is())
2941 if (!xCertificate.is())
2952 LibreOfficeKitCallback pCallback,
2961 pLib->maLastExceptionMsg.clear();
2967static int doc_saveAs(LibreOfficeKitDocument* pThis,
const char* sUrl,
const char* pFormat,
const char* pFilterOptions)
2984 SAL_INFO(
"lok",
"URL for save is empty");
2990 const ExtensionMap* pMap;
2994 case LOK_DOCTYPE_SPREADSHEET:
2997 case LOK_DOCTYPE_PRESENTATION:
3000 case LOK_DOCTYPE_DRAWING:
3003 case LOK_DOCTYPE_TEXT:
3006 case LOK_DOCTYPE_OTHER:
3008 SAL_INFO(
"lok",
"Can't save document - unsupported document type.");
3012 if (pFormat ==
nullptr)
3015 sal_Int32
idx =
aURL.lastIndexOf(
".");
3018 sFormat =
aURL.copy(
idx + 1 );
3027 OUString aFilterName;
3028 for (sal_Int32
i = 0; pMap[
i].extn; ++
i)
3030 if (sFormat.equalsIgnoreAsciiCaseAscii(pMap[
i].extn))
3036 if (aFilterName.isEmpty())
3042 OUString aFilterOptions =
getUString(pFilterOptions);
3046 OUString watermarkText;
3047 std::u16string_view sFullSheetPreview;
3049 if ((
aIndex = aFilterOptions.indexOf(
",Watermark=")) >= 0)
3051 int bIndex = aFilterOptions.indexOf(
"WATERMARKEND");
3052 watermarkText = aFilterOptions.subView(
aIndex+11, bIndex-(
aIndex+11));
3053 aFilterOptions = OUString::Concat(aFilterOptions.subView(0,
aIndex)) + aFilterOptions.subView(bIndex+12);
3056 if ((
aIndex = aFilterOptions.indexOf(
",FullSheetPreview=")) >= 0)
3058 int bIndex = aFilterOptions.indexOf(
"FULLSHEETPREVEND");
3059 sFullSheetPreview = aFilterOptions.subView(
aIndex+18, bIndex-(
aIndex+18));
3060 aFilterOptions = OUString::Concat(aFilterOptions.subView(0,
aIndex)) + aFilterOptions.subView(bIndex+16);
3063 bool bFullSheetPreview = sFullSheetPreview ==
u"true";
3067 sal_Int32 pdfVer = 0;
3068 if ((
aIndex = aFilterOptions.indexOf(
",PDFVer=")) >= 0)
3070 int bIndex = aFilterOptions.indexOf(
"PDFVEREND");
3071 std::u16string_view sPdfVer = aFilterOptions.subView(
aIndex+8, bIndex-(
aIndex+8));
3072 aFilterOptions = OUString::Concat(aFilterOptions.subView(0,
aIndex)) + aFilterOptions.subView(bIndex+9);
3097 std::vector<OUString> aFilteredOptionVec;
3098 bool bTakeOwnership =
false;
3100 for (
const auto& rOption : aOptionSeq)
3102 if (rOption ==
"TakeOwnership")
3103 bTakeOwnership =
true;
3104 else if (rOption ==
"NoFileSync")
3105 aSaveMediaDescriptor[
"NoFileSync"] <<=
true;
3107 aFilteredOptionVec.push_back(rOption);
3110 aSaveMediaDescriptor[
"Overwrite"] <<=
true;
3111 aSaveMediaDescriptor[
"FilterName"] <<= aFilterName;
3113 auto aFilteredOptionSeq = comphelper::containerToSequence<OUString>(aFilteredOptionVec);
3115 aSaveMediaDescriptor[MediaDescriptor::PROP_FILTEROPTIONS] <<= aFilterOptions;
3121 if (!aFilterOptions.startsWith(
"{"))
3123 setFormatSpecificFilterData(sFormat, aFilterDataMap);
3126 if (!watermarkText.isEmpty())
3127 aFilterDataMap[
"TiledWatermark"] <<= watermarkText;
3129 if (bFullSheetPreview)
3130 aFilterDataMap[
"SinglePageSheets"] <<=
true;
3133 aFilterDataMap[
"SelectPdfVersion"] <<= pdfVer;
3135 if (!aFilterDataMap.
empty())
3148 aSaveMediaDescriptor[MediaDescriptor::PROP_INTERACTIONHANDLER] <<= xInteraction;
3153 xStorable->storeAsURL(
aURL, aSaveMediaDescriptor.getAsConstPropertyValueList());
3155 xStorable->storeToURL(
aURL, aSaveMediaDescriptor.getAsConstPropertyValueList());
3159 catch (
const uno::Exception& exception)
3177 OUString sUnoCommands[] =
3179 OUString(
".uno:AlignLeft"),
3180 OUString(
".uno:AlignHorizontalCenter"),
3181 OUString(
".uno:AlignRight"),
3182 OUString(
".uno:BackColor"),
3183 OUString(
".uno:BackgroundColor"),
3184 OUString(
".uno:TableCellBackgroundColor"),
3185 OUString(
".uno:Bold"),
3186 OUString(
".uno:CenterPara"),
3187 OUString(
".uno:CharBackColor"),
3188 OUString(
".uno:CharBackgroundExt"),
3189 OUString(
".uno:CharFontName"),
3190 OUString(
".uno:Color"),
3191 OUString(
".uno:ControlCodes"),
3192 OUString(
".uno:DecrementIndent"),
3193 OUString(
".uno:DefaultBullet"),
3194 OUString(
".uno:DefaultNumbering"),
3195 OUString(
".uno:FontColor"),
3196 OUString(
".uno:FontHeight"),
3197 OUString(
".uno:IncrementIndent"),
3198 OUString(
".uno:Italic"),
3199 OUString(
".uno:JustifyPara"),
3200 OUString(
".uno:JumpToMark"),
3201 OUString(
".uno:OutlineFont"),
3202 OUString(
".uno:LeftPara"),
3203 OUString(
".uno:LanguageStatus"),
3204 OUString(
".uno:RightPara"),
3205 OUString(
".uno:Shadowed"),
3206 OUString(
".uno:SubScript"),
3207 OUString(
".uno:SuperScript"),
3208 OUString(
".uno:Strikeout"),
3209 OUString(
".uno:StyleApply"),
3210 OUString(
".uno:Underline"),
3211 OUString(
".uno:ModifiedStatus"),
3212 OUString(
".uno:Undo"),
3213 OUString(
".uno:Redo"),
3214 OUString(
".uno:InsertPage"),
3215 OUString(
".uno:DeletePage"),
3216 OUString(
".uno:DuplicatePage"),
3217 OUString(
".uno:InsertSlide"),
3218 OUString(
".uno:DeleteSlide"),
3219 OUString(
".uno:DuplicateSlide"),
3220 OUString(
".uno:Cut"),
3221 OUString(
".uno:Copy"),
3222 OUString(
".uno:Paste"),
3223 OUString(
".uno:SelectAll"),
3224 OUString(
".uno:ReplyComment"),
3225 OUString(
".uno:ResolveComment"),
3226 OUString(
".uno:ResolveCommentThread"),
3227 OUString(
".uno:InsertRowsBefore"),
3228 OUString(
".uno:InsertRowsAfter"),
3229 OUString(
".uno:InsertColumnsBefore"),
3230 OUString(
".uno:InsertColumnsAfter"),
3231 OUString(
".uno:DeleteRows"),
3232 OUString(
".uno:DeleteColumns"),
3233 OUString(
".uno:DeleteTable"),
3234 OUString(
".uno:SelectTable"),
3235 OUString(
".uno:EntireRow"),
3236 OUString(
".uno:EntireColumn"),
3237 OUString(
".uno:EntireCell"),
3238 OUString(
".uno:AssignLayout"),
3239 OUString(
".uno:StatusDocPos"),
3240 OUString(
".uno:RowColSelCount"),
3241 OUString(
".uno:StatusPageStyle"),
3242 OUString(
".uno:InsertMode"),
3243 OUString(
".uno:SpellOnline"),
3244 OUString(
".uno:StatusSelectionMode"),
3245 OUString(
".uno:StateTableCell"),
3246 OUString(
".uno:StatusBarFunc"),
3247 OUString(
".uno:StatePageNumber"),
3248 OUString(
".uno:StateWordCount"),
3249 OUString(
".uno:SelectionMode"),
3250 OUString(
".uno:PageStatus"),
3251 OUString(
".uno:LayoutStatus"),
3252 OUString(
".uno:Scale"),
3253 OUString(
".uno:Context"),
3254 OUString(
".uno:WrapText"),
3255 OUString(
".uno:ToggleMergeCells"),
3256 OUString(
".uno:NumberFormatCurrency"),
3257 OUString(
".uno:NumberFormatPercent"),
3258 OUString(
".uno:NumberFormatDecimal"),
3259 OUString(
".uno:NumberFormatDate"),
3260 OUString(
".uno:EditHeaderAndFooter"),
3261 OUString(
".uno:FrameLineColor"),
3262 OUString(
".uno:SortAscending"),
3263 OUString(
".uno:SortDescending"),
3264 OUString(
".uno:TrackChanges"),
3265 OUString(
".uno:ShowTrackedChanges"),
3266 OUString(
".uno:NextTrackedChange"),
3267 OUString(
".uno:PreviousTrackedChange"),
3268 OUString(
".uno:AcceptAllTrackedChanges"),
3269 OUString(
".uno:RejectAllTrackedChanges"),
3270 OUString(
".uno:TableDialog"),
3271 OUString(
".uno:FormatCellDialog"),
3272 OUString(
".uno:FontDialog"),
3273 OUString(
".uno:ParagraphDialog"),
3274 OUString(
".uno:OutlineBullet"),
3275 OUString(
".uno:InsertIndexesEntry"),
3276 OUString(
".uno:DocumentRepair"),
3277 OUString(
".uno:TransformDialog"),
3278 OUString(
".uno:InsertPageHeader"),
3279 OUString(
".uno:InsertPageFooter"),
3280 OUString(
".uno:OnlineAutoFormat"),
3281 OUString(
".uno:InsertObjectChart"),
3282 OUString(
".uno:InsertSection"),
3283 OUString(
".uno:InsertAnnotation"),
3284 OUString(
".uno:DeleteAnnotation"),
3285 OUString(
".uno:InsertPagebreak"),
3286 OUString(
".uno:InsertColumnBreak"),
3287 OUString(
".uno:HyperlinkDialog"),
3288 OUString(
".uno:InsertSymbol"),
3289 OUString(
".uno:EditRegion"),
3290 OUString(
".uno:ThesaurusDialog"),
3291 OUString(
".uno:FormatArea"),
3292 OUString(
".uno:FormatLine"),
3293 OUString(
".uno:FormatColumns"),
3294 OUString(
".uno:Watermark"),
3295 OUString(
".uno:ResetAttributes"),
3296 OUString(
".uno:Orientation"),
3297 OUString(
".uno:ObjectAlignLeft"),
3298 OUString(
".uno:ObjectAlignRight"),
3299 OUString(
".uno:AlignCenter"),
3300 OUString(
".uno:TransformPosX"),
3301 OUString(
".uno:TransformPosY"),
3302 OUString(
".uno:TransformWidth"),
3303 OUString(
".uno:TransformHeight"),
3304 OUString(
".uno:ObjectBackOne"),
3305 OUString(
".uno:SendToBack"),
3306 OUString(
".uno:ObjectForwardOne"),
3307 OUString(
".uno:BringToFront"),
3308 OUString(
".uno:WrapRight"),
3309 OUString(
".uno:WrapThrough"),
3310 OUString(
".uno:WrapLeft"),
3311 OUString(
".uno:WrapIdeal"),
3312 OUString(
".uno:WrapOn"),
3313 OUString(
".uno:WrapOff"),
3314 OUString(
".uno:UpdateCurIndex"),
3315 OUString(
".uno:InsertCaptionDialog"),
3316 OUString(
".uno:FormatGroup"),
3317 OUString(
".uno:SplitTable"),
3318 OUString(
".uno:SplitCell"),
3319 OUString(
".uno:MergeCells"),
3320 OUString(
".uno:DeleteNote"),
3321 OUString(
".uno:AcceptChanges"),
3322 OUString(
".uno:FormatPaintbrush"),
3323 OUString(
".uno:SetDefault"),
3324 OUString(
".uno:ParaLeftToRight"),
3325 OUString(
".uno:ParaRightToLeft"),
3326 OUString(
".uno:ParaspaceIncrease"),
3327 OUString(
".uno:ParaspaceDecrease"),
3328 OUString(
".uno:AcceptTrackedChange"),
3329 OUString(
".uno:RejectTrackedChange"),
3330 OUString(
".uno:ShowResolvedAnnotations"),
3331 OUString(
".uno:InsertBreak"),
3332 OUString(
".uno:InsertEndnote"),
3333 OUString(
".uno:InsertFootnote"),
3334 OUString(
".uno:InsertReferenceField"),
3335 OUString(
".uno:InsertBookmark"),
3336 OUString(
".uno:InsertAuthoritiesEntry"),
3337 OUString(
".uno:InsertMultiIndex"),
3338 OUString(
".uno:InsertField"),
3339 OUString(
".uno:PageNumberWizard"),
3340 OUString(
".uno:InsertPageNumberField"),
3341 OUString(
".uno:InsertPageCountField"),
3342 OUString(
".uno:InsertDateField"),
3343 OUString(
".uno:InsertTitleField"),
3344 OUString(
".uno:InsertFieldCtrl"),
3345 OUString(
".uno:CharmapControl"),
3346 OUString(
".uno:EnterGroup"),
3347 OUString(
".uno:LeaveGroup"),
3348 OUString(
".uno:AlignUp"),
3349 OUString(
".uno:AlignMiddle"),
3350 OUString(
".uno:AlignDown"),
3351 OUString(
".uno:TraceChangeMode"),
3352 OUString(
".uno:Combine"),
3353 OUString(
".uno:Merge"),
3354 OUString(
".uno:Dismantle"),
3355 OUString(
".uno:Substract"),
3356 OUString(
".uno:DistributeSelection"),
3357 OUString(
".uno:Intersect"),
3358 OUString(
".uno:BorderInner"),
3359 OUString(
".uno:BorderOuter"),
3360 OUString(
".uno:FreezePanes"),
3361 OUString(
".uno:FreezePanesColumn"),
3362 OUString(
".uno:FreezePanesRow"),
3363 OUString(
".uno:Sidebar"),
3364 OUString(
".uno:SheetRightToLeft"),
3365 OUString(
".uno:RunMacro"),
3366 OUString(
".uno:SpacePara1"),
3367 OUString(
".uno:SpacePara15"),
3368 OUString(
".uno:SpacePara2"),
3369 OUString(
".uno:InsertSparkline"),
3370 OUString(
".uno:DeleteSparkline"),
3371 OUString(
".uno:DeleteSparklineGroup"),
3372 OUString(
".uno:EditSparklineGroup"),
3373 OUString(
".uno:EditSparkline"),
3374 OUString(
".uno:GroupSparklines"),
3375 OUString(
".uno:UngroupSparklines"),
3376 OUString(
".uno:FormatSparklineMenu"),
3377 OUString(
".uno:Protect"),
3378 OUString(
".uno:UnsetCellsReadOnly"),
3379 OUString(
".uno:ContentControlProperties"),
3380 OUString(
".uno:InsertCheckboxContentControl"),
3381 OUString(
".uno:InsertContentControl"),
3382 OUString(
".uno:InsertDateContentControl"),
3383 OUString(
".uno:InsertDropdownContentControl"),
3384 OUString(
".uno:InsertPlainTextContentControl"),
3385 OUString(
".uno:InsertPictureContentControl")
3388 util::URL aCommandURL;
3395 SAL_WARN(
"lok",
"iniUnoCommands: No Frame-Controller created.");
3403 SAL_WARN(
"lok",
"iniUnoCommands: Component context is not available");
3407#if !defined IOS && !defined ANDROID && !defined __EMSCRIPTEN__
3409 if (!xSEInitializer.is())
3411 SAL_WARN(
"lok",
"iniUnoCommands: XSEInitializer is not available");
3416 xSEInitializer->createSecurityContext(OUString());
3417 if (!xSecurityContext.is())
3419 SAL_WARN(
"lok",
"iniUnoCommands: failed to create security context");
3426 for (
const auto & sUnoCommand : sUnoCommands)
3428 aCommandURL.Complete = sUnoCommand;
3429 xParser->parseStrict(aCommandURL);
3454 if (xDocument->supportsService(
"com.sun.star.sheet.SpreadsheetDocument"))
3456 return LOK_DOCTYPE_SPREADSHEET;
3458 else if (xDocument->supportsService(
"com.sun.star.presentation.PresentationDocument"))
3460 return LOK_DOCTYPE_PRESENTATION;
3462 else if (xDocument->supportsService(
"com.sun.star.drawing.DrawingDocument"))
3464 return LOK_DOCTYPE_DRAWING;
3466 else if (xDocument->supportsService(
"com.sun.star.text.TextDocument") || xDocument->supportsService(
"com.sun.star.text.WebDocument"))
3468 return LOK_DOCTYPE_TEXT;
3475 catch (
const uno::Exception& exception)
3479 return LOK_DOCTYPE_OTHER;
3488 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3495 return pDoc->getParts();
3505 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3512 return pDoc->getPart();
3515static void doc_setPartImpl(LibreOfficeKitDocument* pThis,
int nPart,
bool bAllowChangeFocus =
true)
3522 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3529 pDoc->setPart( nPart, bAllowChangeFocus );
3542 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3558 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3565 pDoc->selectPart( nPart, nSelect );
3574 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3581 pDoc->moveSelectedParts(nPosition, bDuplicate);
3591 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3608 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3625 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3643 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3651 int nCurrentPart = pDoc->getPart();
3653 pDoc->setPartMode(nPartMode);
3664 if ( nCurrentPart < pDoc->getParts() )
3666 pDoc->setPart( nCurrentPart );
3681 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3688 return pDoc->getEditMode();
3692 unsigned char* pBuffer,
3693 const int nCanvasWidth,
const int nCanvasHeight,
3694 const int nTilePosX,
const int nTilePosY,
3695 const int nTileWidth,
const int nTileHeight)
3702 SAL_INFO(
"lok.tiledrendering",
"paintTile: painting [" << nTileWidth <<
"x" << nTileHeight <<
3703 "]@(" << nTilePosX <<
", " << nTilePosY <<
") to [" <<
3704 nCanvasWidth <<
"x" << nCanvasHeight <<
"]px" );
3706 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3713#if defined(UNX) && !defined(MACOSX) || defined(_WIN32)
3723 double fDPIScaleX = 1.0;
3724 paintTileIOS(pThis, pBuffer, nCanvasWidth, nCanvasHeight, fDPIScaleX, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3731 pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(
3735 pDoc->paintTile(*pDevice, nCanvasWidth, nCanvasHeight,
3736 nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3738 static bool bDebug = getenv(
"LOK_DEBUG_TILES") !=
nullptr;
3743 aRect = pDevice->PixelToLogic(aRect);
3744 pDevice->Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
3746 pDevice->SetLineColor();
3747 pDevice->DrawRect(aRect);
3753 pDevice->EnableMapMode(
false);
3754 BitmapEx aBmpEx = pDevice->GetBitmapEx({ 0, 0 }, { nCanvasWidth, nCanvasHeight });
3760 assert(sraBmp->Height() == nCanvasHeight);
3761 assert(sraBmp->Width() == nCanvasWidth);
3762 assert(!sraAlpha || sraBmp->Height() == sraAlpha->Height());
3763 assert(!sraAlpha || sraBmp->Width() == sraAlpha->Width());
3767 Scanline dataBmp = sraBmp->GetScanline(
y);
3768 Scanline dataAlpha = sraAlpha ? sraAlpha->GetScanline(
y) :
nullptr;
3772 sal_uInt8 alpha = dataAlpha ? sraAlpha->GetPixelFromData(dataAlpha,
x).GetBlue() : 255;
3791static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis,
3793 const int nCanvasWidth,
const int nCanvasHeight,
3794 const int nTilePosX,
const int nTilePosY,
3795 const int nTileWidth,
const int nTileHeight)
3800 SAL_INFO(
"lok.tiledrendering",
"paintTileToCGContext: painting [" << nTileWidth <<
"x" << nTileHeight <<
3801 "]@(" << nTilePosX <<
", " << nTilePosY <<
") to [" <<
3802 nCanvasWidth <<
"x" << nCanvasHeight <<
"]px" );
3804 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3811 Size aCanvasSize(nCanvasWidth, nCanvasHeight);
3812 paintTileToCGContext(pDoc, rCGContext, aCanvasSize, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3818 unsigned char* pBuffer,
3821 const int nCanvasWidth,
const int nCanvasHeight,
3822 const int nTilePosX,
const int nTilePosY,
3823 const int nTileWidth,
const int nTileHeight)
3830 SAL_INFO(
"lok.tiledrendering",
"paintPartTile: painting @ " << nPart <<
" : " << nMode <<
" ["
3831 << nTileWidth <<
"x" << nTileHeight <<
"]@("
3832 << nTilePosX <<
", " << nTilePosY <<
") to ["
3833 << nCanvasWidth <<
"x" << nCanvasHeight <<
"]px" );
3838 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3845 if (nOrigViewId < 0)
3856 std::vector<int> viewIds(viewCount);
3859 nOrigViewId = viewIds[0];
3864 if (nOrigViewId >= 0)
3868 handlerIt->second->disableCallbacks();
3876 const bool isText = (aType == LOK_DOCTYPE_TEXT);
3877 const bool isCalc = (aType == LOK_DOCTYPE_SPREADSHEET);
3878 int nOrigEditMode = 0;
3879 bool bPaintTextEdit =
true;
3880 int nViewId = nOrigViewId;
3881 int nLastNonEditorView = -1;
3882 int nViewMatchingMode = -1;
3887 if (nPart !=
doc_getPart(pThis) || nMode != pDoc->getEditMode())
3897 if (pViewShell->
getPart() == nPart &&
3902 nViewMatchingMode = nViewId;
3903 nLastNonEditorView = nViewId;
3907 else if (pViewShell->
getEditMode() == nMode && !bIsInEdit)
3920 if (nViewMatchingMode >= 0 && nViewMatchingMode != nViewId)
3922 nViewId = nViewMatchingMode;
3925 else if (!isCalc && nLastNonEditorView >= 0 && nLastNonEditorView != nViewId &&
3926 pCurrentViewShell && pCurrentViewShell->
GetDrawView() &&
3929 nViewId = nLastNonEditorView;
3934 if (nViewId != nOrigViewId && nViewId >= 0)
3938 handlerIt->second->disableCallbacks();
3942 if (nPart != nOrigPart)
3947 nOrigEditMode = pDoc->getEditMode();
3948 if (nOrigEditMode != nMode)
3953 bPaintTextEdit = (nPart == nOrigPart && nMode == nOrigEditMode);
3954 pDoc->setPaintTextEdit(bPaintTextEdit);
3957 doc_paintTile(pThis, pBuffer, nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3961 pDoc->setPaintTextEdit(
true);
3963 if (nMode != nOrigEditMode)
3968 if (nPart != nOrigPart)
3973 if (nViewId != nOrigViewId)
3979 handlerIt->second->enableCallbacks();
3986 catch (
const std::exception&)
3991 if (nOrigViewId >= 0)
3995 handlerIt->second->enableCallbacks();
4002 return LOK_TILEMODE_BGRA;
4014 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4017 Size aDocumentSize = pDoc->getDocumentSize();
4018 *pWidth = aDocumentSize.
Width();
4019 *pHeight = aDocumentSize.
Height();
4037 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4040 Size aDocumentSize = pDoc->getDataArea(nTab);
4041 *pCol = aDocumentSize.
Width();
4042 *pRow = aDocumentSize.
Height();
4051 const char* pArguments)
4058 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4062 pDoc->initializeForTiledRendering(
4068 LibreOfficeKitCallback pCallback,
4080 const size_t nId = nView;
4081 if (pCallback !=
nullptr)
4085 if (pair.first ==
nId)
4088 pair.second->addViewStates(nView);
4095 if (pair.first ==
nId)
4098 pair.second->removeViewStates(nView);
4104 if (pCallback !=
nullptr)
4108 if (pair.first ==
nId)
4122 std::string sPayload =
"{ \"fontsmissing\": [ ";
4130 sPayload +=
"\"" + std::string(f.toUtf8().getStr()) +
"\"";
4133 pCallback(LOK_CALLBACK_FONTS_MISSING, sPayload.c_str(),
pData);
4151 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4158 pDoc->getPostIts(aJsonWriter);
4166 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4173 pDoc->getPostItsPos(aJsonWriter);
4180 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4187 pDoc->getRulerState(aJsonWriter);
4191static void doc_postKeyEvent(LibreOfficeKitDocument* pThis,
int nType,
int nCharCode,
int nKeyCode)
4198 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4207 pDoc->postKeyEvent(
nType, nCharCode, nKeyCode);
4209 catch (
const uno::Exception& exception)
4212 SAL_INFO(
"lok",
"Failed to postKeyEvent " << exception.Message);
4230 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4236 pWindow = pDoc->getDocWindow();
4256 if (nLOKWindowId == 0)
4258 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4264 pWindow = pDoc->getDocWindow();
4280 if (nCharBefore > 0)
4283 if (nLOKWindowId == 0)
4286 for (
int i = 0;
i < nCharBefore; ++
i)
4287 pWindow->KeyInput(aEvt);
4296 if (nLOKWindowId == 0)
4299 for (
int i = 0;
i < nCharAfter; ++
i)
4300 pWindow->KeyInput(aEvt);
4325 case LOK_KEYEVENT_KEYINPUT:
4328 case LOK_KEYEVENT_KEYUP:
4361 case LOK_DOCTYPE_PRESENTATION:
4362 aMediaDescriptor[
"FilterName"] <<= OUString(
"impress_svg_Export");
4364 case LOK_DOCTYPE_DRAWING:
4365 aMediaDescriptor[
"FilterName"] <<= OUString(
"draw_svg_Export");
4367 case LOK_DOCTYPE_TEXT:
4368 aMediaDescriptor[
"FilterName"] <<= OUString(
"writer_svg_Export");
4370 case LOK_DOCTYPE_SPREADSHEET:
4371 aMediaDescriptor[
"FilterName"] <<= OUString(
"calc_svg_Export");
4374 SAL_WARN(
"lok",
"Failed to render shape selection: Document type is not supported");
4376 aMediaDescriptor[
"SelectionOnly"] <<=
true;
4377 aMediaDescriptor[
"OutputStream"] <<= xOut;
4378 aMediaDescriptor[
"IsPreview"] <<=
true;
4380 xStorable->storeToURL(
"private:stream", aMediaDescriptor.getAsConstPropertyValueList());
4385 *pOutput =
static_cast<char*
>(malloc(nOutputSize));
4388 std::memcpy(*pOutput, aOutStream.
GetData(), nOutputSize);
4393 catch (
const uno::Exception& exception)
4412class DispatchResultListener :
public cppu::WeakImplHelper<css::frame::XDispatchResultListener>
4415 std::shared_ptr<CallbackFlushHandler> mpCallback;
4418 DispatchResultListener(
const char* pCommand, std::shared_ptr<CallbackFlushHandler> pCallback)
4419 : maCommand(pCommand)
4420 , mpCallback(
std::move(pCallback))
4425 virtual void SAL_CALL dispatchFinished(
const css::frame::DispatchResultEvent& rEvent)
override
4428 aJson.
put(
"commandName", maCommand);
4430 if (rEvent.State != frame::DispatchResultState::DONTKNOW)
4432 bool bSuccess = (rEvent.State == frame::DispatchResultState::SUCCESS);
4433 aJson.
put(
"success", bSuccess);
4437 mpCallback->queue(LOK_CALLBACK_UNO_COMMAND_RESULT, aJson.
extractData());
4440 virtual void SAL_CALL disposing(
const css::lang::EventObject&)
override {}
4463 if (!bFoundWeldedControl)
4465 if (!bFoundWeldedControl)
4467 if (!bFoundWeldedControl)
4476 if (bFoundWeldedControl)
4486static void doc_sendDialogEvent(LibreOfficeKitDocument* ,
unsigned long long int nWindowId,
const char* pArguments)
4491static void lo_sendDialogEvent(LibreOfficeKit* ,
unsigned long long int nWindowId,
const char* pArguments)
4496static void lo_setOption(LibreOfficeKit* ,
const char *pOption,
const char* pValue)
4498 static char* pCurrentSalLogOverride =
nullptr;
4500 if (strcmp(pOption,
"traceeventrecording") == 0)
4502 if (strcmp(pValue,
"start") == 0)
4509 else if (strcmp(pValue,
"stop") == 0)
4512 else if (strcmp(pOption,
"sallogoverride") == 0)
4514 if (pCurrentSalLogOverride !=
nullptr)
4515 free(pCurrentSalLogOverride);
4516 if (pValue ==
nullptr)
4517 pCurrentSalLogOverride =
nullptr;
4519 pCurrentSalLogOverride = strdup(pValue);
4521 if (pCurrentSalLogOverride ==
nullptr || pCurrentSalLogOverride[0] ==
'\0')
4522 sal_detail_set_log_selector(
nullptr);
4524 sal_detail_set_log_selector(pCurrentSalLogOverride);
4526 else if (strcmp(pOption,
"addfont") == 0)
4535static void lo_dumpState (LibreOfficeKit* pThis,
const char* ,
char** pState)
4544 OStringBuffer aState(4096*256);
4548 pLib->dumpState(aState);
4550 OString
aStr = aState.makeStringAndClear();
4551 *pState = strdup(
aStr.getStr());
4556 rState.append(
"LibreOfficeKit state:");
4557 rState.append(
"\n\tLastExceptionMsg:\t");
4559 rState.append(
"\n\tUnipoll:\t");
4561 rState.append(
"\n\tOptionalFeatures:\t0x");
4563 rState.append(
"\n\tCallbackData:\t0x");
4564 rState.append(
reinterpret_cast<sal_Int64
>(
mpCallback), 16);
4570static void doc_postUnoCommand(LibreOfficeKitDocument* pThis,
const char* pCommand,
const char* pArguments,
bool bNotifyWhenFinished)
4578 OUString
aCommand(pCommand, strlen(pCommand), RTL_TEXTENCODING_UTF8);
4585 beans::PropertyValue aSynchronMode;
4586 aSynchronMode.Name =
"SynchronMode";
4587 aSynchronMode.Value <<=
false;
4588 aPropertyValuesVector.push_back(aSynchronMode);
4597 ExecuteOrientationChange();
4605 OUString
aMimeType = lcl_getCurrentDocumentMimeType(pDocument);
4612 OUString
aURL = xStorable->getLocation();
4614 bool bResult =
doc_saveAs(pThis, aURLUtf8.getStr(),
"pdf",
nullptr);
4618 aJson.
put(
"commandName", pCommand);
4619 aJson.
put(
"success", bResult);
4629 beans::PropertyValue aValue;
4630 aValue.Name =
"InteractionHandler";
4631 aValue.Value <<= xInteraction;
4632 aPropertyValuesVector.push_back(aValue);
4634 bool bDontSaveIfUnmodified =
false;
4635 aPropertyValuesVector.erase(std::remove_if(aPropertyValuesVector.begin(),
4636 aPropertyValuesVector.end(),
4637 [&bDontSaveIfUnmodified](
const beans::PropertyValue& aItem){
4638 if (aItem.Name ==
"DontSaveIfUnmodified")
4640 bDontSaveIfUnmodified = aItem.Value.get<bool>();
4644 }), aPropertyValuesVector.end());
4647 if (bDontSaveIfUnmodified && (!pDocSh || !pDocSh->
IsModified()))
4650 aJson.
put(
"commandName", pCommand);
4651 aJson.
put(
"success",
false);
4654 auto resultNode = aJson.
startNode(
"result");
4655 aJson.
put(
"type",
"string");
4656 aJson.
put(
"value",
"unmodified");
4662 else if (
gImpl && aCommand ==
".uno:TransformDialog")
4664 bool bNeedConversion =
false;
4668 if (aChartHelper.GetWindow() )
4670 bNeedConversion =
true;
4674 if (
OutputDevice* pOutputDevice = pView->GetFirstOutputDevice())
4676 bNeedConversion = (pOutputDevice->GetMapMode().GetMapUnit() == MapUnit::Map100thMM);
4680 if (bNeedConversion)
4683 for (beans::PropertyValue& rPropValue: aPropertyValuesVector)
4685 if (rPropValue.Name ==
"TransformPosX"
4686 || rPropValue.Name ==
"TransformPosY"
4687 || rPropValue.Name ==
"TransformWidth"
4688 || rPropValue.Name ==
"TransformHeight"
4689 || rPropValue.Name ==
"TransformRotationX"
4690 || rPropValue.Name ==
"TransformRotationY")
4692 rPropValue.Value >>=
value;
4694 rPropValue.Value <<=
value;
4699 if (aChartHelper.GetWindow() && aPropertyValuesVector.size() > 0)
4701 if (aPropertyValuesVector[0].Name !=
"Action")
4708 for (beans::PropertyValue& rPropValue: aPropertyValuesVector)
4710 if (rPropValue.Name ==
"TransformPosX" || rPropValue.Name ==
"TransformRotationX")
4712 auto const value = *o3tl::doAccess<sal_Int32>(rPropValue.Value);
4713 rPropValue.Value <<=
value - nLeft;
4715 else if (rPropValue.Name ==
"TransformPosY" || rPropValue.Name ==
"TransformRotationY")
4717 auto const value = *o3tl::doAccess<sal_Int32>(rPropValue.Value);
4718 rPropValue.Value <<=
value - nTop;
4722 util::URL aCommandURL;
4723 aCommandURL.Path =
"LOKTransform";
4724 css::uno::Reference<css::frame::XDispatch>& aChartDispatcher = aChartHelper.GetXDispatcher();
4729 else if (
gImpl && aCommand ==
".uno:LOKSidebarWriterPage")
4731 setupSidebar(u
"WriterPageDeck");
4734 else if (
gImpl && aCommand ==
".uno:SidebarShow")
4739 else if (
gImpl && aCommand ==
".uno:SidebarHide")
4745 bool bResult =
false;
4748 if (aChartHelper.GetWindow() && aCommand !=
".uno:Save" )
4750 util::URL aCommandURL;
4751 aCommandURL.Path =
aCommand.copy(5);
4752 css::uno::Reference<css::frame::XDispatch>& aChartDispatcher = aChartHelper.GetXDispatcher();
4762 if (bNotifyWhenFinished && pDocument->mpCallbackFlushHandlers.count(nView))
4765 new DispatchResultListener(pCommand, pDocument->mpCallbackFlushHandlers[nView]));
4776static void doc_postMouseEvent(LibreOfficeKitDocument* pThis,
int nType,
int nX,
int nY,
int nCount,
int nButtons,
int nModifier)
4783 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4791 pDoc->postMouseEvent(
nType, nX, nY,
nCount, nButtons, nModifier);
4793 catch (
const uno::Exception& exception)
4796 SAL_INFO(
"lok",
"Failed to postMouseEvent " << exception.Message);
4800static void doc_postWindowMouseEvent(LibreOfficeKitDocument* ,
unsigned nLOKWindowId,
int nType,
int nX,
int nY,
int nCount,
int nButtons,
int nModifier)
4814 const Point aPos(nX, nY);
4822 case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
4825 case LOK_MOUSEEVENT_MOUSEBUTTONUP:
4828 case LOK_MOUSEEVENT_MOUSEMOVE:
4851 OString aType(pType);
4854 if (aType ==
"panBegin")
4855 eEventType = GestureEventPanType::Begin;
4856 else if (aType ==
"panEnd")
4857 eEventType = GestureEventPanType::End;
4864 PanningOrientation::Vertical,
4879 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4886 pDoc->setTextSelection(
nType, nX, nY);
4904 Size aOffset(pWindow->GetOutOffXPixel(), pWindow->GetOutOffYPixel());
4905 Point aCursorPos(nX, nY);
4906 aCursorPos.Move(aOffset);
4909 MouseEvent aCursorEvent(aCursorPos, 1, MouseEventModifiers::SIMPLECLICK, 0, nModifier);
4915 const css::uno::Reference<css::datatransfer::XTransferable> &xTransferable,
4916 const OString &aInMimeType, OString &aRet);
4919 const css::uno::Reference<css::datatransfer::XTransferable> &xTransferable,
4920 const OString &aMimeType, OString &aRet)
4926 auto aSeq = Sequence<sal_Int8>(
reinterpret_cast<const sal_Int8*
>(aRet.getStr()),
4928 OStringBuffer aBase64Data;
4932 aRet =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"
4934 "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/><meta "
4935 "name=\"generator\" content=\""
4938 "</head><body><img src=\"data:" +
aMimeType +
";base64,"
4939 + aBase64Data +
"\"/></body></html>";
4945 const css::uno::Reference<css::datatransfer::XTransferable> &xTransferable,
4946 const OString &aMimeType, OString &aRet)
4952 aRet =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"
4954 "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/><meta "
4955 "name=\"generator\" content=\""
4957 +
"\"/></head><body><pre>" + aRet +
"</pre></body></html>";
4963 const css::uno::Reference<css::datatransfer::XTransferable> &xTransferable,
4964 const OString &aInMimeType, OString &aRet)
4969 bool bConvert =
false;
4975 aMimeType =
"text/plain;charset=utf-16";
4980 datatransfer::DataFlavor aFlavor;
4981 aFlavor.MimeType = OUString::fromUtf8(
aMimeType.getStr());
4982 if (
aMimeType ==
"text/plain;charset=utf-16")
4987 if (!xTransferable->isDataFlavorSupported(aFlavor))
4990 if (aInMimeType ==
"text/html")
5007 aAny = xTransferable->getTransferData(aFlavor);
5009 catch (
const css::datatransfer::UnsupportedFlavorException& e)
5011 SetLastExceptionMsg(
"Unsupported flavor " + aFlavor.MimeType +
" exception " + e.Message);
5014 catch (
const css::uno::Exception& e)
5027 aRet = OString(
reinterpret_cast<const char *
>(aString.getStr()), aString.getLength() *
sizeof(
sal_Unicode));
5033 aRet = OString(
reinterpret_cast<const char*
>(aSequence.getConstArray()), aSequence.getLength());
5046 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5053 css::uno::Reference<css::datatransfer::XTransferable> xTransferable = pDoc->getSelection();
5060 const char *pType = pMimeType;
5061 if (!pType || pType[0] ==
'\0')
5062 pType =
"text/plain;charset=utf-8";
5072 *pUsedMimeType = strdup(pMimeType);
5074 *pUsedMimeType =
nullptr;
5087 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5091 return LOK_SELTYPE_NONE;
5094 css::uno::Reference<css::datatransfer::XTransferable> xTransferable = pDoc->getSelection();
5098 return LOK_SELTYPE_NONE;
5101 css::uno::Reference<css::datatransfer::XTransferable2> xTransferable2(xTransferable, css::uno::UNO_QUERY);
5102 if (xTransferable2.is() && xTransferable2->isComplex())
5103 return LOK_SELTYPE_COMPLEX;
5108 return LOK_SELTYPE_NONE;
5110 if (aRet.getLength() > 10000)
5111 return LOK_SELTYPE_COMPLEX;
5113 return !aRet.isEmpty() ? LOK_SELTYPE_TEXT : LOK_SELTYPE_NONE;
5125 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5129 return LOK_SELTYPE_NONE;
5132 css::uno::Reference<css::datatransfer::XTransferable> xTransferable = pDoc->getSelection();
5136 return LOK_SELTYPE_NONE;
5139 css::uno::Reference<css::datatransfer::XTransferable2> xTransferable2(xTransferable, css::uno::UNO_QUERY);
5140 if (xTransferable2.is() && xTransferable2->isComplex())
5141 return LOK_SELTYPE_COMPLEX;
5143 const char *pType = pMimeType;
5144 if (!pType || pType[0] ==
'\0')
5145 pType =
"text/plain;charset=utf-8";
5150 return LOK_SELTYPE_NONE;
5152 if (aRet.getLength() > 10000)
5153 return LOK_SELTYPE_COMPLEX;
5156 return LOK_SELTYPE_NONE;
5164 *pUsedMimeType = strdup(pMimeType);
5166 *pUsedMimeType =
nullptr;
5169 return LOK_SELTYPE_TEXT;
5173 const char **pMimeTypes,
5175 char ***pOutMimeTypes,
5177 char ***pOutStreams)
5183 (void) pOutMimeTypes;
5187 assert(!
"doc_getClipboard should not be called on iOS");
5197 assert (pOutMimeTypes);
5199 assert (pOutStreams);
5202 *pOutMimeTypes =
nullptr;
5203 *pOutSizes =
nullptr;
5204 *pOutStreams =
nullptr;
5206 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5215 css::uno::Reference<css::datatransfer::XTransferable> xTransferable = xClip->getContents();
5216 SAL_INFO(
"lok",
"Got from clip: " << xClip.get() <<
" transferable: " << xTransferable);
5223 std::vector<OString> aMimeTypes;
5227 if (!flavors.getLength())
5232 for (
const auto &it : flavors)
5237 for (
size_t i = 0; pMimeTypes[
i]; ++
i)
5238 aMimeTypes.push_back(OString(pMimeTypes[
i]));
5241 *pOutCount = aMimeTypes.size();
5242 *pOutSizes =
static_cast<size_t *
>(malloc(*pOutCount *
sizeof(
size_t)));
5243 *pOutMimeTypes =
static_cast<char **
>(malloc(*pOutCount *
sizeof(
char *)));
5244 *pOutStreams =
static_cast<char **
>(malloc(*pOutCount *
sizeof(
char *)));
5245 for (
size_t i = 0;
i < aMimeTypes.size(); ++
i)
5247 if (aMimeTypes[
i] ==
"text/plain;charset=utf-16")
5248 (*pOutMimeTypes)[
i] = strdup(
"text/plain;charset=utf-8");
5250 (*pOutMimeTypes)[
i] = strdup(aMimeTypes[
i].getStr());
5254 if (!bSuccess || aRet.getLength() < 1)
5256 (*pOutSizes)[
i] = 0;
5257 (*pOutStreams)[
i] =
nullptr;
5261 (*pOutSizes)[
i] = aRet.getLength();
5271 const size_t nInCount,
5272 const char **pInMimeTypes,
5273 const size_t *pInSizes,
5274 const char **pInStreams)
5279 (void) pInMimeTypes;
5288 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5297 auto xClip = forceSetClipboardForCurrentView(pThis);
5300 SAL_INFO(
"lok",
"Set clip: " << xClip.get() <<
" to: " << xTransferable);
5302 if (!pDoc->isMimeTypeSupported())
5311static bool doc_paste(LibreOfficeKitDocument* pThis,
const char* pMimeType,
const char* pData,
size_t nSize)
5317 const char *pInMimeTypes[1];
5318 const char *pInStreams[1];
5320 pInMimeTypes[0] = pMimeType;
5321 pInSizes[0] = nSize;
5322 pInStreams[0] =
pData;