11#include <config_buildconfig.h>
12#include <config_cairo_rgba.h>
13#include <config_features.h>
22#include <unicode/udata.h>
23#include <unicode/ucnv.h>
25#import <Foundation/Foundation.h>
26#import <CoreGraphics/CoreGraphics.h>
30#undef HAVE_MALLOC_TRIM
36# define HAVE_MALLOC_TRIM
41#include <osl/detail/android-bootstrap.h>
45#include <osl/detail/emscripten-bootstrap.h>
53#include <boost/property_tree/json_parser.hpp>
54#include <boost/algorithm/string.hpp>
56#include <LibreOfficeKit/LibreOfficeKit.h>
57#include <LibreOfficeKit/LibreOfficeKitEnums.h>
66#include <osl/file.hxx>
67#include <osl/process.h>
68#include <osl/thread.h>
69#include <rtl/bootstrap.hxx>
70#include <rtl/strbuf.hxx>
88#include <com/sun/star/document/MacroExecMode.hpp>
89#include <com/sun/star/beans/XPropertySet.hpp>
90#include <com/sun/star/container/XNameAccess.hpp>
91#include <com/sun/star/document/XDocumentLanguages.hpp>
92#include <com/sun/star/frame/Desktop.hpp>
93#include <com/sun/star/frame/DispatchResultEvent.hpp>
94#include <com/sun/star/frame/DispatchResultState.hpp>
95#include <com/sun/star/frame/XDispatchProvider.hpp>
96#include <com/sun/star/frame/XDispatchResultListener.hpp>
97#include <com/sun/star/frame/XSynchronousDispatch.hpp>
98#include <com/sun/star/frame/XStorable.hpp>
99#include <com/sun/star/lang/Locale.hpp>
100#include <com/sun/star/lang/XComponent.hpp>
101#include <com/sun/star/lang/XMultiServiceFactory.hpp>
102#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
103#include <com/sun/star/util/URLTransformer.hpp>
104#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
105#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp>
106#include <com/sun/star/datatransfer/XTransferable2.hpp>
107#include <com/sun/star/text/TextContentAnchorType.hpp>
108#include <com/sun/star/document/XRedlinesSupplier.hpp>
109#include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
111#include <com/sun/star/xml/crypto/SEInitializer.hpp>
112#include <com/sun/star/xml/crypto/XSEInitializer.hpp>
113#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
114#include <com/sun/star/xml/crypto/XCertificateCreator.hpp>
115#include <com/sun/star/security/XCertificate.hpp>
117#include <com/sun/star/linguistic2/LanguageGuessing.hpp>
118#include <com/sun/star/linguistic2/LinguServiceManager.hpp>
119#include <com/sun/star/linguistic2/XSpellChecker.hpp>
120#include <com/sun/star/i18n/LocaleCalendar2.hpp>
121#include <com/sun/star/i18n/ScriptType.hpp>
122#include <com/sun/star/lang/DisposedException.hpp>
141#include <svx/strings.hrc>
143#include <svx/svxids.hrc>
164#include <unicode/uchar.h>
172#include <osl/module.hxx>
185#include <com/sun/star/document/XUndoManager.hpp>
186#include <com/sun/star/document/XUndoManagerSupplier.hpp>
187#include <com/sun/star/document/XLinkTargetSupplier.hpp>
194#include "../app/cmdlineargs.hxx"
196#include "../app/sofficemain.h"
197#include "../app/officeipcthread.hxx"
202#include <officecfg/Office/Common.hxx>
203#include <officecfg/Office/Impress.hxx>
204#include <officecfg/Office/Linguistic.hxx>
221#include <officecfg/Setup.hxx>
222#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
237 SAL_WARN_IF(!s.isEmpty(),
"lok",
"lok exception '" + s +
"'");
247 const char *filterName;
252 static const int dumpTimeoutMS = 5000;
255 TraceEventDumper() :
AutoTimer(
"Trace Event dumper" )
261 virtual void Invoke()
override
266 static void flushRecordings()
268 const css::uno::Sequence<OUString> aEvents =
270 OStringBuffer aOutput;
271 for (
const auto &s : aEvents)
276 if (aOutput.getLength() > 0)
278 OString aChunk = aOutput.makeStringAndClear();
291 {
"doc",
"MS Word 97" },
292 {
"docm",
"MS Word 2007 XML VBA" },
293 {
"docx",
"MS Word 2007 XML" },
294 {
"fodt",
"OpenDocument Text Flat XML" },
295 {
"html",
"HTML (StarWriter)" },
296 {
"odt",
"writer8" },
297 {
"ott",
"writer8_template" },
298 {
"pdf",
"writer_pdf_Export" },
300 {
"rtf",
"Rich Text Format" },
302 {
"xhtml",
"XHTML Writer File" },
303 {
"png",
"writer_png_Export" },
304 {
"xml",
"writer_indexing_export" },
310 {
"csv",
"Text - txt - csv (StarCalc)" },
311 {
"fods",
"OpenDocument Spreadsheet Flat XML" },
312 {
"html",
"HTML (StarCalc)" },
314 {
"ots",
"calc8_template" },
315 {
"pdf",
"calc_pdf_Export" },
316 {
"xhtml",
"XHTML Calc File" },
317 {
"xls",
"MS Excel 97" },
318 {
"xlsm",
"Calc MS Excel 2007 VBA XML" },
319 {
"xlsx",
"Calc MS Excel 2007 XML" },
320 {
"png",
"calc_png_Export" },
326 {
"fodp",
"OpenDocument Presentation Flat XML" },
327 {
"html",
"impress_html_Export" },
328 {
"odg",
"impress8_draw" },
329 {
"odp",
"impress8" },
330 {
"otp",
"impress8_template" },
331 {
"pdf",
"impress_pdf_Export" },
332 {
"potm",
"Impress MS PowerPoint 2007 XML Template" },
333 {
"pot",
"MS PowerPoint 97 Vorlage" },
334 {
"pptm",
"Impress MS PowerPoint 2007 XML VBA" },
335 {
"pptx",
"Impress MS PowerPoint 2007 XML" },
336 {
"pps",
"MS PowerPoint 97 Autoplay" },
337 {
"ppt",
"MS PowerPoint 97" },
338 {
"svg",
"impress_svg_Export" },
339 {
"xhtml",
"XHTML Impress File" },
340 {
"png",
"impress_png_Export"},
346 {
"fodg",
"draw_ODG_FlatXML" },
347 {
"html",
"draw_html_Export" },
349 {
"pdf",
"draw_pdf_Export" },
350 {
"svg",
"draw_svg_Export" },
351 {
"xhtml",
"XHTML Draw File" },
352 {
"png",
"draw_png_Export"},
358 if (pString ==
nullptr)
361 std::string_view sString(pString, strlen(pString));
362 return OStringToOUString(sString, RTL_TEXTENCODING_UTF8);
368 char* pMemory =
static_cast<char*
>(malloc(rStr.getLength() + 1));
370 memcpy(pMemory, rStr.getStr(), rStr.getLength() + 1);
387 OUString aWorkingDir;
388 osl_getProcessWorkingDir(&aWorkingDir.pData);
389 if (!aWorkingDir.endsWith(
"/"))
394 return rtl::Uri::convertRelToAbs(aWorkingDir,
aURL);
396 catch (
const rtl::MalformedUriException &)
406 if (pJSON && pJSON[0] !=
'\0')
417 const sal_uLong nLinks = aNames.getLength();
418 const OUString* pNames = aNames.getConstArray();
419 static constexpr OUStringLiteral aProp_LinkDisplayName(
u"LinkDisplayName" );
420 static constexpr OUStringLiteral aProp_LinkTarget(
u"com.sun.star.document.LinkTarget" );
421 bool bIsTarget =
false;
425 OUString aLink( *pNames++ );
430 aAny = xLinks->getByName( aLink );
432 catch(
const uno::Exception&)
447 aAny =
xTarget->getPropertyValue( aProp_LinkDisplayName );
448 OUString aDisplayName;
449 aAny >>= aDisplayName;
450 OUString aStrDisplayname ( aDisplayName );
454 aJson.
put(aStrDisplayname, aLink);
459 bIsTarget = xSI->supportsService( aProp_LinkTarget );
463 aJson.
put(aStrDisplayname, aLink);
479 SAL_WARN(
"lok",
"extractLinks: Exception");
488 OUString aType = anyItem.getValueTypeName();
489 rJson.
put(
"type", aType);
491 if (aType ==
"string")
492 rJson.
put(
"value", anyItem.get<OUString>());
493 else if (aType ==
"unsigned long")
494 rJson.
put(
"value", OString::number(anyItem.get<sal_uInt32>()));
495 else if (aType ==
"long")
496 rJson.
put(
"value", OString::number(anyItem.get<sal_Int32>()));
497 else if (aType ==
"[]any")
500 if (anyItem >>=
aSeq)
502 auto valueNode = rJson.
startNode(
"value");
504 for (
auto i = 0;
i <
aSeq.getLength(); ++
i)
519 if (rPayload.startsWith(
"EMPTY"))
524 int nSeparatorPos = rPayload.indexOf(
',', 6);
525 bool bHasMode = nSeparatorPos > 0;
529 assert(rPayload.getLength() > nSeparatorPos);
543 const char*
pos = rPayload.getStr();
544 const char*
end = rPayload.getStr() + rPayload.getLength();
569 nPart = rtl_str_toInt64_WithLength(
pos, 10,
end -
pos);
571 while( *
pos && *
pos !=
',' )
577 nMode = rtl_str_toInt64_WithLength(
pos, 10,
end -
pos);
589 if (nWidth <= 0 || nHeight <= 0)
606 if (nWidth > 0 && nHeight > 0)
631 PayloadObject = rRectAndPart;
632 PayloadString.clear();
639 if(PayloadObject.which() != 1)
641 return boost::get<RectangleAndPart>(PayloadObject);
646 boost::property_tree::ptree aTree;
647 std::stringstream aStream(payload);
648 boost::property_tree::read_json(aStream, aTree);
654 return boost::get<boost::property_tree::ptree>(PayloadObject);
659 std::stringstream aJSONStream;
660 constexpr bool bPretty =
false;
661 boost::property_tree::write_json(aJSONStream, rTree, bPretty);
662 PayloadString = OString(
o3tl::trim(aJSONStream.str()));
664 PayloadObject = rTree;
669 assert(PayloadObject.which() == 2);
670 return boost::get<boost::property_tree::ptree>(PayloadObject);
677 assert(PayloadObject.which() == 3);
678 return boost::get<int>(PayloadObject);
685 switch (PayloadObject.which())
693 return getRectangleAndPart().toString().getStr() == getPayload();
698 std::stringstream aJSONStream;
699 boost::property_tree::write_json(aJSONStream, getJson(),
false);
700 const std::string aExpected = boost::trim_copy(aJSONStream.str());
701 return getPayload() == std::string_view(aExpected);
709 assert(!
"Unknown variant type; please add an entry to validate.");
721 case LOK_CALLBACK_CELL_VIEW_CURSOR:
722 case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
723 case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
724 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
725 case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
737 case LOK_CALLBACK_TEXT_SELECTION:
738 case LOK_CALLBACK_TEXT_SELECTION_START:
739 case LOK_CALLBACK_TEXT_SELECTION_END:
750 case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
751 case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
752 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
763 size_t viewIdPos = payload.find(
"viewId");
764 if (viewIdPos == std::string::npos)
767 size_t numberPos = payload.find(
":", viewIdPos + 6);
768 if (numberPos == std::string::npos)
771 for (++numberPos; numberPos < payload.length(); ++numberPos)
773 if (payload[numberPos] ==
',' || payload[numberPos] ==
'}' || (payload[numberPos] >=
'0' && payload[numberPos] <=
'9'))
777 if (numberPos < payload.length() && payload[numberPos] >=
'0' && payload[numberPos] <=
'9')
785std::string extractCertificate(
const std::string & certificate)
787 const std::string
header(
"-----BEGIN CERTIFICATE-----");
788 const std::string footer(
"-----END CERTIFICATE-----");
792 size_t pos1 = certificate.find(header);
793 if (pos1 == std::string::npos)
796 size_t pos2 = certificate.find(footer, pos1 + 1);
797 if (pos2 == std::string::npos)
800 pos1 = pos1 +
header.length();
803 return certificate.substr(pos1, pos2);
806std::string extractPrivateKey(
const std::string & privateKey)
808 const std::string
header(
"-----BEGIN PRIVATE KEY-----");
809 const std::string footer(
"-----END PRIVATE KEY-----");
813 size_t pos1 = privateKey.find(header);
814 if (pos1 == std::string::npos)
817 size_t pos2 = privateKey.find(footer, pos1 + 1);
818 if (pos2 == std::string::npos)
821 pos1 = pos1 +
header.length();
824 return privateKey.substr(pos1, pos2);
845 return pFilter->GetMimeType();
849css::uno::Reference< css::document::XUndoManager > getUndoManager(
const css::uno::Reference< css::frame::XFrame >& rxFrame )
851 const css::uno::Reference< css::frame::XController >&
xController = rxFrame->getController();
854 const css::uno::Reference< css::frame::XModel >&
xModel =
xController->getModel();
857 const css::uno::Reference< css::document::XUndoManagerSupplier > xSuppUndo( xModel, css::uno::UNO_QUERY_THROW );
858 return css::uno::Reference< css::document::XUndoManager >( xSuppUndo->getUndoManager(), css::uno::UNO_SET_THROW );
862 return css::uno::Reference< css::document::XUndoManager > ();
866void ExecuteMarginLRChange(
871 pPageLRMarginItem->
SetLeft( nPageLeftMargin );
872 pPageLRMarginItem->
SetRight( nPageRightMargin );
874 SfxCallMode::RECORD, { pPageLRMarginItem });
878void ExecuteMarginULChange(
883 pPageULMarginItem->
SetUpper( nPageTopMargin );
884 pPageULMarginItem->
SetLower( nPageBottomMargin );
886 SfxCallMode::RECORD, { pPageULMarginItem });
890void ExecuteOrientationChange()
896 std::unique_ptr<SvxPageItem> pPageItem(
new SvxPageItem(SID_ATTR_PAGE));
902 css::uno::Reference< css::document::XUndoManager > mxUndoManager(
905 if ( mxUndoManager.is() )
906 mxUndoManager->enterUndoContext(
"" );
911 std::unique_ptr<SvxSizeItem> pPageSizeItem(pSizeItem->
Clone());
915 std::unique_ptr<SvxLongLRSpaceItem> pPageLRMarginItem(pLRSpaceItem->
Clone());
919 std::unique_ptr<SvxLongULSpaceItem> pPageULMarginItem(pULSpaceItem->
Clone());
922 bool bIsLandscape =
false;
923 if ( pPageSizeItem->GetSize().Width() > pPageSizeItem->GetSize().Height())
927 pPageItem->SetLandscape(!bIsLandscape);
931 const tools::Long nRotatedWidth = pPageSizeItem->GetSize().Height();
932 const tools::Long nRotatedHeight = pPageSizeItem->GetSize().Width();
933 pPageSizeItem->SetSize(
Size(nRotatedWidth, nRotatedHeight));
940 SfxCallMode::RECORD, { pPageSizeItem.get(), pPageItem.get() });
952 const tools::Long nPW = pPageSizeItem->GetSize().Width();
958 ExecuteMarginLRChange( pPageLRMarginItem->
GetLeft(), nMR - (nTmpPW - nPW ), pPageLRMarginItem.get() );
962 ExecuteMarginLRChange( nML - (nTmpPW - nPW ), pPageLRMarginItem->
GetRight(), pPageLRMarginItem.get() );
970 const tools::Long nPH = pPageSizeItem->GetSize().Height();
976 ExecuteMarginULChange( pPageULMarginItem->
GetUpper(), nMB - ( nTmpPH - nPH ), pPageULMarginItem.get() );
980 ExecuteMarginULChange( nMT - ( nTmpPH - nPH ), pPageULMarginItem->
GetLower(), pPageULMarginItem.get() );
985 if ( mxUndoManager.is() )
986 mxUndoManager->leaveUndoContext();
989void setupSidebar(std::u16string_view sidebarDeckId = u
"")
1012 = pDockingWin->GetOrCreateSidebarController();
1017 if (!sidebarDeckId.empty())
1026 pDockingWin->SyncUpdate();
1050 OUString aNameEquals(OUString::Concat(rName) +
"=");
1051 OUString aCommaNameEquals(OUString::Concat(
",") + rName +
"=");
1054 if (rOptions.startsWith(aNameEquals))
1056 size_t nLen = aNameEquals.getLength();
1057 int nComma = rOptions.indexOf(
",", nLen);
1060 aValue = rOptions.copy(nLen, nComma - nLen);
1061 rOptions = rOptions.copy(nComma + 1);
1065 aValue = rOptions.copy(nLen);
1069 else if ((
nIndex = rOptions.indexOf(aCommaNameEquals)) >= 0)
1071 size_t nLen = aCommaNameEquals.getLength();
1072 int nComma = rOptions.indexOf(
",",
nIndex + nLen);
1075 aValue = rOptions.copy(
nIndex + nLen, nComma -
nIndex - nLen);
1076 rOptions = OUString::Concat(rOptions.subView(0,
nIndex)) + rOptions.subView(nComma);
1080 aValue = rOptions.copy(
nIndex + nLen);
1081 rOptions = rOptions.copy(0,
nIndex);
1091static void doc_destroy(LibreOfficeKitDocument* pThis);
1092static int doc_saveAs(LibreOfficeKitDocument* pThis,
const char* pUrl,
const char* pFormat,
const char* pFilterOptions);
1096static int doc_getPart(LibreOfficeKitDocument* pThis);
1097static void doc_setPart(LibreOfficeKitDocument* pThis,
int nPart);
1098static void doc_selectPart(LibreOfficeKitDocument* pThis,
int nPart,
int nSelect);
1100static char*
doc_getPartName(LibreOfficeKitDocument* pThis,
int nPart);
1101static void doc_setPartMode(LibreOfficeKitDocument* pThis,
int nPartMode);
1104 unsigned char* pBuffer,
1105 const int nCanvasWidth,
const int nCanvasHeight,
1106 const int nTilePosX,
const int nTilePosY,
1107 const int nTileWidth,
const int nTileHeight);
1109 unsigned char* pBuffer,
1112 const int nCanvasWidth,
const int nCanvasHeight,
1113 const int nTilePosX,
const int nTilePosY,
1114 const int nTileWidth,
const int nTileHeight);
1124 const char* pArguments);
1127 LibreOfficeKitCallback pCallback,
1135 const char* blockedCommandList);
1142 unsigned nLOKWindowId,
1146 unsigned long long int nLOKWindowId,
1147 const char* pArguments);
1149 unsigned nLOKWindowId,
1161 unsigned nLOKWindowId,
1169 unsigned nLOKWindowId,
1175 const char* pCommand,
1176 const char* pArguments,
1177 bool bNotifyWhenFinished);
1179 unsigned nLOKWindowId,
1188 const char* pMimeType,
1189 char** pUsedMimeType);
1192 const char* pMimeType,
1194 char** pUsedMimeType);
1196 const char **pMimeTypes,
1198 char ***pOutMimeTypes,
1200 char ***pOutStreams);
1202 const size_t nInCount,
1203 const char **pInMimeTypes,
1204 const size_t *pInSizes,
1205 const char **pInStreams);
1206static bool doc_paste(LibreOfficeKitDocument* pThis,
1207 const char* pMimeType,
1217 int nTilePixelWidth,
1218 int nTilePixelHeight,
1220 int nTileTwipHeight);
1222static void doc_setOutlineState(LibreOfficeKitDocument* pThis,
bool bColumn,
int nLevel,
int nIndex,
bool bHidden);
1232 const char *pFontName,
1237static unsigned char*
doc_renderFont(LibreOfficeKitDocument* pThis,
1238 const char *pFontName,
1242static char*
doc_getPartHash(LibreOfficeKitDocument* pThis,
int nPart);
1244static void doc_paintWindow(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
unsigned char* pBuffer,
1245 const int nX,
const int nY,
1246 const int nWidth,
const int nHeight);
1248static void doc_paintWindowDPI(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
unsigned char* pBuffer,
1249 const int nX,
const int nY,
1250 const int nWidth,
const int nHeight,
1251 const double fDPIScale);
1253static void doc_paintWindowForView(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
unsigned char* pBuffer,
1254 const int nX,
const int nY,
1255 const int nWidth,
const int nHeight,
1256 const double fDPIScale,
int viewId);
1258static void doc_postWindow(LibreOfficeKitDocument* pThis,
unsigned
1259 nLOKWindowId,
int nAction,
const char* pData);
1261static char*
doc_getPartInfo(LibreOfficeKitDocument* pThis,
int nPart);
1264 const unsigned char* pCertificateBinary,
1265 const int nCertificateBinarySize,
1266 const unsigned char* pPrivateKeyBinary,
1267 const int nPrivateKeyBinarySize);
1270 const unsigned char* pCertificateBinary,
1271 const int nCertificateBinarySize);
1277static void doc_resizeWindow(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
1278 const int nWidth,
const int nHeight);
1284 const char* pArguments);
1287 const char* pSearchResult,
unsigned char** pBitmapBuffer,
1288 int* pWidth,
int* pHeight,
size_t* pByteSize);
1302ITiledRenderable* getTiledRenderable(LibreOfficeKitDocument* pThis)
1305 return dynamic_cast<ITiledRenderable*
>(pDocument->
mxComponent.get());
1317 ITiledRenderable* pDoc = getTiledRenderable(pThis);
1320 SAL_INFO(
"lok",
"Set to clipboard for view " << xClip.get());
1329const vcl::Font* FindFont(std::u16string_view rFontName)
1337 if (pList && !rFontName.empty())
1343vcl::Font FindFont_FallbackToDefault(std::u16string_view rFontName)
1345 if (
auto pFound = FindFont(rFontName))
1349 GetDefaultFontFlags::NONE);
1352int getDocumentType (LibreOfficeKitDocument* pThis)
1362 if (xDocument->supportsService(
"com.sun.star.sheet.SpreadsheetDocument"))
1364 return LOK_DOCTYPE_SPREADSHEET;
1366 else if (xDocument->supportsService(
"com.sun.star.presentation.PresentationDocument"))
1368 return LOK_DOCTYPE_PRESENTATION;
1370 else if (xDocument->supportsService(
"com.sun.star.drawing.DrawingDocument"))
1372 return LOK_DOCTYPE_DRAWING;
1374 else if (xDocument->supportsService(
"com.sun.star.text.TextDocument") || xDocument->supportsService(
"com.sun.star.text.WebDocument"))
1376 return LOK_DOCTYPE_TEXT;
1383 catch (
const uno::Exception& exception)
1387 return LOK_DOCTYPE_OTHER;
1393 : mxComponent(
std::move(xComponent))
1394 , mnDocumentId(nDocumentId)
1396 assert(nDocumentId != -1 &&
"Cannot set mnDocumentId to -1");
1497 forceSetClipboardForCurrentView(
this);
1507 catch (
const css::lang::DisposedException&)
1515 OUString sGenerator(
1517 OUString os(
"$_OS");
1518 ::rtl::Bootstrap::expandMacros(os);
1519 return sGenerator.replaceFirst(
"%1", os);
1525 :
Timer(
"lokit timer callback" )
1526 , mHandler( handler )
1541 :
Idle(
"lokit idle callback" ),
1552 m_states.emplace(LOK_CALLBACK_TEXT_SELECTION,
"NIL");
1553 m_states.emplace(LOK_CALLBACK_GRAPHIC_SELECTION,
"NIL");
1554 m_states.emplace(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR,
"NIL");
1555 m_states.emplace(LOK_CALLBACK_STATE_CHANGED,
"NIL");
1556 m_states.emplace(LOK_CALLBACK_MOUSE_POINTER,
"NIL");
1557 m_states.emplace(LOK_CALLBACK_CELL_CURSOR,
"NIL");
1558 m_states.emplace(LOK_CALLBACK_CELL_FORMULA,
"NIL");
1559 m_states.emplace(LOK_CALLBACK_CELL_ADDRESS,
"NIL");
1560 m_states.emplace(LOK_CALLBACK_CURSOR_VISIBLE,
"NIL");
1561 m_states.emplace(LOK_CALLBACK_SET_PART,
"NIL");
1562 m_states.emplace(LOK_CALLBACK_TABLE_SELECTED,
"NIL");
1563 m_states.emplace(LOK_CALLBACK_TAB_STOP_LIST,
"NIL");
1564 m_states.emplace(LOK_CALLBACK_RULER_UPDATE,
"NIL");
1565 m_states.emplace(LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE,
"NIL");
1575 int delta = std::distance(
m_queue1.begin(), pos);
1581 int delta = std::distance(
m_queue1.rbegin(), pos);
1605 types.resize(
nType + 1 );
1614 bool allViewIds =
false;
1625 std::vector<PerViewIdData>& types = it.second;
1627 types[
nType ].set =
false;
1646 queue(LOK_CALLBACK_INVALIDATE_TILES, callbackData);
1652 std::unique_lock<std::recursive_mutex>
lock(
m_mutex);
1660 std::unique_lock<std::recursive_mutex>
lock(
m_mutex);
1668 rState.append(
"\nView:\t");
1669 rState.append(
static_cast<sal_Int32
>(
m_viewId));
1670 rState.append(
"\n\tDisableCallbacks:\t");
1672 rState.append(
"\n\tStates:\n");
1675 rState.append(
"\n\t\t");
1676 rState.append(
static_cast<sal_Int32
>(
i.first));
1677 rState.append(
"\t");
1678 rState.append(
i.second);
1700 bool bIsChartActive =
false;
1701 bool bIsComment =
false;
1702 if (
type == LOK_CALLBACK_GRAPHIC_SELECTION)
1705 bIsChartActive = aChartHelper.
GetWindow() !=
nullptr;
1707 else if (
type == LOK_CALLBACK_COMMENT)
1721 if (
type != LOK_CALLBACK_STATE_CHANGED &&
1722 type != LOK_CALLBACK_INVALIDATE_TILES &&
1723 type != LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR &&
1724 type != LOK_CALLBACK_CURSOR_VISIBLE &&
1725 type != LOK_CALLBACK_VIEW_CURSOR_VISIBLE &&
1726 type != LOK_CALLBACK_TEXT_SELECTION &&
1727 type != LOK_CALLBACK_TEXT_SELECTION_START &&
1728 type != LOK_CALLBACK_TEXT_SELECTION_END &&
1729 type != LOK_CALLBACK_MEDIA_SHAPE &&
1730 type != LOK_CALLBACK_REFERENCE_MARKS)
1742 if (
type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR &&
1743 aCallbackData.
getPayload().indexOf(
", 0, 0, ") != -1 &&
1744 aCallbackData.
getPayload().indexOf(
"\"hyperlink\":\"\"") == -1 &&
1745 aCallbackData.
getPayload().indexOf(
"\"hyperlink\": {}") == -1)
1755 std::unique_lock<std::recursive_mutex>
lock(
m_mutex);
1762 SAL_INFO(
"lok",
"Received event with updated type [" <<
type <<
"] as normal callback");
1767 SAL_INFO(
"lok",
"Received event with updated type [" <<
type <<
"] as normal callback");
1774 case LOK_CALLBACK_TEXT_SELECTION_START:
1775 case LOK_CALLBACK_TEXT_SELECTION_END:
1776 case LOK_CALLBACK_TEXT_SELECTION:
1777 case LOK_CALLBACK_GRAPHIC_SELECTION:
1778 case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
1779 case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
1780 case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
1781 case LOK_CALLBACK_STATE_CHANGED:
1782 case LOK_CALLBACK_MOUSE_POINTER:
1783 case LOK_CALLBACK_CELL_CURSOR:
1784 case LOK_CALLBACK_CELL_VIEW_CURSOR:
1785 case LOK_CALLBACK_CELL_FORMULA:
1786 case LOK_CALLBACK_CELL_ADDRESS:
1787 case LOK_CALLBACK_CELL_SELECTION_AREA:
1788 case LOK_CALLBACK_CURSOR_VISIBLE:
1789 case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
1790 case LOK_CALLBACK_SET_PART:
1791 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
1792 case LOK_CALLBACK_INVALIDATE_HEADER:
1793 case LOK_CALLBACK_WINDOW:
1794 case LOK_CALLBACK_CALC_FUNCTION_LIST:
1795 case LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY:
1796 case LOK_CALLBACK_REFERENCE_MARKS:
1797 case LOK_CALLBACK_CELL_AUTO_FILL_AREA:
1798 case LOK_CALLBACK_A11Y_FOCUS_CHANGED:
1799 case LOK_CALLBACK_A11Y_CARET_CHANGED:
1800 case LOK_CALLBACK_A11Y_TEXT_SELECTION_CHANGED:
1801 case LOK_CALLBACK_COLOR_PALETTES:
1814 if (
type == LOK_CALLBACK_TEXT_SELECTION && aCallbackData.
isEmpty())
1816 const auto& posStart = std::find(
m_queue1.rbegin(),
m_queue1.rend(), LOK_CALLBACK_TEXT_SELECTION_START);
1817 auto posStart2 =
toQueue2(posStart);
1821 const auto& posEnd = std::find(
m_queue1.rbegin(),
m_queue1.rend(), LOK_CALLBACK_TEXT_SELECTION_END);
1832 case LOK_CALLBACK_TEXT_SELECTION_START:
1833 case LOK_CALLBACK_TEXT_SELECTION_END:
1834 case LOK_CALLBACK_TEXT_SELECTION:
1835 case LOK_CALLBACK_GRAPHIC_SELECTION:
1836 case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
1837 case LOK_CALLBACK_INVALIDATE_TILES:
1849 case LOK_CALLBACK_TEXT_SELECTION_START:
1850 case LOK_CALLBACK_TEXT_SELECTION_END:
1851 case LOK_CALLBACK_TEXT_SELECTION:
1852 case LOK_CALLBACK_MOUSE_POINTER:
1853 case LOK_CALLBACK_CELL_CURSOR:
1854 case LOK_CALLBACK_CELL_FORMULA:
1855 case LOK_CALLBACK_CELL_ADDRESS:
1856 case LOK_CALLBACK_CURSOR_VISIBLE:
1857 case LOK_CALLBACK_SET_PART:
1858 case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
1859 case LOK_CALLBACK_RULER_UPDATE:
1860 case LOK_CALLBACK_A11Y_FOCUS_CHANGED:
1861 case LOK_CALLBACK_A11Y_CARET_CHANGED:
1862 case LOK_CALLBACK_A11Y_TEXT_SELECTION_CHANGED:
1863 case LOK_CALLBACK_COLOR_PALETTES:
1873 case LOK_CALLBACK_CELL_VIEW_CURSOR:
1874 case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
1875 case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
1876 case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
1877 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
1878 case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
1879 case LOK_CALLBACK_CALC_FUNCTION_LIST:
1880 case LOK_CALLBACK_FORM_FIELD_BUTTON:
1884 const bool hyperLinkException =
type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR &&
1885 aCallbackData.
getPayload().indexOf(
"\"hyperlink\":\"\"") == -1 &&
1886 aCallbackData.
getPayload().indexOf(
"\"hyperlink\": {}") == -1;
1887 if(!hyperLinkException)
1889 const int nViewId = aCallbackData.
getViewId();
1891 return (nViewId == elemData.
getViewId());
1898 case LOK_CALLBACK_INVALIDATE_TILES:
1905 case LOK_CALLBACK_STATE_CHANGED:
1914 if (
name !=
".uno:ModifiedStatus=")
1925 case LOK_CALLBACK_WINDOW:
1930 case LOK_CALLBACK_GRAPHIC_SELECTION:
1935 {
return (elemData.
getPayload().indexOf(
"INPLACE") == -1); });
1942 assert(aCallbackData.
validate() &&
"Cached callback payload object and string mismatch!");
1944 m_queue2.emplace_back(aCallbackData);
1952 std::ostringstream oss;
1956 oss <<
m_queue1.size() <<
" items\n";
1959 for (; it1 !=
m_queue1.end(); ++it1, ++it2)
1960 oss <<
i++ <<
": [" << *it1 <<
"] [" << it2->getPayload() <<
"].\n";
1961 SAL_INFO(
"lok",
"Current Queue: " << oss.str());
1985 = std::find(
m_queue1.rbegin(),
m_queue1.rend(), LOK_CALLBACK_INVALIDATE_TILES);
1994 <<
"] since all tiles need to be invalidated.");
2004 <<
"] since overlaps existing all-parts.");
2013 <<
"] so removing all with part " << rcNew.
m_nPart <<
".");
2022 const auto rcOrig = rcNew;
2024 SAL_INFO(
"lok",
"Have [" <<
type <<
"]: [" << aCallbackData.
getPayload() <<
"] so merging overlapping.");
2030 SAL_INFO(
"lok",
"Nothing to merge between new: "
2031 << rcNew.toString() <<
", and old: " << rcOld.toString());
2038 SAL_INFO(
"lok",
"New " << rcNew.toString() <<
" has " << rcOld.toString()
2040 if (rcNew.m_aRectangle.Contains(rcOld.m_aRectangle) && rcOld.m_nMode == rcNew.m_nMode)
2042 SAL_INFO(
"lok",
"New " << rcNew.toString() <<
" engulfs old "
2043 << rcOld.toString() <<
".");
2047 else if (rcOld.m_nPart == -1)
2050 SAL_INFO(
"lok",
"Old " << rcOld.toString() <<
" has " << rcNew.toString()
2052 if (rcOld.m_aRectangle.Contains(rcNew.m_aRectangle) && rcOld.m_nMode == rcNew.m_nMode)
2054 SAL_INFO(
"lok",
"New " << rcNew.toString() <<
" engulfs old "
2055 << rcOld.toString() <<
".");
2063 const bool bOverlap = !rcOverlap.
IsEmpty() && rcOld.m_nMode == rcNew.
m_nMode;
2064 SAL_INFO(
"lok",
"Merging " << rcNew.
toString() <<
" & " << rcOld.toString()
2066 <<
" Overlap: " << bOverlap);
2079 if (rcNew.m_aRectangle != rcOrig.m_aRectangle)
2081 SAL_INFO(
"lok",
"Replacing: " << rcOrig.toString() <<
" by " << rcNew.toString());
2082 if (rcNew.m_aRectangle.GetWidth() < rcOrig.m_aRectangle.GetWidth()
2083 || rcNew.m_aRectangle.GetHeight() < rcOrig.m_aRectangle.GetHeight())
2085 SAL_WARN(
"lok",
"Error: merged rect smaller.");
2090 aCallbackData.updateRectangleAndPart(rcNew);
2097 const OString& payload = aCallbackData.
getPayload();
2099 boost::property_tree::ptree& aTree = aCallbackData.
setJson(std::string(payload));
2100 const unsigned nLOKWindowId = aTree.get<
unsigned>(
"id", 0);
2101 const std::string aAction = aTree.get<std::string>(
"action",
"");
2102 if (aAction ==
"invalidate")
2104 std::string aRectStr = aTree.get<std::string>(
"rectangle",
"");
2107 if (aRectStr.empty())
2110 const boost::property_tree::ptree& aOldTree = elemData.
getJson();
2111 if (nLOKWindowId == aOldTree.get<
unsigned>(
"id", 0)
2112 && aOldTree.get<std::string>(
"action",
"") ==
"invalidate")
2123 bool invAllExist =
false;
2126 for (;it1 !=
m_queue1.rend(); ++it1, ++it2)
2128 if (*it1 != LOK_CALLBACK_WINDOW)
2130 const boost::property_tree::ptree& aOldTree = it2->getJson();
2131 if (nLOKWindowId == aOldTree.get<
unsigned>(
"id", 0)
2132 && aOldTree.get<std::string>(
"action",
"") ==
"invalidate"
2133 && aOldTree.get<std::string>(
"rectangle",
"").empty())
2143 SAL_INFO(
"lok.dialog",
"Skipping queue ["
2144 <<
type <<
"]: [" << payload
2145 <<
"] since whole window needs to be invalidated.");
2149 std::istringstream aRectStream(aRectStr);
2152 aRectStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight;
2154 bool currentIsRedundant =
false;
2155 removeAll(LOK_CALLBACK_WINDOW, [&aNewRect, &nLOKWindowId,
2157 const boost::property_tree::ptree& aOldTree = elemData.
getJson();
2158 if (aOldTree.get<std::string>(
"action",
"") ==
"invalidate")
2161 std::istringstream aOldRectStream(aOldTree.get<std::string>(
"rectangle",
""));
2162 tools::Long nOldLeft, nOldTop, nOldWidth, nOldHeight;
2164 aOldRectStream >> nOldLeft >> nOldComma >> nOldTop >> nOldComma >> nOldWidth
2165 >> nOldComma >> nOldHeight;
2166 const tools::Rectangle aOldRect = tools::Rectangle(
2167 nOldLeft, nOldTop, nOldLeft + nOldWidth, nOldTop + nOldHeight);
2169 if (nLOKWindowId == aOldTree.get<unsigned>(
"id", 0))
2171 if (aNewRect == aOldRect)
2173 SAL_INFO(
"lok.dialog",
"Duplicate rect [" << aNewRect.toString()
2174 <<
"]. Skipping new.");
2176 currentIsRedundant = true;
2180 else if (aNewRect.Contains(aOldRect))
2182 SAL_INFO(
"lok.dialog",
2183 "New rect [" << aNewRect.toString() <<
"] engulfs old ["
2184 << aOldRect.toString() <<
"]. Replacing old.");
2188 else if (aOldRect.Contains(aNewRect))
2190 SAL_INFO(
"lok.dialog",
2191 "Old rect [" << aOldRect.toString() <<
"] engulfs new ["
2192 << aNewRect.toString() <<
"]. Skipping new.");
2194 currentIsRedundant = true;
2200 const tools::Rectangle aPreMergeRect = aNewRect;
2201 aNewRect.Union(aOldRect);
2202 SAL_INFO(
"lok.dialog",
"Merging rects ["
2203 << aPreMergeRect.toString() <<
"] & ["
2204 << aOldRect.toString() <<
"] = ["
2205 << aNewRect.toString()
2206 <<
"]. Replacing old.");
2217 if (currentIsRedundant)
2220 aTree.put(
"rectangle", aNewRect.toString().getStr());
2222 assert(aCallbackData.
validate() &&
"Validation after setJson failed!");
2225 else if (aAction ==
"created")
2228 removeAll(LOK_CALLBACK_WINDOW,[&nLOKWindowId](
const CallbackData& elemData) {
2229 const boost::property_tree::ptree& aOldTree = elemData.getJson();
2230 if (nLOKWindowId == aOldTree.get<
unsigned>(
"id", 0))
2243 auto xClip = forceSetClipboardForCurrentView(m_pDocument);
2246 pWindow->SetClipboard(xClipboard);
2249 else if (aAction ==
"size_changed")
2253 removeAll(LOK_CALLBACK_WINDOW, [&nLOKWindowId](
const CallbackData& elemData) {
2254 const boost::property_tree::ptree& aOldTree = elemData.getJson();
2255 if (nLOKWindowId == aOldTree.get<
unsigned>(
"id", 0))
2257 const std::string aOldAction = aOldTree.get<std::string>(
"action",
"");
2258 if (aOldAction ==
"invalidate")
2276 assert(viewShell !=
nullptr);
2279 std::vector<bool> updatedTypes;
2281 boost::container::flat_map<int, std::vector<PerViewIdData>> updatedTypesPerViewId;
2288 static const int orderedUpdatedTypes[] = {
2289 LOK_CALLBACK_TEXT_SELECTION_START, LOK_CALLBACK_TEXT_SELECTION_END, LOK_CALLBACK_TEXT_SELECTION };
2292 static const int orderedUpdatedTypesPerViewId[] = {
2293 LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR,
2294 LOK_CALLBACK_INVALIDATE_VIEW_CURSOR,
2295 LOK_CALLBACK_TEXT_VIEW_SELECTION };
2297 for(
int type : orderedUpdatedTypes )
2304 for(
const auto& it : updatedTypesPerViewId )
2306 int viewId = it.first;
2307 const std::vector<PerViewIdData>& types = it.second;
2308 for(
int type : orderedUpdatedTypesPerViewId )
2313 const int sourceViewId = types[
type ].sourceViewId;
2316 assert(sourceViewId >= 0);
2320 if(sourceViewShell ==
nullptr)
2322 SAL_INFO(
"lok",
"View #" << sourceViewId <<
" no longer found for updated event [" <<
type <<
"]");
2333 if (
type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR)
2336 viewShell = viewShell2;
2343 m_queue2.emplace_back(callbackData);
2345 <<
"] to have " <<
m_queue1.size() <<
" entries.");
2361 viewShell->flushPendingLOKInvalidateTiles();
2364 std::unique_lock<std::recursive_mutex>
lock(
m_mutex);
2372 for (; it1 !=
m_queue1.end(); ++it1, ++it2)
2374 const int type = *it1;
2375 const auto& payload = it2->getPayload();
2378 SAL_INFO(
"lok",
"processing event: [" <<
type <<
',' << viewId <<
"]: [" << payload <<
"].");
2385 if (
type == LOK_CALLBACK_STATE_CHANGED &&
2386 (
idx = payload.indexOf(
'=')) != -1)
2388 OString key = payload.copy(0,
idx);
2389 OString
value = payload.copy(
idx+1);
2394 if (stateIt->second ==
value)
2396 SAL_INFO(
"lok",
"Skipping new state duplicate: [" <<
type <<
"]: [" << payload <<
"].");
2399 SAL_INFO(
"lok",
"Replacing a state element [" <<
type <<
"]: [" << payload <<
"].");
2400 stateIt->second =
value;
2404 SAL_INFO(
"lok",
"Inserted a new state element: [" <<
type <<
"]: [" << payload <<
"]");
2414 if (stateIt->second == payload)
2416 SAL_INFO(
"lok",
"Skipping duplicate [" <<
type <<
"]: [" << payload <<
"].");
2419 stateIt->second = payload;
2428 auto& states = statesIt->second;
2429 const auto stateIt = states.find(
type);
2430 if (stateIt != states.end())
2433 if (stateIt->second == payload)
2435 SAL_INFO(
"lok",
"Skipping view duplicate [" <<
type <<
',' << viewId <<
"]: [" << payload <<
"].");
2439 SAL_INFO(
"lok",
"Replacing an element in view states [" <<
type <<
',' << viewId <<
"]: [" << payload <<
"].");
2440 stateIt->second = payload;
2444 SAL_INFO(
"lok",
"Inserted a new element in view states: [" <<
type <<
',' << viewId <<
"]: [" << payload <<
"]");
2445 states.emplace(
type, payload);
2470 bool bErased =
false;
2486 bool bErased =
false;
2494 if (rTestFunc(*it2))
2511 result.first->second.clear();
2535static void lo_destroy (LibreOfficeKit* pThis);
2536static int lo_initialize (LibreOfficeKit* pThis,
const char* pInstallPath,
const char* pUserProfilePath);
2537static LibreOfficeKitDocument*
lo_documentLoad (LibreOfficeKit* pThis,
const char* pURL);
2542 const char* pOptions);
2544 LibreOfficeKitCallback pCallback,
2550 const char* pPassword);
2552static int lo_runMacro (LibreOfficeKit* pThis,
const char* pURL);
2556 const unsigned char* pCertificateBinary,
2557 const int nCertificateBinarySize,
2558 const unsigned char* pPrivateKeyBinary,
2559 const int nPrivateKeyBinarySize);
2562 const char* pFilePath);
2564static void lo_trimMemory(LibreOfficeKit* pThis,
int nTarget);
2567 LibreOfficeKitPollCallback pPollCallback,
2568 LibreOfficeKitWakeCallback pWakeCallback,
2572 unsigned long long int nLOKWindowId,
2573 const char* pArguments);
2575static void lo_setOption(LibreOfficeKit* pThis,
const char* pOption,
const char* pValue);
2577static void lo_dumpState(LibreOfficeKit* pThis,
const char* pOptions,
char** pState);
2582 , mpCallback(nullptr)
2583 , mpCallbackData(nullptr)
2584 , mOptionalFeatures(0)
2622void setLanguageAndLocale(OUString
const & aLangISO)
2632 if (sFormat == u
"pdf")
2635 rFilterDataMap[
"ExportBookmarks"] <<=
true;
2657 static int nDocumentIdCounter = 0;
2660 pLib->maLastExceptionMsg.clear();
2665 pLib->maLastExceptionMsg =
"Filename to load was not provided.";
2666 SAL_INFO(
"lok",
"URL for load is empty");
2670 pLib->maLastExceptionMsg.clear();
2674 pLib->maLastExceptionMsg =
"ComponentContext is not available";
2675 SAL_INFO(
"lok",
"ComponentContext is not available");
2681 if (!xComponentLoader.is())
2683 pLib->maLastExceptionMsg =
"ComponentLoader is not available";
2684 SAL_INFO(
"lok",
"ComponentLoader is not available");
2696 if (!aLanguage.isEmpty() && isValidLangTag)
2698 static bool isLoading =
true;
2711 SAL_INFO(
"lok",
"Set document language to " << aLanguage);
2714 setLanguageAndLocale(aLanguage);
2721 if (!aTimezone.isEmpty())
2728 const char* tz = ::getenv(
"TZ");
2732 OStringToOUString(tz, RTL_TEXTENCODING_UTF8));
2740 const OUString aDeviceFormFactor =
extractParameter(aOptions,
u"DeviceFormFactor");
2744 if (!aBatch.isEmpty())
2749 const OUString sFilterOptions = aOptions;
2753 auto const pair(
pLib->mInteractionMap.insert(std::make_pair(
aURL.toUtf8(), pInteraction)));
2757 pLib->mInteractionMap.erase(aURL.toUtf8());
2762 int nMacroSecurityLevel = 1;
2763 const OUString aMacroSecurityLevel =
extractParameter(aOptions,
u"MacroSecurityLevel");
2764 if (!aMacroSecurityLevel.isEmpty())
2767 sal_uInt32 nFormat = 1;
2769 if (aFormatter.
IsNumberFormat(aMacroSecurityLevel, nFormat, nNumber))
2770 nMacroSecurityLevel =
static_cast<int>(nNumber);
2774#if defined(ANDROID) && HAVE_FEATURE_ANDROID_LOK
2775 sal_Int16 nMacroExecMode = document::MacroExecMode::USE_CONFIG;
2777 const OUString aEnableMacrosExecution =
extractParameter(aOptions,
u"EnableMacrosExecution");
2778 sal_Int16 nMacroExecMode = aEnableMacrosExecution ==
"true" ? document::MacroExecMode::USE_CONFIG :
2779 document::MacroExecMode::NEVER_EXECUTE;
2801 const int nThisDocumentId = nDocumentIdCounter++;
2807 assert(!xComponent.is() || pair.second);
2809 if (!xComponent.is())
2811 pLib->maLastExceptionMsg =
"loadComponentFromURL returned an empty reference";
2812 SAL_INFO(
"lok",
"Document can't be loaded - " <<
pLib->maLastExceptionMsg);
2819 if (
pLib->mpCallback)
2822 pLib->mpCallback(LOK_CALLBACK_SIGNATURE_STATUS, OString::number(
nState).getStr(),
pLib->mpCallbackData);
2827 if (aFontMappingUseData.size() > 0)
2829 SAL_INFO(
"lok.fontsubst",
"================ Original substitutions:");
2830 for (
const auto &
i : aFontMappingUseData)
2832 SAL_INFO(
"lok.fontsubst",
i.mOriginalFont);
2833 for (
const auto &j :
i.mUsedFonts)
2834 SAL_INFO(
"lok.fontsubst",
" " << j);
2842 aFontMappingUseData.erase
2843 (std::remove_if(aFontMappingUseData.begin(), aFontMappingUseData.end(),
2855 if (x.mOriginalFont.indexOf(
'/') == -1)
2856 for (const auto &j : x.mUsedFonts)
2857 if (j == x.mOriginalFont ||
2858 j.startsWith(Concat2View(x.mOriginalFont +
"/")))
2863 aFontMappingUseData.end());
2869 aFontMappingUseData.erase
2870 (std::remove_if(aFontMappingUseData.begin(), aFontMappingUseData.end(),
2877 if (x.mOriginalFont.indexOf(
'/') == -1)
2878 for (const auto &j : x.mUsedFonts)
2879 if ((x.mOriginalFont ==
"Arial" &&
2880 j.startsWith(
"Liberation Sans/")) ||
2881 (x.mOriginalFont ==
"Times New Roman" &&
2882 j.startsWith(
"Liberation Serif/")) ||
2883 (x.mOriginalFont ==
"Courier New" &&
2884 j.startsWith(
"Liberation Mono/")) ||
2885 (x.mOriginalFont ==
"Arial Narrow" &&
2886 j.startsWith(
"Liberation Sans Narrow/")) ||
2887 (x.mOriginalFont ==
"Cambria" &&
2888 j.startsWith(
"Caladea/")) ||
2889 (x.mOriginalFont ==
"Calibri" &&
2890 j.startsWith(
"Carlito/")) ||
2891 (x.mOriginalFont ==
"Palatino Linotype" &&
2892 j.startsWith(
"P052/")) ||
2896 (x.mOriginalFont ==
"Symbol" &&
2897 j.startsWith(
"OpenSymbol/")))
2904 aFontMappingUseData.end());
2906 if (aFontMappingUseData.size() > 0)
2908 SAL_INFO(
"lok.fontsubst",
"================ Pruned substitutions:");
2909 for (
const auto &
i : aFontMappingUseData)
2911 SAL_INFO(
"lok.fontsubst",
i.mOriginalFont);
2912 for (
const auto &j :
i.mUsedFonts)
2913 SAL_INFO(
"lok.fontsubst",
" " << j);
2917 for (std::size_t
i = 0;
i < aFontMappingUseData.size(); ++
i)
2919 pDocument->
maFontsMissing.insert(aFontMappingUseData[
i].mOriginalFont);
2924 catch (
const uno::Exception& exception)
2926 pLib->maLastExceptionMsg = exception.Message;
2940 pLib->maLastExceptionMsg.clear();
2942 OUString sURL( pURL, strlen(pURL), RTL_TEXTENCODING_UTF8 );
2945 pLib->maLastExceptionMsg =
"Macro to run was not provided.";
2946 SAL_INFO(
"lok",
"Macro URL is empty");
2950 if (!sURL.startsWith(
"macro://"))
2952 pLib->maLastExceptionMsg =
"This doesn't look like macro URL";
2953 SAL_INFO(
"lok",
"Macro URL is invalid");
2957 pLib->maLastExceptionMsg.clear();
2961 pLib->maLastExceptionMsg =
"ComponentContext is not available";
2962 SAL_INFO(
"lok",
"ComponentContext is not available");
2967 aURL.Complete = sURL;
2972 xParser->parseStrict(
aURL );
2976 if (!xComponentLoader.is())
2978 pLib->maLastExceptionMsg =
"ComponentLoader is not available";
2979 SAL_INFO(
"lok",
"ComponentLoader is not available");
2990 xDP.set(
xSFactory->createInstance(
"com.sun.star.comp.sfx2.SfxMacroLoader"), uno::UNO_QUERY );
2995 pLib->maLastExceptionMsg =
"Macro loader is not available";
2996 SAL_INFO(
"lok",
"Macro loader is not available");
3002 css::beans::PropertyValue aErr;
3003 uno::Any aRet = xSyncDisp->dispatchWithReturnValue(
aURL, aEmpty );
3006 if (aErr.Name ==
"ErrorCode")
3008 sal_uInt32 nErrCode = 0;
3009 aErr.
Value >>= nErrCode;
3011 pLib->maLastExceptionMsg =
"An error occurred running macro (error code: " + OUString::number( nErrCode ) +
")";
3012 SAL_INFO(
"lok",
"Macro execution terminated with error code " << nErrCode);
3022 const unsigned char* pCertificateBinary,
3023 const int nCertificateBinarySize,
3024 const unsigned char* pPrivateKeyBinary,
3025 const int nPrivateKeyBinarySize)
3038 std::string aCertificateString(
reinterpret_cast<const char*
>(pCertificateBinary), nCertificateBinarySize);
3039 std::string aCertificateBase64String = extractCertificate(aCertificateString);
3040 if (!aCertificateBase64String.empty())
3042 OUString aBase64OUString = OUString::createFromAscii(aCertificateBase64String);
3047 aCertificateSequence.realloc(nCertificateBinarySize);
3048 std::copy(pCertificateBinary, pCertificateBinary + nCertificateBinarySize, aCertificateSequence.getArray());
3052 std::string aPrivateKeyString(
reinterpret_cast<const char*
>(pPrivateKeyBinary), nPrivateKeyBinarySize);
3053 std::string aPrivateKeyBase64String = extractPrivateKey(aPrivateKeyString);
3054 if (!aPrivateKeyBase64String.empty())
3056 OUString aBase64OUString = OUString::createFromAscii(aPrivateKeyBase64String);
3061 aPrivateKeySequence.realloc(nPrivateKeyBinarySize);
3062 std::copy(pPrivateKeyBinary, pPrivateKeyBinary + nPrivateKeyBinarySize, aPrivateKeySequence.getArray());
3067 if (!xSecurityContext.is())
3073 if (!xCertificateCreator.is())
3078 if (!xCertificate.is())
3095 if (!
aURL.isEmpty())
3097 if (xComponentLoader.is())
3103 {
"Hidden", css::uno::Any(
true)},
3104 {
"ReadOnly", css::uno::Any(
true)}
3106 xComp = xComponentLoader->loadComponentFromURL(
aURL,
"_blank", 0, aFilterOptions );
3108 catch (
const lang::IllegalArgumentException&
ex )
3110 SAL_WARN(
"lok",
"lo_extractRequest: IllegalArgumentException: " <<
ex.Message);
3116 SAL_WARN(
"lok",
"lo_extractRequest: Exception on loadComponentFromURL, url= " <<
aURL);
3129 auto aNode = aJson.
startNode(
"Targets");
3153#ifdef HAVE_MALLOC_TRIM
3160 LibreOfficeKitCallback pCallback,
3169 pLib->maLastExceptionMsg.clear();
3175static int doc_saveAs(LibreOfficeKitDocument* pThis,
const char* sUrl,
const char* pFormat,
const char* pFilterOptions)
3192 SAL_INFO(
"lok",
"URL for save is empty");
3198 const ExtensionMap* pMap;
3202 case LOK_DOCTYPE_SPREADSHEET:
3205 case LOK_DOCTYPE_PRESENTATION:
3208 case LOK_DOCTYPE_DRAWING:
3211 case LOK_DOCTYPE_TEXT:
3214 case LOK_DOCTYPE_OTHER:
3216 SAL_INFO(
"lok",
"Can't save document - unsupported document type.");
3220 if (pFormat ==
nullptr)
3223 sal_Int32
idx =
aURL.lastIndexOf(
".");
3226 sFormat =
aURL.copy(
idx + 1 );
3235 OUString aFilterName;
3236 for (sal_Int32
i = 0; pMap[
i].extn; ++
i)
3238 if (sFormat.equalsIgnoreAsciiCaseAscii(pMap[
i].extn))
3244 if (aFilterName.isEmpty())
3250 OUString aFilterOptions =
getUString(pFilterOptions);
3254 OUString watermarkText;
3255 std::u16string_view sFullSheetPreview;
3257 if ((
aIndex = aFilterOptions.indexOf(
",Watermark=")) >= 0)
3259 int bIndex = aFilterOptions.indexOf(
"WATERMARKEND");
3260 watermarkText = aFilterOptions.subView(
aIndex+11, bIndex-(
aIndex+11));
3261 aFilterOptions = OUString::Concat(aFilterOptions.subView(0,
aIndex)) + aFilterOptions.subView(bIndex+12);
3264 if ((
aIndex = aFilterOptions.indexOf(
",FullSheetPreview=")) >= 0)
3266 int bIndex = aFilterOptions.indexOf(
"FULLSHEETPREVEND");
3267 sFullSheetPreview = aFilterOptions.subView(
aIndex+18, bIndex-(
aIndex+18));
3268 aFilterOptions = OUString::Concat(aFilterOptions.subView(0,
aIndex)) + aFilterOptions.subView(bIndex+16);
3271 bool bFullSheetPreview = sFullSheetPreview ==
u"true";
3273 OUString filePassword;
3274 if ((
aIndex = aFilterOptions.indexOf(
",Password=")) >= 0)
3276 int bIndex = aFilterOptions.indexOf(
"PASSWORDEND");
3277 filePassword = aFilterOptions.subView(
aIndex + 10, bIndex - (
aIndex + 10));
3278 aFilterOptions = OUString::Concat(aFilterOptions.subView(0,
aIndex))
3279 + aFilterOptions.subView(bIndex + 11);
3281 OUString filePasswordToModify;
3282 if ((
aIndex = aFilterOptions.indexOf(
",PasswordToModify=")) >= 0)
3284 int bIndex = aFilterOptions.indexOf(
"PASSWORDTOMODIFYEND");
3285 filePassword = aFilterOptions.subView(
aIndex + 18, bIndex - (
aIndex + 18));
3286 aFilterOptions = OUString::Concat(aFilterOptions.subView(0,
aIndex))
3287 + aFilterOptions.subView(bIndex + 19);
3292 sal_Int32 pdfVer = 0;
3293 if ((
aIndex = aFilterOptions.indexOf(
",PDFVer=")) >= 0)
3295 int bIndex = aFilterOptions.indexOf(
"PDFVEREND");
3296 std::u16string_view sPdfVer = aFilterOptions.subView(
aIndex+8, bIndex-(
aIndex+8));
3297 aFilterOptions = OUString::Concat(aFilterOptions.subView(0,
aIndex)) + aFilterOptions.subView(bIndex+9);
3322 std::vector<OUString> aFilteredOptionVec;
3323 bool bTakeOwnership =
false;
3325 for (
const auto& rOption : aOptionSeq)
3327 if (rOption ==
"TakeOwnership")
3328 bTakeOwnership =
true;
3329 else if (rOption ==
"NoFileSync")
3330 aSaveMediaDescriptor[
"NoFileSync"] <<=
true;
3332 aFilteredOptionVec.push_back(rOption);
3335 aSaveMediaDescriptor[
"Overwrite"] <<=
true;
3336 aSaveMediaDescriptor[
"FilterName"] <<= aFilterName;
3338 auto aFilteredOptionSeq = comphelper::containerToSequence<OUString>(aFilteredOptionVec);
3340 aSaveMediaDescriptor[MediaDescriptor::PROP_FILTEROPTIONS] <<= aFilterOptions;
3346 if (!aFilterOptions.startsWith(
"{"))
3348 setFormatSpecificFilterData(sFormat, aFilterDataMap);
3351 if (!watermarkText.isEmpty())
3352 aFilterDataMap[
"TiledWatermark"] <<= watermarkText;
3354 if (bFullSheetPreview)
3355 aFilterDataMap[
"SinglePageSheets"] <<=
true;
3358 aFilterDataMap[
"SelectPdfVersion"] <<= pdfVer;
3360 if (!aFilterDataMap.
empty())
3364 if (!filePassword.isEmpty())
3365 aSaveMediaDescriptor[
"Password"] <<= filePassword;
3366 if (!filePasswordToModify.isEmpty())
3367 aSaveMediaDescriptor[
"PasswordToModify"] <<= filePasswordToModify;
3377 aSaveMediaDescriptor[MediaDescriptor::PROP_INTERACTIONHANDLER] <<= xInteraction;
3382 xStorable->storeAsURL(
aURL, aSaveMediaDescriptor.getAsConstPropertyValueList());
3384 xStorable->storeToURL(
aURL, aSaveMediaDescriptor.getAsConstPropertyValueList());
3388 catch (
const uno::Exception& exception)
3406 OUString sUnoCommands[] =
3408 OUString(
".uno:AlignLeft"),
3409 OUString(
".uno:AlignHorizontalCenter"),
3410 OUString(
".uno:AlignRight"),
3411 OUString(
".uno:BackColor"),
3412 OUString(
".uno:BackgroundColor"),
3413 OUString(
".uno:TableCellBackgroundColor"),
3414 OUString(
".uno:Bold"),
3415 OUString(
".uno:CenterPara"),
3416 OUString(
".uno:CharBackColor"),
3417 OUString(
".uno:CharBackgroundExt"),
3418 OUString(
".uno:CharFontName"),
3419 OUString(
".uno:Color"),
3420 OUString(
".uno:ControlCodes"),
3421 OUString(
".uno:DecrementIndent"),
3422 OUString(
".uno:DefaultBullet"),
3423 OUString(
".uno:DefaultNumbering"),
3424 OUString(
".uno:FontColor"),
3425 OUString(
".uno:FontHeight"),
3426 OUString(
".uno:IncrementIndent"),
3427 OUString(
".uno:Italic"),
3428 OUString(
".uno:JustifyPara"),
3429 OUString(
".uno:JumpToMark"),
3430 OUString(
".uno:OutlineFont"),
3431 OUString(
".uno:LeftPara"),
3432 OUString(
".uno:LanguageStatus"),
3433 OUString(
".uno:RightPara"),
3434 OUString(
".uno:Shadowed"),
3435 OUString(
".uno:SubScript"),
3436 OUString(
".uno:SuperScript"),
3437 OUString(
".uno:Strikeout"),
3438 OUString(
".uno:StyleApply"),
3439 OUString(
".uno:Underline"),
3440 OUString(
".uno:ModifiedStatus"),
3441 OUString(
".uno:Undo"),
3442 OUString(
".uno:Redo"),
3443 OUString(
".uno:InsertPage"),
3444 OUString(
".uno:DeletePage"),
3445 OUString(
".uno:DuplicatePage"),
3446 OUString(
".uno:InsertSlide"),
3447 OUString(
".uno:DeleteSlide"),
3448 OUString(
".uno:DuplicateSlide"),
3449 OUString(
".uno:ChangeTheme"),
3450 OUString(
".uno:Cut"),
3451 OUString(
".uno:Copy"),
3452 OUString(
".uno:Paste"),
3453 OUString(
".uno:SelectAll"),
3454 OUString(
".uno:ReplyComment"),
3455 OUString(
".uno:ResolveComment"),
3456 OUString(
".uno:ResolveCommentThread"),
3457 OUString(
".uno:InsertRowsBefore"),
3458 OUString(
".uno:InsertRowsAfter"),
3459 OUString(
".uno:InsertColumnsBefore"),
3460 OUString(
".uno:InsertColumnsAfter"),
3461 OUString(
".uno:DeleteRows"),
3462 OUString(
".uno:DeleteColumns"),
3463 OUString(
".uno:DeleteTable"),
3464 OUString(
".uno:SelectTable"),
3465 OUString(
".uno:EntireRow"),
3466 OUString(
".uno:EntireColumn"),
3467 OUString(
".uno:EntireCell"),
3468 OUString(
".uno:AssignLayout"),
3469 OUString(
".uno:StatusDocPos"),
3470 OUString(
".uno:RowColSelCount"),
3471 OUString(
".uno:StatusPageStyle"),
3472 OUString(
".uno:InsertMode"),
3473 OUString(
".uno:SpellOnline"),
3474 OUString(
".uno:StatusSelectionMode"),
3475 OUString(
".uno:StateTableCell"),
3476 OUString(
".uno:StatusBarFunc"),
3477 OUString(
".uno:StatePageNumber"),
3478 OUString(
".uno:StateWordCount"),
3479 OUString(
".uno:SelectionMode"),
3480 OUString(
".uno:PageStatus"),
3481 OUString(
".uno:LayoutStatus"),
3482 OUString(
".uno:Scale"),
3483 OUString(
".uno:Context"),
3484 OUString(
".uno:WrapText"),
3485 OUString(
".uno:ToggleMergeCells"),
3486 OUString(
".uno:NumberFormatCurrency"),
3487 OUString(
".uno:NumberFormatPercent"),
3488 OUString(
".uno:NumberFormatDecimal"),
3489 OUString(
".uno:NumberFormatIncDecimals"),
3490 OUString(
".uno:NumberFormatDecDecimals"),
3491 OUString(
".uno:NumberFormatDate"),
3492 OUString(
".uno:EditHeaderAndFooter"),
3493 OUString(
".uno:FrameLineColor"),
3494 OUString(
".uno:SortAscending"),
3495 OUString(
".uno:SortDescending"),
3496 OUString(
".uno:TrackChanges"),
3497 OUString(
".uno:ShowTrackedChanges"),
3498 OUString(
".uno:NextTrackedChange"),
3499 OUString(
".uno:PreviousTrackedChange"),
3500 OUString(
".uno:AcceptAllTrackedChanges"),
3501 OUString(
".uno:RejectAllTrackedChanges"),
3502 OUString(
".uno:TableDialog"),
3503 OUString(
".uno:FormatCellDialog"),
3504 OUString(
".uno:FontDialog"),
3505 OUString(
".uno:ParagraphDialog"),
3506 OUString(
".uno:OutlineBullet"),
3507 OUString(
".uno:InsertIndexesEntry"),
3508 OUString(
".uno:DocumentRepair"),
3509 OUString(
".uno:TransformDialog"),
3510 OUString(
".uno:InsertPageHeader"),
3511 OUString(
".uno:InsertPageFooter"),
3512 OUString(
".uno:OnlineAutoFormat"),
3513 OUString(
".uno:InsertObjectChart"),
3514 OUString(
".uno:InsertSection"),
3515 OUString(
".uno:InsertAnnotation"),
3516 OUString(
".uno:DeleteAnnotation"),
3517 OUString(
".uno:InsertPagebreak"),
3518 OUString(
".uno:InsertColumnBreak"),
3519 OUString(
".uno:HyperlinkDialog"),
3520 OUString(
".uno:InsertSymbol"),
3521 OUString(
".uno:EditRegion"),
3522 OUString(
".uno:ThesaurusDialog"),
3523 OUString(
".uno:FormatArea"),
3524 OUString(
".uno:FormatLine"),
3525 OUString(
".uno:FormatColumns"),
3526 OUString(
".uno:Watermark"),
3527 OUString(
".uno:ResetAttributes"),
3528 OUString(
".uno:Orientation"),
3529 OUString(
".uno:ObjectAlignLeft"),
3530 OUString(
".uno:ObjectAlignRight"),
3531 OUString(
".uno:AlignCenter"),
3532 OUString(
".uno:TransformPosX"),
3533 OUString(
".uno:TransformPosY"),
3534 OUString(
".uno:TransformWidth"),
3535 OUString(
".uno:TransformHeight"),
3536 OUString(
".uno:ObjectBackOne"),
3537 OUString(
".uno:SendToBack"),
3538 OUString(
".uno:ObjectForwardOne"),
3539 OUString(
".uno:BringToFront"),
3540 OUString(
".uno:WrapRight"),
3541 OUString(
".uno:WrapThrough"),
3542 OUString(
".uno:WrapLeft"),
3543 OUString(
".uno:WrapIdeal"),
3544 OUString(
".uno:WrapOn"),
3545 OUString(
".uno:WrapOff"),
3546 OUString(
".uno:UpdateCurIndex"),
3547 OUString(
".uno:InsertCaptionDialog"),
3548 OUString(
".uno:FormatGroup"),
3549 OUString(
".uno:SplitTable"),
3550 OUString(
".uno:SplitCell"),
3551 OUString(
".uno:MergeCells"),
3552 OUString(
".uno:DeleteNote"),
3553 OUString(
".uno:AcceptChanges"),
3554 OUString(
".uno:FormatPaintbrush"),
3555 OUString(
".uno:SetDefault"),
3556 OUString(
".uno:ParaLeftToRight"),
3557 OUString(
".uno:ParaRightToLeft"),
3558 OUString(
".uno:ParaspaceIncrease"),
3559 OUString(
".uno:ParaspaceDecrease"),
3560 OUString(
".uno:AcceptTrackedChange"),
3561 OUString(
".uno:RejectTrackedChange"),
3562 OUString(
".uno:ShowResolvedAnnotations"),
3563 OUString(
".uno:InsertBreak"),
3564 OUString(
".uno:InsertEndnote"),
3565 OUString(
".uno:InsertFootnote"),
3566 OUString(
".uno:InsertReferenceField"),
3567 OUString(
".uno:InsertBookmark"),
3568 OUString(
".uno:InsertAuthoritiesEntry"),
3569 OUString(
".uno:InsertMultiIndex"),
3570 OUString(
".uno:InsertField"),
3571 OUString(
".uno:PageNumberWizard"),
3572 OUString(
".uno:InsertPageNumberField"),
3573 OUString(
".uno:InsertPageCountField"),
3574 OUString(
".uno:InsertDateField"),
3575 OUString(
".uno:InsertTitleField"),
3576 OUString(
".uno:InsertFieldCtrl"),
3577 OUString(
".uno:CharmapControl"),
3578 OUString(
".uno:EnterGroup"),
3579 OUString(
".uno:LeaveGroup"),
3580 OUString(
".uno:AlignUp"),
3581 OUString(
".uno:AlignMiddle"),
3582 OUString(
".uno:AlignDown"),
3583 OUString(
".uno:TraceChangeMode"),
3584 OUString(
".uno:Combine"),
3585 OUString(
".uno:Merge"),
3586 OUString(
".uno:Dismantle"),
3587 OUString(
".uno:Substract"),
3588 OUString(
".uno:DistributeSelection"),
3589 OUString(
".uno:Intersect"),
3590 OUString(
".uno:BorderInner"),
3591 OUString(
".uno:BorderOuter"),
3592 OUString(
".uno:FreezePanes"),
3593 OUString(
".uno:FreezePanesColumn"),
3594 OUString(
".uno:FreezePanesRow"),
3595 OUString(
".uno:Sidebar"),
3596 OUString(
".uno:SheetRightToLeft"),
3597 OUString(
".uno:RunMacro"),
3598 OUString(
".uno:SpacePara1"),
3599 OUString(
".uno:SpacePara15"),
3600 OUString(
".uno:SpacePara2"),
3601 OUString(
".uno:InsertSparkline"),
3602 OUString(
".uno:DeleteSparkline"),
3603 OUString(
".uno:DeleteSparklineGroup"),
3604 OUString(
".uno:EditSparklineGroup"),
3605 OUString(
".uno:EditSparkline"),
3606 OUString(
".uno:GroupSparklines"),
3607 OUString(
".uno:UngroupSparklines"),
3608 OUString(
".uno:FormatSparklineMenu"),
3609 OUString(
".uno:Protect"),
3610 OUString(
".uno:UnsetCellsReadOnly"),
3611 OUString(
".uno:ContentControlProperties"),
3612 OUString(
".uno:InsertCheckboxContentControl"),
3613 OUString(
".uno:InsertContentControl"),
3614 OUString(
".uno:InsertDateContentControl"),
3615 OUString(
".uno:InsertDropdownContentControl"),
3616 OUString(
".uno:InsertPlainTextContentControl"),
3617 OUString(
".uno:InsertPictureContentControl"),
3618 OUString(
".uno:DataFilterAutoFilter")
3621 util::URL aCommandURL;
3628 SAL_WARN(
"lok",
"iniUnoCommands: No Frame-Controller created.");
3636 SAL_WARN(
"lok",
"iniUnoCommands: Component context is not available");
3640#if !defined IOS && !defined ANDROID && !defined __EMSCRIPTEN__
3642 if (!xSEInitializer.is())
3644 SAL_WARN(
"lok",
"iniUnoCommands: XSEInitializer is not available");
3649 xSEInitializer->createSecurityContext(OUString());
3650 if (!xSecurityContext.is())
3652 SAL_WARN(
"lok",
"iniUnoCommands: failed to create security context");
3659 for (
const auto & sUnoCommand : sUnoCommands)
3661 aCommandURL.Complete = sUnoCommand;
3662 xParser->parseStrict(aCommandURL);
3679 return getDocumentType(pThis);
3688 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3695 return pDoc->getParts();
3705 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3712 return pDoc->getPart();
3715static void doc_setPartImpl(LibreOfficeKitDocument* pThis,
int nPart,
bool bAllowChangeFocus =
true)
3722 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3729 pDoc->setPart( nPart, bAllowChangeFocus );
3742 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3758 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3765 pDoc->selectPart( nPart, nSelect );
3774 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3781 pDoc->moveSelectedParts(nPosition, bDuplicate);
3791 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3806 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3826 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3848 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3865 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3883 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3891 int nCurrentPart = pDoc->getPart();
3893 pDoc->setPartMode(nPartMode);
3904 if ( nCurrentPart < pDoc->getParts() )
3906 pDoc->setPart( nCurrentPart );
3921 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3928 return pDoc->getEditMode();
3932 unsigned char* pBuffer,
3933 const int nCanvasWidth,
const int nCanvasHeight,
3934 const int nTilePosX,
const int nTilePosY,
3935 const int nTileWidth,
const int nTileHeight)
3942 SAL_INFO(
"lok.tiledrendering",
"paintTile: painting [" << nTileWidth <<
"x" << nTileHeight <<
3943 "]@(" << nTilePosX <<
", " << nTilePosY <<
") to [" <<
3944 nCanvasWidth <<
"x" << nCanvasHeight <<
"]px" );
3946 ITiledRenderable* pDoc = getTiledRenderable(pThis);
3953#if defined(UNX) && !defined(MACOSX) || defined(_WIN32)
3963 double fDPIScale = 1.0;
3967 CGContextRef pCGContext = CGBitmapContextCreate(pBuffer, nCanvasWidth, nCanvasHeight, 8,
3968 nCanvasWidth * 4, CGColorSpaceCreateDeviceRGB(),
3969 kCGImageAlphaPremultipliedLast | kCGImageByteOrder32Big);
3971 CGContextTranslateCTM(pCGContext, 0, nCanvasHeight);
3972 CGContextScaleCTM(pCGContext, fDPIScale, -fDPIScale);
3974 SAL_INFO(
"lok.tiledrendering",
"doc_paintTile: painting [" << nTileWidth <<
"x" << nTileHeight <<
3975 "]@(" << nTilePosX <<
", " << nTilePosY <<
") to [" <<
3976 nCanvasWidth <<
"x" << nCanvasHeight <<
"]px" );
3978 Size aCanvasSize(nCanvasWidth, nCanvasHeight);
3981 aData.rCGContext =
reinterpret_cast<CGContextRef
>(pCGContext);
3985 pDevice->SetOutputSizePixel(aCanvasSize);
3986 pDoc->paintTile(*pDevice, aCanvasSize.
Width(), aCanvasSize.
Height(),
3987 nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3989 CGContextRelease(pCGContext);
3996 pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(
4000 pDoc->paintTile(*pDevice, nCanvasWidth, nCanvasHeight,
4001 nTilePosX, nTilePosY, nTileWidth, nTileHeight);
4003 static bool bDebug = getenv(
"LOK_DEBUG_TILES") !=
nullptr;
4008 aRect = pDevice->PixelToLogic(aRect);
4009 pDevice->Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
4011 pDevice->SetLineColor();
4012 pDevice->DrawRect(aRect);
4018 pDevice->EnableMapMode(
false);
4019 BitmapEx aBmpEx = pDevice->GetBitmapEx({ 0, 0 }, { nCanvasWidth, nCanvasHeight });
4025 assert(sraBmp->Height() == nCanvasHeight);
4026 assert(sraBmp->Width() == nCanvasWidth);
4027 assert(!sraAlpha || sraBmp->Height() == sraAlpha->Height());
4028 assert(!sraAlpha || sraBmp->Width() == sraAlpha->Width());
4032 Scanline dataBmp = sraBmp->GetScanline(
y);
4033 Scanline dataAlpha = sraAlpha ? sraAlpha->GetScanline(
y) :
nullptr;
4037 sal_uInt8 alpha = dataAlpha ? sraAlpha->GetPixelFromData(dataAlpha,
x).GetBlue() : 255;
4053 unsigned char* pBuffer,
4056 const int nCanvasWidth,
const int nCanvasHeight,
4057 const int nTilePosX,
const int nTilePosY,
4058 const int nTileWidth,
const int nTileHeight)
4065 SAL_INFO(
"lok.tiledrendering",
"paintPartTile: painting @ " << nPart <<
" : " << nMode <<
" ["
4066 << nTileWidth <<
"x" << nTileHeight <<
"]@("
4067 << nTilePosX <<
", " << nTilePosY <<
") to ["
4068 << nCanvasWidth <<
"x" << nCanvasHeight <<
"]px" );
4073 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4080 if (nOrigViewId < 0)
4091 std::vector<int> viewIds(viewCount);
4094 nOrigViewId = viewIds[0];
4099 if (nOrigViewId >= 0)
4103 handlerIt->second->disableCallbacks();
4111 const bool isText = (aType == LOK_DOCTYPE_TEXT);
4112 const bool isCalc = (aType == LOK_DOCTYPE_SPREADSHEET);
4113 int nOrigEditMode = 0;
4114 bool bPaintTextEdit =
true;
4115 int nViewId = nOrigViewId;
4116 int nLastNonEditorView = -1;
4117 int nViewMatchingMode = -1;
4122 if (nPart !=
doc_getPart(pThis) || nMode != pDoc->getEditMode())
4132 if (pViewShell->
getPart() == nPart &&
4137 nViewMatchingMode = nViewId;
4138 nLastNonEditorView = nViewId;
4142 else if (pViewShell->
getEditMode() == nMode && !bIsInEdit)
4155 if (nViewMatchingMode >= 0 && nViewMatchingMode != nViewId)
4157 nViewId = nViewMatchingMode;
4160 else if (!isCalc && nLastNonEditorView >= 0 && nLastNonEditorView != nViewId &&
4161 pCurrentViewShell && pCurrentViewShell->
GetDrawView() &&
4164 nViewId = nLastNonEditorView;
4169 if (nViewId != nOrigViewId && nViewId >= 0)
4173 handlerIt->second->disableCallbacks();
4177 if (nPart != nOrigPart)
4182 nOrigEditMode = pDoc->getEditMode();
4183 if (nOrigEditMode != nMode)
4188 bPaintTextEdit = (nPart == nOrigPart && nMode == nOrigEditMode);
4189 pDoc->setPaintTextEdit(bPaintTextEdit);
4192 doc_paintTile(pThis, pBuffer, nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
4196 pDoc->setPaintTextEdit(
true);
4198 if (nMode != nOrigEditMode)
4203 if (nPart != nOrigPart)
4208 if (nViewId != nOrigViewId)
4214 handlerIt->second->enableCallbacks();
4221 catch (
const std::exception&)
4226 if (nOrigViewId >= 0)
4230 handlerIt->second->enableCallbacks();
4237#if ENABLE_CAIRO_RGBA || defined IOS
4238 return LOK_TILEMODE_RGBA;
4240 return LOK_TILEMODE_BGRA;
4253 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4256 Size aDocumentSize = pDoc->getDocumentSize();
4257 *pWidth = aDocumentSize.
Width();
4258 *pHeight = aDocumentSize.
Height();
4276 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4279 Size aDocumentSize = pDoc->getDataArea(nTab);
4280 *pCol = aDocumentSize.
Width();
4281 *pRow = aDocumentSize.
Height();
4290 const char* pArguments)
4297 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4301 pDoc->initializeForTiledRendering(
4307 LibreOfficeKitCallback pCallback,
4319 const size_t nId = nView;
4320 if (pCallback !=
nullptr)
4324 if (pair.first ==
nId)
4327 pair.second->addViewStates(nView);
4334 if (pair.first ==
nId)
4337 pair.second->removeViewStates(nView);
4343 if (pCallback !=
nullptr)
4347 if (pair.first ==
nId)
4361 std::string sPayload =
"{ \"fontsmissing\": [ ";
4369 sPayload +=
"\"" + std::string(f.toUtf8()) +
"\"";
4372 pCallback(LOK_CALLBACK_FONTS_MISSING, sPayload.c_str(),
pData);
4390 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4397 pDoc->getPostIts(aJsonWriter);
4405 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4412 pDoc->getPostItsPos(aJsonWriter);
4419 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4426 pDoc->getRulerState(aJsonWriter);
4430static void doc_postKeyEvent(LibreOfficeKitDocument* pThis,
int nType,
int nCharCode,
int nKeyCode)
4437 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4446 pDoc->postKeyEvent(
nType, nCharCode, nKeyCode);
4448 catch (
const uno::Exception& exception)
4451 SAL_INFO(
"lok",
"Failed to postKeyEvent " << exception.Message);
4469 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4475 pWindow = pDoc->getDocWindow();
4495 if (nLOKWindowId == 0)
4497 ITiledRenderable* pDoc = getTiledRenderable(pThis);
4503 pWindow = pDoc->getDocWindow();
4519 if (nCharBefore > 0)
4522 if (nLOKWindowId == 0)
4525 for (
int i = 0;
i < nCharBefore; ++
i)
4526 pWindow->KeyInput(aEvt);
4535 if (nLOKWindowId == 0)
4538 for (
int i = 0;
i < nCharAfter; ++
i)
4539 pWindow->KeyInput(aEvt);
4564 case LOK_KEYEVENT_KEYINPUT:
4567 case LOK_KEYEVENT_KEYUP:
4600 case LOK_DOCTYPE_PRESENTATION:
4601 aMediaDescriptor[
"FilterName"] <<= OUString(
"impress_svg_Export");
4603 case LOK_DOCTYPE_DRAWING:
4604 aMediaDescriptor[
"FilterName"] <<= OUString(
"draw_svg_Export");
4606 case LOK_DOCTYPE_TEXT:
4607 aMediaDescriptor[
"FilterName"] <<= OUString(
"writer_svg_Export");
4609 case LOK_DOCTYPE_SPREADSHEET:
4610 aMediaDescriptor[
"FilterName"] <<= OUString(
"calc_svg_Export");
4613 SAL_WARN(
"lok",
"Failed to render shape selection: Document type is not supported");
4615 aMediaDescriptor[
"SelectionOnly"] <<=
true;
4616 aMediaDescriptor[
"OutputStream"] <<= xOut;
4617 aMediaDescriptor[
"IsPreview"] <<=
true;
4619 xStorable->storeToURL(
"private:stream", aMediaDescriptor.getAsConstPropertyValueList());
4624 *pOutput =
static_cast<char*
>(malloc(nOutputSize));
4627 std::memcpy(*pOutput, aOutStream.
GetData(), nOutputSize);
4632 catch (
const uno::Exception& exception)
4651class DispatchResultListener :
public cppu::WeakImplHelper<css::frame::XDispatchResultListener>
4653 const OString maCommand;
4654 const std::shared_ptr<CallbackFlushHandler> mpCallback;
4655 const std::chrono::steady_clock::time_point mSaveTime;
4656 const bool mbWasModified;
4659 DispatchResultListener(
const char* pCommand, std::shared_ptr<CallbackFlushHandler> pCallback)
4660 : maCommand(pCommand)
4661 , mpCallback(
std::move(pCallback))
4662 , mSaveTime(
std::chrono::steady_clock::
now())
4668 virtual void SAL_CALL dispatchFinished(
const css::frame::DispatchResultEvent& rEvent)
override
4671 aJson.
put(
"commandName", maCommand);
4673 if (rEvent.State != frame::DispatchResultState::DONTKNOW)
4675 bool bSuccess = (rEvent.State == frame::DispatchResultState::SUCCESS);
4676 aJson.
put(
"success", bSuccess);
4680 aJson.
put(
"wasModified", mbWasModified);
4681 aJson.
put(
"startUnixTimeMics",
4682 std::chrono::time_point_cast<std::chrono::microseconds>(mSaveTime)
4685 aJson.
put(
"saveDurationMics", std::chrono::duration_cast<std::chrono::microseconds>(
4686 std::chrono::steady_clock::now() - mSaveTime)
4691 virtual void SAL_CALL disposing(
const css::lang::EventObject&)
override {}
4710 OUString sControlId =
aMap[
"id"];
4715 auto sCurrentShellId = OUString::number(nCurrentShellId);
4734static void doc_sendDialogEvent(LibreOfficeKitDocument* ,
unsigned long long int nWindowId,
const char* pArguments)
4739static void lo_sendDialogEvent(LibreOfficeKit* ,
unsigned long long int nWindowId,
const char* pArguments)
4744static void lo_setOption(LibreOfficeKit* ,
const char *pOption,
const char* pValue)
4746 static char* pCurrentSalLogOverride =
nullptr;
4748 if (strcmp(pOption,
"traceeventrecording") == 0)
4750 if (strcmp(pValue,
"start") == 0)
4757 else if (strcmp(pValue,
"stop") == 0)
4760 else if (strcmp(pOption,
"sallogoverride") == 0)
4762 if (pCurrentSalLogOverride !=
nullptr)
4763 free(pCurrentSalLogOverride);
4764 if (pValue ==
nullptr)
4765 pCurrentSalLogOverride =
nullptr;
4767 pCurrentSalLogOverride = strdup(pValue);
4769 if (pCurrentSalLogOverride ==
nullptr || pCurrentSalLogOverride[0] ==
'\0')
4770 sal_detail_set_log_selector(
nullptr);
4772 sal_detail_set_log_selector(pCurrentSalLogOverride);
4775 else if (strcmp(pOption,
"addfont") == 0)
4777 if (memcmp(pValue,
"file://", 7) == 0)
4780 int fd = open(pValue, O_RDONLY);
4783 std::cerr <<
"Could not open font file '" << pValue <<
"': " << strerror(errno) << std::endl;
4787 OUString sMagicFileName =
"file:///:FD:/" + OUString::number(fd);
4797static void lo_dumpState (LibreOfficeKit* pThis,
const char* ,
char** pState)
4806 OStringBuffer aState(4096*256);
4810 pLib->dumpState(aState);
4812 OString
aStr = aState.makeStringAndClear();
4813 *pState = strdup(
aStr.getStr());
4818 rState.append(
"LibreOfficeKit state:");
4819 rState.append(
"\n\tLastExceptionMsg:\t");
4821 rState.append(
"\n\tUnipoll:\t");
4823 rState.append(
"\n\tOptionalFeatures:\t0x");
4825 rState.append(
"\n\tCallbackData:\t0x");
4826 rState.append(
reinterpret_cast<sal_Int64
>(
mpCallback), 16);
4832static void doc_postUnoCommand(LibreOfficeKitDocument* pThis,
const char* pCommand,
const char* pArguments,
bool bNotifyWhenFinished)
4840 OUString
aCommand(pCommand, strlen(pCommand), RTL_TEXTENCODING_UTF8);
4847 beans::PropertyValue aSynchronMode;
4848 aSynchronMode.Name =
"SynchronMode";
4849 aSynchronMode.Value <<=
false;
4850 aPropertyValuesVector.push_back(aSynchronMode);
4859 ExecuteOrientationChange();
4867 OUString
aMimeType = lcl_getCurrentDocumentMimeType(pDocument);
4874 OUString
aURL = xStorable->getLocation();
4876 bool bResult =
doc_saveAs(pThis, aURLUtf8.getStr(),
"pdf",
nullptr);
4880 aJson.
put(
"commandName", pCommand);
4881 aJson.
put(
"success", bResult);
4891 beans::PropertyValue aValue;
4892 aValue.Name =
"InteractionHandler";
4893 aValue.Value <<= xInteraction;
4894 aPropertyValuesVector.push_back(aValue);
4896 bool bDontSaveIfUnmodified =
false;
4897 aPropertyValuesVector.erase(std::remove_if(aPropertyValuesVector.begin(),
4898 aPropertyValuesVector.end(),
4899 [&bDontSaveIfUnmodified](
const beans::PropertyValue& aItem){
4900 if (aItem.Name ==
"DontSaveIfUnmodified")
4902 bDontSaveIfUnmodified = aItem.Value.get<bool>();
4906 }), aPropertyValuesVector.end());
4909 if (bDontSaveIfUnmodified && (!pDocSh || !pDocSh->
IsModified()))
4912 aJson.
put(
"commandName", pCommand);
4913 aJson.
put(
"success",
false);
4916 auto resultNode = aJson.
startNode(
"result");
4917 aJson.
put(
"type",
"string");
4918 aJson.
put(
"value",
"unmodified");
4924 else if (
gImpl && aCommand ==
".uno:TransformDialog")
4926 bool bNeedConversion =
false;
4930 if (aChartHelper.GetWindow() )
4932 bNeedConversion =
true;
4936 if (
OutputDevice* pOutputDevice = pView->GetFirstOutputDevice())
4938 bNeedConversion = (pOutputDevice->GetMapMode().GetMapUnit() == MapUnit::Map100thMM);
4942 if (bNeedConversion)
4945 for (beans::PropertyValue& rPropValue: aPropertyValuesVector)
4947 if (rPropValue.Name ==
"TransformPosX"
4948 || rPropValue.Name ==
"TransformPosY"
4949 || rPropValue.Name ==
"TransformWidth"
4950 || rPropValue.Name ==
"TransformHeight"
4951 || rPropValue.Name ==
"TransformRotationX"
4952 || rPropValue.Name ==
"TransformRotationY")
4954 rPropValue.Value >>=
value;
4956 rPropValue.Value <<=
value;
4961 if (aChartHelper.GetWindow() && aPropertyValuesVector.size() > 0)
4963 if (aPropertyValuesVector[0].Name !=
"Action")
4970 for (beans::PropertyValue& rPropValue: aPropertyValuesVector)
4972 if (rPropValue.Name ==
"TransformPosX" || rPropValue.Name ==
"TransformRotationX")
4974 auto const value = *o3tl::doAccess<sal_Int32>(rPropValue.Value);
4975 rPropValue.Value <<=
value - nLeft;
4977 else if (rPropValue.Name ==
"TransformPosY" || rPropValue.Name ==
"TransformRotationY")
4979 auto const value = *o3tl::doAccess<sal_Int32>(rPropValue.Value);
4980 rPropValue.Value <<=
value - nTop;
4984 util::URL aCommandURL;
4985 aCommandURL.Path =
"LOKTransform";
4986 css::uno::Reference<css::frame::XDispatch>& aChartDispatcher = aChartHelper.GetXDispatcher();
4991 else if (
gImpl && aCommand ==
".uno:LOKSidebarWriterPage")
4993 setupSidebar(u
"WriterPageDeck");
4996 else if (
gImpl && aCommand ==
".uno:SidebarShow")
5001 else if (
gImpl && aCommand ==
".uno:SidebarHide")
5007 bool bResult =
false;
5010 if (aChartHelper.GetWindow() && aCommand !=
".uno:Save" )
5012 util::URL aCommandURL;
5013 aCommandURL.Path =
aCommand.copy(5);
5014 css::uno::Reference<css::frame::XDispatch>& aChartDispatcher = aChartHelper.GetXDispatcher();
5038static void doc_postMouseEvent(LibreOfficeKitDocument* pThis,
int nType,
int nX,
int nY,
int nCount,
int nButtons,
int nModifier)
5045 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5053 pDoc->postMouseEvent(
nType, nX, nY,
nCount, nButtons, nModifier);
5055 catch (
const uno::Exception& exception)
5058 SAL_INFO(
"lok",
"Failed to postMouseEvent " << exception.Message);
5062static void doc_postWindowMouseEvent(LibreOfficeKitDocument* ,
unsigned nLOKWindowId,
int nType,
int nX,
int nY,
int nCount,
int nButtons,
int nModifier)
5076 const Point aPos(nX, nY);
5084 case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
5087 case LOK_MOUSEEVENT_MOUSEBUTTONUP:
5090 case LOK_MOUSEEVENT_MOUSEMOVE:
5113 OString aType(pType);
5116 if (aType ==
"panBegin")
5117 eEventType = GestureEventPanType::Begin;
5118 else if (aType ==
"panEnd")
5119 eEventType = GestureEventPanType::End;
5126 PanningOrientation::Vertical,
5141 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5148 pDoc->setTextSelection(
nType, nX, nY);
5166 Size aOffset(pWindow->GetOutOffXPixel(), pWindow->GetOutOffYPixel());
5167 Point aCursorPos(nX, nY);
5168 aCursorPos.
Move(aOffset);
5171 MouseEvent aCursorEvent(aCursorPos, 1, MouseEventModifiers::SIMPLECLICK, 0, nModifier);
5177 const css::uno::Reference<css::datatransfer::XTransferable> &xTransferable,
5178 const OString &aInMimeType, OString &aRet);
5181 const css::uno::Reference<css::datatransfer::XTransferable> &xTransferable,
5182 const OString &aMimeType, OString &aRet)
5188 auto aSeq = Sequence<sal_Int8>(
reinterpret_cast<const sal_Int8*
>(aRet.getStr()),
5190 OStringBuffer aBase64Data;
5194 aRet =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"
5196 "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/><meta "
5197 "name=\"generator\" content=\""
5200 "</head><body><img src=\"data:" +
aMimeType +
";base64,"
5201 + aBase64Data +
"\"/></body></html>";
5207 const css::uno::Reference<css::datatransfer::XTransferable> &xTransferable,
5208 const OString &aMimeType, OString &aRet)
5214 aRet =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"
5216 "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/><meta "
5217 "name=\"generator\" content=\""
5219 +
"\"/></head><body><pre>" + aRet +
"</pre></body></html>";
5225 const css::uno::Reference<css::datatransfer::XTransferable> &xTransferable,
5226 const OString &aInMimeType, OString &aRet)
5231 bool bConvert =
false;
5237 aMimeType =
"text/plain;charset=utf-16";
5242 datatransfer::DataFlavor aFlavor;
5243 aFlavor.MimeType = OUString::fromUtf8(
aMimeType);
5244 if (
aMimeType ==
"text/plain;charset=utf-16")
5249 if (!xTransferable->isDataFlavorSupported(aFlavor))
5252 if (aInMimeType ==
"text/html")
5269 aAny = xTransferable->getTransferData(aFlavor);
5271 catch (
const css::datatransfer::UnsupportedFlavorException& e)
5273 SetLastExceptionMsg(
"Unsupported flavor " + aFlavor.MimeType +
" exception " + e.Message);
5276 catch (
const css::uno::Exception& e)
5289 aRet = OString(
reinterpret_cast<const char *
>(aString.getStr()), aString.getLength() *
sizeof(
sal_Unicode));
5295 aRet = OString(
reinterpret_cast<const char*
>(aSequence.getConstArray()), aSequence.getLength());
5308 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5315 css::uno::Reference<css::datatransfer::XTransferable> xTransferable = pDoc->getSelection();
5322 const char *pType = pMimeType;
5323 if (!pType || pType[0] ==
'\0')
5324 pType =
"text/plain;charset=utf-8";
5334 *pUsedMimeType = strdup(pMimeType);
5336 *pUsedMimeType =
nullptr;
5349 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5353 return LOK_SELTYPE_NONE;
5356 css::uno::Reference<css::datatransfer::XTransferable> xTransferable = pDoc->getSelection();
5360 return LOK_SELTYPE_NONE;
5363 css::uno::Reference<css::datatransfer::XTransferable2> xTransferable2(xTransferable, css::uno::UNO_QUERY);
5364 if (xTransferable2.is() && xTransferable2->isComplex())
5365 return LOK_SELTYPE_COMPLEX;
5370 return LOK_SELTYPE_NONE;
5372 if (aRet.getLength() > 10000)
5373 return LOK_SELTYPE_COMPLEX;
5375 return !aRet.isEmpty() ? LOK_SELTYPE_TEXT : LOK_SELTYPE_NONE;
5387 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5391 return LOK_SELTYPE_NONE;
5394 css::uno::Reference<css::datatransfer::XTransferable> xTransferable = pDoc->getSelection();
5398 return LOK_SELTYPE_NONE;
5401 css::uno::Reference<css::datatransfer::XTransferable2> xTransferable2(xTransferable, css::uno::UNO_QUERY);
5402 if (xTransferable2.is() && xTransferable2->isComplex())
5403 return LOK_SELTYPE_COMPLEX;
5405 const char *pType = pMimeType;
5406 if (!pType || pType[0] ==
'\0')
5407 pType =
"text/plain;charset=utf-8";
5412 return LOK_SELTYPE_NONE;
5414 if (aRet.getLength() > 10000)
5415 return LOK_SELTYPE_COMPLEX;
5418 return LOK_SELTYPE_NONE;
5426 *pUsedMimeType = strdup(pMimeType);
5428 *pUsedMimeType =
nullptr;
5431 return LOK_SELTYPE_TEXT;
5435 const char **pMimeTypes,
5437 char ***pOutMimeTypes,
5439 char ***pOutStreams)
5445 (void) pOutMimeTypes;
5449 assert(!
"doc_getClipboard should not be called on iOS");
5459 assert (pOutMimeTypes);
5461 assert (pOutStreams);
5464 *pOutMimeTypes =
nullptr;
5465 *pOutSizes =
nullptr;
5466 *pOutStreams =
nullptr;
5468 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5477 css::uno::Reference<css::datatransfer::XTransferable> xTransferable = xClip->getContents();
5478 SAL_INFO(
"lok",
"Got from clip: " << xClip.get() <<
" transferable: " << xTransferable);
5485 std::vector<OString> aMimeTypes;
5489 if (!flavors.getLength())
5494 for (
const auto &it : flavors)
5499 for (
size_t i = 0; pMimeTypes[
i]; ++
i)
5500 aMimeTypes.push_back(OString(pMimeTypes[
i]));
5503 *pOutCount = aMimeTypes.size();
5504 *pOutSizes =
static_cast<size_t *
>(malloc(*pOutCount *
sizeof(
size_t)));
5505 *pOutMimeTypes =
static_cast<char **
>(malloc(*pOutCount *
sizeof(
char *)));
5506 *pOutStreams =
static_cast<char **
>(malloc(*pOutCount *
sizeof(
char *)));
5507 for (
size_t i = 0;
i < aMimeTypes.size(); ++
i)
5509 if (aMimeTypes[
i] ==
"text/plain;charset=utf-16")
5510 (*pOutMimeTypes)[
i] = strdup(
"text/plain;charset=utf-8");
5512 (*pOutMimeTypes)[
i] = strdup(aMimeTypes[
i].getStr());
5516 if (!bSuccess || aRet.getLength() < 1)
5518 (*pOutSizes)[
i] = 0;
5519 (*pOutStreams)[
i] =
nullptr;
5523 (*pOutSizes)[
i] = aRet.getLength();
5533 const size_t nInCount,
5534 const char **pInMimeTypes,
5535 const size_t *pInSizes,
5536 const char **pInStreams)
5541 (void) pInMimeTypes;
5550 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5559 auto xClip = forceSetClipboardForCurrentView(pThis);
5562 SAL_INFO(
"lok",
"Set clip: " << xClip.get() <<
" to: " << xTransferable);
5564 if (!pDoc->isMimeTypeSupported())
5573static bool doc_paste(LibreOfficeKitDocument* pThis,
const char* pMimeType,
const char* pData,
size_t nSize)
5579 const char *pInMimeTypes[1];
5580 const char *pInStreams[1];
5582 pInMimeTypes[0] = pMimeType;
5583 pInSizes[0] = nSize;
5584 pInStreams[0] =
pData;
5591 {
"AnchorType",
uno::Any(
static_cast<sal_uInt16
>(css::text::TextContentAnchorType_AS_CHARACTER))},
5592 {
"IgnoreComments",
uno::Any(
true)},
5610 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5617 pDoc->setGraphicSelection(
nType, nX, nY);
5630 css::uno::Any aLangStatus;
5631 pDispatcher->
QueryState(SID_LANGUAGE_STATUS, aLangStatus);
5635 OUString sGuessText;
5636 SvtScriptType eScriptType = SvtScriptType::LATIN | SvtScriptType::ASIAN
5637 | SvtScriptType::COMPLEX;
5639 Sequence<OUString> aSeqLang;
5640 if (aLangStatus >>= aSeqLang)
5642 if (aSeqLang.getLength() == 4)
5644 sCurrent = aSeqLang[0];
5645 eScriptType =
static_cast<SvtScriptType>(aSeqLang[1].toInt32());
5646 sKeyboard = aSeqLang[1];
5647 sGuessText = aSeqLang[2];
5652 aLangStatus >>= sCurrent;
5656 std::set<LanguageType> aLangItems;
5658 if (!sCurrent.isEmpty())
5663 aLangItems.insert(nLangType);
5672 aLangItems.insert(nLangType);
5679 aLangItems.insert(nLangType);
5682 if (!sKeyboard.isEmpty())
5688 aLangItems.insert(nLangType);
5692 if (!sGuessText.isEmpty())
5694 Reference<linguistic2::XLanguageGuessing> xLangGuesser;
5703 if (xLangGuesser.is())
5705 lang::Locale aLocale = xLangGuesser->guessPrimaryLanguage(sGuessText, 0,
5706 sGuessText.getLength());
5712 aLangItems.insert(nLangType);
5718 Reference<document::XDocumentLanguages> xDocumentLanguages(pDocument->
mxComponent, UNO_QUERY);
5719 if (xDocumentLanguages.is())
5721 const Sequence<lang::Locale> aLocales(xDocumentLanguages->getDocumentLanguages(
5722 static_cast<sal_Int16
>(eScriptType), 64));
5724 for (
const lang::Locale& aLocale : aLocales)
5730 aLangItems.insert(nLangType);
5736 Sequence<lang::Locale> aLocales(aLangItems.size());
5737 auto pLocales = aLocales.getArray();
5753 ITiledRenderable* pDoc = getTiledRenderable(pThis);
5760 pDoc->resetSelection();
5763static char*
getLanguages(LibreOfficeKitDocument* pThis,
const char* pCommand)
5765 css::uno::Sequence< css::lang::Locale > aLocales;
5772 css::uno::Reference<css::linguistic2::XSpellChecker> xSpell = xLangSrv->getSpellChecker();
5774 aLocales = xSpell->getLocales();
5780 if (!aLocales.hasElements())
5788 boost::property_tree::ptree aTree;
5789 aTree.put(
"commandName", pCommand);
5790 boost::property_tree::ptree aValues;
5791 boost::property_tree::ptree aChild;
5793 for ( css::lang::Locale
const & locale : std::as_const(aLocales) )
5797 if (sLanguage.startsWith(
"{") && sLanguage.endsWith(
"}"))
5800 sLanguage +=
";" + aLanguageTag.
getBcp47(
false);
5801 aChild.put(
"", sLanguage.toUtf8());
5802 aValues.push_back(std::make_pair(
"", aChild));
5804 aTree.add_child(
"commandValues", aValues);
5805 std::stringstream aStream;
5806 boost::property_tree::write_json(aStream, aTree);
5807 char* pJson =
static_cast<char*
>(malloc(aStream.str().size() + 1));
5809 strcpy(pJson, aStream.str().c_str());
5810 pJson[aStream.str().size()] =
'\0';
5820 pDocSh->
GetItem(SID_ATTR_CHAR_FONTLIST));
5823 boost::property_tree::ptree aTree;
5824 aTree.put(
"commandName", pCommand);
5825 boost::property_tree::ptree aValues;
5829 for (sal_uInt16
i = 0;
i < nFontCount; ++
i)
5831 boost::property_tree::ptree aChildren;
5834 sal_uInt16 nSizeCount = 0;
5835 while (pAry[nSizeCount])
5837 boost::property_tree::ptree aChild;
5838 aChild.put(
"",
static_cast<float>(pAry[nSizeCount]) / 10);
5839 aChildren.push_back(std::make_pair(
"", aChild));
5842 aValues.add_child(rFontMetric.
GetFamilyName().toUtf8().getStr(), aChildren);
5845 aTree.add_child(
"commandValues", aValues);
5846 std::stringstream aStream;
5847 boost::property_tree::write_json(aStream, aTree);
5848 char* pJson =
static_cast<char*
>(malloc(aStream.str().size() + 1));
5850 strcpy(pJson, aStream.str().c_str());
5851 pJson[aStream.str().size()] =
'\0';
5857 OUString aFoundFont(::rtl::Uri::decode(OStringToOUString(aFontName, RTL_TEXTENCODING_UTF8), rtl_UriDecodeStrict, RTL_TEXTENCODING_UTF8));
5859 boost::property_tree::ptree aTree;
5860 aTree.put(
"commandName",
".uno:FontSubset");
5861 boost::property_tree::ptree aValues;
5863 if (
const vcl::Font* pFont = FindFont(aFoundFont))
5868 aDevice->SetFont(*pFont);
5869 aDevice->GetFontCharMap(xFontCharMap);
5874 boost::property_tree::ptree aChild;
5875 aChild.put(
"",
static_cast<int>(ublock_getCode(subset.GetRangeMin())));
5876 aValues.push_back(std::make_pair(
"", aChild));
5880 aTree.add_child(
"commandValues", aValues);
5881 std::stringstream aStream;
5882 boost::property_tree::write_json(aStream, aTree);
5883 char* pJson =
static_cast<char*
>(malloc(aStream.str().size() + 1));
5885 strcpy(pJson, aStream.str().c_str());
5886 pJson[aStream.str().size()] =
'\0';
5890static char*
getStyles(LibreOfficeKitDocument* pThis,
const char* pCommand)
5894 boost::property_tree::ptree aTree;
5895 aTree.put(
"commandName", pCommand);
5900 static const std::vector<OUString> aWriterStyles =
5914 std::set<OUString> aDefaultStyleNames;
5916 boost::property_tree::ptree aValues;
5917 for (OUString
const & sStyleFam : aStyleFamilies)
5919 boost::property_tree::ptree aChildren;
5925 if (sStyleFam ==
"ParagraphStyles"
5928 for (
const OUString& rStyle: aWriterStyles)
5930 aDefaultStyleNames.insert( rStyle );
5932 boost::property_tree::ptree aChild;
5933 aChild.put(
"", rStyle.toUtf8());
5934 aChildren.push_back(std::make_pair(
"", aChild));
5939 for (
const OUString& rStyle: aStyles )
5943 if (aDefaultStyleNames.find(rStyle) == aDefaultStyleNames.end() ||
5946 boost::property_tree::ptree aChild;
5947 aChild.put(
"", rStyle.toUtf8());
5948 aChildren.push_back(std::make_pair(
"", aChild));
5951 aValues.add_child(sStyleFam.toUtf8().getStr(), aChildren);
5956 boost::property_tree::ptree aChild;
5957 boost::property_tree::ptree aChildren;
5958 static constexpr OUStringLiteral sPageStyles(
u"PageStyles");
5962 if (xStyleFamilies->hasByName(sPageStyles) && (xStyleFamilies->getByName(sPageStyles) >>= xContainer))
5965 for (OUString
const &
sName : aSeqNames)
5968 xProperty.set(xContainer->getByName(
sName), uno::UNO_QUERY);
5969 if (xProperty.is() && (xProperty->getPropertyValue(
"IsPhysical") >>= bIsPhysical) && bIsPhysical)
5971 OUString displayName;
5972 xProperty->getPropertyValue(
"DisplayName") >>= displayName;
5973 aChild.put(
"", displayName.toUtf8());
5974 aChildren.push_back(std::make_pair(
"", aChild));
5977 aValues.add_child(
"HeaderFooter", aChildren);
5982 boost::property_tree::ptree aCommandList;
5985 boost::property_tree::ptree aChild;
5987 OUString sClearFormat =
SvxResId(RID_SVXSTR_CLEARFORM);
5989 boost::property_tree::ptree
aName;
5990 aName.put(
"", sClearFormat.toUtf8());
5991 aChild.push_back(std::make_pair(
"text",
aName));
5993 boost::property_tree::ptree
aCommand;
5994 aCommand.put(
"",
".uno:ResetAttributes");
5995 aChild.push_back(std::make_pair(
"id",
aCommand));
5997 aCommandList.push_back(std::make_pair(
"", aChild));
6000 aValues.add_child(
"Commands", aCommandList);
6003 aTree.add_child(
"commandValues", aValues);
6004 std::stringstream aStream;
6005 boost::property_tree::write_json(aStream, aTree);
6006 char* pJson =
static_cast<char*
>(malloc(aStream.str().size() + 1));
6008 strcpy(pJson, aStream.str().c_str());
6009 pJson[aStream.str().size()] =
'\0';
6015enum class UndoOrRedo
6041 if (eCommand == UndoOrRedo::UNDO)
6045 char* pJson = strdup(aString.toUtf8().getStr());
6061 auto redlinesNode = aJson.
startArray(
"redlines");
6063 for (
size_t nIndex = 0; xRedlines->hasMoreElements(); ++
nIndex)
6067 aJson.
put(
"index",
static_cast<sal_Int32
>(
nIndex));
6070 xRedline->getPropertyValue(
"RedlineAuthor") >>= sAuthor;
6071 aJson.
put(
"author", sAuthor);
6074 xRedline->getPropertyValue(
"RedlineType") >>=
sType;
6078 xRedline->getPropertyValue(
"RedlineComment") >>= sComment;
6079 aJson.
put(
"comment", sComment);
6081 OUString sDescription;
6082 xRedline->getPropertyValue(
"RedlineDescription") >>= sDescription;
6083 aJson.
put(
"description", sDescription);
6085 util::DateTime aDateTime;
6086 xRedline->getPropertyValue(
"RedlineDateTime") >>= aDateTime;
6088 aJson.
put(
"dateTime", sDateTime);
6093 ITiledRenderable* pDoc = getTiledRenderable(pThis);
6099 pDoc->getTrackedChanges(aJson);
6109 ITiledRenderable* pDoc = getTiledRenderable(pThis);
6116 pDoc->getTrackedChangeAuthors(aJsonWriter);
6127 const std::string_view
aCommand(pCommand);
6128 static constexpr OStringLiteral aViewRowColumnHeaders(
".uno:ViewRowColumnHeaders");
6129 static constexpr OStringLiteral aSheetGeometryData(
".uno:SheetGeometryData");
6130 static constexpr OStringLiteral aCellCursor(
".uno:CellCursor");
6131 static constexpr OStringLiteral aFontSubset(
".uno:FontSubset&name=");
6133 ITiledRenderable* pDoc = getTiledRenderable(pThis);
6140 if (!strcmp(pCommand,
".uno:LanguageStatus"))
6144 else if (!strcmp(pCommand,
".uno:CharFontName"))
6148 else if (!strcmp(pCommand,
".uno:StyleApply"))
6160 else if (
aCommand ==
".uno:AcceptTrackedChanges")
6164 else if (
aCommand ==
".uno:TrackedChangeAuthors")
6168 else if (
aCommand ==
".uno:ViewAnnotations")
6172 else if (
aCommand ==
".uno:ViewAnnotationsPosition")
6176 else if (
aCommand ==
".uno:RulerState")
6190 std::string_view
aArguments =
aCommand.substr(aViewRowColumnHeaders.getLength() + 1);
6191 sal_Int32 nParamIndex = 0;
6196 std::string_view aKey;
6197 std::string_view aValue;
6209 else if (aKey ==
"y")
6211 else if (aKey ==
"width")
6213 else if (aKey ==
"height")
6216 while (nParamIndex >= 0);
6222 pDoc->getRowColumnHeaders(aRectangle, aJsonWriter);
6227 bool bColumns =
true;
6230 bool bHidden =
true;
6231 bool bFiltered =
true;
6232 bool bGroups =
true;
6235 bColumns = bRows = bSizes = bHidden = bFiltered = bGroups =
false;
6238 sal_Int32 nParamIndex = 0;
6243 std::string_view aKey;
6244 std::string_view aValue;
6255 bool bEnableFlag = aValue.empty() ||
6260 if (aKey ==
"columns")
6262 else if (aKey ==
"rows")
6264 else if (aKey ==
"sizes")
6266 else if (aKey ==
"hidden")
6268 else if (aKey ==
"filtered")
6270 else if (aKey ==
"groups")
6273 }
while (nParamIndex >= 0);
6276 OString aGeomDataStr
6277 = pDoc->getSheetGeometryData(bColumns, bRows, bSizes, bHidden, bFiltered, bGroups);
6279 if (aGeomDataStr.isEmpty())
6288 pDoc->getCellCursor(aJsonWriter);
6298 pDoc->getCommandValues(aJsonWriter,
aCommand);
6308static void doc_setClientZoom(LibreOfficeKitDocument* pThis,
int nTilePixelWidth,
int nTilePixelHeight,
6309 int nTileTwipWidth,
int nTileTwipHeight)
6316 ITiledRenderable* pDoc = getTiledRenderable(pThis);
6323 pDoc->setClientZoom(nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight);
6333 ITiledRenderable* pDoc = getTiledRenderable(pThis);
6341 pDoc->setClientVisibleArea(aRectangle);
6344static void doc_setOutlineState(LibreOfficeKitDocument* pThis,
bool bColumn,
int nLevel,
int nIndex,
bool bHidden)
6351 ITiledRenderable* pDoc = getTiledRenderable(pThis);
6358 pDoc->setOutlineState(bColumn, nLevel,
nIndex, bHidden);
6362 const char* pOptions)
6372 if (!aLanguage.isEmpty())
6379 const OUString aDeviceFormFactor =
extractParameter(aOptions,
u"DeviceFormFactor");
6390 forceSetClipboardForCurrentView(pThis);
6418static void doc_setView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* ,
int nId)
6449static bool doc_getViewIds(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* pThis,
int* pArray,
size_t nSize)
6467 OUString sLanguage = OStringToOUString(language, RTL_TEXTENCODING_UTF8);
6473 const char* pFontName,
6482 const char* pFontName,
6493 const int nDefaultFontSize = 25;
6495 auto aFont = FindFont_FallbackToDefault(OStringToOUString(pFontName, RTL_TEXTENCODING_UTF8));
6497 OUString aText(OStringToOUString(
pChar, RTL_TEXTENCODING_UTF8));
6498 if (aText.isEmpty())
6499 aText = aFont.GetFamilyName();
6503 aFont.SetFontSize(
Size(0, nDefaultFontSize));
6504 aFont.SetOrientation(
Degree10(pOrientation));
6505 aDevice->SetFont(aFont);
6506 aDevice->GetTextBoundRect(aRect, aText);
6510 int nFontWidth = aRect.
Right() + 1;
6511 int nFontHeight = aRect.
Bottom() + 1;
6513 if (nFontWidth <= 0 || nFontHeight <= 0)
6516 if (*pFontWidth > 0 && *pFontHeight > 0)
6518 double fScaleX = *pFontWidth /
static_cast<double>(nFontWidth) / 1.5;
6519 double fScaleY = *pFontHeight /
static_cast<double>(nFontHeight) / 1.5;
6521 double fScale = std::min(fScaleX, fScaleY);
6525 int nFontSize = fScale * nDefaultFontSize;
6526 aFont.SetFontSize(
Size(0, nFontSize));
6527 aDevice->SetFont(aFont);
6532 nFontWidth = *pFontWidth;
6533 nFontHeight = *pFontHeight;
6537 unsigned char* pBuffer =
static_cast<unsigned char*
>(malloc(4 * nFontWidth * nFontHeight));
6541 memset(pBuffer, 0, nFontWidth * nFontHeight * 4);
6543 aDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(
6547 if (*pFontWidth > 0 && *pFontHeight > 0)
6550 DrawTextFlags::Center
6551 | DrawTextFlags::VCenter
6552 | DrawTextFlags::MultiLine
6553 | DrawTextFlags::WordBreak;
6555 aDevice->DrawText(aRect, aText, nStyle);
6559 *pFontWidth = nFontWidth;
6560 *pFontHeight = nFontHeight;
6562 aDevice->DrawText(
Point(0,0), aText);
6571 unsigned char* pBuffer,
6572 const int nX,
const int nY,
6573 const int nWidth,
const int nHeight)
6579 unsigned char* pBuffer,
6580 const int nX,
const int nY,
6581 const int nWidth,
const int nHeight,
6582 const double fDPIScale)
6588 unsigned char* pBuffer,
const int nX,
const int nY,
6589 const int nWidth,
const int nHeight,
6590 const double fDPIScale,
int viewId)
6618 CGContextRef cgc = CGBitmapContextCreate(pBuffer, nWidth, nHeight, 8, nWidth*4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipLast | kCGImageByteOrder32Big);
6620 CGContextTranslateCTM(cgc, 0, nHeight);
6621 CGContextScaleCTM(cgc, fDPIScale, -fDPIScale);
6624 aData.rCGContext = cgc;
6629 pDevice->SetOutputSizePixel(
Size(nWidth, nHeight));
6631 MapMode aMapMode(pDevice->GetMapMode());
6633 pDevice->SetMapMode(aMapMode);
6635 pWindow->PaintToDevice(pDevice.
get(),
Point(0, 0));
6637 CGContextRelease(cgc);
6644 pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(
Size(nWidth, nHeight),
Fraction(1.0),
Point(), pBuffer);
6646 MapMode aMapMode(pDevice->GetMapMode());
6648 pDevice->SetMapMode(aMapMode);
6650 pWindow->PaintToDevice(pDevice.
get(),
Point(0, 0));
6656static void doc_postWindow(LibreOfficeKitDocument* ,
unsigned nLOKWindowId,
int nAction,
const char* pData)
6670 if (nAction == LOK_WINDOW_CLOSE)
6674 else if (nAction == LOK_WINDOW_PASTE)
6678 css::uno::Sequence<sal_Int8>
aData;
6681 aArgs.size() == 2 &&
6682 aArgs[0].Name ==
"MimeType" && (aArgs[0].Value >>=
aMimeType) &&
6691 pWindow->SetClipboard(xClipboard);
6700 assert(!
"doc_postWindow() with LOK_WINDOW_PASTE should not be called on iOS");
6707 const unsigned char* pCertificateBinary,
const int nCertificateBinarySize,
6708 const unsigned char* pPrivateKeyBinary,
const int nPrivateKeySize)
6731 if (!xSecurityContext.is())
6737 if (!xCertificateCreator.is())
6742 std::string aCertificateString(
reinterpret_cast<const char*
>(pCertificateBinary), nCertificateBinarySize);
6743 std::string aCertificateBase64String = extractCertificate(aCertificateString);
6744 if (!aCertificateBase64String.empty())
6746 OUString aBase64OUString = OUString::createFromAscii(aCertificateBase64String);
6751 aCertificateSequence.realloc(nCertificateBinarySize);
6752 std::copy(pCertificateBinary, pCertificateBinary + nCertificateBinarySize, aCertificateSequence.getArray());
6756 std::string aPrivateKeyString(
reinterpret_cast<const char*
>(pPrivateKeyBinary), nPrivateKeySize);
6757 std::string aPrivateKeyBase64String = extractPrivateKey(aPrivateKeyString);
6758 if (!aPrivateKeyBase64String.empty())
6760 OUString aBase64OUString = OUString::createFromAscii(aPrivateKeyBase64String);
6765 aPrivateKeySequence.realloc(nPrivateKeySize);
6766 std::copy(pPrivateKeyBinary, pPrivateKeyBinary + nPrivateKeySize, aPrivateKeySequence.getArray());
6771 if (!xCertificate.is())
6780 const unsigned char* pCertificateBinary,
const int nCertificateBinarySize)
6803 if (!xSecurityContext.is())
6809 if (!xCertificateCreator.is())
6814 std::string aCertificateString(
reinterpret_cast<const char*
>(pCertificateBinary), nCertificateBinarySize);
6815 std::string aCertificateBase64String = extractCertificate(aCertificateString);
6816 if (!aCertificateBase64String.empty())
6818 OUString aBase64OUString = OUString::createFromAscii(aCertificateBase64String);
6823 aCertificateSequence.realloc(nCertificateBinarySize);
6824 std::copy(pCertificateBinary, pCertificateBinary + nCertificateBinarySize, aCertificateSequence.getArray());
6829 if (!xCertificate.is())
6832 SAL_INFO(
"lok",
"Certificate Added = IssuerName: " << xCertificate->getIssuerName() <<
" SubjectName: " << xCertificate->getSubjectName());
6844 return int(SignatureState::UNKNOWN);
6848 return int(SignatureState::UNKNOWN);
6852 return int(SignatureState::UNKNOWN);
6862 const int nWidth,
const int nHeight)
6875 pWindow->SetSizePixel(
Size(nWidth, nHeight));
6883 ITiledRenderable* pDoc = getTiledRenderable(pThis);
6890 pDoc->completeFunction(OUString::fromUtf8(pFunctionName));
6903 ITiledRenderable* pDoc = getTiledRenderable(pThis);
6917 pDoc->executeFromFieldEvent(
aMap);
6921 const char* pSearchResult,
unsigned char** pBitmapBuffer,
6922 int* pWidth,
int* pHeight,
size_t* pByteSize)
6927 if (pBitmapBuffer ==
nullptr)
6930 if (!pSearchResult || pSearchResult[0] ==
'\0')
6933 ITiledRenderable* pDoc = getTiledRenderable(pThis);
6940 auto aRectangleVector = pDoc->getSearchResultRectangles(pSearchResult);
6946 aRangeUnion.
expand(rRange);
6952 size_t nByteSize = aPixelWidth * aPixelHeight * 4;
6954 *pWidth = aPixelWidth;
6955 *pHeight = aPixelHeight;
6956 *pByteSize = nByteSize;
6958 auto* pBuffer =
static_cast<unsigned char*
>(std::malloc(nByteSize));
6961 aPixelWidth, aPixelHeight,
6965 *pBitmapBuffer = pBuffer;
6981 ITiledRenderable* pDoc = getTiledRenderable(pThis);
6989 if (
aMap.find(
"type") ==
aMap.end())
6995 pDoc->executeContentControlEvent(
aMap);
6999 const char* pTimezone)
7009 OUString sTimezone = OStringToOUString(pTimezone, RTL_TEXTENCODING_UTF8);
7019 int nDocType = getDocumentType(pThis);
7020 if (nDocType != LOK_DOCTYPE_TEXT)
7060 for (
const OUString& rType :
aTypes)
7063 if (xTypeDetection->getByName(rType) >>= aValues)
7065 auto it = std::find_if(std::cbegin(aValues), std::cend(aValues), [](
const beans::PropertyValue& rValue) {
return rValue.Name ==
"MediaType"; });
7067 if (it != std::cend(aValues) && (it->Value >>= aValue) && !aValue.isEmpty())
7069 auto typeNode = aJson.
startNode(rType.toUtf8());
7070 aJson.
put(
"MediaType", aValue.toUtf8());
7086 pLib->mOptionalFeatures = features;
7087 if (features & LOK_FEATURE_PART_IN_INVALIDATION_CALLBACK)
7089 if (features & LOK_FEATURE_NO_TILED_ANNOTATIONS)
7091 if (features & LOK_FEATURE_RANGE_HEADERS)
7093 if (features & LOK_FEATURE_VIEWID_IN_VISCURSOR_INVALIDATION_CALLBACK)
7098 const char* pURL,
const char* pPassword)
7108 assert(
pLib->mInteractionMap.find(OString(pURL)) !=
pLib->mInteractionMap.end());
7109 pLib->mInteractionMap.find(OString(pURL))->second->SetPassword(pPassword);
7117 "\"ProductName\": \"%PRODUCTNAME\", "
7118 "\"ProductVersion\": \"%PRODUCTVERSION\", "
7119 "\"ProductExtension\": \"%PRODUCTEXTENSION\", "
7120 "\"BuildId\": \"%BUILDID\", "
7121 "\"BuildConfig\": \"" BUILDCONFIG
"\" "
7127 OString
aBuffer =
"Unexpected dialog: " +
7132 fprintf(stderr,
"Unexpected basic error dialog '%s'\n",
aBuffer.getStr());
7139 rtl::Bootstrap::setIniFilename(aAppProgramURL +
"/" SAL_CONFIGFILE(
"fundamental"));
7142 rtl::Bootstrap::setIniFilename(aAppProgramURL +
"/../Resources/" SAL_CONFIGFILE(
"soffice"));
7145 rtl::Bootstrap::setIniFilename(aAppProgramURL +
"/" SAL_CONFIGFILE(
"soffice"));
7152 SAL_INFO(
"lok",
"XComponentContext could not be created");
7160 SAL_INFO(
"lok",
"XMultiComponentFactory could not be created");
7180 osl_setThreadName(
"lo_startmain");
7194 LibreOfficeKitPollCallback pPollCallback,
7195 LibreOfficeKitWakeCallback pWakeCallback,
7198#if defined(IOS) || defined(ANDROID) || defined(__EMSCRIPTEN__)
7209#if defined(IOS) || defined(ANDROID) || defined(__EMSCRIPTEN__)
7221 if (!
pLib->mpCallback)
7227 pLib->mpCallback(LOK_CALLBACK_STATUS_INDICATOR_START, pText,
pLib->mpCallbackData);
7230 pLib->mpCallback(LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE,
7231 OUString(OUString::number(
percent)).toUtf8().getStr(),
pLib->mpCallbackData);
7234 pLib->mpCallback(LOK_CALLBACK_STATUS_INDICATOR_FINISH,
nullptr,
pLib->mpCallbackData);
7243 css::uno::Sequence<OUString> installedLocales(officecfg::Setup::Office::InstalledLocales::get()->getElementNames());
7244 OUString actualLang = officecfg::Setup::L10N::ooLocale::get();
7246 for (sal_Int32
i = 0;
i < installedLocales.getLength();
i++)
7256 officecfg::Setup::L10N::ooLocale::set(installedLocales[
i], batch);
7260 std::vector<OUString> supportedModuleNames = {
"com.sun.star.text.TextDocument",
"com.sun.star.sheet.SpreadsheetDocument",
"com.sun.star.drawing.DrawingDocument",
"com.sun.star.presentation.PresentationDocument" };
7262 for (std::size_t j = 0; j < supportedModuleNames.size(); j++)
7264 OUString key = supportedModuleNames[j] + installedLocales[
i];
7270 std::cerr <<
"Language is installed in core but not in the list of COOL languages: " << language <<
"\n";
7276 officecfg::Setup::L10N::ooLocale::set(actualLang, batch);
7287 rtl::Bootstrap::get(
"UserInstallation", sUserPath);
7290 rtl::Bootstrap::set(
"UserInstallation", aTempDir.
GetURL());
7296 std::cerr <<
"CheckExtensionDependencies failed" << std::endl;
7299 css::uno::Reference<css::linguistic2::XLinguServiceManager> xLngSvcMgr =
7301 css::uno::Reference<linguistic2::XSpellChecker> xSpellChecker(xLngSvcMgr->getSpellChecker());
7303 std::cerr <<
"Preloading dictionaries: ";
7304 css::uno::Reference<linguistic2::XSupportedLocales> xSpellLocales(xSpellChecker, css::uno::UNO_QUERY_THROW);
7306 for (
auto &it : std::as_const(aLocales))
7309 css::beans::PropertyValues aNone;
7310 xSpellChecker->isValid(
"forcefed", it, aNone);
7319 css::lang::Locale aAsianLocale = {
"hi",
"IN",
""};
7320 xCal->loadDefaultCalendar(aAsianLocale);
7323 css::uno::Reference<linguistic2::XThesaurus> xThesaurus(xLngSvcMgr->getThesaurus());
7324 css::uno::Reference<linguistic2::XSupportedLocales> xThesLocales(xSpellChecker, css::uno::UNO_QUERY_THROW);
7325 aLocales = xThesLocales->getLocales();
7326 std::cerr <<
"Preloading thesauri: ";
7327 for (
auto &it : std::as_const(aLocales))
7330 css::beans::PropertyValues aNone;
7331 xThesaurus->queryMeanings(
"forcefed", it, aNone);
7337 xGlobalCfg->getAllKeyEvents();
7339 std::cerr <<
"Preload icons\n";
7341 images.
getImageUrl(
"forcefed.png",
"style",
"FO_oo");
7343 std::cerr <<
"Preload short cut accelerators\n";
7346 std::cerr <<
"Preload languages\n";
7352 std::cerr <<
"Preload fonts\n";
7358 css::uno::Reference<css::linguistic2::XSpellChecker> xSpell = xLangSrv->getSpellChecker();
7360 aLocales = xSpell->getLocales();
7363 for (
const auto& aLocale : std::as_const(aLocales))
7366 using namespace ::com::sun::star::i18n::ScriptType;
7376 std::cerr <<
"Preload config\n";
7377#if defined __GNUC__ || defined __clang__
7378#pragma GCC diagnostic push
7379#pragma GCC diagnostic ignored "-Wunused-variable"
7402#if defined __GNUC__ || defined __clang__
7403#pragma GCC diagnostic pop
7407 rtl::Bootstrap::set(
"UserInstallation", sUserPath);
7412static void activateNotebookbar(std::u16string_view rApp)
7414 OUString aPath = OUString::Concat(
"org.openoffice.Office.UI.ToolbarMode/Applications/") + rApp;
7418 if (aAppNode.isValid())
7420 aAppNode.setNodeValue(
"Active",
Any(OUString(
"notebookbar_online.ui")));
7425void setCertificateDir()
7427 const char* pEnvVarString = ::getenv(
"LO_CERTIFICATE_DATABASE_PATH");
7430 OUString aCertificateDatabasePath = OStringToOUString(pEnvVarString, RTL_TEXTENCODING_UTF8);
7434 officecfg::Office::Common::Security::Scripting::CertDir::set(aCertificateDatabasePath, pBatch);
7435 officecfg::Office::Common::Security::Scripting::ManualCertDir::set(aCertificateDatabasePath, pBatch);
7438 catch (uno::Exception
const& rException)
7440 SAL_WARN(
"lok",
"Failed to set the NSS certificate database directory: " << rException.Message);
7445void setDeeplConfig()
7447 const char* pAPIUrlString = ::getenv(
"DEEPL_API_URL");
7448 const char* pAuthKeyString = ::getenv(
"DEEPL_AUTH_KEY");
7449 if (pAPIUrlString && pAuthKeyString)
7451 OUString aAPIUrl = OStringToOUString(pAPIUrlString, RTL_TEXTENCODING_UTF8);
7452 OUString aAuthKey = OStringToOUString(pAuthKeyString, RTL_TEXTENCODING_UTF8);
7456 officecfg::Office::Linguistic::Translation::Deepl::ApiURL::set(aAPIUrl, batch);
7457 officecfg::Office::Linguistic::Translation::Deepl::AuthKey::set(aAuthKey, batch);
7460 catch(uno::Exception
const& rException)
7462 SAL_WARN(
"lok",
"Failed to set Deepl API settings: " << rException.Message);
7467void setLanguageToolConfig()
7469 const char* pEnabled = ::getenv(
"LANGUAGETOOL_ENABLED");
7470 const char* pBaseUrlString = ::getenv(
"LANGUAGETOOL_BASEURL");
7472 if (pEnabled && pBaseUrlString)
7474 const char* pUsername = ::getenv(
"LANGUAGETOOL_USERNAME");
7475 const char* pApikey = ::getenv(
"LANGUAGETOOL_APIKEY");
7476 const char* pSSLVerification = ::getenv(
"LANGUAGETOOL_SSL_VERIFICATION");
7477 const char* pRestProtocol = ::getenv(
"LANGUAGETOOL_RESTPROTOCOL");
7479 OUString aEnabled = OStringToOUString(pEnabled, RTL_TEXTENCODING_UTF8);
7480 if (aEnabled !=
"true")
7482 OUString aBaseUrl = OStringToOUString(pBaseUrlString, RTL_TEXTENCODING_UTF8);
7485 using LanguageToolCfg = officecfg::Office::Linguistic::GrammarChecking::LanguageTool;
7488 LanguageToolCfg::BaseURL::set(aBaseUrl, batch);
7489 LanguageToolCfg::IsEnabled::set(
true, batch);
7490 if (pSSLVerification)
7492 OUString aSSLVerification = OStringToOUString(pSSLVerification, RTL_TEXTENCODING_UTF8);
7493 LanguageToolCfg::SSLCertVerify::set(aSSLVerification ==
"true", batch);
7497 OUString aRestProtocol = OStringToOUString(pRestProtocol, RTL_TEXTENCODING_UTF8);
7498 LanguageToolCfg::RestProtocol::set(aRestProtocol, batch);
7500 if (pUsername && pApikey)
7502 OUString aUsername = OStringToOUString(pUsername, RTL_TEXTENCODING_UTF8);
7503 OUString aApiKey = OStringToOUString(pApikey, RTL_TEXTENCODING_UTF8);
7504 LanguageToolCfg::Username::set(aUsername, batch);
7505 LanguageToolCfg::ApiKey::set(aApiKey, batch);
7509 css::uno::Reference<css::linguistic2::XLinguServiceManager2> xLangSrv =
7513 css::uno::Reference<css::linguistic2::XSpellChecker> xSpell = xLangSrv->getSpellChecker();
7516 Sequence<OUString> aEmpty;
7517 Sequence<css::lang::Locale> aLocales = xSpell->getLocales();
7519 for (
int itLocale = 0; itLocale < aLocales.getLength(); itLocale++)
7521 xLangSrv->setConfiguredServices(SN_SPELLCHECKER, aLocales[itLocale], aEmpty);
7526 catch(uno::Exception
const& rException)
7528 SAL_WARN(
"lok",
"Failed to set LanguageTool API settings: " << rException.Message);
7535static int lo_initialize(LibreOfficeKit* pThis,
const char* pAppPath,
const char* pUserProfileUrl)
7544 static bool bPreInited =
false;
7545 static bool bUnipoll =
false;
7546 static bool bProfileZones =
false;
7547 static bool bNotebookbar =
false;
7550 std::vector<OUString> aOpts;
7553 const char *pOptions = getenv(
"SAL_LOK_OPTIONS");
7556 for (
const auto &it : aOpts)
7558 if (it ==
"unipoll")
7560 else if (it ==
"profile_events")
7561 bProfileZones =
true;
7562 else if (it ==
"sc_no_grid_bg")
7564 comphelper::LibreOfficeKit::Compat::scNoGridBackground);
7565 else if (it ==
"sc_print_twips_msgs")
7567 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
7568 else if (it ==
"notebookbar")
7569 bNotebookbar =
true;
7574 if (pThis ==
nullptr)
7579 SAL_INFO(
"lok",
"Create libreoffice object");
7583 else if (bPreInited)
7584 eStage = SECOND_INIT;
7594 if (bProfileZones && eStage == SECOND_INIT)
7602 if (eStage == PRE_INIT)
7604 rtl_alloc_preInit(
true);
7607 const char* tz = ::getenv(
"TZ");
7612 if (eStage != SECOND_INIT)
7615 if (eStage != PRE_INIT)
7618 if (pUserProfileUrl && eStage != PRE_INIT)
7621 pUserProfileUrl, strlen(pUserProfileUrl), RTL_TEXTENCODING_UTF8);
7623 if (url.startsWithIgnoreAsciiCase(
"vnd.sun.star.pathname:", &path))
7626 osl::FileBase::RC e = osl::FileBase::getFileURLFromSystemPath(
7628 if (e == osl::FileBase::E_None)
7631 SAL_WARN(
"lok",
"resolving <" << url <<
"> failed with " << +e);
7633 rtl::Bootstrap::set(
"UserInstallation", url);
7634 if (eStage == SECOND_INIT)
7641 aAppPath = OUString(pAppPath, strlen(pAppPath), RTL_TEXTENCODING_UTF8);
7645#if defined ANDROID || defined EMSCRIPTEN
7646 aAppPath = OUString::fromUtf8(lo_get_app_data_dir()) +
"/program";
7650 ::osl::Module::getUrlFromAddress(
reinterpret_cast< oslGenericFunction
>(
lo_initialize),
7652 osl::FileBase::getSystemPathFromFileURL( aAppURL, aAppPath );
7659 sal_Int32 lastSlash = aAppPath.lastIndexOf(
'/');
7660 assert(lastSlash > 0);
7661 aAppPath = aAppPath.copy(0, lastSlash);
7666 if (osl::FileBase::getFileURLFromSystemPath(aAppPath, aAppURL) != osl::FileBase::E_None)
7672 NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
7674 int fd = open([[bundlePath stringByAppendingPathComponent:
@"ICU.dat"] UTF8String], O_RDONLY);
7676 NSLog(
@"Could not open ICU data file %s", [[bundlePath stringByAppendingPathComponent:
@"ICU.dat"] UTF8String]);
7680 if (fstat(fd, &st) == -1)
7681 NSLog(
@"fstat on ICU data file failed: %s", strerror(errno));
7684 void *icudata = mmap(0, (
size_t) st.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0);
7685 if (icudata == MAP_FAILED)
7686 NSLog(
@"mmap failed: %s", strerror(errno));
7689 UErrorCode icuStatus = U_ZERO_ERROR;
7690 udata_setCommonData(icudata, &icuStatus);
7691 if (U_FAILURE(icuStatus))
7692 NSLog(
@"udata_setCommonData failed");
7696 UConverter *cnv = ucnv_open(
"iso-8859-3", &icuStatus);
7697 if (U_SUCCESS(icuStatus))
7700 NSLog(
@"ucnv_open() failed: %s", u_errorName(icuStatus));
7710 if (eStage != SECOND_INIT)
7712 SAL_INFO(
"lok",
"Attempting to initialize UNO");
7718 rtl::Bootstrap::set(
"SAL_USE_VCLPLUGIN",
"svp");
7726 if (
InitVCL() && [NSThread isMainThread])
7728 static bool bFirstTime =
true;
7738#if HAVE_FEATURE_ANDROID_LOK
7743 SAL_INFO(
"lok",
"CheckExtensionDependencies failed");
7746 if (eStage == PRE_INIT)
7750 std::cerr <<
"Init vcl\n";
7756 throw css::uno::DeploymentException(
"preInit: XComponentContext is not created");
7758 css::uno::Reference< css::uno::XInterface > xService;
7759 xContext->getValueByName(
"/singletons/com.sun.star.lang.theServiceManager") >>= xService;
7761 throw css::uno::DeploymentException(
"preInit: XMultiComponentFactory is not created");
7763 css::uno::Reference<css::lang::XInitialization> aService(
7764 xService, css::uno::UNO_QUERY_THROW);
7774 aService->initialize({css::uno::Any(OUString(
"preload"))});
7788 setLanguageAndLocale(
"en-US");
7791 if (eStage != PRE_INIT)
7793 SAL_INFO(
"lok",
"Re-initialize temp paths");
7796 osl::FileBase::getTempDirURL(aNewTemp);
7807 SAL_INFO(
"lok",
"Enabling RequestHandler");
7809 SAL_INFO(
"lok",
"Starting soffice_main");
7815 SAL_INFO(
"lok",
"Waiting for RequestHandler");
7817 SAL_INFO(
"lok",
"RequestHandler ready -- continuing");
7823 if (eStage != SECOND_INIT)
7826 SAL_INFO(
"lok",
"LOK Initialized");
7827 if (eStage == PRE_INIT)
7832 catch (css::uno::Exception& exception)
7834 fprintf(stderr,
"Bootstrapping exception '%s'\n",
7838 if (eStage == PRE_INIT)
7844#if defined IOS || defined ANDROID || defined __EMSCRIPTEN__
7845 if (officecfg::Office::Impress::Misc::TextObject::QuickEditing::get())
7848 officecfg::Office::Impress::Misc::TextObject::QuickEditing::set(
false, batch);
7853 setCertificateDir();
7855 setLanguageToolConfig();
7859 activateNotebookbar(
u"Writer");
7860 activateNotebookbar(
u"Calc");
7861 activateNotebookbar(
u"Impress");
7862 activateNotebookbar(
u"Draw");
7866 if (eStage == PRE_INIT)
7867 rtl_alloc_preInit(
false);
7875 static bool alreadyCalled =
false;
7879 alreadyCalled =
true;
7883 SAL_INFO(
"lok",
"Create libreoffice object");
7892 return static_cast<LibreOfficeKit*
>(
gImpl);
7902int lok_preinit(
const char* install_path,
const char* user_profile_url)
7904 return lo_initialize(
nullptr, install_path, user_profile_url);
7908int lok_preinit_2(
const char* install_path,
const char* user_profile_url, LibreOfficeKit** kit)
7930 bool bSuccess = xDesktop.is() && xDesktop->terminate();
7944 osl_joinWithThread(
pLib->maThread);
7945 osl_destroyThread(
pLib->maThread);
7949 SAL_INFO(
"lok",
"LO Destroy Done");
constexpr sal_Int8 header[]
constexpr tools::Long MINBODY
PropertyValueVector_t aPropertyValues
const LanguageTag & GetLanguageTag() const
const LanguageTag & GetUILanguageTag() const
static void SetDialogCancelMode(DialogCancelMode mode)
LibreOfficeKitCallback m_pCallback
static ImplSVEvent * PostKeyEvent(VclEventId nEvent, vcl::Window *pWin, KeyEvent const *pKeyEvent)
static OutputDevice * GetDefaultDevice()
static ImplSVEvent * PostGestureEvent(VclEventId nEvent, vcl::Window *pWin, GestureEventPan const *pGestureEvent)
static void UpdateMainThread()
static const AllSettings & GetSettings()
static comphelper::SolarMutex & GetSolarMutex()
static sal_uInt32 ReleaseSolarMutex()
static ImplSVEvent * PostMouseEvent(VclEventId nEvent, vcl::Window *pWin, MouseEvent const *pMouseEvent)
const AlphaMask & GetAlphaMask() const
Bitmap GetBitmap(Color aTransparentReplaceColor) const
static void RegisterDisplay(BasicDisplayErrorFunc *)
size_t GetFontNameCount() const
static const FontMetric & GetFontMetric(sal_Handle hFontMetric)
static const int * GetStdSizeAry()
sal_Handle GetFirstFontMetric(std::u16string_view rName) const
const FontMetric & GetFontName(size_t nFont) const
virtual void Start(bool bStartTimer=true) override
VCL_DLLPUBLIC OUString getImageUrl(OUString const &name, OUString const &style, OUString const &lang)
static VCL_DLLPUBLIC ImageTree & get()
static rtl::Reference< LOKClipboard > getClipboardForCurView()
Fetch clipboard from the global pool.
static void releaseClipboardForView(int nViewId)
Release a clipboard before its document dies, nViewId of -1 clears all.
A clipboard implementation for LibreOfficeKit.
InteractionHandler is an interface that provides the user with various dialogs / error messages.
Represents the contents of LOKClipboard.
LanguageType getLanguageType(bool bResolveSystem=true) const
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
const OUString & getBcp47(bool bResolveSystem=true) const
bool isValidBcp47() const
static OUString convertToBcp47(LanguageType nLangID)
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
vcl::Window * GetWindow()
vcl::Window * GetGraphicWindow()
void SetOrigin(const Point &rOrigin)
static LanguageType resolveSystemLanguageByScriptType(LanguageType nLang, sal_Int16 nType)
static FontMappingUseData FinishTrackingFontMappingUse()
static void ImplClearAllFontData(bool bNewFontLists)
bool AddTempDevFont(const OUString &rFileURL, const OUString &rFontName)
static void ImplRefreshAllFontData(bool bNewFontLists)
static void StartTrackingFontMappingUse()
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
void Move(tools::Long nHorzMove, tools::Long nVertMove)
const SdrOutliner * GetTextEditOutliner() const
static SfxApplication * GetOrCreate()
SfxObjectShell * GetObjectShell() const
css::uno::Reference< css::frame::XDispatch > GetDispatch(const SfxSlot *, const css::util::URL &aURL, bool bMasterCommand)
SfxDispatcher * GetDispatcher() const
vcl::Window * GetWindow() const
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
SfxItemState QueryState(sal_uInt16 nSID, const SfxPoolItem *&rpState)
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
static void setBlockedCommandList(int nViewId, const char *blockedCommandList)
static void setView(int nId)
static std::size_t getViewsCount(int nDocId)
static void postKeyEventAsync(const VclPtr< vcl::Window > &xWindow, int nType, int nCharCode, int nKeyCode, int nRepeat=0)
static void setViewTimezone(int nId, bool isSet, const OUString &rTimezone)
static void destroyView(int nId)
static const tools::Long MaxTwips
static void setDefaultTimezone(bool isSet, const OUString &rTimezone)
static void setViewLocale(int nId, const OUString &rBcp47LanguageTag)
static void setDeviceFormFactor(std::u16string_view rDeviceFormFactor)
static bool getViewIds(int nDocId, int *pArray, size_t nSize)
static void postExtTextEventAsync(const VclPtr< vcl::Window > &xWindow, int nType, const OUString &rText)
static void setDefaultLanguage(const OUString &rBcp47LanguageTag)
static std::unordered_map< OUString, css::uno::Reference< com::sun::star::ui::XAcceleratorConfiguration > > & getAcceleratorConfs()
static void setLoadLanguage(const OUString &rBcp47LanguageTag)
static void setAccessibilityState(int nId, bool nEnabled)
static int getView(const SfxViewShell *pViewShell=nullptr)
static void setViewLanguage(int nId, const OUString &rBcp47LanguageTag)
static void setEditMode(int nMode, vcl::ITiledRenderable *pDoc)
static void dumpState(rtl::OStringBuffer &rState)
const std::shared_ptr< const SfxFilter > & GetFilter() const
void RecheckSignature(bool bAlsoRecheckScriptingSignature)
bool SignDocumentContentUsingCertificate(const css::uno::Reference< css::security::XCertificate > &xCertificate)
SfxMedium * GetMedium() const
SignatureState GetDocumentSignatureState()
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
virtual SfxUndoManager * GetUndoManager()
SfxDispatcher * GetDispatcher() const
static SfxSlotPool & GetSlotPool(SfxViewFrame *pFrame=nullptr)
const SfxSlot * GetUnoSlot(const OUString &rUnoName) const
OUString GetUndoActionsInfo() const
OUString GetRedoActionsInfo() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxBindings & GetBindings()
void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true)
SfxChildWindow * GetChildWindow(sal_uInt16)
SfxFrame & GetFrame() const
void ShowChildWindow(sal_uInt16, bool bVisible=true)
ViewShellId GetViewShellId() const override
SfxViewFrame & GetViewFrame() const
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
virtual int getEditMode() const
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
int getA11yCaretPosition() const
void setLibreOfficeKitViewCallback(SfxLokCallbackInterface *pCallback)
virtual std::optional< OString > getLOKPayload(int nType, int nViewId) const
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
virtual SdrView * GetDrawView() const
static void SetCurrentDocId(ViewShellDocId nId)
OUString getA11yFocusedParagraph() const
virtual int getPart() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const SubsetVec & GetSubsetMap() const
std::size_t GetEndOfData() const
static OUString GetLanguageString(const LanguageType eType)
static bool HasLanguageType(const LanguageType eType)
static LanguageType GetLanguageType(std::u16string_view rStr)
void SetTempPath(const OUString &rPath)
void SetLocaleConfigString(const OUString &rStr)
void SetUILocaleConfigString(const OUString &rStr)
const FontList * GetFontList() const
virtual SvxLongLRSpaceItem * Clone(SfxItemPool *pPool=nullptr) const override
tools::Long GetRight() const
void SetLeft(tools::Long lArgLeft)
tools::Long GetLeft() const
void SetRight(tools::Long lArgRight)
tools::Long GetLower() const
void SetLower(tools::Long lArgRight)
tools::Long GetUpper() const
virtual SvxLongULSpaceItem * Clone(SfxItemPool *pPool=nullptr) const override
void SetUpper(tools::Long lArgLeft)
virtual SvxSizeItem * Clone(SfxItemPool *pPool=nullptr) const override
void SetPriority(TaskPriority ePriority)
void SetTimeout(sal_uInt64 nTimeoutMs)
virtual void Start(bool bStartTimer=true) override
virtual void Invoke() override
static VclAbstractDialogFactory * Create()
reference_type * get() const
void expand(const Tuple2D< TYPE > &rTuple)
static void encode(OUStringBuffer &aStrBuffer, const css::uno::Sequence< sal_Int8 > &aPass)
static void decode(css::uno::Sequence< sal_Int8 > &aPass, std::u16string_view sBuffer)
static std::shared_ptr< ConfigurationChanges > create()
css::uno::Sequence< css::beans::PropertyValue > getAsConstPropertyValueList() const
static SolarMutex * get()
sal_uInt32 release(bool bUnlockAll=false)
void acquire(sal_uInt32 nLockCount=1)
virtual bool tryToAcquire()
static ThreadPool & getSharedOptimalPool()
static void setBufferSizeAndCallback(std::size_t bufferSize, void(*bufferFullCallback)())
static void stopRecording()
static css::uno::Sequence< OUString > getRecordingAndClear()
static void startRecording()
css::uno::Type const & get()
TimeoutIdle(CallbackFlushHandler *handler)
virtual void Invoke() override
One instance of this per view, handles flushing callbacks.
LibreOfficeKitDocument * m_pDocument
virtual void libreOfficeKitViewAddPendingInvalidateTiles() override
virtual void dumpState(rtl::OStringBuffer &rState) override
void resetUpdatedTypePerViewId(int nType, int nViewId)
std::unordered_map< OString, OString > m_lastStateChange
std::unordered_map< int, std::unordered_map< int, OString > > m_viewStates
void resetUpdatedType(int nType)
virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle *pRect, int nPart, int nMode) override
virtual void Invoke() override
std::map< int, OString > m_states
void setUpdatedType(int nType, bool value)
void enqueueUpdatedTypes()
std::vector< bool > m_updatedTypes
virtual void libreOfficeKitViewCallbackWithViewId(int nType, const OString &pPayload, int nViewId) override
virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId) override
void removeViewStates(int viewId)
bool callbacksDisabled() const
Returns true iff callbacks are disabled.
CallbackFlushHandler(LibreOfficeKitDocument *pDocument, LibreOfficeKitCallback pCallback, void *pData)
queue_type2::iterator toQueue2(queue_type1::iterator)
void enqueueUpdatedType(int type, const SfxViewShell *sourceViewShell, int viewId)
boost::container::flat_map< int, std::vector< PerViewIdData > > m_updatedTypesPerViewId
virtual void libreOfficeKitViewUpdatedCallback(int nType) override
virtual ~CallbackFlushHandler() override
LibreOfficeKitCallback m_pCallback
bool processInvalidateTilesEvent(int type, CallbackData &aCallbackData)
std::recursive_mutex m_mutex
queue_type1 m_queue1
we frequently want to scan the queue, and mostly when we do so, we only care about the element type s...
void addViewStates(int viewId)
void setUpdatedTypePerViewId(int nType, int nViewId, int nSourceViewId, bool value)
bool processWindowEvent(int type, CallbackData &aCallbackData)
void queue(const int type, const OString &data)
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) override
TimeoutIdle m_TimeoutIdle
static bool CheckExtensionDependencies()
static void SynchronizeExtensionRepositories(bool bCleanedExtensionCache, Desktop *pDesktop=nullptr)
static CommandLineArgs & GetCommandLineArgs()
static void CreateTemporaryDirectory()
static void WaitForReady()
static Status Enable(bool ipc)
static void SetReady(bool bIsReady)
bool signDocument(css::uno::Reference< css::security::XCertificate > const &rxCertificate)
static css::uno::Reference< css::ui::XAcceleratorConfiguration > lok_createNewAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext > &rxContext, OUString sModule)
void EnableKillingFile(bool bEnable=true)
OUString const & GetURL() const
const OUString & GetFamilyName() const
static VclPtr< vcl::Window > FindLOKWindow(vcl::LOKWindowId nWindowId)
constexpr ::Color COL_LIGHTRED(0xFF, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define SAL_CONFIGFILE(name)
OString exceptionToString(const css::uno::Any &caught)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define TOOLS_INFO_EXCEPTION(area, stream)
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
Reference< XInterface > xTarget
std::deque< AttacherIndex_Impl > aIndex
static int doc_getSignatureState(LibreOfficeKitDocument *pThis)
static char * lo_extractRequest(LibreOfficeKit *pThis, const char *pFilePath)
SAL_JNI_EXPORT LibreOfficeKit * libreofficekit_hook_2(const char *install_path, const char *user_profile_url)
static void lo_destroy(LibreOfficeKit *pThis)
static void doc_destroyView(LibreOfficeKitDocument *pThis, int nId)
static char * getPostIts(LibreOfficeKitDocument *pThis)
Returns the JSON representation of all the comments in the document.
static bool lo_signDocument(LibreOfficeKit *pThis, const char *pUrl, const unsigned char *pCertificateBinary, const int nCertificateBinarySize, const unsigned char *pPrivateKeyBinary, const int nPrivateKeyBinarySize)
static OUString getUString(const char *pString)
static int doc_getViewsCount(LibreOfficeKitDocument *pThis)
static int lo_initialize(LibreOfficeKit *pThis, const char *pInstallPath, const char *pUserProfilePath)
static int doc_getA11yCaretPosition(LibreOfficeKitDocument *pThis)
static void doc_paintWindowForView(LibreOfficeKitDocument *pThis, unsigned nLOKWindowId, unsigned char *pBuffer, const int nX, const int nY, const int nWidth, const int nHeight, const double fDPIScale, int viewId)
static int doc_getPart(LibreOfficeKitDocument *pThis)
static void lo_setOption(LibreOfficeKit *pThis, const char *pOption, const char *pValue)
static char * getLanguages(LibreOfficeKitDocument *pThis, const char *pCommand)
static LibLibreOffice_Impl * gImpl
static LibreOfficeKitDocument * lo_documentLoadWithOptions(LibreOfficeKit *pThis, const char *pURL, const char *pOptions)
const ExtensionMap aWriterExtensionMap[]
static uno::Reference< css::uno::XComponentContext > xContext
static bool isUpdatedType(int type)
static void doc_postWindowMouseEvent(LibreOfficeKitDocument *pThis, unsigned nLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
static bool encodeImageAsHTML(const css::uno::Reference< css::datatransfer::XTransferable > &xTransferable, const OString &aMimeType, OString &aRet)
static void doc_setView(LibreOfficeKitDocument *pThis, int nId)
SAL_JNI_EXPORT int lok_preinit(const char *install_path, const char *user_profile_url)
static void doc_resizeWindow(LibreOfficeKitDocument *pThis, unsigned nLOKWindowId, const int nWidth, const int nHeight)
SAL_JNI_EXPORT LibreOfficeKit * libreofficekit_hook(const char *install_path)
static int doc_getTileMode(LibreOfficeKitDocument *pThis)
static void doc_sendFormFieldEvent(LibreOfficeKitDocument *pThis, const char *pArguments)
static char * convertOUString(std::u16string_view aStr)
static void doc_registerCallback(LibreOfficeKitDocument *pThis, LibreOfficeKitCallback pCallback, void *pData)
static void doc_setViewLanguage(LibreOfficeKitDocument *pThis, int nId, const char *language)
static void doc_sendContentControlEvent(LibreOfficeKitDocument *pThis, const char *pArguments)
static void doc_postWindowKeyEvent(LibreOfficeKitDocument *pThis, unsigned nLOKWindowId, int nType, int nCharCode, int nKeyCode)
static void aBasicErrorFunc(const OUString &rError, const OUString &rAction)
static int doc_getSelectionType(LibreOfficeKitDocument *pThis)
static void doc_setGraphicSelection(LibreOfficeKitDocument *pThis, int nType, int nX, int nY)
static void doc_setPartImpl(LibreOfficeKitDocument *pThis, int nPart, bool bAllowChangeFocus=true)
static int lo_runMacro(LibreOfficeKit *pThis, const char *pURL)
static void lo_sendDialogEvent(LibreOfficeKit *pThis, unsigned long long int nLOKWindowId, const char *pArguments)
static void doc_postUnoCommand(LibreOfficeKitDocument *pThis, const char *pCommand, const char *pArguments, bool bNotifyWhenFinished)
static char * getRulerState(LibreOfficeKitDocument *pThis)
static void lo_status_indicator_callback(void *data, comphelper::LibreOfficeKit::statusIndicatorCallbackType type, int percent, const char *pText)
static char * doc_getPartName(LibreOfficeKitDocument *pThis, int nPart)
static int doc_getEditMode(LibreOfficeKitDocument *pThis)
const ExtensionMap aDrawExtensionMap[]
static void lo_registerCallback(LibreOfficeKit *pThis, LibreOfficeKitCallback pCallback, void *pData)
static std::weak_ptr< LibreOfficeKitClass > gOfficeClass
static void lo_runLoop(LibreOfficeKit *pThis, LibreOfficeKitPollCallback pPollCallback, LibreOfficeKitWakeCallback pWakeCallback, void *pData)
static void doc_setPart(LibreOfficeKitDocument *pThis, int nPart)
static int doc_getDocumentType(LibreOfficeKitDocument *pThis)
static bool doc_insertCertificate(LibreOfficeKitDocument *pThis, const unsigned char *pCertificateBinary, const int nCertificateBinarySize, const unsigned char *pPrivateKeyBinary, const int nPrivateKeyBinarySize)
static void getDocLanguages(LibreOfficeKitDocument *pThis, uno::Sequence< lang::Locale > &rSeq)
static char * lo_getFilterTypes(LibreOfficeKit *pThis)
static bool encodeTextAsHTML(const css::uno::Reference< css::datatransfer::XTransferable > &xTransferable, const OString &aMimeType, OString &aRet)
static void doc_selectPart(LibreOfficeKitDocument *pThis, int nPart, int nSelect)
static char * doc_getA11yFocusedParagraph(LibreOfficeKitDocument *pThis)
static uno::Reference< css::lang::XMultiServiceFactory > xSFactory
static TraceEventDumper * traceEventDumper
static bool lok_preinit_2_called
static char * getStyles(LibreOfficeKitDocument *pThis, const char *pCommand)
static unsigned char * doc_renderFont(LibreOfficeKitDocument *pThis, const char *pFontName, const char *pChar, int *pFontWidth, int *pFontHeight)
static void doc_setBlockedCommandList(LibreOfficeKitDocument *pThis, int nViewId, const char *blockedCommandList)
static char * getTrackedChangeAuthors(LibreOfficeKitDocument *pThis)
Returns the JSON representation of the redline author table.
static void doc_destroy(LibreOfficeKitDocument *pThis)
static void doc_paintWindowDPI(LibreOfficeKitDocument *pThis, unsigned nLOKWindowId, unsigned char *pBuffer, const int nX, const int nY, const int nWidth, const int nHeight, const double fDPIScale)
static void lo_setDocumentPassword(LibreOfficeKit *pThis, const char *pURL, const char *pPassword)
static void doc_postKeyEvent(LibreOfficeKitDocument *pThis, int nType, int nCharCode, int nKeyCode)
static void doc_setWindowTextSelection(LibreOfficeKitDocument *pThis, unsigned nLOKWindowId, bool swap, int nX, int nY)
static int doc_getSelectionTypeAndText(LibreOfficeKitDocument *pThis, const char *pMimeType, char **pText, char **pUsedMimeType)
static char * doc_getPartHash(LibreOfficeKitDocument *pThis, int nPart)
static void doc_paintTile(LibreOfficeKitDocument *pThis, unsigned char *pBuffer, const int nCanvasWidth, const int nCanvasHeight, const int nTilePosX, const int nTilePosY, const int nTileWidth, const int nTileHeight)
static void doc_resetSelection(LibreOfficeKitDocument *pThis)
static int doc_getParts(LibreOfficeKitDocument *pThis)
static int doc_createView(LibreOfficeKitDocument *pThis)
static void extractLinks(const uno::Reference< container::XNameAccess > &xLinks, bool subcontent, tools::JsonWriter &aJson)
static char * lo_getVersionInfo(LibreOfficeKit *pThis)
static char * doc_getTextSelection(LibreOfficeKitDocument *pThis, const char *pMimeType, char **pUsedMimeType)
static void doc_postMouseEvent(LibreOfficeKitDocument *pThis, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
SAL_JNI_EXPORT int lok_preinit_2(const char *install_path, const char *user_profile_url, LibreOfficeKit **kit)
static void doc_getDataArea(LibreOfficeKitDocument *pThis, long nTab, long *pCol, long *pRow)
const ExtensionMap aImpressExtensionMap[]
static void doc_setClientZoom(LibreOfficeKitDocument *pThis, int nTilePixelWidth, int nTilePixelHeight, int nTileTwipWidth, int nTileTwipHeight)
static void doc_postWindow(LibreOfficeKitDocument *pThis, unsigned nLOKWindowId, int nAction, const char *pData)
static char * lo_getError(LibreOfficeKit *pThis)
static void doc_setTextSelection(LibreOfficeKitDocument *pThis, int nType, int nX, int nY)
static void lo_freeError(char *pFree)
static int doc_createViewWithOptions(LibreOfficeKitDocument *pThis, const char *pOptions)
static void preLoadShortCutAccelerators()
Used by preloadData (LibreOfficeKit) for providing different shortcuts for different languages.
static char * convertOString(const OString &rStr)
static void doc_setPartMode(LibreOfficeKitDocument *pThis, int nPartMode)
static std::weak_ptr< LibreOfficeKitDocumentClass > gDocumentClass
static int doc_setClipboard(LibreOfficeKitDocument *pThis, const size_t nInCount, const char **pInMimeTypes, const size_t *pInSizes, const char **pInStreams)
static void doc_setClientVisibleArea(LibreOfficeKitDocument *pThis, int nX, int nY, int nWidth, int nHeight)
static bool doc_getViewIds(LibreOfficeKitDocument *pThis, int *pArray, size_t nSize)
static void lo_startmain(void *)
static void doc_setAccessibilityState(LibreOfficeKitDocument *pThis, int nId, bool bEnabled)
static void doc_completeFunction(LibreOfficeKitDocument *pThis, const char *)
static void lo_setOptionalFeatures(LibreOfficeKit *pThis, unsigned long long features)
static uno::Reference< css::lang::XMultiComponentFactory > xFactory
static void lo_trimMemory(LibreOfficeKit *pThis, int nTarget)
static int lcl_getViewId(std::string_view payload)
static OUString getAbsoluteURL(const char *pURL)
Try to convert a relative URL to an absolute one, unless it already looks like a URL.
const ExtensionMap aCalcExtensionMap[]
static char * getPostItsPos(LibreOfficeKitDocument *pThis)
Returns the JSON representation of the positions of all the comments in the document.
static void lo_dumpState(LibreOfficeKit *pThis, const char *pOptions, char **pState)
static LibreOfficeKitDocument * lo_documentLoad(LibreOfficeKit *pThis, const char *pURL)
static void doc_moveSelectedParts(LibreOfficeKitDocument *pThis, int nPosition, bool bDuplicate)
static char * doc_getPartPageRectangles(LibreOfficeKitDocument *pThis)
static OUString getGenerator()
static bool lcl_isViewCallbackType(const int type)
static int doc_getView(LibreOfficeKitDocument *pThis)
static char * doc_getCommandValues(LibreOfficeKitDocument *pThis, const char *pCommand)
static int doc_getClipboard(LibreOfficeKitDocument *pThis, const char **pMimeTypes, size_t *pOutCount, char ***pOutMimeTypes, size_t **pOutSizes, char ***pOutStreams)
static bool isUpdatedTypePerViewId(int type)
static bool initialize_uno(const OUString &aAppProgramURL)
static void doc_setViewTimezone(LibreOfficeKitDocument *pThis, int nId, const char *timezone)
static void SetLastExceptionMsg(const OUString &s=OUString())
static void doc_setOutlineState(LibreOfficeKitDocument *pThis, bool bColumn, int nLevel, int nIndex, bool bHidden)
static void doc_postWindowGestureEvent(LibreOfficeKitDocument *pThis, unsigned nLOKWindowId, const char *pType, int nX, int nY, int nOffset)
static char * getTrackedChanges(LibreOfficeKitDocument *pThis)
Returns the JSON representation of the redline stack.
static char * getFontSubset(std::string_view aFontName)
static size_t doc_renderShapeSelection(LibreOfficeKitDocument *pThis, char **pOutput)
static bool doc_paste(LibreOfficeKitDocument *pThis, const char *pMimeType, const char *pData, size_t nSize)
static void doc_getDocumentSize(LibreOfficeKitDocument *pThis, long *pWidth, long *pHeight)
static char * getUndoOrRedo(LibreOfficeKitDocument *pThis, UndoOrRedo eCommand)
Returns the JSON representation of either an undo or a redo stack.
static char * getFonts(const char *pCommand)
static void doc_iniUnoCommands()
Initialize UNO commands, in the sense that from now on, the LOK client gets updates for status change...
static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument *pThis, unsigned nWindowId, int nType, const char *pText)
static void doc_initializeForRendering(LibreOfficeKitDocument *pThis, const char *pArguments)
static int doc_saveAs(LibreOfficeKitDocument *pThis, const char *pUrl, const char *pFormat, const char *pFilterOptions)
static void preloadData()
Used only by LibreOfficeKit when used by Online to pre-initialize.
static void doc_paintWindow(LibreOfficeKitDocument *pThis, unsigned nLOKWindowId, unsigned char *pBuffer, const int nX, const int nY, const int nWidth, const int nHeight)
static unsigned char * doc_renderFontOrientation(LibreOfficeKitDocument *pThis, const char *pFontName, const char *pChar, int *pFontWidth, int *pFontHeight, int pOrientation)
static void lcl_sendDialogEvent(unsigned long long int nWindowId, const char *pArguments)
static char * doc_getPartInfo(LibreOfficeKitDocument *pThis, int nPart)
static bool doc_addCertificate(LibreOfficeKitDocument *pThis, const unsigned char *pCertificateBinary, const int nCertificateBinarySize)
static bool doc_renderSearchResult(LibreOfficeKitDocument *pThis, const char *pSearchResult, unsigned char **pBitmapBuffer, int *pWidth, int *pHeight, size_t *pByteSize)
static void doc_removeTextContext(LibreOfficeKitDocument *pThis, unsigned nLOKWindowId, int nCharBefore, int nCharAfter)
static void unoAnyToJson(tools::JsonWriter &rJson, std::string_view pNodeName, const uno::Any &anyItem)
static bool getFromTransferable(const css::uno::Reference< css::datatransfer::XTransferable > &xTransferable, const OString &aInMimeType, OString &aRet)
static void doc_paintPartTile(LibreOfficeKitDocument *pThis, unsigned char *pBuffer, const int nPart, const int nMode, const int nCanvasWidth, const int nCanvasHeight, const int nTilePosX, const int nTilePosY, const int nTileWidth, const int nTileHeight)
static void doc_sendDialogEvent(LibreOfficeKitDocument *pThis, unsigned long long int nLOKWindowId, const char *pArguments)
Sequence< PropertyValue > aArguments
constexpr sal_uInt16 KEY_MOD2
constexpr sal_uInt16 KEY_MOD1
constexpr sal_uInt16 KEY_PASTE
constexpr sal_uInt16 KEY_SHIFT
#define LANGUAGE_DONTKNOW
#define LANGUAGE_ENGLISH_US
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
void SetMacroSecurityLevel(sal_Int32 _nLevel)
OUString ExpandVariables(const OUString &rString)
void setCompatFlag(Compat flag)
void setDialogPainting(bool bDialogPainting)
statusIndicatorCallbackType
bool isAllowlistedLanguage(const OUString &lang)
bool isPartInInvalidation()
void setRangeHeaders(bool bTiledAnnotations)
void setPartInInvalidation(bool bPartInInvalidation)
bool isViewIdForVisCursorInvalidation()
void setLocale(const LanguageTag &languageTag)
void setTiledAnnotations(bool bTiledAnnotations)
void setLanguageTag(const LanguageTag &languageTag)
void setStatusIndicatorCallback(void(*callback)(void *data, statusIndicatorCallbackType type, int percent, const char *pText), void *data)
void setActive(bool bActive)
void setViewIdForVisCursorInvalidation(bool bViewIdForVisCursorInvalidation)
void setDPIScale(double fDPIScale)
OUString convertCommaSeparated(uno::Sequence< OUString > const &i_rSeq)
std::vector< OUString > split(std::u16string_view rStr, sal_Unicode cSeparator)
void setProcessServiceFactory(const Reference< XMultiServiceFactory > &xSMgr)
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
Reference< XMultiServiceFactory > getProcessServiceFactory()
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
std::vector< css::beans::PropertyValue > JsonToPropertyValues(const OString &rJson)
Reference< XComponentContext > getProcessComponentContext()
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
std::shared_ptr< osl::Mutex > const & lock()
Any SAL_CALL getCaughtException()
CPPUHELPER_DLLPUBLIC css::uno::Reference< css::uno::XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext()
DESKTOP_DLLPUBLIC OUString extractParameter(OUString &aOptions, std::u16string_view rName)
Helper function to extract the value from parameters delimited by comma, like: Name1=Value1,...
OUString ReplaceStringHookProc(const OUString &rStr)
DESKTOP_DLLPUBLIC std::vector< com::sun::star::beans::PropertyValue > jsonToPropertyValuesVector(const char *pJSON)
Helper function to convert JSON to a vector of PropertyValues.
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
constexpr double alpha[nDetails]
VCL_DLLPUBLIC bool ExecuteAction(const OUString &nWindowId, const OUString &rWidget, StringMap &rData)
VCL_DLLPUBLIC StringMap jsonToStringMap(const char *pJSON)
VCL_DLLPUBLIC void SendFullUpdate(const OUString &nWindowId, const OUString &rWidget)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
void swap(cow_wrapper< T, P > &a, cow_wrapper< T, P > &b)
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
constexpr auto toTwips(N number, Length from)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
OUString toISO8601(const css::util::DateTime &rDateTime)
void registerPollCallbacks(LibreOfficeKitPollCallback pPollCallback, LibreOfficeKitWakeCallback pWakeCallback, void *pData)
void numberOfViewsChanged(int count)
void unregisterPollCallbacks()
void trimMemory(int nTarget)
void dumpState(rtl::OStringBuffer &rState)
void CloseTopLevel(vcl::Window *pWindow)
void EnableDialogInput(vcl::Window *pWindow)
HashMap_OWString_Interface aMap
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
const sal_Unicode *const aMimeType[]
int DESKTOP_DLLPUBLIC soffice_main()
boost::property_tree::ptree & setJson(const std::string &payload)
Parse and set the JSON object and return it. Clobbers PayloadString.
const boost::property_tree::ptree & getJson() const
Return the parsed JSON instance.
bool validate() const
Validate that the payload and parsed object match.
void updateRectangleAndPart(const RectangleAndPart &rRectAndPart)
Update a RectangleAndPart object and update PayloadString if necessary.
boost::variant< boost::blank, RectangleAndPart, boost::property_tree::ptree, int > PayloadObject
The parsed payload cache. Update validate() when changing this.
const OString & getPayload() const
const RectangleAndPart & getRectangleAndPart() const
Return the parsed RectangleAndPart instance.
LibLODocument_Impl(css::uno::Reference< css::lang::XComponent > xComponent, int nDocumentId)
std::map< size_t, std::shared_ptr< CallbackFlushHandler > > mpCallbackFlushHandlers
std::set< OUString > maFontsMissing
std::shared_ptr< LibreOfficeKitDocumentClass > m_pDocumentClass
css::uno::Reference< css::lang::XComponent > mxComponent
int64_t mOptionalFeatures
OUString maLastExceptionMsg
LibreOfficeKitCallback mpCallback
std::shared_ptr< LibreOfficeKitClass > m_pOfficeClass
void dumpState(rtl::OStringBuffer &aState)
Represents an invalidated rectangle inside a given document part.
tools::Rectangle m_aRectangle
static tools::Rectangle SanitizedRectangle(tools::Long nLeft, tools::Long nTop, tools::Long nWidth, tools::Long nHeight)
Makes sure a rectangle is valid (apparently some code does not like negative coordinates for example)...
static RectangleAndPart Create(const OString &rPayload)
bool isInfinite() const
Infinite Rectangle is both sides are equal or longer than SfxLokHelper::MaxTwips.
bool isEmpty() const
Empty Rectangle is when it has zero dimensions.
UNDERLYING_TYPE get() const
Reference< XController > xController
Reference< XModel > xModel
VCL_DLLPUBLIC bool InitVCL()
VCL_DLLPUBLIC Application * GetpApp()
std::unique_ptr< char[]> aBuffer
std::map< OUString, OUString > StringMap