@@ -70,79 +70,13 @@ public function build()
7070
7171 $ this ->diffDom = new \DOMDocument ();
7272
73- // $this->normalizeFormat();
74-
7573 $ this ->indexCellValues ($ this ->newTable );
7674
7775 $ this ->diffTableContent ();
7876
7977 return $ this ->content ;
8078 }
8179
82- protected function normalizeFormat ()
83- {
84- $ oldRows = $ this ->oldTable ->getRows ();
85- $ newRows = $ this ->newTable ->getRows ();
86-
87- foreach ($ newRows as $ rowIndex => $ newRow ) {
88- $ oldRow = isset ($ oldRows [$ rowIndex ]) ? $ oldRows [$ rowIndex ] : null ;
89-
90- if (!$ oldRow ) {
91- continue ;
92- }
93-
94- $ newRowOffset = 0 ;
95- $ oldRowOffset = 0 ;
96-
97- $ newCells = $ newRow ->getCells ();
98- $ oldCells = $ oldRow ->getCells ();
99-
100- foreach ($ newCells as $ cellIndex => $ newCell ) {
101- $ oldCell = isset ($ oldCells [$ cellIndex ]) ? $ oldCells [$ cellIndex ] : null ;
102-
103- if ($ oldCell ) {
104- $ oldNode = $ oldCell ->getDomNode ();
105- $ newNode = $ newCell ->getDomNode ();
106-
107- $ oldRowspan = $ oldNode ->getAttribute ('rowspan ' ) ?: 1 ;
108- $ newRowspan = $ newNode ->getAttribute ('rowspan ' ) ?: 1 ;
109-
110- if ($ oldRowspan > $ newRowspan ) {
111- // add placeholders in next row of new rows
112- $ offset = $ oldRowspan - $ newRowspan ;
113- if ($ offset > $ newRowOffset ) {
114- $ newRowOffset = $ offset ;
115- }
116- } elseif ($ newRowspan > $ oldRowspan ) {
117- $ offset = $ newRowspan - $ oldRowspan ;
118- if ($ offset > $ oldRowOffset ) {
119- $ oldRowOffset = $ offset ;
120- }
121- }
122- }
123- }
124-
125- if ($ oldRowOffset > 0 && isset ($ newRows [$ rowIndex + 1 ])) {
126- $ blankRow = $ this ->diffDom ->createElement ('tr ' );
127-
128- $ insertArray = array ();
129- for ($ i = 0 ; $ i < $ oldRowOffset ; $ i ++) {
130- $ insertArray [] = new TableRow ($ blankRow );
131- }
132-
133- $ this ->oldTable ->insertRows ($ insertArray , $ rowIndex + 1 );
134- } elseif ($ newRowOffset > 0 && isset ($ newRows [$ rowIndex + 1 ])) {
135- $ blankRow = $ this ->diffDom ->createElement ('tr ' );
136-
137- $ insertArray = array ();
138- for ($ i = 0 ; $ i < $ newRowOffset ; $ i ++) {
139- $ insertArray [] = new TableRow ($ blankRow );
140- }
141- $ this ->newTable ->insertRows ($ insertArray , $ rowIndex + 1 );
142- }
143- }
144- }
145-
14680 protected function diffTableContent ()
14781 {
14882 $ this ->diffDom = new \DOMDocument ();
0 commit comments