/**
  * Function used by Block Alias
  * The first start tag on the left is supposed to be the good one.
  * Note: encapuslation is not yet supported in this version.
  */
 function XML_BlockAlias_Prefix($TagPrefix, $Txt, $PosBeg, $Forward, $LevelStop)
 {
     $loc = clsTbsXmlLoc::FindStartTagByPrefix($Txt, $TagPrefix, $PosBeg, false);
     if ($Forward) {
         $loc->FindEndTag();
         return $loc->PosEnd;
     } else {
         return $loc->PosBeg;
     }
 }
예제 #2
0
 /**
  * Fixes the problem of ODS files built with LibreOffice >= 4 and merged with OpenTBS and opened with Ms Excel.
  * The virtual number of row can exeed the maximum supported, then Excem raises an error when opening the file.
  * LibreOffice does not.
  */
 function OpenDoc_MsExcelCompatibility(&$Txt)
 {
     $el_tbl = 'table:table';
     $el_col = 'table:table-column';
     // Column definition
     $el_row = 'table:table-row';
     $el_cell = 'table:table-cell';
     $att_rep_col = 'table:number-columns-repeated';
     $att_rep_row = 'table:number-rows-repeated';
     $loop = array($att_rep_col, $att_rep_row);
     // Loop for deleting useless repeated columns
     foreach ($loop as $att_rep) {
         $p = 0;
         while ($xml = clsTbsXmlLoc::FindElementHavingAtt($Txt, $att_rep, $p)) {
             $xml->FindName();
             $p = $xml->PosEnd;
             // Next tag (opening or closing)
             $next = clsTbsXmlLoc::FindStartTagByPrefix($Txt, '', $p);
             $next_name = $next->Name;
             if ($next_name == '') {
                 $next_name = $next->GetSrc();
                 $next_name = substr($next_name, 1, strlen($next_name) - 2);
             }
             $z_src = $next->GetSrc();
             //echo " * name=" . $xml->Name . ", suiv_name=$next_name, suiv_src=$z_src\n";
             $delete = false;
             if ($xml->Name == $el_col && $xml->SelfClosing) {
                 if ($next_name == $el_row || $next_name == '/' . $el_tbl) {
                     $delete = true;
                 }
             } elseif ($xml->Name == $el_cell && $xml->SelfClosing) {
                 if ($next_name == '/' . $el_row) {
                     $delete = true;
                 }
             } elseif ($xml->Name == $el_row) {
                 if ($next_name == '/' . $el_tbl) {
                     $inner_src = '' . $xml->GetInnerSrc();
                     if (strpos($inner_src, '<') === false) {
                         $delete = true;
                     }
                 }
             }
             if ($delete) {
                 //echo " * SUPPRIME " . $xml->Name . " : " . $xml->GetSrc() . "\n";
                 $p = $xml->PosBeg;
                 $xml->Delete();
             }
         }
     }
 }