1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
16 #include <liblibreoffice.hxx>
21 gettimeofday(&t
, NULL
);
22 return t
.tv_sec
*1000 + t
.tv_usec
/1000;
27 fprintf( stderr
, "Usage: libtest <absolute-path-to-libreoffice-install> [path to load document] [path to save document].\n" );
31 int main (int argc
, char **argv
)
38 ( argc
> 1 && ( !strcmp( argv
[1], "--help" ) || !strcmp( argv
[1], "-h" ) ) ) )
41 if (argv
[1][0] != '/')
43 fprintf( stderr
, "Absolute path required to libreoffice install\n" );
47 LibLibreOffice
*pOffice
= lo_cpp_init( argv
[1] );
50 fprintf( stderr
, "Failed to initialize\n" );
54 // This separate init is lame I think.
55 if( !pOffice
->initialize( argv
[1] ) )
57 fprintf( stderr
, "failed to initialize\n" );
62 fprintf( stderr
, "init time: %ld ms\n", (end
-start
) );
65 fprintf( stderr
, "start to load document '%s'\n", argv
[2] );
66 LODocument
*pDocument
= pOffice
->documentLoad( argv
[2] );
69 char *pError
= pOffice
->getError();
70 fprintf( stderr
, "failed to load document '%s': '%s'\n",
77 fprintf( stderr
, "load time: %ld ms\n", (end
-start
) );
82 const char *pFilter
= NULL
;
85 fprintf( stderr
, "save document as '%s' (%s)\n", argv
[3], pFilter
? pFilter
: "<null>" );
86 if( !pDocument
->saveAs( argv
[3], pFilter
) )
88 char *pError
= pOffice
->getError();
89 fprintf( stderr
, "failed to save document '%s'\n", pError
);
94 fprintf( stderr
, "Save succeeded\n" );
96 fprintf( stderr
, "save time: %ld ms\n", (end
-start
) );
99 fprintf( stderr
, "all tests passed.\n" );
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */