Skip to content

Commit 042ccf1

Browse files
committed
ACI0105520: Fix cell background color when converting to picture if explicitly set to no color
+ use var declarations
1 parent 4c5c48c commit 042ccf1

File tree

3 files changed

+102
-146
lines changed

3 files changed

+102
-146
lines changed

Project/Sources/Methods/VP Convert to picture.4dm

Lines changed: 60 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,33 @@
11
//%attributes = {"invisible":true,"shared":true,"preemptive":"capable"}
2-
TRY
2+
#DECLARE($vpObject : Object; $cells : Object)->$result : Picture
33

4-
C_OBJECT:C1216($1; $vpObject; $2; $cells; $range)
4+
TRY
55

66
// MARK:- Declaration
7-
C_OBJECT:C1216($sheets; $table; $cell; $style)
8-
C_TEXT:C284($svgSource)
9-
C_TEXT:C284($svgRef)
10-
C_TEXT:C284($elemRef)
11-
C_LONGINT:C283($iterX; $iterY; $svgHeight; $svgWidth; $x1; $x2; $y1; $y2; $height; $width)
12-
C_LONGINT:C283($defaultColWidth; $defaultRowHeight; $initialColWidth; $initialRowHeight)
137
ARRAY LONGINT:C221($colPos; 0)
148
ARRAY LONGINT:C221($rowPos; 0)
15-
C_REAL:C285($colWidth; $rowHeight)
16-
C_OBJECT:C1216($lineObj)
17-
C_OBJECT:C1216($obj)
18-
C_BOOLEAN:C305($displayValue)
19-
C_LONGINT:C283($pos)
20-
C_PICTURE:C286($0)
21-
C_OBJECT:C1216($defaultStyle)
22-
C_COLLECTION:C1488($valCol)
23-
C_LONGINT:C283($rightOverflow; $leftOverflow)
24-
C_REAL:C285($pictWidth; $pictHeight)
25-
C_REAL:C285($pictX; $pictY)
26-
C_TEXT:C284($shrinkStr)
27-
C_TEXT:C284($defaultFontSize; $fontSize)
28-
C_LONGINT:C283($textWidth)
29-
C_LONGINT:C283($i)
30-
C_BOOLEAN:C305($visible; $condition)
31-
C_OBJECT:C1216($namedStyle)
32-
C_OBJECT:C1216($workbook)
33-
C_COLLECTION:C1488($namedStyleCol)
34-
C_LONGINT:C283($index)
35-
C_BOOLEAN:C305($cascadingStyleSheet)
36-
C_COLLECTION:C1488($sheetCol)
37-
C_TEXT:C284($s)
38-
C_TEXT:C284($valueStr)
39-
C_COLLECTION:C1488($bgImgCol)
40-
C_OBJECT:C1216($strPart)
41-
C_TEXT:C284($defaultGridLineColor)
42-
C_OBJECT:C1216($parsedStyle)
43-
C_COLLECTION:C1488($namedStyleQuery)
44-
C_BOOLEAN:C305($borderOrientation)
45-
C_REAL:C285($borderOffset)
46-
C_BOOLEAN:C305($drawLine)
47-
C_LONGINT:C283($indexColWidth; $indexRowHeight)
48-
C_OBJECT:C1216($bcObj)
49-
C_LONGINT:C283($rowCount; $colCount)
50-
C_LONGINT:C283($maxSvgWidth; $maxSvgHeight)
9+
10+
var $sheets; $table; $cell; $style : Object
11+
var $lineObj; $obj; $defaultStyle : Object
12+
var $namedStyle; $workbook; $parsedStyle; $bcObj : Object
13+
var $strPart : Object
14+
var $svgSource; $svgRef; $elemRef : Text
15+
var $shrinkStr; $defaultFontSize; $fontSize; $valueStr; $defaultGridLineColor : Text
16+
17+
var $textWidth; $i; $index; $indexColWidth; $indexRowHeight; $rowCount; $colCount; $maxSvgWidth; $maxSvgHeight : Integer
18+
var $iterX; $iterY; $svgHeight; $svgWidth; $x1; $x2; $y1; $y2; $height; $width : Integer
19+
var $defaultColWidth; $defaultRowHeight; $initialColWidth; $initialRowHeight : Integer
20+
var $rightOverflow; $leftOverflow : Integer
21+
var $pos : Integer
22+
23+
var $colWidth; $rowHeight : Real
24+
var $borderOffset : Real
25+
var $pictWidth; $pictHeight : Real
26+
var $pictX; $pictY : Real
27+
28+
var $valCol; $namedStyleCol; $sheetCol; $namedStyleQuery; $bgImgCol : Collection
29+
var $visible; $condition; $cascadingStyleSheet; $borderOrientation; $drawLine; $displayValue : Boolean
30+
5131

5232
// MARK:- Initialize Objects and Constants
5333
$bcObj:=New object:C1471("bcGrid"; New object:C1471; "bcCol"; New collection:C1472)
@@ -105,18 +85,12 @@ $valCol:=New collection:C1472
10585

10686
$lineObj:=New object:C1471("H"; New object:C1471; "V"; New object:C1471; "lines"; New collection:C1472)
10787

108-
$vpObject:=$1
109-
If (Count parameters:C259>=2)
110-
$cells:=$2
111-
Else
112-
$cells:=Null:C1517
113-
End if
114-
11588
// MARK:- Workbook and Sheets Handling
11689
If (Value type:C1509($vpObject.spreadJS)=Is object:K8:27)
11790
$workbook:=$vpObject.spreadJS
11891

11992
$sheetCol:=New collection:C1472
93+
var $s : Text
12094
For each ($s; $workbook.sheets)
12195
$sheetCol.push($workbook.sheets[$s])
12296
End for each
@@ -203,8 +177,8 @@ If ($defaultStyle#Null:C1517)
203177
End if
204178
End if
205179

206-
207180
// MARK:- Cell Range and Dimensions
181+
var $range : Object
208182
$range:=vp_getCellRange($vpObject; $cells)
209183

210184
If ($sheets.columnCount#Null:C1517)
@@ -224,9 +198,9 @@ If ($range.y2>=$rowCount)
224198
End if
225199

226200
// MARK:- Row and Column Positions
227-
C_LONGINT:C283($size)
201+
var $size : Integer
228202

229-
C_LONGINT:C283($startY)
203+
var $startY : Integer
230204
$startY:=0
231205
For ($iterY; 0; $range.y1-1)
232206

@@ -313,7 +287,7 @@ Case of
313287
$svgHeight:=$svgHeight-$size
314288
End case
315289

316-
C_LONGINT:C283($startX)
290+
var $startX : Integer
317291
$startX:=0
318292
For ($iterX; 0; $range.x1-1)
319293

@@ -427,9 +401,9 @@ Else
427401
End if
428402

429403
///SPANS HANDLING///
430-
C_COLLECTION:C1488($mergeTab)
431-
C_OBJECT:C1216($span; $cellMergeStatus)
432-
C_LONGINT:C283($row; $col)
404+
var $mergeTab : Collection
405+
var $span; $cellMergeStatus : Object
406+
var $row; $col : Integer
433407

434408
$mergeTab:=Null:C1517
435409
If ($sheets#Null:C1517)
@@ -1087,10 +1061,10 @@ End if
10871061
$parsedStyle.vAlign:=TOP_VERTICAL_ALIGN
10881062
End if
10891063

1090-
C_REAL:C285($spaceWidth)
1064+
var $spaceWidth : Real
10911065

10921066
If ($parsedStyle.textOrientation#0) & ($parsedStyle.textOrientation#NONE_TEXT_ORIENTATION)
1093-
C_REAL:C285($lineHeight)
1067+
var $lineHeight : Real
10941068

10951069
$lineHeight:=DEFAULT_LINE_HEIGHT
10961070

@@ -1100,11 +1074,10 @@ End if
11001074
End if
11011075
End if
11021076

1103-
C_REAL:C285($radOrientation)
1104-
1077+
var $radOrientation : Real
11051078
$radOrientation:=Abs:C99($parsedStyle.textOrientation*Degree:K30:2)
11061079

1107-
C_OBJECT:C1216($initialBox; $rotatedBox; $translatedBox)
1080+
var $initialBox; $rotatedBox; $translatedBox : Object
11081081

11091082
$initialBox:=svg_getTextBox($x1; $y2; 10; $lineHeight)
11101083
$rotatedBox:=svg_getRotatedBox($initialBox; $initialBox.topLeft.x; $initialBox.topLeft.y; $radOrientation)
@@ -1119,16 +1092,13 @@ End if
11191092
: ($parsedStyle.formatInfo=Null:C1517)
11201093
Case of
11211094
: (Value type:C1509($cell.value)=Is real:K8:4) & ($parsedStyle.isVerticalText#1)
1122-
C_REAL:C285($e)
1123-
C_REAL:C285($p)
1124-
C_LONGINT:C283($nbU; $epos; $pos)
1125-
C_TEXT:C284($cvStr)
1126-
C_TEXT:C284($intPart)
1127-
C_TEXT:C284($decPart)
1128-
C_COLLECTION:C1488($cvCol)
1129-
C_LONGINT:C283($intLen; $decLen)
1130-
C_REAL:C285($x; $v)
1095+
var $e; $p : Real
1096+
var $nbU; $epos : Integer
1097+
var $cvCol : Collection
1098+
var $intLen; $decLen : Integer
1099+
var $x; $v : Real
11311100

1101+
var $cvStr; $intPart; $decPart : Text
11321102
$cvStr:=String:C10($cell.value)
11331103
If ($cell.value>=10000000000000)
11341104
$intPart:=$cvStr[[1]]
@@ -1194,7 +1164,6 @@ End if
11941164
End if
11951165

11961166
: ($nbC<=$intLen)
1197-
C_LONGINT:C283($i)
11981167

11991168
For ($i; 1; $nbC)
12001169

@@ -1304,37 +1273,36 @@ End if
13041273
End if
13051274

13061275
: (Value type:C1509($parsedStyle.formatInfo.content)=Is collection:K8:32)
1307-
C_REAL:C285($w)
1308-
C_REAL:C285($c)
1309-
C_OBJECT:C1216($valPart)
13101276

1311-
C_TEXT:C284($str)
1277+
1278+
var $str : Text
13121279
$str:=""
1280+
var $valPart : Object
13131281
For each ($valPart; $parsedStyle.formatInfo.content)
1314-
If ($valPart.type#"fillingChar") & ($valPart.type#"placeHolder")
1282+
If ($valPart.type#"fillingChar") && ($valPart.type#"placeHolder") && ($valPart.type#"numberPlaceholder")
13151283
$str:=$str+$valPart.value
13161284
End if
13171285
End for each
1286+
var $w : Real
13181287
$w:=svg_getTextWidth($str; $parsedStyle.fontObj)
13191288

13201289
Case of
13211290
: (($parsedStyle.shrinkToFit=1) & ($w>(Int:C8($spaceWidth)-3))) | ($parsedStyle.isVerticalText=1)
13221291
For each ($valPart; $parsedStyle.formatInfo.content)
1323-
If ($valPart.type#"fillingChar") & ($valPart.type#"placeHolder")
1292+
If ($valPart.type#"fillingChar") && ($valPart.type#"placeHolder") && ($valPart.type#"numberPlaceholder")
13241293
$valueStr:=$valueStr+$valPart.value
13251294
End if
13261295
End for each
13271296

13281297
Else
13291298

13301299
If ($w>(Int:C8($spaceWidth)-3))
1300+
var $c : Real
13311301
$c:=svg_getTextWidth("#"; $parsedStyle.fontObj)
13321302

13331303
$valueStr:="#"*Int:C8(((Int:C8($spaceWidth)-3)/$c))
13341304
Else
1335-
C_LONGINT:C283($nbC)
1336-
C_TEXT:C284($fc)
1337-
1305+
var $fc : Text
13381306
$fc:=$parsedStyle.formatInfo.content.query("type = fillingChar")[0].value
13391307

13401308
If ($fc=" ")
@@ -1343,6 +1311,7 @@ End if
13431311

13441312
$c:=svg_getTextWidth($fc; $parsedStyle.fontObj)
13451313

1314+
var $nbC : Integer
13461315
If (($parsedStyle.textOrientation#0) & ($parsedStyle.textOrientation#NONE_TEXT_ORIENTATION))
13471316
$nbC:=Int:C8((Int:C8($rowHeight)-3-$w)/$c)
13481317
Else
@@ -1355,11 +1324,14 @@ End if
13551324
$valueStr:=$valueStr+($fc*$nbC)
13561325
$strPart:=New object:C1471("part1"; $valueStr; "part2"; "")
13571326
Else
1358-
If ($valPart.type#"placeHolder")
1327+
If (($valPart.type#"placeHolder") && ($valPart.type#"numberPlaceholder"))
13591328
$valueStr:=$valueStr+$valPart.value
13601329
If ($strPart#Null:C1517)
13611330
$strPart.part2:=$strPart.part2+$valPart.value
13621331
End if
1332+
Else
1333+
1334+
13631335
End if
13641336
End if
13651337
End for each
@@ -1676,8 +1648,7 @@ If ($sheets.floatingObjects#Null:C1517)
16761648
$width:=$obj.width
16771649
$height:=$obj.height
16781650

1679-
C_TEXT:C284($name)
1680-
1651+
var $name : Text
16811652
$name:=Replace string:C233($obj.name; " "; "_")
16821653

16831654
$elemRef:=DOM Create XML element:C865($svgRef; "/svg/clipPath"; "id"; $name)
@@ -1692,9 +1663,9 @@ If ($sheets.floatingObjects#Null:C1517)
16921663
$svgWidth:=$x1+$Width
16931664
End if
16941665

1695-
C_TEXT:C284($layout; $src)
1696-
//C_LONGINT($pictWidth;$pictHeight;$pictX;$pictY)
1666+
//var $pictWidth; $pictHeight; $pictX; $pictY: Integer
16971667

1668+
var $src : Text
16981669
$src:=$obj.src
16991670

17001671
svg_getPictSize(->$src; ->$pictWidth; ->$pictHeight)
@@ -1716,7 +1687,7 @@ If ($sheets.floatingObjects#Null:C1517)
17161687

17171688
End case
17181689

1719-
1690+
var $layout : Text
17201691
Case of
17211692
: ($obj.pictureStretch=Null:C1517)
17221693
$layout:="none"
@@ -1763,12 +1734,11 @@ DOM SET XML ATTRIBUTE:C866($svgRef; "x"; "0"; "y"; "0"; "width"; String:C10(Choo
17631734
//DOM EXPORT TO FILE($svgRef; saveImgFileName)
17641735
//End if
17651736

1766-
17671737
// MARK:- Export SVG to Picture
17681738
var $svgImg : Picture
17691739

17701740
SVG EXPORT TO PICTURE:C1017($svgRef; $svgImg; Own XML data source:K45:18)
1771-
$0:=$svgImg
1741+
$result:=$svgImg
17721742

17731743
//Else
17741744

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
11
//%attributes = {"invisible":true,"preemptive":"capable"}
2-
C_OBJECT:C1216($1;$bcObj)
3-
C_LONGINT:C283($2;$iterX;$3;$iterY;$4;$x1;$5;$y1;$6;$width;$7;$height;$9;$offset)
4-
C_TEXT:C284($8;$color)
5-
C_BOOLEAN:C305($10;$isOriented)
6-
7-
C_BOOLEAN:C305($sameLeftColor)
8-
C_LONGINT:C283($ref)
9-
C_TEXT:C284($sIterX;$sIterY;$sIterXm)
10-
11-
$bcObj:=$1
12-
$iterX:=$2
13-
$iterY:=$3
14-
$x1:=$4
15-
$y1:=$5
16-
$width:=$6
17-
$height:=$7
18-
$color:=$8
19-
$offset:=$9
20-
$isOriented:=$10
2+
#DECLARE($bcObj : Object; $iterX : Integer; $iterY : Integer; $x1 : Integer; $y1 : Integer; $width : Integer; $height : Integer; $color : Text; $offset : Integer; $isOriented : Boolean)
213

4+
var $sIterX; $sIterY : Text
225
$sIterX:=String:C10($iterX)
236
$sIterY:=String:C10($iterY)
247

@@ -27,27 +10,35 @@ If ($bcObj.bcGrid[$sIterY]=Null:C1517)
2710
End if
2811

2912
If ($bcObj.bcGrid[$sIterY][$sIterX]=Null:C1517)
30-
$bcObj.bcGrid[$sIterY][$sIterX]:=New object:C1471("col";$color;"isOriented";$isOriented;"offset";$offset)
13+
$bcObj.bcGrid[$sIterY][$sIterX]:=New object:C1471("col"; $color; "isOriented"; $isOriented; "offset"; $offset)
3114
End if
3215

16+
If ($color="$4D_NOCOLOR")
17+
return
18+
End if
19+
20+
var $sameLeftColor : Boolean
3321
$sameLeftColor:=False:C215
3422

23+
var $sIterXm : Text
3524
$sIterXm:=String:C10($iterX-1)
3625

26+
var $ref : Integer
3727
Case of
3828
: ($iterX=0)
3929
: ($bcObj.bcGrid[$sIterY]=Null:C1517)
4030
: ($bcObj.bcGrid[$sIterY][$sIterXm]=Null:C1517)
41-
: ($bcObj.bcGrid[$sIterY][$sIterXm].col=$color) & (Not:C34($bcObj.bcGrid[$sIterY][$sIterXm].isOriented))
31+
: ($bcObj.bcGrid[$sIterY][$sIterXm].col=$color) && (Not:C34($bcObj.bcGrid[$sIterY][$sIterXm].isOriented))
4232
$sameLeftColor:=True:C214
4333
$ref:=$bcObj.bcGrid[$sIterY][$sIterXm].ref
4434
$bcObj.bcGrid[$sIterY][$sIterX].ref:=$ref
4535
$bcObj.bcCol[$ref].w:=$bcObj.bcCol[$ref].w+$width
4636
End case
4737

4838
If (Not:C34($sameLeftColor))
39+
4940
$ref:=$bcObj.bcCol.length
5041
$bcObj.bcGrid[$sIterY][$sIterX].ref:=$ref
51-
$bcObj.bcCol[$ref]:=New object:C1471("x";$x1;"y";$y1;"w";$width;"h";$height;"c";$color;"isOriented";$isOriented;"offset";$offset)
42+
$bcObj.bcCol[$ref]:=New object:C1471("x"; $x1; "y"; $y1; "w"; $width; "h"; $height; "c"; $color; "isOriented"; $isOriented; "offset"; $offset)
5243

5344
End if

0 commit comments

Comments
 (0)