diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 60333f36af..6f3ea3058f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,21 @@ The license applies to all entries newer than 2009-04-28. */ +2012-11-10 17:02 UTC+0100 Viktor Szakats (harbour syenar.net) + * extras/hbxlsxml/tests/example.prg + * extras/hbxlsxml/tests/example2.prg + * extras/hbxlsxml/tests/example3.prg + * extras/hbxlsxml/xlsxml_s.prg + * extras/hbxlsxml/xlsxml_y.prg + * extras/hbxlsxml/xlsxml.prg + + various cleanups, optimizations, one minor fix, + improved bad parameter type handling + + output to contain much less empty space in tags + + * tests/foreach.prg + * tests/menutest.prg + * cleanups ('=' operator still, hb_ntos()) + 2012-11-10 15:33 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbpre.hbm * contrib/make.hb diff --git a/harbour/extras/hbxlsxml/tests/example.prg b/harbour/extras/hbxlsxml/tests/example.prg index c2ff49cf28..ff8437b0b8 100644 --- a/harbour/extras/hbxlsxml/tests/example.prg +++ b/harbour/extras/hbxlsxml/tests/example.prg @@ -269,10 +269,12 @@ PROCEDURE Main() :writeString( nLinha, 4, "", "textLeft" ) :writeString( nLinha, 5, "", "textLeft" ) :writeString( nLinha, 6, "", "textLeft" ) - :writeString( nLinha, 7, "TOTAL ==> " + Str( xqtddoc, 5 ) + " documentos", "textLeftBold" ) + :writeString( nLinha, 7, "TOTAL ==> " + hb_ntos( xqtddoc ) + " document(s)", "textLeftBold" ) :writeString( nLinha, 8, "", "textLeft" ) :writeFormula( "Number", nLinha, 9, "=SUM(R[-40]C:R[-1]C)", "numberRightBold" ) - //:writeNumber( nLinha, 9, xttotnot, "numberRightBold" ) +#if 0 + :writeNumber( nLinha, 9, xttotnot, "numberRightBold" ) +#endif :writeNumber( nLinha, 10, xtbascal, "numberRightBold" ) :writeNumber( nLinha, 11, xtvlricm, "numberRightBold" ) :writeNumber( nLinha, 12, xtbasipi, "numberRightBold" ) diff --git a/harbour/extras/hbxlsxml/tests/example2.prg b/harbour/extras/hbxlsxml/tests/example2.prg index 4e48cbe752..63c9272f03 100644 --- a/harbour/extras/hbxlsxml/tests/example2.prg +++ b/harbour/extras/hbxlsxml/tests/example2.prg @@ -72,7 +72,9 @@ PROCEDURE Main() /** * Choose to show any formatting/input errors on a seperate sheet */ -// xml:showErrorSheet( .T. ) +#if 0 + xml:showErrorSheet( .T. ) +#endif /** * Show the style options @@ -102,8 +104,9 @@ PROCEDURE Main() sheet1:writeString( 1, 1, "left_rotate45", format1 ) sheet1:writeString( 1, 2, "vertical left", "verticaltext_left" ) sheet1:writeString( 1, 3, "this text has been wrapped and is aligned at the top", "wraptext_top" ) -// sheet1:writeString( 1, 4, "No style applied" ) - +#if 0 + sheet1:writeString( 1, 4, "No style applied" ) +#endif sheet2 := xml:addSheet( "Formulas" ) /** @@ -121,10 +124,14 @@ PROCEDURE Main() sheet2:writeNumber( 3, 2, 20 ) sheet2:writeString( 4, 1, "=SUM(R[-3]C:R[-1]C)" ) sheet2:writeFormula( "Number", 4, 2, "=SUM(R[-3]C:R[-1]C)" ) -// sheet2:addComment( 4, 2, "Here is my formula: =SUM(R[-3]C:R[-1]C)","My NAME" ) +#if 0 + sheet2:addComment( 4, 2, "Here is my formula: =SUM(R[-3]C:R[-1]C)","My NAME" ) +#endif sheet2:writeString( 5, 1, "=SUM(R1C2:R3C2)" ) sheet2:writeFormula( "Number", 5, 2, "=SUM(R1C1:R3C2)" ) -// sheet2:addComment( 5, 2, "Here is my formula: =SUM(R1C1:R3C2)" ) +#if 0 + sheet2:addComment( 5, 2, "Here is my formula: =SUM(R1C1:R3C2)" ) +#endif sheet4 := xml:addSheet( "more formatting" ) format4 := xml:addStyle( "my style" ) @@ -134,18 +141,22 @@ PROCEDURE Main() format4:bgColor( "Black" ) format4:setFontColor( "White" ) format4:setNumberFormatDateTime() -// mydate := sheet4:convertMysqlDateTime( "2008-02-14 19:30:00" ) +#if 0 + mydate := sheet4:convertMysqlDateTime( "2008-02-14 19:30:00" ) +#endif sheet4:writeDateTime( 1, 1, DToC( Date() ), format4 ) -// Change the row1 height to 30 pixels + // Change the row1 height to 30 pixels sheet4:rowHeight( 1, "30" ) sheet4:writeString( 2, 1, "formatted text + cell color + merged + underlined", format4 ) -// Merge (2,1) with 4 columns to the right and 2 rows down + // Merge (2,1) with 4 columns to the right and 2 rows down sheet4:cellMerge( 2, 1, 4, 2 ) /** * Send the headers, then output the data */ -// xml:sendHeaders() +#if 0 + xml:sendHeaders() +#endif xml:writeData( "example2.xml" ) RETURN diff --git a/harbour/extras/hbxlsxml/tests/example3.prg b/harbour/extras/hbxlsxml/tests/example3.prg index 6bf32994a8..8f8ed92c3e 100644 --- a/harbour/extras/hbxlsxml/tests/example3.prg +++ b/harbour/extras/hbxlsxml/tests/example3.prg @@ -75,7 +75,9 @@ PROCEDURE Main() sheet1:writeString( 2, 1, "celula 2_1", format4 ) sheet1:writeString( 1, 1, "celula 1_1", format4 ) -// sheet1:writeString( 1, 2, "celula 1_2", format4 ) +#if 0 + sheet1:writeString( 1, 2, "celula 1_2", format4 ) +#endif sheet1:writeString( 1, 3, "celula 1_3", format4 ) sheet1:cellMerge( 1, 1, 1, 0 ) diff --git a/harbour/extras/hbxlsxml/xlsxml.prg b/harbour/extras/hbxlsxml/xlsxml.prg index ff1485c50b..2ed1602f8e 100644 --- a/harbour/extras/hbxlsxml/xlsxml.prg +++ b/harbour/extras/hbxlsxml/xlsxml.prg @@ -133,14 +133,10 @@ METHOD ExcelWriterXML:showErrorSheet( show ) METHOD ExcelWriterXML:addError( cFunction, cMessage ) - LOCAL tmp - - tmp := { ; + ::formatErrors += { ; "FUNCTION" => cFunction, ; "MESSAGE" => cMessage } - ::formatErrors += tmp - RETURN NIL METHOD ExcelWriterXML:getDefaultStyle() diff --git a/harbour/extras/hbxlsxml/xlsxml_s.prg b/harbour/extras/hbxlsxml/xlsxml_s.prg index 653c2033eb..060951dbaa 100644 --- a/harbour/extras/hbxlsxml/xlsxml_s.prg +++ b/harbour/extras/hbxlsxml/xlsxml_s.prg @@ -52,7 +52,6 @@ * */ - #include "hbclass.ch" CREATE CLASS ExcelWriterXML_Sheet @@ -99,14 +98,11 @@ METHOD ExcelWriterXML_Sheet:getID() METHOD ExcelWriterXML_Sheet:addError( cFunction, cMessage ) - LOCAL tmp - - tmp := { "sheet" => ::id, ; + ::formatErrors += { ; + "sheet" => ::id, ; "FUNCTION" => cFunction, ; "MESSAGE" => cMessage } - ::formatErrors += tmp - RETURN NIL METHOD ExcelWriterXML_Sheet:getErrors() @@ -129,10 +125,10 @@ METHOD ExcelWriterXML_Sheet:writeString( row, column, xData, style ) METHOD ExcelWriterXML_Sheet:writeNumber( row, column, xData, style ) - IF ! HB_ISNUMERIC( xData ) - ::writeData( "String", row, column, xData, style ) - ELSE + IF HB_ISNUMERIC( xData ) ::writeData( "Number", row, column, AllTrim( Str( xData, 18, 6 ) ), style ) + ELSE + ::writeData( "String", row, column, xData, style ) ENDIF RETURN NIL @@ -166,6 +162,7 @@ METHOD ExcelWriterXML_Sheet:writeData( type, row, column, xData, style, formula "style" => styleID, ; "data" => xData, ; "formula" => formula } + IF hb_HPos( ::cells, row ) > 0 hcol := ::cells[ row ] hcol[ column ] := cell @@ -198,80 +195,77 @@ METHOD ExcelWriterXML_Sheet:getSheetXML( handle ) FWrite( handle, xml ) xml := "" - IF Len( ::colWidth ) > 0 - FOR ic := 1 TO Len( ::colWidth ) - colIndex := hb_HKeyAt( ::colWidth, ic ) - colWidth := hb_HValueAt( ::colWidth, ic ) - colIndex := hb_ntos( colIndex ) - colWidth := hb_ntos( colWidth ) - xml += ' ' + hb_eol() - NEXT - ENDIF + FOR EACH ic IN ::colWidth + colIndex := ic:__enumKey() + colWidth := ic:__enumValue() + colIndex := hb_ntos( colIndex ) + colWidth := hb_ntos( colWidth ) + xml += ' ' + hb_eol() + NEXT FWrite( handle, xml ) xml := "" - IF Len( ::cells ) > 0 - FOR ir := 1 TO Len( ::cells ) - row := hb_HKeyAt( ::cells, ir ) - rowData := hb_HValueAt( ::cells, ir ) + FOR EACH ir IN ::cells + row := ir:__enumKey() + rowData := ir:__enumValue() - IF hb_HPos( ::rowHeight, row ) > 0 - rowHeight := 'ss:AutoFitHeight="0" ss:Height="' + AllTrim( Str( ::rowHeight[ row ], 14, 2 ) ) + '"' + IF hb_HPos( ::rowHeight, row ) > 0 + rowHeight := 'ss:AutoFitHeight="0" ss:Height="' + AllTrim( Str( ::rowHeight[ row ], 14, 2 ) ) + '"' + ELSE + rowHeight := "" + ENDIF + + xml += ' " + hb_eol() + FOR EACH ic IN rowData + column := ic:__enumKey() + cell := ic:__enumValue() + IF Empty( cell[ "formula" ] ) + formula := "" ELSE - rowHeight := "" + formula := 'ss:Formula="' + cell[ "formula" ] + '"' ENDIF - - xml += ' " + hb_eol() - FOR ic := 1 TO Len( rowData ) - column := hb_HKeyAt( rowData, ic ) - cell := hb_HValueAt( rowData, ic ) - IF ! Empty( cell[ "formula" ] ) - formula := 'ss:Formula="' + cell[ "formula" ] + '"' - ELSE - formula := "" + IF Empty( cell[ "style" ] ) + style := "" + ELSE + style := 'ss:StyleID="' + cell[ "style" ] + '"' + ENDIF + URL := "" + mergeCell := "" + IF hb_HPos( ::mergeCells, row ) > 0 + IF hb_HPos( ::mergeCells[ row ], column ) > 0 + mergeCell := 'ss:MergeAcross="' + hb_ntos( ::mergeCells[ row ][ column ][ "width" ] ) + '" ss:MergeDown="' + hb_ntos( ::mergeCells[ row ][ column ][ "height" ] ) + '"' ENDIF - IF ! Empty( cell[ "style" ] ) - style := 'ss:StyleID="' + cell[ "style" ] + '"' - ELSE - style := "" + ENDIF + comment := "" + IF hb_HPos( ::comments, row ) > 0 + IF hb_HPos( ::comments[ row ], column ) > 0 + comment := ' ' + hb_eol() + comment += ' ' + hb_eol() + comment += ' ' + ::comments[ row ][ column ][ "author" ] + ":" + hb_eol() + comment += ' ' + ::comments[ row ][ column ][ "comment" ] + "" + hb_eol() + comment += " " + hb_eol() + comment += " " + hb_eol() ENDIF - URL := "" - mergeCell := "" - IF hb_HPos( ::mergeCells, row ) > 0 - IF hb_HPos( ::mergeCells[ row ], column ) > 0 - mergeCell := 'ss:MergeAcross="' + hb_ntos( ::mergeCells[ row ][ column ][ "width" ] ) + '" ss:MergeDown="' + hb_ntos( ::mergeCells[ row ][ column ][ "height" ] ) + '"' - ENDIF - ENDIF - comment := "" - IF hb_HPos( ::comments, row ) > 0 - IF hb_HPos( ::comments[ row ], column ) > 0 - comment := ' ' + hb_eol() - comment += ' ' + hb_eol() - comment += ' ' + ::comments[ row ][ column ][ "author" ] + ":" + hb_eol() - comment += ' ' + ::comments[ row ][ column ][ "comment" ] + "" + hb_eol() - comment += " " + hb_eol() - comment += " " + hb_eol() - ENDIF - ENDIF - comment := "" - type := cell[ "type" ] - xData := cell[ "data" ] + ENDIF + comment := "" + type := cell[ "type" ] + xData := cell[ "data" ] - xml += " " + hb_eol() - xml += ' ' - xml += StrToHtmlSpecial( xData ) - xml += "" + hb_eol() - xml += comment - xml += " " + hb_eol() + xml += " " + hb_eol() + xml += ' ' + xml += StrToHtmlSpecial( xData ) + xml += "" + hb_eol() + xml += comment + xml += " " + hb_eol() - NEXT - xml += " " + hb_eol() - - FWrite( handle, xml ) - xml := "" NEXT - ENDIF + xml += " " + hb_eol() + + FWrite( handle, xml ) + xml := "" + NEXT + xml += " " + hb_eol() xml += "" + hb_eol() @@ -285,18 +279,16 @@ METHOD ExcelWriterXML_Sheet:cellWidth( row, col, width ) HB_SYMBOL_UNUSED( row ) HB_SYMBOL_UNUSED( col ) - IF width == NIL - width := 48 - ENDIF + hb_default( @width, 48 ) + ::columnWidth( col, width ) RETURN NIL METHOD ExcelWriterXML_Sheet:columnWidth( col, width ) - IF width == NIL - width := 48 - ENDIF + hb_default( @width, 48 ) + ::colWidth[ col ] := width RETURN NIL @@ -305,18 +297,16 @@ METHOD ExcelWriterXML_Sheet:cellHeight( row, col, height ) HB_SYMBOL_UNUSED( col ) - IF height == NIL - height := 12.5 - ENDIF + hb_default( @height, 12.5 ) + ::setRowHeight( row, height ) RETURN NIL METHOD ExcelWriterXML_Sheet:setRowHeight( row, height ) - IF height == NIL - height := 12.5 - ENDIF + hb_default( @height, 12.5 ) + ::rowHeight[ row ] := height RETURN NIL @@ -328,7 +318,9 @@ METHOD ExcelWriterXML_Sheet:cellMerge( row, col, width, height ) IF hb_HPos( ::mergeCells, row ) > 0 haux := ::mergeCells[ row ] ENDIF - haux[ col ] := { "width" => width, ; + + haux[ col ] := { ; + "width" => width, ; "height" => height } ::mergeCells[ row ] := haux @@ -339,8 +331,9 @@ METHOD ExcelWriterXML_Sheet:addComment( row, col, comment, author ) LOCAL haux := { => } - haux[ col ] := { "comment" => comment, ; - "author" => author } + haux[ col ] := { ; + "comment" => comment, ; + "author" => author } ::comments[ row ] := haux diff --git a/harbour/extras/hbxlsxml/xlsxml_y.prg b/harbour/extras/hbxlsxml/xlsxml_y.prg index 5aafbd2626..9e336aa22b 100644 --- a/harbour/extras/hbxlsxml/xlsxml_y.prg +++ b/harbour/extras/hbxlsxml/xlsxml_y.prg @@ -52,7 +52,6 @@ * */ - #include "hbclass.ch" CREATE CLASS ExcelWriterXML_Style @@ -252,9 +251,9 @@ METHOD ExcelWriterXML_Style:getStyleXML() 'ss:Color="' + pData[ "Color" ] + '"', ; "" ) bWeight := iif( hb_HPos( pData, "Weight" ) > 0, ; - 'ss:Weight="' + Str( pData[ "Weight" ], 1 ) + '"', ; + 'ss:Weight="' + hb_ntos( pData[ "Weight" ] ) + '"', ; "" ) - borders += '" + hb_eol() + borders += '" + hb_eol() NEXT borders += "" + hb_eol() ENDIF @@ -269,24 +268,24 @@ METHOD ExcelWriterXML_Style:getStyleXML() IF ! Empty( ::interiorPatternColor ) interiorPatternColor := 'ss:PatternColor="' + ::interiorPatternColor + '"' ENDIF - interior := " " + hb_eol() + interior := " " + hb_eol() ENDIF - IF ! Empty( ::numberFormat ) - numberFormat := ' ' + hb_eol() - ELSE + IF Empty( ::numberFormat ) numberFormat := " " + hb_eol() + ELSE + numberFormat := ' ' + hb_eol() ENDIF xml := '