package org.libreoffice;

import android.graphics.Bitmap;

import org.mozilla.gecko.gfx.BufferedCairoImage;
import org.mozilla.gecko.gfx.CairoImage;
import org.mozilla.gecko.gfx.LayerController;
import org.mozilla.gecko.gfx.SubTile;

public class MockTileProvider implements TileProvider {
    private final LayerController layerController;
    private static final int TILE_SIZE = 256;

    public MockTileProvider(LayerController layerController) {
        this.layerController = layerController;
    }

    @Override
    public int getPageWidth() {
        return 549;
    }

    @Override
    public int getPageHeight() {
        return 630*5;
    }

    @Override
    public boolean isReady() {
        return true;
    }

    @Override
    public SubTile createTile(int x, int y) {
        int tiles = (getPageWidth() / TILE_SIZE) + 1;
        int tileNumber = (y / TILE_SIZE) * tiles + (x / TILE_SIZE);
        tileNumber %= 9;
        tileNumber += 1; // 0 to 1 based numbering

        String imageName = "d" + tileNumber;
        Bitmap bitmap = layerController.getDrawable(imageName);

        CairoImage image = new BufferedCairoImage(bitmap);
        SubTile tile = new SubTile(image, x, y);
        tile.beginTransaction();

        return tile;
    }
}

@@ -283,16 +283,62 @@
 vider %7B%0A
+    private static final int TILE_SIZE = 256;%0A
     priv
@@ -396,40 +396,30 @@
 ate 
-static final int TILE_SIZE = 256
+final String inputFile
 ;%0A%0A 
@@ -476,16 +476,34 @@
 ntroller
+, String inputFile
 ) %7B%0A    
@@ -542,24 +542,60 @@
 Controller;%0A
+        this.inputFile = inputFile;%0A
     %7D%0A%0A    @

change MockTileProvider to accept filename