Teach symstore more duplicated DLLs
[LibreOffice.git] / ios / source / LibreOfficeKit.c
bloba4a78e8112f85f2f692fd1b56f14e9d3e1982cdf
1 //
2 // This file is part of the LibreOffice project.
3 //
4 // This Source Code Form is subject to the terms of the Mozilla Public
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 //
8 #include <stdio.h>
9 #include <TargetConditionals.h>
10 #define LOK_USE_UNSTABLE_API 1
11 #include "LibreOfficeKit.h"
13 #include <LibreOfficeKit/LibreOfficeKitInit.h>
15 #include <osl/process.h>
17 // generated by solenv/bin/native-code.py:
18 #include <../workdir/CustomTarget/ios/native-code.h>
21 // pointers to our instance
22 static LibreOfficeKit* kit;
23 static LibreOfficeKitDocument* document;
26 // Tile variables
27 static int tileSizeX, tileSizeY, tileMaxY, documentParts;
28 static double twipsPerXtile, twipsPerYtile;
32 // Bridge functions to LibreOfficeKit
33 __attribute__((visibility("default")))
34 int BridgeLOkit_Init(const char *appPath, const char *userPath)
37 // Initialize LibreOfficeKit
38 if (!kit) {
39 kit = lok_init_2(appPath, userPath);
40 if (!kit)
41 return 1;
43 return 0;
48 __attribute__((visibility("default")))
49 int BridgeLOkit_Sizing(const int countXtiles, const int countYtiles,
50 const int pixelsXtile, const int pixelsYtile)
52 long docWidth, docHeight;
54 (void)countXtiles;
55 (void)countYtiles;
57 // Remember for later
58 tileSizeX = pixelsXtile;
59 tileSizeY = pixelsYtile;
61 // Calculate twips to pixels in X,Y direction
62 document->pClass->getDocumentSize(document, &docWidth, &docHeight);
63 twipsPerXtile = docWidth / countXtiles;
64 double ratio = (double)docHeight / (double)docWidth + 0.05;
65 int x0 = (int)((ratio - (int)ratio) * 10.0);
66 int x1 = x0 * countXtiles / 10;
67 int x2 = (int)ratio;
68 tileMaxY = x1 + x2;
69 twipsPerYtile = docHeight / tileMaxY;
70 documentParts = document->pClass->getParts(document);
71 return 0;
76 __attribute__((visibility("default")))
77 int BridgeLOkit_open(const char *path)
79 document = kit->pClass->documentLoad(kit, path);
80 document->pClass->initializeForRendering(document, "");
81 return 0;
86 __attribute__((visibility("default")))
87 int BridgeLOkit_ClientCommand(const char *input)
89 (void)input;
90 return 0;
95 __attribute__((visibility("default")))
96 int BridgeLOkit_Hipernate()
98 //FIXME
99 // check if document needs to be saved, to avoid data loss
100 // terminate all threads (basically terminate LOkit)
101 return 0;
106 __attribute__((visibility("default")))
107 int BridgeLOkit_LeaveHipernate()
109 //FIXME
110 // restart LOkit
111 // reload document (it may have been changed by other programs, especially if iCloud
112 return 0;
115 __attribute__((visibility("default")))
116 LibreOfficeKit* BridgeLOkit_getLOK()
118 return kit;