fixing bugs #5698 and #2823 for method writeUrl(). Cell ranges still don't work tough

git-svn-id: https://svn.php.net/repository/pear/packages/Spreadsheet_Excel_Writer/trunk@200373 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Xavier Noguer Gallego 2005-11-12 03:33:54 +00:00
parent 2595518d58
commit 51be039267
1 changed files with 44 additions and 32 deletions

View File

@ -1935,7 +1935,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
}
// Strip URL type
$url = preg_replace('[^internal:]', '', $url);
$url = preg_replace('/^internal:/', '', $url);
// Write the visible label
if ($str == '') {
@ -1998,82 +1998,94 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
if (preg_match('[^external:\\\\]', $url)) {
return; //($this->_writeUrlExternal_net($row1, $col1, $row2, $col2, $url, $str, $format));
}
$record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow
if ($format == 0) {
$format = $this->_url_format;
}
// Strip URL type and change Unix dir separator to Dos style (if needed)
//
$url = preg_replace('[^external:]', '', $url);
$url = preg_replace('[/]', "\\", $url);
$url = preg_replace('/^external:/', '', $url);
$url = preg_replace('/\//', "\\", $url);
// Write the visible label
if ($str == '') {
$str = preg_replace('[\#]', ' - ', $url);
$str = preg_replace('/\#/', ' - ', $url);
}
$str_error = $this->writeString($row1, $col1, $str, $format);
if (($str_error == -2) || ($str_error == -3)) {
if (($str_error == -2) or ($str_error == -3)) {
return $str_error;
}
// Determine if the link is relative or absolute:
// relative if link contains no dir separator, "somefile.xls"
// relative if link starts with up-dir, "..\..\somefile.xls"
// otherwise, absolute
$absolute = 0x02; // Bit mask
if (!preg_match('[\\]', $url)) {
if (!preg_match("/\\\/", $url)) {
$absolute = 0x00;
}
if (preg_match('[^\.\.\\]', $url)) {
if (preg_match("/^\.\.\\\/", $url)) {
$absolute = 0x00;
}
$link_type = 0x01 | $absolute;
// Determine if the link contains a sheet reference and change some of the
// parameters accordingly.
// Split the dir name and sheet name (if it exists)
list($dir_long , $sheet) = split('/\#/', $url);
$link_type = 0x01 | $absolute;
/*if (preg_match("/\#/", $url)) {
list($dir_long, $sheet) = split("\#", $url);
}
else {
$dir_long = $url;
}
if (isset($sheet)) {
$link_type |= 0x08;
$sheet_len = pack("V", strlen($sheet) + 0x01);
$sheet = join("\0", split('', $sheet));
$sheet .= "\0\0\0";
} else {
}
else {
$sheet_len = '';
$sheet = '';
}*/
$dir_long = $url;
if (preg_match("/\#/", $url)) {
$link_type |= 0x08;
}
// Pack the link type
$link_type = pack("V", $link_type);
// Calculate the up-level dir count e.g.. (..\..\..\ == 3)
$up_count = preg_match_all("/\.\.\\/", $dir_long, $useless);
$up_count = preg_match_all("/\.\.\\\/", $dir_long, $useless);
$up_count = pack("v", $up_count);
// Store the short dos dir name (null terminated)
$dir_short = preg_replace('/\.\.\\/', '', $dir_long) . "\0";
$dir_short = preg_replace("/\.\.\\\/", '', $dir_long) . "\0";
// Store the long dir name as a wchar string (non-null terminated)
$dir_long = join("\0", split('', $dir_long));
//$dir_long = join("\0", split('', $dir_long));
$dir_long = $dir_long . "\0";
// Pack the lengths of the dir strings
$dir_short_len = pack("V", strlen($dir_short) );
$dir_long_len = pack("V", strlen($dir_long) );
$stream_len = pack("V", strlen($dir_long) + 0x06);
$stream_len = pack("V", 0);//strlen($dir_long) + 0x06);
// Pack the undocumented parts of the hyperlink stream
$unknown1 = pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000' );
$unknown2 = pack("H*",'0303000000000000C000000000000046' );
$unknown3 = pack("H*",'FFFFADDE000000000000000000000000000000000000000');
$unknown4 = pack("v", 0x03 );
// Pack the main data stream
$data = pack("vvvv", $row1, $row2, $col1, $col2) .
$unknown1 .
@ -2083,17 +2095,17 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
$dir_short_len.
$dir_short .
$unknown3 .
$stream_len .
$stream_len ;/*.
$dir_long_len .
$unknown4 .
$dir_long .
$sheet_len .
$sheet ;
$sheet ;*/
// Pack the header data
$length = strlen($data);
$header = pack("vv", $record, $length);
// Write the packed data
$this->_append($header. $data);
return($str_error);