Copy link to clipboard
Copied
Hi all,
I tried to change the color in CellOverrideShading but I didn't get it.
My attempts were the following:
First I tried to get the index of the color property via GetPropIndex:
var testProp = cell.CellOverrideShading.GetProps();
var testPropIndex = GetPropIndex(testProp, Constants.FP_Color);
But the result is "-4", so it seems that CellOverrideShading has no FP_Color property.
Second: I tried to change the color via the PropVal object:
testProp[1].propVal.sval = 'Olive';
When I print the properties to the Console the color name seems to be updated to 'Olive'
for (var i=0; i <testProp.length; i++)
{
propText = propText + ' \n' + i + ': ' + testProp.propIdent.name + ' - ' + testProp.propIdent.num + ' - ' + testProp.propVal.sval;
}
1: - 20 - Olive
Then I assin the properties to the cell.
cell.CellOverrideShading.SetProps(testProp);
But the color in the Frame document remains unchanged. When I print the color name to the Console [Console('FARBE: ' + cell.CellOverrideShading.Name);]
I still receive FARBE: Königsblau
What's my mistake? Any ideas?
Yours Wolfgang
Hi Tracey, This works for me. I used 0 instead of 15. Make sure you refresh the screen after you run the code.
#target framemaker
var doc = app.ActiveDoc;
var pgf = doc.TextSelection.beg.obj;
var cell = pgf.InTextObj;
// Get the Red color object.
var color = doc.GetNamedColor ("Red");
// Set the cell's properties to 100% Red.
cell.CellOverrideShading = color;
cell.CellUseOverrideShading = true;
cell.CellOverrideFill = 0;
cell.CellUseOverrideFill = true;
Rick
Copy link to clipboard
Copied
Hi Wolfgang,
I think you have a misunderstanding of GetProps() and SetProps(), which is the foundation of your trouble. When you do this:
var testProp = cell.CellOverrideShading.GetProps()
... you are getting the properties of the color object assigned to the CellOverrideShading property, not the cell. And, in this case, the CellOverrideShading property just happens to be an object, otherwise the GetProps() method would not be valid at all. Anyway, a color object has no FP_Color property, hence the reason that you can't find it in the PropVals array.
You could do it with the cell properties directly, maybe something like this (note - I didn't test this!):
var testProps = cell.GetProps();
var testPropIndex = GetPropIndex(testProps, Constants.FP_CellOverrideShading);
...then more code to manipulate the array and reset the properties. However, I would recommend this direct approach instead (again, I didn't test this!):
var colorObj = doc.GetNamedColor("Olive");
if(colorObj.ObjectValid()) cell.CellOverrideShading = colorObj;
I hope this helps some.
Russ
Copy link to clipboard
Copied
Hi Russ, I'm trying to achieve the same thing but am having a little trouble.
Used>
// Get the table cell that contains the paragraph.
var cell = pgf.InTextObj; (alert returns a cell object)
cell.CellUseOverrideShading = true ;
cell.CellUseOverrideFill = true ;
cell.CellOverrideFill = 15 ;
var colorObj = doc.GetNamedColor("Red");
cell.CellOverrideShading = colorObj;
Expect to see red cells in my table but am not, any idea what I'm missing?
thanks,
Tracey
Copy link to clipboard
Copied
Hi Tracey, This works for me. I used 0 instead of 15. Make sure you refresh the screen after you run the code.
#target framemaker
var doc = app.ActiveDoc;
var pgf = doc.TextSelection.beg.obj;
var cell = pgf.InTextObj;
// Get the Red color object.
var color = doc.GetNamedColor ("Red");
// Set the cell's properties to 100% Red.
cell.CellOverrideShading = color;
cell.CellUseOverrideShading = true;
cell.CellOverrideFill = 0;
cell.CellUseOverrideFill = true;
Rick
Copy link to clipboard
Copied
Hi Tracey,
Rick is correct. The CellOverrideFill property indicates the fill pattern and it is specified as a constant from 0-15, where 15 is effectively no pattern. Hence why you were seeing nothing happen. Here is a figure from the FDK manual that describes the constants, with a convenient reference to the FM GUI:
Russ
Copy link to clipboard
Copied
@frameexpert Hello Rick,
For some reason your script doesn't change the cell color until change from 0 to 100:
cell.CellOverrideFill = 100;
Do you know why?
Thanks in advance.
Copy link to clipboard
Copied
Could you please post YOUR script?
Maybe something with "cell" is wrong?
Copy link to clipboard
Copied
You need a companion property:
cell.CellUseOverrideFill = 1;
Note that you may not see the change until you refresh your screen.
Copy link to clipboard
Copied
I answered without reading the whole thread. See Russ Ward's post above when the screenshot of valid values.
Copy link to clipboard
Copied
See my code below:
oColor = oDoc.GetNamedColor ("Cyan");
// Set the cell's properties
oCell.CellUseOverrideShading = true;
oCell.CellOverrideShading = oColor;
oCell.CellUseOverrideFill = true;
oCell.CellOverrideFill = 0; // why 0?
oDoc.Redisplay();
This is the table after running the code, the cell is not Cyan, I highlighted the cell with Paint:
These are the shading settings after running the code:
If I change the Fill to 100:
oCell.CellOverrideFill = 100;
Seems like Fill is a %??
Copy link to clipboard
Copied
I just tested it and it looks like you are correct! It is a percentage from 0 to 100. The FrameMaker engineers must have changed it somewhere along the lines. The FrameMaker 2019 FDK header files still show this:
#define FP_CellOverrideFill 1195 /* R/W Enum */
...
#define FV_FILL_BLACK 0
#define FV_FILL_WHITE 7
#define FV_FILL_CLEAR 15
Copy link to clipboard
Copied
Interesting find! Well, I achieved what was inteded. Thanks @Klaus Göbel and @frameexpert for your input ans testing.