Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 96159 Details for
Bug 225536
[Bidi] Support global orientation of report output
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for WPML emitter
doc_080415.diff (text/plain), 9.93 KB, created by
Lina Kemmel
on 2008-04-15 16:19:55 EDT
(
hide
)
Description:
Patch for WPML emitter
Filename:
MIME Type:
Creator:
Lina Kemmel
Created:
2008-04-15 16:19:55 EDT
Size:
9.93 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.birt.report.engine.emitter.wpml >Index: src/org/eclipse/birt/report/engine/emitter/wpml/WordEmitterImpl.java >=================================================================== >RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine.emitter.wpml/src/org/eclipse/birt/report/engine/emitter/wpml/WordEmitterImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 WordEmitterImpl.java >--- src/org/eclipse/birt/report/engine/emitter/wpml/WordEmitterImpl.java 28 Mar 2008 05:39:45 -0000 1.2 >+++ src/org/eclipse/birt/report/engine/emitter/wpml/WordEmitterImpl.java 15 Apr 2008 20:19:03 -0000 >@@ -33,6 +33,7 @@ > import org.apache.batik.transcoder.TranscoderOutput; > import org.apache.batik.transcoder.image.JPEGTranscoder; > import org.eclipse.birt.report.engine.api.IHTMLActionHandler; >+import org.eclipse.birt.report.engine.api.IRenderOption; > import org.eclipse.birt.report.engine.api.IReportRunnable; > import org.eclipse.birt.report.engine.api.InstanceID; > import org.eclipse.birt.report.engine.api.RenderOption; >@@ -173,7 +174,9 @@ > else > { > pageStatus = WordEmitterImpl.firstPage; >- writer.start( ); >+ // bidi_hcg: Pass Bidi orientation to the writer >+ writer.start( Boolean.TRUE.equals( eservice >+ .getOption( IRenderOption.RTL_FLAG ) ) ); > } > > this.page = page; >Index: src/org/eclipse/birt/report/engine/emitter/wpml/WpmlWriter.java >=================================================================== >RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine.emitter.wpml/src/org/eclipse/birt/report/engine/emitter/wpml/WpmlWriter.java,v >retrieving revision 1.32 >diff -u -r1.32 WpmlWriter.java >--- src/org/eclipse/birt/report/engine/emitter/wpml/WpmlWriter.java 28 Mar 2008 05:39:45 -0000 1.32 >+++ src/org/eclipse/birt/report/engine/emitter/wpml/WpmlWriter.java 15 Apr 2008 20:19:04 -0000 >@@ -12,6 +12,7 @@ > package org.eclipse.birt.report.engine.emitter.wpml; > > import java.io.OutputStream; >+import java.text.Bidi; > import java.util.List; > import java.util.StringTokenizer; > import java.util.logging.Level; >@@ -22,6 +23,7 @@ > import org.eclipse.birt.report.engine.emitter.XMLWriter; > import org.eclipse.birt.report.engine.content.IAutoTextContent; > import org.eclipse.birt.report.engine.css.engine.value.css.CSSConstants; >+import org.eclipse.birt.report.engine.css.engine.value.birt.BIRTConstants; > > public class WpmlWriter > { >@@ -49,7 +51,14 @@ > > protected static Logger logger = Logger.getLogger( WpmlWriter.class > .getName( ) ); >- >+ >+ // Holds the global layout orientation. >+ private boolean rtl = false; // bidi_hcg >+ >+ // Holds Bidi text information >+ private String[] bidiChunks = new String[0]; // bidi_hcg >+ private int[] bidiLevels = new int[0]; // bidi_hcg >+ > public WpmlWriter( OutputStream out ) > { > this( out, "UTF-8" ); >@@ -60,8 +69,19 @@ > writer.open( out, encoding ); > } > >+ /** >+ * >+ * @deprecated replaced by {@link #start( boolean )} >+ */ > public void start( ) > { >+ start( false ); >+ } >+ >+ public void start( boolean rtl ) >+ { >+ this.rtl = rtl; // bidi_hcg >+ > writer.startWriter( ); > writer.literal( "\n" ); > writer.literal( "<?mso-application progid=\"Word.Document\"?>" ); >@@ -108,6 +128,8 @@ > writer.attribute( "w:val", 4 ); > writer.closeTag( "w:pStyle" ); > >+ writeBidi( rtl ); // bidi_hcg >+ > //writer.openTag( "w:tabs" ); > //writer.openTag( "w:tab" ); > //writer.attribute( "w:val", "right" ); >@@ -372,6 +394,10 @@ > writer.closeTag( "w:tblInd" ); > writeAttrTag( "w:tblStyle", "TableGrid" ); > writeAttrTag( "w:tblOverlap", "Never" ); >+ >+ // bidi_hcg: Bidi layout orientation >+ writeBidiTable( ); >+ > writer.openTag( "w:tblW" ); > writer.attribute( "w:w", tablewidth ); > writer.attribute( "w:type", "dxa" ); >@@ -387,7 +413,10 @@ > > String color = parseColor( style.getBackgroundColor( ) ); > writeBackgroundColor( color ); >- writeAlign( style.getTextAlign( ) ); >+ >+ writeAlign( style.getTextAlign( ), >+ style.getDirection( ) ); // bidi_hcg >+ > writer.closeTag( "w:tblPr" ); > } > >@@ -421,14 +450,58 @@ > > } > >- private void writeAlign( String align ) >+ private void writeAlign( String align, String direction ) > { > if ( "justify".equalsIgnoreCase( align ) ) > { > align = "both"; > } >+ // bidi_hcg start >+ // Need to swap 'left' and 'right' when orientation is RTL. >+ if ( BIRTConstants.BIRT_RTL_VALUE.equalsIgnoreCase( direction ) ) >+ { >+ if ( IStyle.CSS_RIGHT_VALUE.equals( align ) ) >+ writeAttrTag( "w:jc", IStyle.CSS_LEFT_VALUE ); >+ else if ( IStyle.CSS_LEFT_VALUE.equals( align ) ) >+ writeAttrTag( "w:jc", IStyle.CSS_RIGHT_VALUE ); >+ else >+ writeAttrTag( "w:jc", align ); >+ } >+ // bidi_hcg end >+ else >+ writeAttrTag( "w:jc", align ); >+ } >+ >+ /** >+ * @param direction >+ * >+ * @author bidi_hcg >+ */ >+ private void writeBidi( boolean rtl ) >+ { >+ if ( rtl ) >+ { >+ writer.openTag( "w:bidi" ); >+ writer.closeTag( "w:bidi" ); >+ } >+ else >+ { >+ writeAttrTag( "w:bidi", "off" ); >+ } >+ } > >- writeAttrTag( "w:jc", align ); >+ /** >+ * @param direction >+ * >+ * @author bidi_hcg >+ */ >+ private void writeBidiTable( ) >+ { >+ if ( this.rtl ) >+ { >+ writer.openTag( "w:bidiVisual" ); >+ writer.closeTag( "w:bidiVisual" ); >+ } > } > > private void writeBorders( IStyle style ) >@@ -743,7 +816,8 @@ > .getCssText( ), ( style > .getProperty( IStyle.STYLE_MARGIN_BOTTOM ) ) > .getCssText( ) ); >- writeAlign( style.getTextAlign( ) ); >+ writeAlign( style.getTextAlign( ), >+ style.getDirection( ) ); // bidi_hcg > String val = parseColor( style.getBackgroundColor( ) ); > writeBackgroundColor( val ); > writer.closeTag( "w:pPr" ); >@@ -765,6 +839,21 @@ > openHyperlink( info ); > boolean reserved = isReserved( type ); > >+ // bidi_hcg start >+ // We need to determine Bidi runs and write each run separately, >+ // with RTL tags to indicate RTL run direction. Otherwise RTL runs >+ // won't be recognized by some Word versions. >+ // Non Bidi text will result in a single LTR Bidi run and won't be >+ // really affected. >+ String direction = style.getDirection( ); >+ boolean textIsRtl = BIRTConstants.BIRT_RTL_VALUE.equals( direction ); >+ int nChunks = reserved ? 1 : 0; >+ >+ writer.openTag( "w:pPr" ); >+ writeBidi( textIsRtl ); >+ writer.closeTag( "w:pPr" ); >+ // bidi_hcg end >+ > if ( reserved ) > { > writer.openTag( "w:r" ); >@@ -773,32 +862,53 @@ > writer.closeTag( "w:fldChar" ); > writer.closeTag( "w:r" ); > } >- >- writer.openTag( "w:r" ); >- writer.openTag( "w:rPr" ); >- writeRunProperties( style, info != null ); >- >- if ( prop ) >+ // bidi_hcg start >+ else > { >- writeAlign( style.getTextAlign( ) ); >- String val = parseColor( style.getBackgroundColor( ) ); >- writeBackgroundColor( val ); >- writeRunBorders( style ); >+ buildBidiChunks( txt, textIsRtl ); >+ nChunks = bidiChunks.length; >+ assert nChunks > 0; > } >+ for ( int i = 0; i < nChunks; i++ ) >+ { >+ // bidi_hcg end > >- writer.closeTag( "w:rPr" ); >+ writer.openTag( "w:r" ); >+ writer.openTag( "w:rPr" ); >+ writeRunProperties( style, info != null ); > >- if ( reserved ) >- { >- writeAutoText( type ); >+ if ( prop ) >+ { >+ // XXX bidi_hcg: It would be expected to only write align for >+ // the first run, however it seems to work as-is. >+ writeAlign( style.getTextAlign( ), >+ direction ); // bidi_hcg >+ String val = parseColor( style.getBackgroundColor( ) ); >+ writeBackgroundColor( val ); >+ writeRunBorders( style ); >+ } >+ // bidi_hcg start >+ if ( !reserved >+ && bidiLevels[i] == Bidi.DIRECTION_RIGHT_TO_LEFT ) >+ { >+ writer.openTag( "w:rtl" ); >+ writer.closeTag( "w:rtl" ); >+ } >+ // bidi_hcg end > >- } >- else >- { >- writeString( txt , style); >- } >+ writer.closeTag( "w:rPr" ); > >- writer.closeTag( "w:r" ); >+ if ( reserved ) >+ { >+ writeAutoText( type ); >+ } >+ else >+ { >+ writeString( bidiChunks[i], style ); >+ } >+ >+ writer.closeTag( "w:r" ); >+ } > if ( reserved ) > { > writer.openTag( "w:r" ); >@@ -872,7 +982,8 @@ > writeSpacing( style.getLineHeight( ) ); > } > >- writeAlign( style.getTextAlign( ) ); >+ writeAlign( style.getTextAlign( ), >+ style.getDirection( ) ); // bidi_hcg > > String val = parseColor( style.getBackgroundColor( ) ); > writeBackgroundColor( val ); >@@ -888,7 +999,8 @@ > { > writer.openTag( "w:p" ); > writer.openTag( "w:pPr" ); >- writeAlign( "center"); >+ writeAlign( "center", >+ null ); // bidi_hcg > writer.closeTag( "w:pPr" ); > writer.openTag( "w:r"); > writer.openTag("w:rPr"); >@@ -1313,14 +1425,19 @@ > > writeCellProp( style ); > writer.closeTag( "w:tcPr" ); >- >- if(style.getTextAlign( ).equals( "left" )) >+ >+ String direction = style.getDirection( ); // bidi_hcg >+ if(style.getTextAlign( ).equals( "left" ) ) > { >+ // bidi_hcg start >+ if ( BIRTConstants.BIRT_RTL_VALUE.equals( direction ) ) >+ writeAlign( style.getTextAlign( ), direction ); >+ // bidi_hcg end > return ; > } > > writer.openTag( "w:pPr"); >- writeAlign( style.getTextAlign( ) ); >+ writeAlign( style.getTextAlign( ), direction ); > writer.closeTag( "w:pPr"); > > } >@@ -1544,4 +1661,30 @@ > > writer.closeTag( "w:p" ); > } >+ >+ /** >+ * @param text >+ * @param rtl >+ * @return >+ * >+ * @author bidi_hcg >+ */ >+ private void buildBidiChunks( String text, boolean rtl ) >+ { >+ Bidi bidiObj = new Bidi( text, rtl ? Bidi.DIRECTION_RIGHT_TO_LEFT >+ : Bidi.DIRECTION_LEFT_TO_RIGHT ); >+ >+ int nRuns = bidiObj.getRunCount( ); >+ if ( nRuns != bidiChunks.length ) >+ { >+ bidiChunks = new String[nRuns]; >+ bidiLevels = new int[nRuns]; >+ } >+ for ( int i = 0; i < nRuns; i++ ) >+ { >+ bidiChunks[i] = text.substring(bidiObj.getRunStart( i ), >+ bidiObj.getRunLimit( i ) ); >+ bidiLevels[i] = bidiObj.getRunLevel( i ) & 1; >+ } >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
bjorn.freeman-benson
:
iplog+
Lina.Kemmel
:
review?
Actions:
View
|
Diff
Attachments on
bug 225536
:
95596
|
95598
|
96157
| 96159 |
96282
|
96299
|
96652
|
99946
|
101888
|
103603