|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Xls\Record; |
|
4
|
|
|
|
|
5
|
|
|
use Xls\Range; |
|
6
|
|
|
use Xls\Margin; |
|
7
|
|
|
|
|
8
|
|
|
class ObjPicture extends Obj |
|
9
|
|
|
{ |
|
10
|
|
|
const TYPE = 0x08; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Generate the OBJ record that precedes an IMDATA record. This could be generalise |
|
14
|
|
|
* to support other Excel objects. |
|
15
|
|
|
* |
|
16
|
|
|
* @param integer $objectId |
|
17
|
|
|
* @param Range $area Picture position area |
|
18
|
|
|
* @param Margin $margin Margins from cell sides |
|
19
|
|
|
* @return string |
|
20
|
|
|
*/ |
|
21
|
|
|
public function getData($objectId, Range $area, Margin $margin) |
|
22
|
|
|
{ |
|
23
|
|
|
$objCount = 0x01; // Count of objects in file (set to 1) |
|
24
|
|
|
$grbit = 0x0614; // Option flags |
|
25
|
|
|
$data = pack("Vv3", $objCount, static::TYPE, $objectId, $grbit); |
|
26
|
|
|
|
|
27
|
|
|
$cbMacro = 0x00; // Length of FMLA structure |
|
28
|
|
|
$reserved = 0x00; // Reserved |
|
29
|
|
|
|
|
30
|
|
|
$icvBack = 0x09; // Background colour |
|
31
|
|
|
$icvFore = 0x09; // Foreground colour |
|
32
|
|
|
$fls = 0x00; // Fill pattern |
|
33
|
|
|
$fAuto = 0x00; // Automatic fill |
|
34
|
|
|
$icv = 0x08; // Line colour |
|
35
|
|
|
$lns = 0xff; // Line style |
|
36
|
|
|
$lnw = 0x01; // Line weight |
|
37
|
|
|
$fAutoB = 0x00; // Automatic border |
|
38
|
|
|
$frs = 0x00; // Frame style |
|
39
|
|
|
$imageFormat = 0x09; // Image format, 9 = bitmap |
|
40
|
|
|
$cbPictFmla = 0x00; // Length of FMLA structure |
|
41
|
|
|
$grbit2 = 0x01; // Option flags |
|
42
|
|
|
|
|
43
|
|
|
$data .= $this->packArea($area, $margin); |
|
44
|
|
|
|
|
45
|
|
|
$data .= pack("v", $cbMacro); |
|
46
|
|
|
$data .= pack("Vv", $reserved, $reserved); |
|
47
|
|
|
$data .= pack("C2", $icvBack, $icvFore); |
|
48
|
|
|
$data .= pack("C6", $fls, $fAuto, $icv, $lns, $lnw, $fAutoB); |
|
49
|
|
|
$data .= pack("vV", $frs, $imageFormat); |
|
50
|
|
|
$data .= pack("v4", $reserved, $cbPictFmla, $reserved, $grbit2); |
|
51
|
|
|
|
|
52
|
|
|
$data .= $this->getFtEndSubrecord(); |
|
53
|
|
|
|
|
54
|
|
|
return $this->getFullRecord($data); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param Range $area |
|
59
|
|
|
* @param Margin $margin |
|
60
|
|
|
* |
|
61
|
|
|
* @return string |
|
62
|
|
|
*/ |
|
63
|
|
|
protected function packArea(Range $area, Margin $margin) |
|
64
|
|
|
{ |
|
65
|
|
|
$data = pack("v2", $area->getColFrom(), $margin->getLeft()); |
|
66
|
|
|
$data .= pack("v2", $area->getRowFrom(), $margin->getTop()); |
|
67
|
|
|
$data .= pack("v2", $area->getColTo(), $margin->getRight()); |
|
68
|
|
|
$data .= pack("v2", $area->getRowTo(), $margin->getBottom()); |
|
69
|
|
|
|
|
70
|
|
|
return $data; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|