7 Replies Latest reply on Sep 1, 2016 3:12 AM by Laubender

    Table Cells oveflows detection - again

    mechaichezilla Level 1

      Hi,

       

      I'm back to my old problem from this thread:

      Detect Overset in Cell and/or Force Wrap

       

      I encountered a situation where the old workaround no longer works in Adobe InDesign CC Server 2015 (same script works fine in CS5.5). The overflows property never is true, even if there is overflow in the table cell.

       

      I already tried using a higher sleep timer to make sure it isn't a timing problem again, but even 500ms did not help. I also tried checking for overflow in each cell after the row has been finished, still no success. It doesn't seem to be a general problem, since in the same table the overflow detection works on cells in later rows and in other tables as well. In this screenshot you can see the result on InDesign Server (left) and CS5.5:

       

       

      CS5.5 detects the overflow and rotates the text, InDesign server doesn't in the first row, but it does so in later Rows. Are there any other ways to detect overflow apart from cell.overflows?

       

      Thanks a lot

        • 1. Re: Table Cells oveflows detection - again
          Laubender Adobe Community Professional & MVP

          Do you see a red dot in the overflowing cell after opening the document with InDesign Desktop?

           

          Another way, perhaps a bit more calculation intensive, would be to get the horizontal offsets of every insertionPoint of the text in a cell. If an insertion point is in overflow, horizontal offset should return an error.

           

          Just a test snippet to illustrate my point:

           

          /*
              Test with:
              document with one story, 
              one table and text in cell one that overflows
          */
          
          var myInsertionPoints = 
          
              app.documents[0].
              stories[0].
              tables[0].
              cells[0].
              texts[0].
              insertionPoints.
              everyItem().getElements();
          
          // Loop from the end of the text:
          for(var n=myInsertionPoints.length-1;n>=0;n--)
          {
              try{
                  myInsertionPoints[n].horizontalOffset;
                  }catch(e){
                      $.writeln(n+"\t"+e.message);
                      $.writeln("ERROR: Cell overflows!");
                      break
                  };
          }
          

           

          //EDIT: Removed $.writeln in line 21.

           

          Regards,
          Uwe

          • 2. Re: Table Cells oveflows detection - again
            Laubender Adobe Community Professional & MVP

            Or just address the last insertion point and check for horizontalOffset or baseline (the "vertical offset").

             

            /*
                Test with:
                document with one story,
                one table and text in cell one that overflows
            */
            
            var myInsertionPoints =
            
                app.documents[0].
                stories[0].
                tables[0].
                cells[0].
                texts[0].
                insertionPoints.
                everyItem().getElements();
            
            try{
            myInsertionPoints.pop().horizontalOffset();
            }catch(e){$.writeln(e.message)};
            

             

            Uwe

            1 person found this helpful
            • 3. Re: Table Cells oveflows detection - again
              mechaichezilla Level 1

              Yes, this worked.

               

              While I tested it, I found out another method that doesn't need to trigger and catch an error:

               

              I let InDesign output the content of the cell to check if the error is triggered on the correct cell and saw, that cell.contents only contains the text that's actually displayed on screen, while cell.texts[0].contents contains the complete string. So, if I compare cell.texts[0].contents with cell.contents I can find out overflow text as well.

               

              Thanks again!

              • 4. Re: Table Cells oveflows detection - again
                Laubender Adobe Community Professional & MVP

                Just a note on cell.contents :

                 

                Years ago I ran into trouble using cell.contents on a large, freshly imported table from Excel into a text frame, that could not hold the whole table. The rows in overset of that text frame, and there were hundreth, returned an empty string for all their cell's contents even if there was actually contents. That problem went away after the table was flown fully the first time to threaded text frames.

                 

                So I'm not sure, if comparing contents will always work with table cells.

                 

                Regards,
                Uwe

                • 5. Re: Table Cells oveflows detection - again
                  mechaichezilla Level 1

                  Good to know. The table will never leave the text frame though, since the column widths are calculated to always fit the frame, but we might run into the problem, that the width is smaller than the height of one line of rotated text, when there's too many columns. That would then cause an endless loop. So I guess I better prepare for that

                   

                  On that note, is it possible to create tooltips for table cells? That could be another solution for our problem. So the data people could just hover over the cell and check the cell content in the tooltip.

                   

                  Thanks

                  • 6. Re: Table Cells oveflows detection - again
                    Laubender Adobe Community Professional & MVP

                    mechaichezilla wrote:

                    … On that note, is it possible to create tooltips for table cells?…

                    Where would one invoke the tooltips?

                     

                    One could assign the contents of a cell as the value for the Label property.


                    And if a cell is selected, the contents, overset or not, would be viewable in the Script Label Panel of InDesign.
                    However, that is not dynamic. If you change the contents of the cell, the label will not update automatically.

                     

                    // Table selected:
                    // Only text cells, no graphic cells!
                    var table = app.selection[0];
                    var cells = table.cells.everyItem().getElements();
                    
                    for(var n=0;n<cells.length;n++)
                    {
                        cells[n].label = cells[n].texts[0].contents;
                    };
                    

                     

                    Cell one selected:

                    CellLabels-1-ScriptLabelPanel.png

                    Cell two selected:

                    CellLabels-2-ScriptLabelPanel.png

                     

                    Just an idea…

                     

                    Regards,
                    Uwe

                    • 7. Re: Table Cells oveflows detection - again
                      Laubender Adobe Community Professional & MVP

                      Ah, and you can even select cells and get their contents in overset tables.

                       

                      Selected cell not in overset of the table:

                      SelectingCellsInOversetTable-1.png

                       

                      Selected cell inside overset of the table:

                       

                      SelectingCellsInOversetTable-2.png

                       

                      And we have the Story Editor Window as well.

                       

                      Regards,
                      Uwe