Fix #7909 - key value settings on word writer
authorAlan <alan@roojs.com>
Tue, 21 Nov 2023 06:29:17 +0000 (14:29 +0800)
committerAlan <alan@roojs.com>
Tue, 21 Nov 2023 06:29:17 +0000 (14:29 +0800)
Document/Word/Writer/Style/Cell.php
Document/Word/Writer/Style/Font.php
Document/Word/Writer/Style/Paragraph.php
Document/Word/Writer/Style/Table.php
File/Convert/AbiToDocx.php

index 66972fa..0d9fca7 100644 (file)
@@ -123,7 +123,12 @@ class Document_Word_Writer_Style_Cell
         */\r
        private $_defaultBorderColor;\r
        \r
-       \r
+       var $_bgStyle;\r
+       var $_botAttach;\r
+       var $_columnNum;\r
+       var $_mergeto;\r
+       var $_rowNum;\r
+\r
        /**\r
         * Create a new Cell Style\r
         */\r
@@ -153,11 +158,25 @@ class Document_Word_Writer_Style_Cell
         {\r
                if($key == '_borderSize') {\r
                        $this->setBorderSize($value);\r
-               } elseif($key == '_borderColor') {\r
+                       return;\r
+               } \r
+               if ($key == '_borderColor') {\r
                        $this->setBorderColor($value);\r
-               } else {\r
-                       $this->$key = $value;\r
+                       return;\r
                }\r
+               \r
+               $cache = array();\r
+               if (empty($cache)) {\r
+                       $ar = get_class_vars(get_class($this));\r
+                       foreach($ar as $k => $v) {\r
+                               $cache[strtolower($k)] = $k;\r
+                       }\r
+               }\r
+               $key = strtolower(str_replace('-','', $key));\r
+               $key = isset($cache[$key]) ? $cache[$key] : $key;\r
+                \r
+               $this->$key = $value;\r
+               \r
        }\r
        \r
        public function getVAlign() \r
index d73516d..b606447 100644 (file)
@@ -96,6 +96,27 @@ class Document_Word_Writer_Style_Font
        private $_color;
        private $_fgColor;
 
+       /// not used - but set by setstyle      
+       var $_align;
+       var $_bgcolor;
+       var $_fontStretch;
+       var $_fontVariant;
+       var $_href;
+       var $_lang;
+       var $_lineHeight;
+       var $_marginBottom;
+       var $_marginLeft;
+       var $_marginRight;
+       var $_marginTop;
+       var $_Normal;
+       var $_Reference;
+       var $_textDecoration;
+       var $_textIndent;
+       var $_textPosition;
+       var $_textTransform;
+       
+       
+       
        public function __construct($type = 'text', $styleParagraph = null) 
         {
                $this->_type            = $type;
@@ -131,12 +152,23 @@ class Document_Word_Writer_Style_Font
        }
        
        public function setStyleValue($key, $value) 
-        {
+     {
                if($key == '_size') {
-                    $value = (int) $value;
-                    $value *= 2;
+                       $value = (int) $value;
+                       $value *= 2;
                }
-               $this->$key = $value;
+               
+               $cache = array();
+               if (empty($cache)) {
+                       $ar = get_class_vars(get_class($this));
+                       foreach($ar as $k => $v) {
+                               $cache[strtolower($k)] = $k;
+                       }
+               }
+               $key = strtolower(str_replace('-','', $key));
+               $key = isset($cache[$key]) ? $cache[$key] : $key;
+               
+               $this->$key =  $value;
        }
        
        public function setName($pValue = 'Arial') 
index f92f520..2931552 100644 (file)
@@ -64,8 +64,29 @@ class Document_Word_Writer_Style_Paragraph
         */\r
        private $_spacing;\r
         \r
-        private $_list_style;\r
+    private $_liststyle;\r
        \r
+       // not used? but set by setter\r
+       var $_bgcolor;\r
+       var $_bold;\r
+       var $_color;\r
+       var $_fontStretch;\r
+       var $_fontVariant;\r
+       var $_italic;\r
+       var $_lineHeight;\r
+       var $_marginBottom;\r
+       var $_marginLeft;\r
+       var $_marginRight;\r
+       var $_marginTop;\r
+       var $_name;\r
+       var $_Normal;\r
+       var $_Reference;\r
+       var $_size;\r
+       var $_textDecoration;\r
+       var $_textIndent;\r
+       var $_textPosition;\r
+       var $_widows;\r
+\r
        \r
        /**\r
         * New Paragraph Style\r
@@ -76,7 +97,7 @@ class Document_Word_Writer_Style_Paragraph
                $this->_spaceBefore     = null;\r
                $this->_spaceAfter      = null;\r
                $this->_spacing         = null;\r
-                $this->_list_style      = null;\r
+        $this->_liststyle      = null;\r
        }\r
        \r
        /**\r
@@ -91,11 +112,22 @@ class Document_Word_Writer_Style_Paragraph
                        $value += 240; // because line height of 1 matches 240 twips\r
                }\r
                 \r
-                if($key == '_list-style'){\r
-                    $key = str_replace('-', '_', $key);\r
-                }\r
-                \r
-               $this->$key = $value;\r
+               if($key == '_list-style'){\r
+                       $key = str_replace('-', '_', $key);\r
+               }\r
+        $cache = array();\r
+               if (empty($cache)) {\r
+                       $ar = get_class_vars(get_class($this));\r
+                       foreach($ar as $k => $v) {\r
+                               $cache[strtolower($k)] = $k;\r
+                       }\r
+               }\r
+               $key = strtolower(str_replace('-','', $key));\r
+               $key = isset($cache[$key]) ? $cache[$key] : $key;\r
+               \r
+               $this->$key =  $value;\r
+                 \r
+                \r
        }\r
 \r
        /**\r
@@ -185,7 +217,7 @@ class Document_Word_Writer_Style_Paragraph
         * @return PHPWord_Style_Paragraph\r
         */\r
        public function setSpacing($pValue = null) \r
-        {\r
+       {\r
           $this->_spacing = $pValue;\r
           return $this;\r
        }\r
@@ -197,7 +229,6 @@ class Document_Word_Writer_Style_Paragraph
         */\r
        public function getListStyle() \r
         {\r
-            return $this->_list_style;\r
+            return $this->_liststyle;\r
        }\r
 }\r
-?>
\ No newline at end of file
index f0885c0..a5eee73 100644 (file)
@@ -33,7 +33,16 @@ class Document_Word_Writer_Style_Table
        private $_cellMarginLeft;\r
        private $_cellMarginRight;\r
        private $_cellMarginBottom;\r
-        public  $_fixed = false;\r
+    public  $_fixed = false;\r
+       \r
+       // not used..\r
+       var $_width0;\r
+       var $_width0_dax;\r
+       var $_width1;\r
+       var $_width1_dax;\r
+       var $_width2;\r
+       var $_width2_dax;\r
+       \r
        \r
        public function __construct() \r
         {\r
@@ -44,7 +53,16 @@ class Document_Word_Writer_Style_Table
        }\r
        \r
        public function setStyleValue($key, $value) \r
-        {\r
+    {\r
+               $cache = array();\r
+               if (empty($cache)) {\r
+                       $ar = get_class_vars(get_class($this));\r
+                       foreach($ar as $k => $v) {\r
+                               $cache[strtolower($k)] = $k;\r
+                       }\r
+               }\r
+               $key = strtolower(str_replace('-','', $key));\r
+               $key = isset($cache[$key]) ? $cache[$key] : $key;\r
                $this->$key = $value;\r
        }\r
        \r
index d7ec82c..114dd4d 100644 (file)
 
 class File_Convert_AbiToDocx 
 {
+    var $fileName;
+    var $keepSection;
+    var $link;
+    var $pass;
+    var $section;
+    var $style;
+    var $tmpdir;
+    var $writer;
+    var $xr;
     
     function __construct($fn) 
     {
-            $this->fileName = $fn;
-        //    echo file_get_contents($fn);exit;
-            
-            return;
-            
-            require_once dirname(__FILE__) .'/../Convert.php';
-            $x = new File_Convert($fn, 'application/abiword' );
-            $x->convert('application/abiword');
-            $x->serve('attachment');
+        $this->fileName = $fn;
+    //    echo file_get_contents($fn);exit;
+        
+        return;
         
-            exit;
+        require_once dirname(__FILE__) .'/../Convert.php';
+        $x = new File_Convert($fn, 'application/abiword' );
+        $x->convert('application/abiword');
+        $x->serve('attachment');
+    
+        exit;
             
     }
         // maps abiword css names to word style attributes
-        var $styleMatch = array(
-                'font-family' => 'name',
-                'font-size' => 'size',
-                'text-align' => 'align',
+    var $styleMatch = array(
+            'font-family' => 'name',
+            'font-size' => 'size',
+            'text-align' => 'align',
 //                'color' => 'color', // might be fgcolor
-        );
-    
-        function save($fn)
-        {
-                require_once __DIR__ . '/../../Document/Word/Writer.php';
-                require_once __DIR__ . '/../../System.php';
-                $this->tmpdir  = System::mktemp("-d abitodocx");
-                //$this->tmpdir  = '/tmp';
-                $this->link = '';
-                $this->style[] = array();
-                $this->keepSection = false;
-                $this->writer = new Document_Word_Writer(); // New Word Document
-                $this->section = $this->writer->createSection();
-                $this->pass = 1;
-                $this->parseAbi();
-                $this->pass = 2;
-                $this->parseAbi();
-                $this->saveDocx( $fn ); // uses this->writer...
-                
-        }
-         function dumpsections($s)
-        {
-            foreach($s as $ss) echo get_class($ss) . ":";
-            echo ":TOP". get_class($this->section);
-            echo '<br/>';
-        }
-        function parseAbi()
-        {
-            ini_set('memory_limit', '512M');
-            $this->xr = new XMLReader(); // New XML Reader
+    );
 
-            if(!$this->xr->open($this->fileName)){
-                return PEAR::raiseError('Failed to open input file.');
-            }
-            $state = array();
-            $sections = array();
-            $stack = array();
-            
-            // this may produce warnings... - &gt; confuses the XML reader.. (as we are using it in abiword generation.)
+    function save($fn)
+    {
+        require_once __DIR__ . '/../../Document/Word/Writer.php';
+        require_once __DIR__ . '/../../System.php';
+        $this->tmpdir  = System::mktemp("-d abitodocx");
+        //$this->tmpdir  = '/tmp';
+        $this->link = '';
+        $this->style[] = array();
+        $this->keepSection = false;
+        $this->writer = new Document_Word_Writer(); // New Word Document
+        $this->section = $this->writer->createSection();
+        $this->pass = 1;
+        $this->parseAbi();
+        $this->pass = 2;
+        $this->parseAbi();
+        $this->saveDocx( $fn ); // uses this->writer...
             
-            while ($this->xr->read()){
-                //$this->dumpsections($sections);
-                 // echo $this->xr->name . '::' . count($sections). "<br/>"; 
-                 $method = 'handle_'.$this->xr->name;
-                 
-                 
-                 if ($this->xr->nodeType == XMLReader::END_ELEMENT) {
-                     if($this->xr->name == 'section'){
-                         $this->keepSection = false;
-                     }
-                     
-                     if (method_exists($this, $method)) {
-                        $this->style = array_pop($state);
-                        $this->section = array_pop($sections);
-                        array_pop($stack);
-                       // echo "AFTER POP:"; $this->dumpsections($sections); 
-                     }
-                     continue;
-                }
-                
-                $textNode = array('p','c','a');
-//                    print_r($this->xr->name);
-                
-                if ($this->xr->name == '#text' && count($stack) &&  $this->pass==2 && in_array($stack[count($stack)-1], $textNode)) {
-                    
-                    // the reader does not clean out the htmlizums...
-                    $text =   $this->xr->value;
-                    
-                    if(strpos($text, '{#PAGE#}') !== false || strpos($text, '{#NUMPAGES#}') !== false){
-                        $this->section->addPreserveText(str_replace("#", "", $text), $this->style,$this->style);
-                        
-                    }elseif(is_array($this->style) && array_key_exists('href', $this->style)) {
-                        $this->section->addLink($this->style['href'], $text,  $this->style);
-                       
-                    }else{
-                        $this->section->addText($text, $this->style);
-                    }
-                    continue;
-                }
-                
-                
-                if ($this->xr->nodeType != XMLReader::ELEMENT) {
-                    continue;
-                }
-               
-                if (!method_exists($this, $method)) {
-                        continue;
-//                        echo "NOT HANLED {$this->xr->name} <br/>";
-                } 
-                
-                if (!$this->xr->isEmptyElement) {
-                   $stack[] = $this->xr->name;
-                   $sections[] = $this->section;
-                   $state[] = $this->style;
-                }
-                
-                $this->$method();  
-               
-            }
+    }
+    function dumpsections($s)
+    {
+        foreach($s as $ss) echo get_class($ss) . ":";
+        echo ":TOP". get_class($this->section);
+        echo '<br/>';
+    }
+    function parseAbi()
+    {
+        ini_set('memory_limit', '512M');
+        $this->xr = new XMLReader(); // New XML Reader
+
+        if(!$this->xr->open($this->fileName)){
+            return PEAR::raiseError('Failed to open input file.');
         }
+        $state = array();
+        $sections = array();
+        $stack = array();
         
-        function handle_s() 
-        {
-            if ($this->pass != 2) {
-                return;
-            }
-            $this->writer->addFontStyle($this->xr->getAttribute('name'), $this->parseProps(),$this->parseProps());
-        }
+        // this may produce warnings... - &gt; confuses the XML reader.. (as we are using it in abiword generation.)
         
-        function handle_table() 
-        {
-            if ($this->pass != 2) {
-                return;
+        while ($this->xr->read()){
+            //$this->dumpsections($sections);
+             // echo $this->xr->name . '::' . count($sections). "<br/>"; 
+             $method = 'handle_'.$this->xr->name;
+             
+             
+             if ($this->xr->nodeType == XMLReader::END_ELEMENT) {
+                 if($this->xr->name == 'section'){
+                     $this->keepSection = false;
+                 }
+                 
+                 if (method_exists($this, $method)) {
+                    $this->style = array_pop($state);
+                    $this->section = array_pop($sections);
+                    array_pop($stack);
+                   // echo "AFTER POP:"; $this->dumpsections($sections); 
+                 }
+                 continue;
             }
-            $this->style =  $this->parseProps();
-//            print_r($this->style);
-            $this->section = $this->section->addTable($this->style); // Add table
             
-        }
-        
-        function handle_cell()
-        {
-            if ($this->pass != 2) {
-                return;
-            }
-            $style =  $this->parseProps();
-             
-            if($style['columnNum'] == 0){
-                $height = '';
-                if(array_key_exists('height' . $style['rowNum'], $this->style)){
-                    $height = $this->converttoDax($this->style['height' . $style['rowNum']],null);
+            $textNode = array('p','c','a');
+//                    print_r($this->xr->name);
+            
+            if ($this->xr->name == '#text' && count($stack) &&  $this->pass==2 && in_array($stack[count($stack)-1], $textNode)) {
+                
+                // the reader does not clean out the htmlizums...
+                $text =   $this->xr->value;
+                
+                if(strpos($text, '{#PAGE#}') !== false || strpos($text, '{#NUMPAGES#}') !== false){
+                    $this->section->addPreserveText(str_replace("#", "", $text), $this->style,$this->style);
+                    
+                }elseif(is_array($this->style) && array_key_exists('href', $this->style)) {
+                    $this->section->addLink($this->style['href'], $text,  $this->style);
+                   
+                }else{
+                    $this->section->addText($text, $this->style);
                 }
-                $this->section->addRow($height);
-            }
-            $cellWidth = '';
-            if (isset($this->style['width' . $style['columnNum'] ])) {
-                $cellWidth = $this->converttoDax($this->style['width' . $style['columnNum']],null);
+                continue;
             }
             
-            //echo "CW? " . $cellWidth . "|";
-            $this->section = $this->section->addCell($cellWidth, $style);
-         }
-        
-         
-         
-        function handle_p()
-        {
-            if ($this->pass != 2) {
-                return;
-            }
             
-            $style =  $this->parseProps();
-            if(!empty($style)){
-                $this->style = array_merge($style, Document_Word_Writer_Style::getStyles());
-            }else{
-                $this->style = $this->xr->getAttribute('style');
+            if ($this->xr->nodeType != XMLReader::ELEMENT) {
+                continue;
             }
+           
+            if (!method_exists($this, $method)) {
+                    continue;
+//                        echo "NOT HANLED {$this->xr->name} <br/>";
+            } 
             
-            if($this->keepSection){
-                return;
+            if (!$this->xr->isEmptyElement) {
+               $stack[] = $this->xr->name;
+               $sections[] = $this->section;
+               $state[] = $this->style;
             }
-            // p must create a text run.. otherwise cells do not work..
-             $this->section = $this->section->createTextRun($this->style);
             
+            $this->$method();  
+           
         }
-        
-        function handle_a()
-        {
-            if ($this->pass != 2) {
-                return;
-            }
-            $this->style = $this->parseProps();
-            $this->style['href'] = $this->xr->getAttribute('xlink:href');
-            
+    }
+    
+    function handle_s() 
+    {
+        if ($this->pass != 2) {
+            return;
         }
+        $this->writer->addFontStyle($this->xr->getAttribute('name'), $this->parseProps(),$this->parseProps());
+    }
+    
+    function handle_table() 
+    {
+        if ($this->pass != 2) {
+            return;
+        }
+        $this->style =  $this->parseProps();
+//            print_r($this->style);
+        $this->section = $this->section->addTable($this->style); // Add table
         
-        function handle_image()
-        {
-            if ($this->pass != 2) {
-                return;
-            }
-            $style =  $this->parseProps();
-            
-            $image = $this->xr->getAttribute('dataid');
-            foreach($style as $key => $value){
-                $style[$key] = $this->converttoDax($value,'image');
-            }
-            if(!empty($image)){
-                $this->section->addImage($this->tmpdir . '/' . $image . '.jpg', $style);
-                return;
+    }
+    
+    function handle_cell()
+    {
+        if ($this->pass != 2) {
+            return;
+        }
+        $style =  $this->parseProps();
+         
+        if($style['columnNum'] == 0){
+            $height = '';
+            if(array_key_exists('height' . $style['rowNum'], $this->style)){
+                $height = $this->converttoDax($this->style['height' . $style['rowNum']],null);
             }
-            
-            $path = $this->xr->getAttribute('filesrc');
-            $this->section->addImage($path, $style);
-            
-//            echo '<PRE>';print_r($this->section);exit;
+            $this->section->addRow($height);
+        }
+        $cellWidth = '';
+        if (isset($this->style['width' . $style['columnNum'] ])) {
+            $cellWidth = $this->converttoDax($this->style['width' . $style['columnNum']],null);
         }
         
-        function handle_pbr() 
-        {
-            if ($this->pass != 2) {
-                return;
-            }
-            $this->section->addPageBreak();
+        //echo "CW? " . $cellWidth . "|";
+        $this->section = $this->section->addCell($cellWidth, $style);
+     }
+    
+     
+     
+    function handle_p()
+    {
+        if ($this->pass != 2) {
+            return;
         }
         
-        function handle_br() 
-        {
-            if ($this->pass != 2) {
-                return;
-            }
-            if (method_exists($this->section, 'addTextBreak')) {
-                // might be called on Table?
-                $this->section->addTextBreak();
-            }
-            //echo '<PRE>';print_r($this->section);exit;
+        $style =  $this->parseProps();
+        if(!empty($style)){
+            $this->style = array_merge($style, Document_Word_Writer_Style::getStyles());
+        }else{
+            $this->style = $this->xr->getAttribute('style');
         }
         
-        function handle_section()
-        {
-            if ($this->pass != 2) {
-                return;
-            }
-            // only made on first pass..
-            
-            $sectionType = $this->xr->getAttribute('type');
-            if($sectionType == 'header'){
-                $this->keepSection = true;
-                $this->section = $this->section->createHeader();
-            }elseif($sectionType == 'footer'){
-                $this->keepSection = true;
-                $this->section = $this->section->createFooter();
-            }
+        if($this->keepSection){
+            return;
         }
+        // p must create a text run.. otherwise cells do not work..
+         $this->section = $this->section->createTextRun($this->style);
         
-        function handle_field()
-        {
-            if ($this->pass != 2) {
-                return;
-            }
-            //return; /// this would not work!
+    }
+    
+    function handle_a()
+    {
+        if ($this->pass != 2) {
+            return;
+        }
+        $this->style = $this->parseProps();
+        $this->style['href'] = $this->xr->getAttribute('xlink:href');
         
-            $fieldType = $this->xr->getAttribute('type');
-            // addPreserveText -- Only available in header / footer. See chapter "footer" or "header".
-            if($fieldType == 'page_number' || $fieldType == 'number_pages'){
-                $this->section->addPreserveText('Page {PAGE} of {NUMPAGES}', $this->style,$this->style);
-            }
+    }
+    
+    function handle_image()
+    {
+        if ($this->pass != 2) {
+            return;
         }
+        $style =  $this->parseProps();
         
-        function handle_c()
-        {
-            if(is_array($this->style) && array_key_exists('href', $this->style)){
-                $this->style = array_merge($this->style , $this->parseProps());
-                return;
-            }
-            $this->style =  $this->parseProps();
-//            $this->section->createTextRun($this->style);
+        $image = $this->xr->getAttribute('dataid');
+        foreach($style as $key => $value){
+            $style[$key] = $this->converttoDax($value,'image');
+        }
+        if(!empty($image)){
+            $this->section->addImage($this->tmpdir . '/' . $image . '.jpg', $style);
+            return;
         }
         
-        /**
-         * handle the image data 
-         * 
-         * not in used, we dont encore the image to base 64 any more
-         */
-        function handle_d()
-        {
-            if ($this->pass == 2) {
-                return;
-            }
-            $data = base64_decode($this->xr->readString()); // Create the image source if not exist!
-            $imageId = $this->xr->getAttribute('name');
-            $path = $this->tmpdir . '/' . $imageId . '.jpg';
-            if(!file_exists($path)){
-               file_put_contents($path, $data); 
-            }   
-           
+        $path = $this->xr->getAttribute('filesrc');
+        $this->section->addImage($path, $style);
+        
+//            echo '<PRE>';print_r($this->section);exit;
+    }
+    
+    function handle_pbr() 
+    {
+        if ($this->pass != 2) {
+            return;
+        }
+        $this->section->addPageBreak();
+    }
+    
+    function handle_br() 
+    {
+        if ($this->pass != 2) {
+            return;
         }
+        if (method_exists($this->section, 'addTextBreak')) {
+            // might be called on Table?
+            $this->section->addTextBreak();
+        }
+        //echo '<PRE>';print_r($this->section);exit;
+    }
+    
+    function handle_section()
+    {
+        if ($this->pass != 2) {
+            return;
+        }
+        // only made on first pass..
         
-        // converts inches / cm into dax (word measurments)
-        function converttoDax($wh,$type=null)
-        {
-            $changeType = preg_replace('/[^a-z]/', '', $wh);
-            $num = preg_replace('/[^0-9.]/', '', $wh);
-            $num = (float) $num;
-            if($type == 'image'){
-                if($changeType == 'in'){
-                    return floor($num * 75);
-                }
-                return floor($num);
-                
-            }
-            
+        $sectionType = $this->xr->getAttribute('type');
+        if($sectionType == 'header'){
+            $this->keepSection = true;
+            $this->section = $this->section->createHeader();
+        }elseif($sectionType == 'footer'){
+            $this->keepSection = true;
+            $this->section = $this->section->createFooter();
+        }
+    }
+    
+    function handle_field()
+    {
+        if ($this->pass != 2) {
+            return;
+        }
+        //return; /// this would not work!
+    
+        $fieldType = $this->xr->getAttribute('type');
+        // addPreserveText -- Only available in header / footer. See chapter "footer" or "header".
+        if($fieldType == 'page_number' || $fieldType == 'number_pages'){
+            $this->section->addPreserveText('Page {PAGE} of {NUMPAGES}', $this->style,$this->style);
+        }
+    }
+    
+    function handle_c()
+    {
+        if(is_array($this->style) && array_key_exists('href', $this->style)){
+            $this->style = array_merge($this->style , $this->parseProps());
+            return;
+        }
+        $this->style =  $this->parseProps();
+//            $this->section->createTextRun($this->style);
+    }
+    
+    /**
+     * handle the image data 
+     * 
+     * not in used, we dont encore the image to base 64 any more
+     */
+    function handle_d()
+    {
+        if ($this->pass == 2) {
+            return;
+        }
+        $data = base64_decode($this->xr->readString()); // Create the image source if not exist!
+        $imageId = $this->xr->getAttribute('name');
+        $path = $this->tmpdir . '/' . $imageId . '.jpg';
+        if(!file_exists($path)){
+           file_put_contents($path, $data); 
+        }   
+       
+    }
+    
+    // converts inches / cm into dax (word measurments)
+    function converttoDax($wh,$type=null)
+    {
+        $changeType = preg_replace('/[^a-z]/', '', $wh);
+        $num = preg_replace('/[^0-9.]/', '', $wh);
+        $num = (float) $num;
+        if($type == 'image'){
             if($changeType == 'in'){
-                return $num * 1435;
-            }elseif($changeType == 'cm'){
-                return $num * 567;
-            }else{
-                return $num;
+                return floor($num * 75);
             }
+            return floor($num);
             
         }
         
-        function parseProps()
-        {
-            ini_set('memory_limit', '512M');
-            $attribute = $this->xr->getAttribute('props');
-            if(empty($attribute)){
-                return array();
-            }
-            $data = explode(';', trim($attribute));
+        if($changeType == 'in'){
+            return $num * 1435;
+        }elseif($changeType == 'cm'){
+            return $num * 567;
+        }else{
+            return $num;
+        }
         
-            foreach ($data as $attrs){
+    }
+    
+    function parseProps()
+    {
+        ini_set('memory_limit', '512M');
+        $attribute = $this->xr->getAttribute('props');
+        if(empty($attribute)){
+            return array();
+        }
+        $data = explode(';', trim($attribute));
+    
+        foreach ($data as $attrs){
+            
+            $attr = explode(':', trim($attrs));
+            if (empty($attr[0])) {
+                continue;
+            }
+            
+            switch (trim($attr[0])){
+                case 'table-width-fixed':
+                    $attrArray['fixed'] = trim($attr[1]);
+                    break;
                 
-                $attr = explode(':', trim($attrs));
-                if (empty($attr[0])) {
-                    continue;
-                }
+                case 'table-column-props':
+                    $props = explode('/', $attr[1]);
+                    foreach($props as $index => $prop){
+                        $attrArray['width'.$index] = trim($prop);
+                        $attrArray['width'.$index.'_dax'] = $this->converttoDax(trim($prop),null);
+                    }
+                    break;
                 
-                switch (trim($attr[0])){
-                    case 'table-width-fixed':
-                        $attrArray['fixed'] = trim($attr[1]);
-                        break;
-                    
-                    case 'table-column-props':
-                        $props = explode('/', $attr[1]);
-                        foreach($props as $index => $prop){
-                            $attrArray['width'.$index] = trim($prop);
-                            $attrArray['width'.$index.'_dax'] = $this->converttoDax(trim($prop),null);
-                        }
-                        break;
-                    
-                    case 'table-row-heights':
-                        $props = explode('/', $attr[1]);
-                        foreach($props as $index => $prop){
-                            $attrArray['height'.$index] = trim($prop);
-                        }
-                        break;
+                case 'table-row-heights':
+                    $props = explode('/', $attr[1]);
+                    foreach($props as $index => $prop){
+                        $attrArray['height'.$index] = trim($prop);
+                    }
+                    break;
+                
+                case 'left-attach':
+                    $props = explode('/', $attr[1]);
+                    foreach($props as $prop){
+                        $attrArray['columnNum'] = trim($prop);
+                    }
+                    break;
+                
+                case 'top-attach':
+                    $props = explode('/', $attr[1]);
+                    foreach($props as $prop){
+                        $attrArray['rowNum'] = trim($prop);
+                    }
+                    break;
                     
-                    case 'left-attach':
-                        $props = explode('/', $attr[1]);
-                        foreach($props as $prop){
-                            $attrArray['columnNum'] = trim($prop);
-                        }
-                        break;
+                case 'right-attach':
+                    $props = explode('/', $attr[1]);
+                    foreach($props as $prop){
+                        $attrArray['mergeto'] = trim($prop);
+                    }
+                    break;
                     
-                    case 'top-attach':
-                        $props = explode('/', $attr[1]);
-                        foreach($props as $prop){
-                            $attrArray['rowNum'] = trim($prop);
-                        }
-                        break;
-                        
-                    case 'right-attach':
-                        $props = explode('/', $attr[1]);
-                        foreach($props as $prop){
-                            $attrArray['mergeto'] = trim($prop);
-                        }
-                        break;
-                        
-                    case 'top-color':
-                        $props = explode('/', $attr[1]);
-                        foreach($props as $prop){
-                            $attrArray['borderTopColor'] = trim($prop);
-                        }
-                        break;
+                case 'top-color':
+                    $props = explode('/', $attr[1]);
+                    foreach($props as $prop){
+                        $attrArray['borderTopColor'] = trim($prop);
+                    }
+                    break;
+                
+                case 'left-color':
+                    $props = explode('/', $attr[1]);
+                    foreach($props as $prop){
+                        $attrArray['borderLeftColor'] = trim($prop);
+                    }
+                    break;
+                
+                case 'right-color':
+                    $props = explode('/', $attr[1]);
+                    foreach($props as $prop){
+                        $attrArray['borderRightColor'] = trim($prop);
+                    }
+                    break;
                     
-                    case 'left-color':
-                        $props = explode('/', $attr[1]);
-                        foreach($props as $prop){
-                            $attrArray['borderLeftColor'] = trim($prop);
-                        }
-                        break;
+                case 'bot-color':
+                    $props = explode('/', $attr[1]);
+                    foreach($props as $prop){
+                        $attrArray['borderBottomColor'] = trim($prop);
+                    }
+                    break;
+                // background color
+                case 'background-color':
+                    $props = explode('/', $attr[1]);
+                    foreach($props as $prop){
+                        $attrArray['bgColor'] = trim($prop);
+                    }
+                    break;
                     
-                    case 'right-color':
-                        $props = explode('/', $attr[1]);
-                        foreach($props as $prop){
-                            $attrArray['borderRightColor'] = trim($prop);
-                        }
-                        break;
+                case 'font-weight':
+                        $attrArray['bold'] = ($attr[1] == 'bold') ? trim($attr[1]) : false;
                         
-                    case 'bot-color':
-                        $props = explode('/', $attr[1]);
-                        foreach($props as $prop){
-                            $attrArray['borderBottomColor'] = trim($prop);
-                        }
-                        break;
-                    // background color
-                    case 'background-color':
-                        $props = explode('/', $attr[1]);
-                        foreach($props as $prop){
-                            $attrArray['bgColor'] = trim($prop);
-                        }
-                        break;
-                        
-                    case 'font-weight':
-                            $attrArray['bold'] = ($attr[1] == 'bold') ? trim($attr[1]) : false;
-                            
-                        break;
-                    case 'font-style':
-                            $attrArray['italic'] = ($attr[1] == 'italic') ? true : false;
-                        break;
+                    break;
+                case 'font-style':
+                        $attrArray['italic'] = ($attr[1] == 'italic') ? true : false;
+                    break;
 //                    
 //                    case 'width':
 //                        $props = explode('/', $attr[1]);
@@ -438,75 +447,75 @@ class File_Convert_AbiToDocx
 //                        }
 //                        break;
 //                        
-                    default :
-                        $key = trim($attr[0]);
-                        if (empty($attr[1]) && $attr[1] != 0) {
-                            // bit annoying.. but we currently only convert from trustes sources, so do not need to handle this. 
-                            PEAR::staticRaiseError("value missing in style key={$attr[0]}  for prop={$attribute}",0,PEAR_ERROR_DIE);
-                        }
-                        $value = trim($attr[1]);
-                        if(array_key_exists($key, $this->styleMatch)){
-                            $attrArray[$this->styleMatch[$key]] = $value;
-                        }else{
-                            $attrArray[$key] = $value;
-                        }
-                }
+                default :
+                    $key = trim($attr[0]);
+                    if (empty($attr[1]) && $attr[1] != 0) {
+                        // bit annoying.. but we currently only convert from trustes sources, so do not need to handle this. 
+                        PEAR::staticRaiseError("value missing in style key={$attr[0]}  for prop={$attribute}",0,PEAR_ERROR_DIE);
+                    }
+                    $value = trim($attr[1]);
+                    if(array_key_exists($key, $this->styleMatch)){
+                        $attrArray[$this->styleMatch[$key]] = $value;
+                    }else{
+                        $attrArray[$key] = $value;
+                    }
             }
-            return  $attrArray;
-        }
-        function saveDocx($fn){
-            require_once __DIR__ . '/../../Document/Word/Writer/IOFactory.php';
-            $objWriter = Document_Word_Writer_IOFactory::createWriter($this->writer, 'Word2007');
-            $objWriter->save($fn);
-            
-        }
-        
-        // NOT Useful Mothed
-        
-        function handle_metadata()
-        {
-            return;
-        }
-        
-        function handle_m()
-        {
-            return;
-        }
-        
-        function handle_rdf()
-        {
-            return;
-        }
-        
-        function handle_history()
-        {
-            return;
         }
+        return  $attrArray;
+    }
+
+    function saveDocx($fn){
+        require_once __DIR__ . '/../../Document/Word/Writer/IOFactory.php';
+        $objWriter = Document_Word_Writer_IOFactory::createWriter($this->writer, 'Word2007');
+        $objWriter->save($fn);
         
-        function handle_styles()
-        {
+    }
+    
+    // NOT Useful Mothed
+    
+    function handle_metadata()
+    {
+        return;
+    }
+    
+    function handle_m()
+    {
+        return;
+    }
+    
+    function handle_rdf()
+    {
+        return;
+    }
+    
+    function handle_history()
+    {
+        return;
+    }
+    
+    function handle_styles()
+    {
+        return;
+    }
+    
+    function handle_version()
+    {
+        return;
+    }
+    
+    function handle_pagesize()
+    {
+        // fill this in so it can handle landscape
+        if ($this->pass == 1) {
             return;
         }
         
-        function handle_version()
-        {
-            return;
-        }
+        $this->section->getSettings()->setSettingValue('_orientation', $this->xr->getAttribute('orientation'));
+        $this->style['pageSizeW'] = $this->xr->getAttribute('width');
+        $this->style['pageSizeH'] = $this->xr->getAttribute('height');
         
-        function handle_pagesize()
-        {
-            // fill this in so it can handle landscape
-            if ($this->pass == 1) {
-                return;
-            }
-            
-            $this->section->getSettings()->setSettingValue('_orientation', $this->xr->getAttribute('orientation'));
-            $this->style['pageSizeW'] = $this->xr->getAttribute('width');
-            $this->style['pageSizeH'] = $this->xr->getAttribute('height');
-            
-            return;
-        }
+        return;
+    }
         
         
 }