Writer Table Columns Access via Java API

sos sos at pmg.be
Tue May 7 07:33:26 UTC 2019


hallo

how it works with basic

"iFotW" is the with off a collumn

   Twidth = oViewCursor.TextTable.width
     TTotalpercent = oViewCursor.TextTable.TableColumnRelativeSum
     startcell = oViewCursor.cell.cellname
     Kindex = asc(left(oViewCursor.cell.cellname,1))-65

     tabstops = CurRow.TableColumnSeparators()

    if uBound(tabstops)< 0 then
     iFotW = tWidth
     else

         if kindex = 0 then
         iFotW = (twidth * tabstops(Kindex).position/TTotalpercent)
         elseif kindex -1 = ubound(tabstops) then
         iFotW = twidth - (twidth * 
tabstops(Kindex-1).position/TTotalpercent)
         else
         iFotW = (twidth * tabstops(Kindex).position/TTotalpercent) - 
(twidth * tabstops(Kindex-1).position/TTotalpercent)
         endif
     end if

Hop it helps

On 5/6/2019 11:00 AM, fxruby wrote:
> Hello,
>
> I'm currently writing a program using the libreoffice java api.
> It's a programm controlling the Writer component. I can insert tables,
> place images inside the table and also change the height of table rows.
> Now I want to change the width of a table column. But when I try to get
> a column, I always get an empty object.
>
> Here's what I do (it's JRuby code, but very similar to java):
>
> [27] pry(main)> table.java_object
> =>
> [Proxy:1640296160,7f207000c9b0;gcc3[0];d5b23e2451b4b4a295c975776715,Type[com.sun.star.text.XTextTable]]>
> [28] pry(main)> columns = table.columns
> => #<Java::Default::$Proxy60:0x5b799640>
> [29] pry(main)> columns.java_object
> =>
> [Proxy:1534694976,7f207c000de0;gcc3[0];d5b23e2451b4b4a295c975776715,Type[com.sun.star.table.XTableColumns]]>
> [30] pry(main)> columns.getCount
> => 12
> [31] pry(main)> col = columns.getByIndex 0
> => nil
>
> I always get nil :(
>
> There's some kind of functionality behind the method, because if I enter
> a wrong index, an exception is raised
>
> [32] pry(main)> col = columns.getByIndex 13
> Java::ComSunStarLang::IndexOutOfBoundsException:
> from
> com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(com/sun/star/lib/uno/environments/remote/Job.java:158)
> [33] pry(main)>
>
> Is this a bug or what am I doing wrong?
>
> kind regards,
>
> Andy
> _______________________________________________
> LibreOffice mailing list
> LibreOffice at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/libreoffice


More information about the LibreOffice mailing list