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/.
10 #ifndef INCLUDED_DESKTOP_INC_LIBLIBREOFFICE_HXX
11 #define INCLUDED_DESKTOP_INC_LIBLIBREOFFICE_HXX
13 #include <liblibreoffice.h>
16 * The reasons this C++ code is not as pretty as it could be are:
17 * a) provide a pure C API - that's useful for some people
18 * b) allow ABI stability - C++ vtables are not good for that.
19 * c) avoid C++ types as part of the API.
24 LibreOfficeDocument
*mpDoc
;
26 inline LODocument( LibreOfficeDocument
*pDoc
) : mpDoc( pDoc
) {}
27 inline ~LODocument() { mpDoc
->destroy( mpDoc
); }
29 // Save as the given format, if format is NULL sniff from ext'n
30 inline bool saveAs( const char *url
, const char *format
= NULL
)
32 return mpDoc
->saveAs( mpDoc
, url
, format
);
40 inline LibLibreOffice( LibreOffice
*pThis
) : mpThis( pThis
) {}
41 inline ~LibLibreOffice() { mpThis
->destroy( mpThis
); };
43 inline bool initialize( const char *installPath
)
45 return mpThis
->initialize( mpThis
, installPath
);
48 inline LODocument
*documentLoad( const char *url
)
50 LibreOfficeDocument
*pDoc
= mpThis
->documentLoad( mpThis
, url
);
53 return new LODocument( pDoc
);
56 // return the last error as a string, free me.
57 inline char *getError() { return mpThis
->getError( mpThis
); }
60 inline LibLibreOffice
*lo_cpp_init( const char *install_path
)
62 LibreOffice
*pThis
= lo_init( install_path
);
63 if( !pThis
|| pThis
->nSize
== 0 )
65 return new LibLibreOffice( pThis
);
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */