Simplify using designated initializers
[LibreOffice.git] / odk / examples / cpp / lokconvert / lokconvert.cxx
blob123d1190e040978e7063a161566290077ea45028
1 #include <iostream>
2 #include "LibreOfficeKit/LibreOfficeKit.hxx"
4 int main(int argc, char* argv[])
6 if (argc < 3)
8 std::cout << "Usage: lokconvert <input_file_path> <output_file_path>\n";
9 return 1;
11 const char* input = argv[1];
12 const char* output = argv[2];
14 lok::Office* llo = NULL;
15 try
17 const char* lo_bin_dir = std::getenv("OO_SDK_URE_BIN_DIR");
18 llo = lok::lok_cpp_init(lo_bin_dir);
19 if (!llo)
21 std::cerr << "Error: could not initialise LibreOfficeKit\n";
22 return 1;
25 lok::Document* lodoc = llo->documentLoad(input, NULL /* options */);
26 if (!lodoc)
28 std::cerr << "Error: could not load document: " << llo->getError() << "\n";
29 return 1;
32 if (!lodoc->saveAs(output, "pdf", NULL /* options */))
34 std::cerr << "Error: could not export document: " << llo->getError() << "\n";
35 return 1;
38 catch (const std::exception& e)
40 std::cerr << "Error: LibreOfficeKit exception: " << e.what() << "\n";
41 return 1;
44 std::cerr << "Success!\n";
45 return 0;