• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Change Color in CellOverrideShading

New Here ,
Aug 26, 2014 Aug 26, 2014

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

TOPICS
Scripting

Views

769

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 29, 2014 Aug 29, 2014

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

Votes

Translate

Translate
Explorer ,
Aug 27, 2014 Aug 27, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2014 Aug 28, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 29, 2014 Aug 29, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 29, 2014 Aug 29, 2014

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:

pen_and_fill_patterns.png

Russ

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 08, 2021 Dec 08, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 08, 2021 Dec 08, 2021

Copy link to clipboard

Copied

Could you please post YOUR script?

Maybe something with "cell" is wrong?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2021 Dec 08, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2021 Dec 08, 2021

Copy link to clipboard

Copied

I answered without reading the whole thread. See Russ Ward's post above when the screenshot of valid values.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 08, 2021 Dec 08, 2021

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:

screen01.png

These are the shading settings after running the code:

screen02.png

If I change the Fill to 100:

oCell.CellOverrideFill = 100;

fonrig_0-1638987152655.png

fonrig_1-1638987198455.png

Seems like Fill is a %??

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2021 Dec 08, 2021

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 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 08, 2021 Dec 08, 2021

Copy link to clipboard

Copied

LATEST

Interesting find! Well, I achieved what was inteded. Thanks @Klaus Göbel and @frameexpert for your input ans testing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines