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 // Strip URL type
$url = preg_replace('[^internal:]', '', $url); $url = preg_replace('/^internal:/', '', $url);
// Write the visible label // Write the visible label
if ($str == '') { if ($str == '') {
@ -2008,15 +2008,15 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
// Strip URL type and change Unix dir separator to Dos style (if needed) // Strip URL type and change Unix dir separator to Dos style (if needed)
// //
$url = preg_replace('[^external:]', '', $url); $url = preg_replace('/^external:/', '', $url);
$url = preg_replace('[/]', "\\", $url); $url = preg_replace('/\//', "\\", $url);
// Write the visible label // Write the visible label
if ($str == '') { if ($str == '') {
$str = preg_replace('[\#]', ' - ', $url); $str = preg_replace('/\#/', ' - ', $url);
} }
$str_error = $this->writeString($row1, $col1, $str, $format); $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; return $str_error;
} }
@ -2026,47 +2026,59 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
// otherwise, absolute // otherwise, absolute
$absolute = 0x02; // Bit mask $absolute = 0x02; // Bit mask
if (!preg_match('[\\]', $url)) { if (!preg_match("/\\\/", $url)) {
$absolute = 0x00; $absolute = 0x00;
} }
if (preg_match('[^\.\.\\]', $url)) { if (preg_match("/^\.\.\\\/", $url)) {
$absolute = 0x00; $absolute = 0x00;
} }
$link_type = 0x01 | $absolute;
// Determine if the link contains a sheet reference and change some of the // Determine if the link contains a sheet reference and change some of the
// parameters accordingly. // parameters accordingly.
// Split the dir name and sheet name (if it exists) // Split the dir name and sheet name (if it exists)
list($dir_long , $sheet) = split('/\#/', $url); /*if (preg_match("/\#/", $url)) {
$link_type = 0x01 | $absolute; list($dir_long, $sheet) = split("\#", $url);
}
else {
$dir_long = $url;
}
if (isset($sheet)) { if (isset($sheet)) {
$link_type |= 0x08; $link_type |= 0x08;
$sheet_len = pack("V", strlen($sheet) + 0x01); $sheet_len = pack("V", strlen($sheet) + 0x01);
$sheet = join("\0", split('', $sheet)); $sheet = join("\0", split('', $sheet));
$sheet .= "\0\0\0"; $sheet .= "\0\0\0";
} else { }
else {
$sheet_len = ''; $sheet_len = '';
$sheet = ''; $sheet = '';
}*/
$dir_long = $url;
if (preg_match("/\#/", $url)) {
$link_type |= 0x08;
} }
// Pack the link type // Pack the link type
$link_type = pack("V", $link_type); $link_type = pack("V", $link_type);
// Calculate the up-level dir count e.g.. (..\..\..\ == 3) // 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); $up_count = pack("v", $up_count);
// Store the short dos dir name (null terminated) // 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) // 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"; $dir_long = $dir_long . "\0";
// Pack the lengths of the dir strings // Pack the lengths of the dir strings
$dir_short_len = pack("V", strlen($dir_short) ); $dir_short_len = pack("V", strlen($dir_short) );
$dir_long_len = pack("V", strlen($dir_long) ); $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 // Pack the undocumented parts of the hyperlink stream
$unknown1 = pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000' ); $unknown1 = pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000' );
@ -2083,12 +2095,12 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
$dir_short_len. $dir_short_len.
$dir_short . $dir_short .
$unknown3 . $unknown3 .
$stream_len . $stream_len ;/*.
$dir_long_len . $dir_long_len .
$unknown4 . $unknown4 .
$dir_long . $dir_long .
$sheet_len . $sheet_len .
$sheet ; $sheet ;*/
// Pack the header data // Pack the header data
$length = strlen($data); $length = strlen($data);