Menu

#3 The PPTGraphics2D code is not compiling against Apache POI 3.17

0.18
open
None
2017-09-27
2017-09-21
No

Sent by Mark Schmieder:

Here's my code snippet that brings PPTGraphics2D in compliance with Apache POI 3.17 API changes. It appears to be the correct code replacement for the old API, but my code comments are reserved as I'm not sure how best to test to prove this is the case.

The code snippet occurs in drawString() and drawUnclippedText():

 // The following code doesn't compile against Apache POI 3.17.
 // int fIndex = coll.getFontIndex(_font.getName());

 // The following code is the Apache POI 3.17 compliant version.
 // This code is contributed by Meyer Sound Laboratories Inc. of Berkeley
 // CA USA and is not guaranteed to be the perfect substitute/update.
 HSLFFontInfo fInfo = coll.getFontInfo( _font.getFontName( Locale.ENGLISH ) );
 int fIndex = ( fInfo == null ) ? -1 : fInfo.getIndex();

Discussion

  • Mark Schmieder

    Mark Schmieder - 2017-09-21

    Although I have tested this code in the context of a heavy scientific visualization app that is CAD-based, my caveats are still in place, so hopefully somebody else knows a really good way to make sure my updates for Apache POI 3.17 compliance (just released a few days ago) are 100% correct.

    The updated code module is attached. I made sure to not run my usual Eclipse formatting rules or super-high compiler error/warning preferences on the file, to isolate and minimize the code changes.

     
  • Mark Schmieder

    Mark Schmieder - 2017-09-22

    Please note that Apache POI 3.17 requires an additional previously-optional JAR file at run-time (when using the PowerPoint functionality), or you'll get "class not found" errors: poi-scratchpad-3.17.jar.

     

    Last edit: Mark Schmieder 2017-09-22
  • Hervé Girod

    Hervé Girod - 2017-09-23
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,3 @@
    -
     Sent by Mark Schmieder:
    
     Here's my code snippet that brings PPTGraphics2D in compliance with Apache POI 3.17 API changes. It appears to be the correct code replacement for the old API, but my code comments are reserved as I'm not sure how best to test to prove this is the case.
    
    • assigned_to: Hervé Girod
     
  • Hervé Girod

    Hervé Girod - 2017-09-23

    It's fixed in trunk. I think that the fix you proposed is perfectly valid! I just changed the line of code which retrived the Font, to use a configurable Locale rather than just ENGLISH. By default the locale is the machine default Locale, but you can force it with a new setLocale property in the class

     
  • Mark Schmieder

    Mark Schmieder - 2017-09-27

    I was concerned about what to do for fonts, thinking that allowing the user locale might result in font-not-found. That’s an area I’m weak on; not enough knowledge of how Java handles locale-sensitive fonts and what it does if not installed. Presumably someone who has set a non-default locale has also troubled to install appropriate fonts as well though. Thanks again for your attention.

     
  • Hervé Girod

    Hervé Girod - 2017-09-27

    By default the PPTGraphics2D class uses the default Locale on the system, so normally it should just work without doing anything. The setLocale() method is just there if you want to specifically set the Locale you want to use, which I think should not be necessary in general.

     

    Last edit: Hervé Girod 2017-09-27

Anonymous
Anonymous

Add attachments
Cancel