0009746: ODS export empty lines
authorAlexander Stintzing <a.stintzing@metaways.de>
Thu, 6 Mar 2014 20:21:06 +0000 (21:21 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 7 Mar 2014 17:19:15 +0000 (18:19 +0100)
the ods export produces 3 empty lines before the headers.
there must not be any if no user or date should be shown.

https://forge.tine20.org/mantisbt/view.php?id=9746

Change-Id: I2d08d40cc2a001808a101d64b951713df403379e
Reviewed-on: http://gerrit.tine20.com/customers/412
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Timetracker/ExportTest.php
tine20/Tinebase/Export/Spreadsheet/Ods.php

index 7d34ee0..80b210d 100644 (file)
@@ -114,6 +114,25 @@ class Timetracker_ExportTest extends Timetracker_AbstractTest
         $this->assertTrue(file_exists($result));
         
         $xmlBody = $odsExportClass->getDocument()->asXML();
+
+        $doc = $odsExportClass->getDocument()->getBody();
+        
+        // the first line must not be empty
+        foreach($odsExportClass->getDocument()->getBody()->getTables() as $table) {
+            
+            $body = $table->getBody();
+            $namespaces = $body->getNamespaces(true);
+            
+            foreach($body->xpath('//table:table') as $tbl) {
+                $cells = $tbl->xpath('//table:table-cell');
+                foreach($cells as $cell) {
+                    $xpath = $cell->xpath('//text:p');
+                    $this->assertEquals('Date', (string) $xpath[0]);
+                    $this->assertEquals('Description', (string) $xpath[1]);
+                }
+            }
+        }
+        
         $this->assertEquals(1, preg_match("/0.5/", $xmlBody), 'no duration');
         $this->assertEquals(1, preg_match("/". $timesheetData['description'] ."/", $xmlBody), 'no description');
         $this->assertEquals(1, preg_match("/Description/", $xmlBody), 'no headline');
index 2a5cffc..097cd63 100644 (file)
@@ -173,11 +173,11 @@ class Tinebase_Export_Spreadsheet_Ods extends Tinebase_Export_Spreadsheet_Abstra
      */
     protected function _addHead()
     {
-        $row = $this->_activeTable->appendRow();
-        
         // add header (replace placeholders)
         if (isset($this->_config->headers)) {
             
+            $row = $this->_activeTable->appendRow();
+            
             $patterns = array(
                 '/\{date\}/', 
                 '/\{user\}/',
@@ -195,8 +195,6 @@ class Tinebase_Export_Spreadsheet_Ods extends Tinebase_Export_Spreadsheet_Abstra
             }
         }
         
-        $row = $this->_activeTable->appendRow();
-        
         // add table headline
         $row = $this->_activeTable->appendRow();
         foreach($this->_config->columns->column as $field) {