Does anyone know why an object would miss a property? - adobe-indesign

We have a script that export our Indesign documents to HTML and one of the routine is to export tables. In this script we go throught each Tables->Rows->Cells and evaluate some of the properties (i.e. bottomEdgeStrokeType, topEdgeStrokeType, etc...) and transport them to HTML.
Now yesterday we had problem converting one particular document because some cells were missing the "bottomEdgeStrokeType" property entirely. I've discovered this by outputting the properties of each cells and compare the faulty ones with the others.
This line bellow was trowing the error: "Invalid object for this request.".
var cellType = cell["bottomEdgeStrokeType"];
Now, to fix this I've wrapped this around a try catch block to handle the case when it's not there, but now what is puzzling me is how on earth can Extendscript instantiate an object with missing properties?
Indesign version: CS5.5

A property is not only 'undefined' if it cannot exist at all (such as asking for the parent text frame for a character in overset text), but InDesign's Javascript engine also fails to return a reasonably accurate result for multiple values.
If you ask for "the" point size of a paragraph, where this paragraph contains multiple sizes, poor ID does not consider to return something like CONSTANT.Mixed, or the first value only, or (what I might have preferred) an array of the values; it returns undefined instead.
So how can a single table cell have multiple bottom strokes? If the cell underneath it is split into multiple cells, and one has a "top" stroke but the other has not.
It's difficult to recommend an adequate solution. You could first test if the current cell is "merged" (as far as InDesign's internal table model is concerned) with columnSpan; and if so, iterate over the number of columns spanned and test the next row's cells for their top stroke, which in theory should match the bottom stroke of the cell above. (I find myself wondering if this is always true. ID's table model is ... weird. It's not entirely like a HTML table, despite the functional overlaps.)
If columnSpan is greater than 1 and equal to the number of cells immediately below the current one, you could test if all of their "top" values are the same and if so use that value. (I never tested this so ID's table model may simply fail because a cell is merged, regardless of same-values or not.)
One could attempt to flag this cell's next row to output "top" strokes as well -- but alternating top and bottom strokes may not align nicely in CSS, side to side. Perhaps it's best to translate only the first top stroke value to "the" bottom stroke property for your current cell, and fix up manually where needed (how?) or, a reasonable action, hope that no-one will ever notice it.

Related

Abaqus: The following parts have some elements without any section assigned / Composite Layups

I am building up composite layups and assigning them to element sets. When I do so as soon as I try to submit the job, Abaqus always gives me the error "The following parts have some elements without any section assigned". There is not a single element without a material property, I do this by a script. As soon as I use a set which does not contain elements but a geometry Abaqus highlights the region green, but using geometry instead of element sets is not very suitable for me, because I am changing the properties of different elements. Also the region selection window opened by abaqus says "Sets below may contain elements, cells, shell faces or wire edges", so it should be possible to use element sets right?
I use the section assignment only for a small amount of elements, everything else is covered by composite layups.
If needed I can share more details from my model, but as I am not sure where to look for any errors right now, I wont do that right now.
Best regards and thanks for any advice!
You can do data check and then in open generated odb in viewer. In opened odb you can find ErrElemMissingSection in 'Display groups'

How to make tablix expand towards the left?

I have a tablix, one with dynamic columns. The order is fine ("total" shows up last) but the problem is that, for scanning purposes, the last column needs to always be aligned right and any additional columns have to be to the left of that origin point. How to accomplish this?
I've tried setting the "Direction" of the column to RTL and tried putting another object on the right of the tablix but that just gets pushed to the right for every extra column. Is there some sort of anchor property I'm missing or something that'll keep the tablix from growing on the right side?
There aren't any properties that allow you to dynamically change the width of columns or the position of tables etc. As a table grouping grows, it pushes other elements out of the way. First thing to try is put both of the tables in a rectangle. This can help keep them in position.
Another option is to use visibility to change where your values appear, while maintaining the same underlying layout. Depending on the specifics of how you're trying to lay things out, this may be difficult to use for your purposes.

Styling INDIVIDUAL cells in GAS FlexTable ...impossible?

It appears there is no way to style individual cells (to, say, change the background color of a header row, for example) within a GAS FlexTable. Is that correct?
The only methods I see here are .setStyleAttribute() and .setStyleAttributes() both of which operate on either the entire application or the entire flextable as the object.
Furthermore, I see no methods that return an individual cell or subset of cells from the flextable such as a .getCell() or .getRow().
Therefore, am I correct in concluding that there is no way at this time to set the style of an individual cell in a GAS flextable? (Sorry if the answer to this question is an obvious, “There is no way to do it.” But I figured I had better check with the experts first before giving up.)
setWidget is expensive
I pull out about 500X12 table in flextable and found use setText is at least twice times faster.
Then again, I also can not figure out how to change font size in flexTable while calling setText. The background, font color etc worked, but not font size.
Setting style to individual cell is done with:
method setStyleAttribute(row, column, attribute, value) - Sets a CSS style on a cell of this FlexTable.
You have to scroll down to the second occurence of setStyleAttribute on the FlexTable page. Since the HTML anchor is #setStyleAttribute for both methods you always get the first.
A getCell method would not be useful as a flextable cell is no widget.
There is also a setStyleAttributes(row, column, attributes) method ...
There is a very easy way to do this. Instead of using FlexTable.setText() to set the contents, use the FlexTable.setWidget() instead.
And you can add a label and style it however you want to and each label can have its own style

How can I programmatically detect if some text is visible or has overflowed in an InDesign document using ExtendScript?

I am building an InDesign panel with ExtendScript which finds text and shows it to the user. To do this, I use the showText() method of the Character object. The problem is that sometimes the text I'm looking for doesn't appear because, even though the method does show the right page at the right place, the text has overflown and is not visible.
Is there a way to check if the text is visible or not? Ideally, I would like to be able to fall back on the story editor if the text cannot be seen as-is...
To check the situation for an individual character, see the parentTextFrames property, it returns an array with 0 or 1 frames. In rare cases of insertion points whose left side is in one frame while the right side is in the following, you get two frames.
app.selection[0].characters.item(0).parentTextFrames.length
You can also compare the index of your character against the last index in the last text container of the story, e.g.
app.selection[0].parentStory.textContainers.pop().characters.lastItem().index
Of course you should first see whether there is overflow at all ...
app.selection[0].parentStory.overflows
You may call the baseline property for the text in a try/catch statement. If text is visible, baseline will return a value, otherwise it will raise an error.
Loic

List Control Adds a Space for an Image to Column 0 When Subsequent Columns Have Images

I’ve come across a problem with Windows list controls (I am specifically using MFC, but it looks like it applies to all list controls in the Windows common controls library).
In my specific case, I want to create a list control that has two or more columns. The first column (0) is text-only and is used to allow the user to jump to entries by typing the text in that row. Column two (or three, or four, or whatever) has an image (or an image and text; either way).
This much is all well and good and can be done easily without problem, however the final list control then ends up having a space to the left of the text in column 0 (it may be on the right on an RTL system). This spacer appears to be reserved for an image and I cannot figure out a way to prevent it. (Arranging the specific order of the columns did not change anything.)
Looking around, I found some other people complaining of the same thing, specifically this thread which leads to this thread. The proposed solution does not work because as was stated, simply shrinking the width of column zero merely cuts off the text rather than the image spacer (plus, you then have to prevent and/or process any changes to column widths that the user tries to make).
Does anyone have any ideas of how to fix this bug short of writing a list control from scratch or using one of the too-fancy grid controls on CodeProject/CodeGuru/etc.?
Thanks a lot.
Did you try to change the iIndent member of the LVITEM struct? MSDN says this:
iIndent Version 4.70. Number of image widths to indent the item. A
single indentation equals the width of
an item image. Therefore, the value 1
indents the item by the width of one
image, the value 2 indents by two
images, and so on. Note that this
field is supported only for items.
Attempting to set subitem indentation
will cause the calling function to
fail.
Column 0 is special in a ListView. As soon as you assign a small image list to the ListView, the control expects you to show an image in column 0, so it leaves space for it.
Solutions:
make column 0 zero-width, give it the value you want the user to be able to type. Column 1 becomes your "first" text column. Columns 2+ are for your images. You need full row select style for this to work. Yes, you have to prevent the user from resizing column 0. Yes, that is a pain.
make a column that does have an image to be column 0 and use LVM_SETCOLUMNORDERARRAY to rearrange the display order
owner draw the items.
give column 0 an icon (just to cover all bases)

Resources