From 87fe92f9d7943fd37d09655a6b44daf63aa4a022 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Thu, 29 Jan 2009 11:54:07 +0000 Subject: [PATCH] fpspreadsheet: Improves OpenDocument support git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@687 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../examples/opendocdemo/oocreated.ods | Bin 0 -> 6946 bytes .../examples/opendocdemo/opendocwrite.lpi | 134 ++++++++++-------- .../examples/opendocdemo/unzipoocreated.sh | 1 + .../examples/opendocdemo/ziptest.sh | 4 + components/fpspreadsheet/fpsopendocument.pas | 53 ++++--- 5 files changed, 110 insertions(+), 82 deletions(-) create mode 100644 components/fpspreadsheet/examples/opendocdemo/oocreated.ods create mode 100755 components/fpspreadsheet/examples/opendocdemo/unzipoocreated.sh create mode 100755 components/fpspreadsheet/examples/opendocdemo/ziptest.sh diff --git a/components/fpspreadsheet/examples/opendocdemo/oocreated.ods b/components/fpspreadsheet/examples/opendocdemo/oocreated.ods new file mode 100644 index 0000000000000000000000000000000000000000..60d3cf5d4297d7e137a690c7488856dfbbab4357 GIT binary patch literal 6946 zcma)B2RzjM9~VVMqQ{JKR)lkBWy=<_M=9%^!+Fk~?#^B*qa=H0mmNa(CP|_sBN=6j zkgYTRcjTe|dS1`x?su>6@B96%@A|wxpZ962lN_ZXB2b2ow1h80Jb)kHCOpUSj~(0& zhIO%rLG0}ja3}-|M4u-_?W9-o|h$Y4b2E%Iqq7$#? zA3BR~DWH&6aBBzjjy8-S2!n-S9WWLUG-y}uINmbBmw$xt4X#7vAW$d_0mG|7p+Qgw zG@9UqvmJtjNL!tZ;5!j9;RjEDc838!`nx+;2owYh+jE8>|GP7XO~M{!?_iH#2Zx`N zI82WD5Nq~mlrWBz5I z$nnBZ6cYP$FRHI=U`8%cRIgrh#!f!8;;5WbF0Ss3)zo^V*Qc2;eC*?lZmQptr)xv> zPh_sT7q$KikG4D(Ak)OCt2bIXV%U>(H^eTI8FLSN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@5542)zb z5dWSb#;Pmln3B_Lbi$cW^r3EaYdwlGM~(LW);^Ur4_%4j?tv2(!Bdb zYr5tg78z}Let8kit10#fs?@LyZ;hT9ue-DGXAWRwmgmvfk+BZh|7 z_;s}VuSd<4o#vd<4x{9pV!5cAZ*-RQq>7LDkxpG5>8%^3SwF<{mXbCoyZd8PR&7E& zRt4D4xHeBj{8cb`Ok~NUq$U&~L#>qU)z=YreAvcJWpbU^GJ-Brv=+L4>L`nv+L}Y% zIogo;9%STFnB}q3mel|j_ZQmTDPYxyKlt7~x--!e?xXM$Tkx=OlDA#iN3zbAyX;E; z{XD-{A1nOC9*$+SWpLl*GAcMzWu7{Zh0EY5V00eIOdC6uwjb2UIRSsAhnfEETGQgM zwT6ZC5z=JDwifPol$6oN3LyHrIl)bzdp( zPq!vtnKP=;WTL*CdoCosui>_SQFemLCka}z=f++pX2I#psb$`hcF(SoH)fT!JnPb4 zXo0fVxjm+}e|_GM}iGdwj@{mhq_YW)tD`r8=DQ6;_r2bkf2&A_K?J zP7S|!-<$m#V6^_Ot_@hjB!tHgOb6%^tK@x1n_vD^zqH#0qBEx_^$PXsLLLxO+du=DG=ZMUC$rz z@qcrUkXr212)_Bd(tULN*M-@a`hALw_@(?^%R#jK&w2=W`9A3!rso&*{Lh+xo!5gy zH0`75|5Z!Lg3t|F#PMGVN_fF7=9s$h)&}_v-oIyo}TdbKPadArvLx| literal 0 HcmV?d00001 diff --git a/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpi b/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpi index 9ce023901..cbc91f793 100644 --- a/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpi +++ b/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpi @@ -11,7 +11,7 @@ <UseAppBundle Value="False"/> - <ActiveEditorIndexAtStart Value="3"/> + <ActiveEditorIndexAtStart Value="1"/> </General> <VersionInfo> <ProjectVersion Value=""/> @@ -33,13 +33,13 @@ <PackageName Value="laz_fpspreadsheet"/> </Item1> </RequiredPackages> - <Units Count="14"> + <Units Count="15"> <Unit0> <Filename Value="opendocwrite.lpr"/> <IsPartOfProject Value="True"/> <UnitName Value="opendocwrite"/> - <CursorPos X="33" Y="61"/> - <TopLine Value="47"/> + <CursorPos X="9" Y="30"/> + <TopLine Value="8"/> <EditorIndex Value="0"/> <UsageCount Value="309"/> <Loaded Value="True"/> @@ -70,7 +70,7 @@ <UnitName Value="xlsbiff5"/> <CursorPos X="26" Y="95"/> <TopLine Value="92"/> - <EditorIndex Value="5"/> + <EditorIndex Value="6"/> <UsageCount Value="140"/> <Loaded Value="True"/> </Unit4> @@ -79,7 +79,7 @@ <UnitName Value="fpsutils"/> <CursorPos X="1" Y="49"/> <TopLine Value="30"/> - <EditorIndex Value="4"/> + <EditorIndex Value="5"/> <UsageCount Value="140"/> <Loaded Value="True"/> </Unit5> @@ -88,7 +88,7 @@ <UnitName Value="xlsbiff2"/> <CursorPos X="1" Y="16"/> <TopLine Value="1"/> - <EditorIndex Value="6"/> + <EditorIndex Value="7"/> <UsageCount Value="139"/> <Loaded Value="True"/> </Unit6> @@ -97,7 +97,7 @@ <UnitName Value="fpolestorage"/> <CursorPos X="30" Y="654"/> <TopLine Value="642"/> - <EditorIndex Value="7"/> + <EditorIndex Value="8"/> <UsageCount Value="139"/> <Loaded Value="True"/> </Unit7> @@ -116,9 +116,9 @@ <Unit10> <Filename Value="..\..\fpspreadsheet.pas"/> <UnitName Value="fpspreadsheet"/> - <CursorPos X="46" Y="308"/> - <TopLine Value="296"/> - <EditorIndex Value="3"/> + <CursorPos X="1" Y="759"/> + <TopLine Value="746"/> + <EditorIndex Value="4"/> <UsageCount Value="95"/> <Loaded Value="True"/> </Unit10> @@ -131,8 +131,8 @@ <Unit12> <Filename Value="..\..\fpsopendocument.pas"/> <UnitName Value="fpsopendocument"/> - <CursorPos X="9" Y="266"/> - <TopLine Value="263"/> + <CursorPos X="7" Y="296"/> + <TopLine Value="275"/> <EditorIndex Value="1"/> <UsageCount Value="13"/> <Loaded Value="True"/> @@ -142,131 +142,139 @@ <UnitName Value="xlsxooxml"/> <CursorPos X="1" Y="268"/> <TopLine Value="253"/> - <EditorIndex Value="2"/> + <EditorIndex Value="3"/> <UsageCount Value="13"/> <Loaded Value="True"/> </Unit13> + <Unit14> + <Filename Value="..\..\..\..\..\..\..\..\usr\local\share\fpcsrc\rtl\objpas\sysutils\sysstrh.inc"/> + <CursorPos X="10" Y="154"/> + <TopLine Value="141"/> + <EditorIndex Value="2"/> + <UsageCount Value="10"/> + <Loaded Value="True"/> + </Unit14> </Units> <JumpHistory Count="30" HistoryIndex="29"> <Position1> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="390" Column="26" TopLine="377"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="265" Column="28" TopLine="253"/> </Position1> <Position2> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="420" Column="32" TopLine="407"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="313" Column="1" TopLine="301"/> </Position2> <Position3> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="421" Column="14" TopLine="408"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="41" Column="45" TopLine="37"/> </Position3> <Position4> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="460" Column="33" TopLine="440"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="355" Column="5" TopLine="331"/> </Position4> <Position5> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="181" Column="91" TopLine="160"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="311" Column="1" TopLine="299"/> </Position5> <Position6> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="769" Column="83" TopLine="754"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="260" Column="28" TopLine="249"/> </Position6> <Position7> <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="102" Column="15" TopLine="89"/> + <Caret Line="365" Column="5" TopLine="340"/> </Position7> <Position8> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="103" Column="15" TopLine="90"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="290" Column="5" TopLine="265"/> </Position8> <Position9> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="404" Column="5" TopLine="379"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="380" Column="74" TopLine="363"/> </Position9> <Position10> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="187" Column="1" TopLine="172"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="278" Column="1" TopLine="265"/> </Position10> <Position11> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="380" Column="17" TopLine="362"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="279" Column="1" TopLine="266"/> </Position11> <Position12> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="412" Column="1" TopLine="404"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="283" Column="1" TopLine="270"/> </Position12> <Position13> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="716" Column="1" TopLine="702"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="284" Column="1" TopLine="271"/> </Position13> <Position14> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="167" Column="17" TopLine="154"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="287" Column="1" TopLine="274"/> </Position14> <Position15> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="69" Column="1" TopLine="57"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="289" Column="1" TopLine="276"/> </Position15> <Position16> - <Filename Value="opendocwrite.lpr"/> - <Caret Line="71" Column="1" TopLine="46"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="290" Column="18" TopLine="277"/> </Position16> <Position17> - <Filename Value="..\..\xlsxooxml.pas"/> - <Caret Line="48" Column="16" TopLine="35"/> + <Filename Value="..\..\fpsopendocument.pas"/> + <Caret Line="289" Column="1" TopLine="276"/> </Position17> <Position18> <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="105" Column="1" TopLine="80"/> + <Caret Line="290" Column="1" TopLine="277"/> </Position18> <Position19> <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="111" Column="1" TopLine="86"/> + <Caret Line="289" Column="1" TopLine="276"/> </Position19> <Position20> <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="386" Column="1" TopLine="377"/> + <Caret Line="290" Column="1" TopLine="277"/> </Position20> <Position21> <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="357" Column="1" TopLine="350"/> + <Caret Line="289" Column="1" TopLine="276"/> </Position21> <Position22> <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="304" Column="3" TopLine="294"/> + <Caret Line="290" Column="1" TopLine="277"/> </Position22> <Position23> <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="265" Column="28" TopLine="253"/> + <Caret Line="293" Column="1" TopLine="280"/> </Position23> <Position24> <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="313" Column="1" TopLine="301"/> + <Caret Line="295" Column="1" TopLine="282"/> </Position24> <Position25> <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="41" Column="45" TopLine="37"/> + <Caret Line="297" Column="1" TopLine="284"/> </Position25> <Position26> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="355" Column="5" TopLine="331"/> + <Filename Value="..\..\fpspreadsheet.pas"/> + <Caret Line="754" Column="1" TopLine="741"/> </Position26> <Position27> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="311" Column="1" TopLine="299"/> + <Filename Value="..\..\fpspreadsheet.pas"/> + <Caret Line="755" Column="1" TopLine="742"/> </Position27> <Position28> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="260" Column="28" TopLine="249"/> + <Filename Value="..\..\fpspreadsheet.pas"/> + <Caret Line="757" Column="1" TopLine="744"/> </Position28> <Position29> <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="365" Column="5" TopLine="340"/> + <Caret Line="759" Column="1" TopLine="746"/> </Position29> <Position30> <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="290" Column="5" TopLine="265"/> + <Caret Line="392" Column="1" TopLine="379"/> </Position30> </JumpHistory> </ProjectOptions> diff --git a/components/fpspreadsheet/examples/opendocdemo/unzipoocreated.sh b/components/fpspreadsheet/examples/opendocdemo/unzipoocreated.sh new file mode 100755 index 000000000..fde5b79f9 --- /dev/null +++ b/components/fpspreadsheet/examples/opendocdemo/unzipoocreated.sh @@ -0,0 +1 @@ +unzip oocreated.ods \ No newline at end of file diff --git a/components/fpspreadsheet/examples/opendocdemo/ziptest.sh b/components/fpspreadsheet/examples/opendocdemo/ziptest.sh new file mode 100755 index 000000000..9fa2d4d14 --- /dev/null +++ b/components/fpspreadsheet/examples/opendocdemo/ziptest.sh @@ -0,0 +1,4 @@ +cd test +zip test.ods * +mv test.ods ../ +cd .. \ No newline at end of file diff --git a/components/fpspreadsheet/fpsopendocument.pas b/components/fpspreadsheet/fpsopendocument.pas index e312dcc38..2b2ee492c 100755 --- a/components/fpspreadsheet/fpsopendocument.pas +++ b/components/fpspreadsheet/fpsopendocument.pas @@ -72,8 +72,8 @@ const OOXML_PATH_SETTINGS = 'settings.xml'; OOXML_PATH_STYLES = 'styles.xml'; OOXML_PATH_MIMETYPE = 'mimetype.xml'; - OPENDOC_PATH_METAINF = 'META-INF\'; - OPENDOC_PATH_METAINF_MANIFEST = 'META-INF\manifest.xml'; + OPENDOC_PATH_METAINF = 'META-INF' + PathDelim; + OPENDOC_PATH_METAINF_MANIFEST = 'META-INF' + PathDelim + 'manifest.xml'; { OpenDocument schemas constants } SCHEMAS_XMLNS_OFFICE = 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'; @@ -261,30 +261,54 @@ procedure TsSpreadOpenDocWriter.WriteWorksheet(CurSheet: TsWorksheet); var j, k: Integer; CurCell: PCell; + CurRow: array of PCell; + LastColNum: Cardinal; begin + LastColNum := CurSheet.GetLastColNumber; + // Header FContent := FContent + ' <table:table table:name="' + CurSheet.Name + '" table:style-name="ta1">' + LineEnding + ' <table:table-column table:style-name="co1" table:number-columns-repeated="' + - IntToStr(CurSheet.GetLastColNumber + 1) + '" table:default-cell-style-name="Default"/>' + LineEnding; + IntToStr(LastColNum) + '" table:default-cell-style-name="Default"/>' + LineEnding; - // The cells need to be written in order, row by row - for j := 0 to CurSheet.GetLastRowNumber do + // The cells need to be written in order, row by row, cell by cell + for j := 1 to CurSheet.GetLastRowNumber do begin FContent := FContent + ' <table:table-row table:style-name="ro1">' + LineEnding; + // First make an array with the cells of this row in their respective order + // nil pointers indicate empty cells, so it's necessary to initialize the array + SetLength(CurRow, LastColNum); + for k := 0 to LastColNum - 1 do CurRow[k] := nil; + + // Now fill the array with the cells in their proper place for k := 0 to CurSheet.FCells.Count - 1 do begin CurCell := CurSheet.FCells.Items[k]; - if CurCell^.Row = j then WriteCellCallback(CurCell, nil); + if CurCell^.Row = j then CurRow[CurCell^.Col - 1] := CurCell; end; - FContent := FContent + ' </table:table-row>' + LineEnding; + for k := 0 to LastColNum - 1 do + begin + CurCell := CurRow[k]; + + if CurCell = nil then + FContent := FContent + '<table:table-cell/>' + LineEnding + else WriteCellCallback(CurCell, nil); + end; + + FContent := FContent + + ' </table:table-row>' + LineEnding; end; + // Clean up + SetLength(CurRow, 0); + // Footer - FContent := FContent + ' </table:table>' + LineEnding; + FContent := FContent + + ' </table:table>' + LineEnding; end; {******************************************************************* @@ -346,15 +370,6 @@ begin WriteStringToFile(TempDir + OPENDOC_PATH_METAINF_MANIFEST, FMetaInfManifest); end; -{******************************************************************* -* TsSpreadOOXMLWriter.WriteToStream () -* -* DESCRIPTION: Writes an Excel 2 file to a stream -* -* Excel 2.x files support only one Worksheet per Workbook, -* so only the first will be written. -* -*******************************************************************} procedure TsSpreadOpenDocWriter.WriteToStream(AStream: TStream; AData: TsWorkbook); begin @@ -377,8 +392,8 @@ procedure TsSpreadOpenDocWriter.WriteNumber(AStream: TStream; const ARow, begin // The row should already be the correct one FContent := FContent + - ' <table:table-cell office:value-type="float" office:value="' + IntToStr(ACol + 1) + '">' + LineEnding + - ' <text:p>1</text:p>' + LineEnding + + ' <table:table-cell office:value-type="float" office:value="' + FloatToStr(AValue) + '">' + LineEnding + + ' <text:p>' + FloatToStr(AValue) + '</text:p>' + LineEnding + ' </table:table-cell>' + LineEnding; end;