android: Add initializeForRendering to LOK

Change-Id: Ibf4721bf4358ef215efde09ef688b2551604bfa2
diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java
index aad4d5a..e415d8f 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/Document.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java
@@ -59,4 +59,7 @@ public class Document {
    public void paintTile(ByteBuffer buffer, int canvasWidth, int canvasHeight, int tilePositionX, int tilePositionY, int tileWidth, int tileHeight) {
        paintTileNative(buffer, canvasWidth, canvasHeight, tilePositionX, tilePositionY, tileWidth, tileHeight);
    }

    public native void initializeForRendering();

}
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b3593d0..8a8538e 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -197,6 +197,8 @@ void        doc_paintTile(LibreOfficeKitDocument* pThis,
static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
                                long* pWidth,
                                long* pHeight);
static void doc_initializeForRendering(LibreOfficeKitDocument* pThis);


struct LibLODocument_Impl : public _LibreOfficeKitDocument
{
@@ -222,6 +224,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
            m_pDocumentClass->setPartMode = doc_setPartMode;
            m_pDocumentClass->paintTile = doc_paintTile;
            m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
            m_pDocumentClass->initializeForRendering = doc_initializeForRendering;

            gDocumentClass = m_pDocumentClass;
        }
@@ -608,6 +611,15 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
    }
}

static void doc_initializeForRendering(LibreOfficeKitDocument* pThis)
{
    ITiledRenderable* pDoc = getTiledRenderable(pThis);
    if (pDoc)
    {
        pDoc->initializeForTiledRendering();
    }
}

static char* lo_getError (LibreOfficeKit *pThis)
{
    LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx
index 0f408ea..2b18071 100644
--- a/desktop/source/lib/lokandroid.cxx
+++ b/desktop/source/lib/lokandroid.cxx
@@ -165,6 +165,13 @@ extern "C" SAL_JNI_EXPORT jlong JNICALL Java_org_libreoffice_kit_Document_getDoc
    return nWidth;
}

extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_initializeForRendering
    (JNIEnv* pEnv, jobject aObject)
{
    LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
    pDocument->pClass->initializeForRendering(pDocument);
}

extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Office_saveAs
    (JNIEnv* pEnv, jobject aObject, jstring sUrl, jstring sFormat, jstring sOptions)
{
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index d7b8e41..de5df7f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -113,6 +113,10 @@ struct _LibreOfficeKitDocumentClass
  void (*getDocumentSize) (LibreOfficeKitDocument* pThis,
                           long* pWidth,
                           long* pHeight);

  // Initialize document for rendering.
  void (*initializeForRendering) (LibreOfficeKitDocument* pThis);

#endif // LOK_USE_UNSTABLE_API
};

diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index f1255f4..274509c 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -87,6 +87,12 @@ public:
    {
        mpDoc->pClass->getDocumentSize(mpDoc, pWidth, pHeight);
    }

    inline void initializeForRendering()
    {
        mpDoc->pClass->initializeForRendering(mpDoc);
    }

#endif // LOK_USE_UNSTABLE_API
};

diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index f07ccd5..d54bbef 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -83,6 +83,10 @@ public:
    {
        (void) ePartMode;
    }

    virtual void initializeForTiledRendering()
    {
    }
};

} // namespace vcl