Reply to topic  [ 4 posts ] 
Flipping Tables 
Author Message
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
NWP 2.0.5 introduced a number of new features for dealing with tables in macros. The following macro takes advantage of these features to improve on previous macros.

This macro will flip a table's rows and columns. It works for tables with different numbers of rows and columns, and it also works with tables that have merged cells. it also copies cell edge attributes, and it tries to preserve the size of the table and the relative widths and heights of the rows and columns, as far as possible.

Attachment:
Swap Rows and Columns.nwm [22.93 KiB]
Downloaded 186 times


Update: found yet another small bug. But fixed now.

_________________
philip


Last edited by phspaelti on 2013-11-02 07:27:06, edited 4 times in total.



2013-11-02 01:43:40
Profile

Joined: 2011-01-12 05:32:38
Posts: 256
Hi, Philip,

Good to see you're still practicing macro-writing :)

I tried this macro on a table (3x3) and it didn't work. Just left a shrunken table in the middle of the page. So then I inserted a table with no left upper box usable and tried the macro on it. Still doesn't work (same result).


2013-11-02 05:48:32
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
Thanks Eric.

The problem seems to be that Nisus treats the rows of a default table as having a height of 0. In such cases the layout engine seems to adjust the height as necessary. But my macro sets the dimensions (the width of the new table) according to that number. So you end up with a 0 width table. You could avoid that result by adjusting the height manually. That forces the table to take on a fixed height and the problem is solved.

Well, to avoid these complications I have replaced the macro with a version that automatically forces the height to be 1 in such cases. It's a kludge, but a small one :)

_________________
philip


2013-11-02 06:34:19
Profile

Joined: 2011-01-12 05:32:38
Posts: 256
Beautiful! Works as described! Way to go!


2013-11-02 06:50:17
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software