Conversion Borderline2 to Borderline
Dietmar
dhiller1 at gmx.de
Fri Feb 10 15:30:08 PST 2012
Hi Eike
Am Dienstag, den 07.02.2012, 23:50 +0100 schrieb Eike Rathke:
> Hi Dietmar,
>
> On Saturday, 2012-02-04 18:47:40 +0100, Dietmar wrote:
>
> > is there a method to convert Borderline2 to Borderline (and vice versa),
> > I can use in a Java extension?
>
> Unfortunately not.
I have already realized a function, actually w/o having yet looked up
the code you mention below.
Here is the function if someone might want to use it (no guarantee for
correctness):
> /** Convert BorderLine2 to BorderLine
> * @param inBL2
> * @return
> */
> private static com.sun.star.table.BorderLine convert2toBorderLine
> (com.sun.star.table.BorderLine2 inBL2) {
> com.sun.star.table.BorderLine outBL = new BorderLine();
>
> switch (inBL2.LineStyle) {
> case com.sun.star.table.BorderLineStyle.NONE:
> outBL.Color = inBL2.Color;
> outBL.InnerLineWidth = 0;
> outBL.LineDistance = 0;
> outBL.OuterLineWidth = 0;
> break;
> case com.sun.star.table.BorderLineStyle.SOLID:
> case com.sun.star.table.BorderLineStyle.DOTTED:
> case com.sun.star.table.BorderLineStyle.DASHED:
> outBL.Color = inBL2.Color;
> outBL.InnerLineWidth = 0;
> outBL.LineDistance = 0;
> outBL.OuterLineWidth = (short) inBL2.LineWidth;
> break;
> case com.sun.star.table.BorderLineStyle.DOUBLE:
> outBL.Color = inBL2.Color;
> outBL.InnerLineWidth = (short) inBL2.LineWidth;
> outBL.LineDistance = (short) Math.max(35, inBL2.LineWidth);
> outBL.OuterLineWidth = (short) inBL2.LineWidth;
> break;
> case com.sun.star.table.BorderLineStyle.THINTHICK_SMALLGAP:
> outBL.Color = inBL2.Color;
> outBL.InnerLineWidth = 26;
> outBL.LineDistance = 35;
> outBL.OuterLineWidth = (short) inBL2.LineWidth;
> break;
> case com.sun.star.table.BorderLineStyle.THINTHICK_MEDIUMGAP:
> outBL.Color = inBL2.Color;
> outBL.InnerLineWidth = (short) (inBL2.LineWidth / 2);
> outBL.LineDistance = (short) Math.max(35, inBL2.LineWidth / 2);
> outBL.OuterLineWidth = (short) (inBL2.LineWidth);
> break;
> case com.sun.star.table.BorderLineStyle.THINTHICK_LARGEGAP:
> outBL.Color = inBL2.Color;
> outBL.InnerLineWidth = 26;
> outBL.LineDistance = (short) Math.max(35, inBL2.LineWidth);
> outBL.OuterLineWidth = 35;
> break;
> case com.sun.star.table.BorderLineStyle.THICKTHIN_SMALLGAP:
> outBL.Color = inBL2.Color;
> outBL.InnerLineWidth = (short) (inBL2.LineWidth);
> outBL.LineDistance = 35;
> outBL.OuterLineWidth = 26;
> break;
> case com.sun.star.table.BorderLineStyle.THICKTHIN_MEDIUMGAP:
> outBL.Color = inBL2.Color;
> outBL.InnerLineWidth = (short) (inBL2.LineWidth);
> outBL.LineDistance = (short) Math.max(35, inBL2.LineWidth / 2);
> outBL.OuterLineWidth = (short) (inBL2.LineWidth / 2);
> break;
> case com.sun.star.table.BorderLineStyle.THICKTHIN_LARGEGAP:
> outBL.Color = inBL2.Color;
> outBL.InnerLineWidth = 53;
> outBL.LineDistance = (short) Math.max(35, inBL2.LineWidth);
> outBL.OuterLineWidth = 26;
> break;
> case com.sun.star.table.BorderLineStyle.EMBOSSED:
> case com.sun.star.table.BorderLineStyle.ENGRAVED:
> outBL.Color = inBL2.Color;
> outBL.InnerLineWidth = (short) (inBL2.LineWidth / 2);
> outBL.LineDistance = (short) Math.max(35, inBL2.LineWidth);
> outBL.OuterLineWidth = (short) (inBL2.LineWidth / 2);
> break;
> case com.sun.star.table.BorderLineStyle.OUTSET:
> outBL.Color = inBL2.Color;
> outBL.InnerLineWidth = (short) (inBL2.LineWidth);
> outBL.LineDistance = (short) Math.max(35, inBL2.LineWidth);
> outBL.OuterLineWidth = 26;
> break;
> case com.sun.star.table.BorderLineStyle.INSET:
> outBL.Color = inBL2.Color;
> outBL.InnerLineWidth = 26;
> outBL.LineDistance = (short) Math.max(35, inBL2.LineWidth);
> outBL.OuterLineWidth = (short) (inBL2.LineWidth);
> break;
> }
> return outBL;
> }
But that function actually did not help, because as far as I found out,
TableBorder does not work the way it did before (OOo 2.3), but removes
the lines in most cases.
I am still trying to find the cause (and hoping it's fixed in 3.5)
> > ...
> I'm working on a TableBorder2 property that contains BorderLine2 instead
> of BorderLine, that will be for 3.6 though so probably doesn't help you
> right now with your actual problem.
I am looking forward to TabelBorder2
>
> > Simple type casting or picking the innerlinewidth etc. shows zero
> > values.
>
> That might also be due to some bugs around the BorderLine properties,
> which we only recently fixed. Master and 3-5 may already be better,
> some fixes are also in 3-5-0. Especially if for non-double lines only
> InnerLineWidth was set and OuterLineWidth was 0 then no border was
> drawn, may be workarounded by setting OuterLineWidth instead.
I will check Tableborders again once 3.5 is out.
>
> > Before doing a conversion tool myself, i would like to know if this has
> > already been done.
> > If not, can someone point me to the code where Borderline2 is
> > interpreted, so that I can reuse that code?
>
> You can peek into editeng/source/items/frmitems.cxx methods
> SvxBoxItem::LineToSvxLine() and lcl_lineToSvxLine() and
> editeng/source/items/borderline.cxx method
> SvxBorderLine::GuessLinesWidths().
>
> Eike
Thanks
Dietmar
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20120211/d6dcbb60/attachment.html>
More information about the LibreOffice
mailing list