LCOV - code coverage report
Current view: top level - include/LibreOfficeKit - LibreOfficeKit.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 34 0.0 %
Date: 2014-11-03 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  */
       9             : 
      10             : #ifndef INCLUDED_DESKTOP_INC_LIBREOFFICEKIT_HXX
      11             : #define INCLUDED_DESKTOP_INC_LIBREOFFICEKIT_HXX
      12             : 
      13             : #include "LibreOfficeKit.h"
      14             : 
      15             : /*
      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.
      20             :  */
      21             : namespace lok
      22             : {
      23             : 
      24             : class Document
      25             : {
      26             : private:
      27             :     LibreOfficeKitDocument* mpDoc;
      28             : 
      29             : public:
      30           0 :     inline Document(LibreOfficeKitDocument* pDoc) :
      31           0 :         mpDoc(pDoc)
      32           0 :     {}
      33             : 
      34           0 :     inline ~Document()
      35             :     {
      36           0 :         mpDoc->pClass->destroy(mpDoc);
      37           0 :     }
      38             : 
      39             :     inline bool saveAs(const char* pUrl, const char* pFormat = NULL, const char* pFilterOptions = NULL)
      40             :     {
      41             :         return mpDoc->pClass->saveAs(mpDoc, pUrl, pFormat, pFilterOptions);
      42             :     }
      43             : 
      44             :     inline LibreOfficeKitDocument *get() { return mpDoc; }
      45             : 
      46             : #ifdef LOK_USE_UNSTABLE_API
      47             :     inline LibreOfficeKitDocumentType getDocumentType()
      48             :     {
      49             :         return mpDoc->pClass->getDocumentType(mpDoc);
      50             :     }
      51             : 
      52           0 :     inline int getParts()
      53             :     {
      54           0 :         return mpDoc->pClass->getParts(mpDoc);
      55             :     }
      56             : 
      57             :     inline int getPart()
      58             :     {
      59             :         return mpDoc->pClass->getPart(mpDoc);
      60             :     }
      61             : 
      62           0 :     inline void setPart(int nPart)
      63             :     {
      64           0 :         mpDoc->pClass->setPart(mpDoc, nPart);
      65           0 :     }
      66             : 
      67           0 :     inline char* getPartName(int nPart)
      68             :     {
      69           0 :         return mpDoc->pClass->getPartName(mpDoc, nPart);
      70             :     }
      71             : 
      72           0 :     inline void paintTile(
      73             :                           unsigned char* pBuffer,
      74             :                           const int nCanvasWidth,
      75             :                           const int nCanvasHeight,
      76             :                           int* pRowStride,
      77             :                           const int nTilePosX,
      78             :                           const int nTilePosY,
      79             :                           const int nTileWidth,
      80             :                           const int nTileHeight)
      81             :     {
      82             :         return mpDoc->pClass->paintTile(mpDoc, pBuffer, nCanvasWidth, nCanvasHeight, pRowStride,
      83           0 :                                 nTilePosX, nTilePosY, nTileWidth, nTileHeight);
      84             :     }
      85             : 
      86           0 :     inline void getDocumentSize(long* pWidth, long* pHeight)
      87             :     {
      88           0 :         mpDoc->pClass->getDocumentSize(mpDoc, pWidth, pHeight);
      89           0 :     }
      90             : #endif // LOK_USE_UNSTABLE_API
      91             : };
      92             : 
      93             : class Office
      94             : {
      95             : private:
      96             :     LibreOfficeKit* mpThis;
      97             : 
      98             : public:
      99           0 :     inline Office(LibreOfficeKit* pThis) :
     100           0 :         mpThis(pThis)
     101           0 :     {}
     102             : 
     103           0 :     inline ~Office()
     104             :     {
     105           0 :         mpThis->pClass->destroy(mpThis);
     106           0 :     }
     107             : 
     108           0 :     inline Document* documentLoad(const char* pUrl)
     109             :     {
     110           0 :         LibreOfficeKitDocument* pDoc = mpThis->pClass->documentLoad(mpThis, pUrl);
     111           0 :         if (pDoc == NULL)
     112           0 :             return NULL;
     113           0 :         return new Document(pDoc);
     114             :     }
     115             : 
     116             :     // return the last error as a string, free me.
     117             :     inline char* getError()
     118             :     {
     119             :         return mpThis->pClass->getError(mpThis);
     120             :     }
     121             : };
     122             : 
     123           0 : inline Office* lok_cpp_init(const char* pInstallPath)
     124             : {
     125           0 :     LibreOfficeKit* pThis = lok_init(pInstallPath);
     126           0 :     if (pThis == NULL || pThis->pClass->nSize == 0)
     127           0 :         return NULL;
     128           0 :     return new ::lok::Office(pThis);
     129             : }
     130             : 
     131             : }
     132             : #endif
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10