<commit_before>/*******************************************************************************
 * Copyright (c) 2006 Inetsoft Technology Corp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Inetsoft Technology Corp  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.engine.emitter.wpml.writer;

import java.io.OutputStream;

import org.apache.commons.codec.binary.Base64;
import org.eclipse.birt.report.engine.content.IForeignContent;
import org.eclipse.birt.report.engine.content.IImageContent;
import org.eclipse.birt.report.engine.content.IStyle;
import org.eclipse.birt.report.engine.css.engine.StyleConstants;
import org.eclipse.birt.report.engine.css.engine.value.FloatValue;
import org.eclipse.birt.report.engine.emitter.EmitterUtil;
import org.eclipse.birt.report.engine.emitter.XMLWriter;
import org.eclipse.birt.report.engine.emitter.wpml.HyperlinkInfo;
import org.eclipse.birt.report.engine.emitter.wpml.IWordWriter;
import org.eclipse.birt.report.engine.emitter.wpml.SpanInfo;
import org.eclipse.birt.report.engine.emitter.wpml.WordUtil;
import org.eclipse.birt.report.engine.emitter.wpml.AbstractEmitterImpl.InlineFlag;
import org.eclipse.birt.report.engine.emitter.wpml.AbstractEmitterImpl.TextFlag;
import org.eclipse.birt.report.engine.layout.emitter.Image;
import org.w3c.dom.css.CSSValue;

public class DocWriter extends AbstractWordXmlWriter implements IWordWriter
{

	public DocWriter( OutputStream out )
	{
		this( out, "UTF-8" );
	}

	public DocWriter( OutputStream out, String encoding )
	{
		writer = new XMLWriter( );
		writer.open( out, encoding );
	}

	public void start( boolean rtl, String creator, String title,
			String description )
	{
		this.rtl = rtl;
		writer.startWriter( );
		writer.literal( "\n" );
		writer.literal( "<?mso-application progid=\"Word.Document\"?>" );
		writer.literal( "\n" );
		writer.openTag( "w:wordDocument" );
		writer.attribute( "xmlns:w",
				"http://schemas.microsoft.com/office/word/2003/wordml" );
		writer.attribute( "xmlns:v", "urn:schemas-microsoft-com:vml" );
		writer.attribute( "xmlns:w10", "urn:schemas-microsoft-com:office:word" );
		writer.attribute( "xmlns:o", "urn:schemas-microsoft-com:office:office" );
		writer.attribute( "xmlns:dt",
				"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" );
		writer.attribute( "xmlns:wx",
				"http://schemas.microsoft.com/office/word/2003/auxHint" );
		writer.attribute( "xmlns:aml",
				"http://schemas.microsoft.com/aml/2001/core" );
		writer.attribute( "xml:space", "preserve" );
		writeCoreProperties( creator, title, description );

		// style for outline
		writer.openTag( "w:styles" );
		writer.openTag( "w:style" );
		writer.attribute( "w:type", "paragraph" );
		writer.attribute( " w:styleId", 4 );
		writer.openTag( "w:name" );
		writer.attribute( "w:val", "toc 4" );
		writer.closeTag( "w:name" );
		writer.openTag( "wx:uiName" );
		writer.attribute( "wx:val", "catalog 4" );
		writer.closeTag( "wx:uiName" );
		writer.openTag( "w:autoRedefine" );
		writer.closeTag( "w:autoRedefine" );
		writer.openTag( "w:semiHidden" );
		writer.closeTag( "w:semiHidden" );
		writer.openTag( "w:rsid" );
		writer.attribute( "w:val", "009B3C8F" );
		writer.closeTag( "w:rsid" );
		writer.openTag( "w:pPr" );
		writer.openTag( "w:pStyle" );
		writer.attribute( "w:val", 4 );
		writer.closeTag( "w:pStyle" );
		writeBidi( rtl ); // bidi_hcg
		writer.closeTag( "w:pPr" );
		writer.openTag( "w:rPr" );
		writer.openTag( "wx:font" );
		writer.attribute( "wx:val", "Times New Roman" );
		writer.closeTag( "wx:font" );
		writer.closeTag( "w:rPr" );
		writer.closeTag( "w:style" );

		writer.openTag( "w:style" );
		writer.attribute( "w:type", "character" );
		writer.attribute( "w:styleId", "Hyperlink" );
		writeAttrTag( "w:name", "Hyperlink" );
		writer.openTag( "w:rPr" );
		writeAttrTag( "w:u", "single" );
		writeAttrTag( "w:color", "0000ff" );
		writer.closeTag( "w:rPr" );
		writer.closeTag( "w:style" );
		writer.closeTag( "w:styles" );

		// For show background
		writer.openTag( "w:displayBackgroundShape" );
		writer.closeTag( "w:displayBackgroundShape" );

		writer.openTag( "w:docPr" );
		writer.openTag( "w:view" );
		writer.attribute( "w:val", "print" );
		writer.closeTag( "w:view" );
		writer.openTag( "w:zoom" );
		writer.attribute( "w:percent", "100" );
		writer.closeTag( "w:zoom" );
		writer.closeTag( "w:docPr" );<commit_msg>Fix bugzilla bug 273162:Part of border of report item in a cell disappeared in doc preview.<commit_after>/*******************************************************************************
 * Copyright (c) 2006 Inetsoft Technology Corp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Inetsoft Technology Corp  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.engine.emitter.wpml.writer;

import java.io.OutputStream;

import org.apache.commons.codec.binary.Base64;
import org.eclipse.birt.report.engine.content.IForeignContent;
import org.eclipse.birt.report.engine.content.IImageContent;
import org.eclipse.birt.report.engine.content.IStyle;
import org.eclipse.birt.report.engine.css.engine.StyleConstants;
import org.eclipse.birt.report.engine.css.engine.value.FloatValue;
import org.eclipse.birt.report.engine.emitter.EmitterUtil;
import org.eclipse.birt.report.engine.emitter.XMLWriter;
import org.eclipse.birt.report.engine.emitter.wpml.HyperlinkInfo;
import org.eclipse.birt.report.engine.emitter.wpml.IWordWriter;
import org.eclipse.birt.report.engine.emitter.wpml.SpanInfo;
import org.eclipse.birt.report.engine.emitter.wpml.WordUtil;
import org.eclipse.birt.report.engine.emitter.wpml.AbstractEmitterImpl.InlineFlag;
import org.eclipse.birt.report.engine.emitter.wpml.AbstractEmitterImpl.TextFlag;
import org.eclipse.birt.report.engine.layout.emitter.Image;
import org.w3c.dom.css.CSSValue;

public class DocWriter extends AbstractWordXmlWriter implements IWordWriter
{

	public DocWriter( OutputStream out )
	{
		this( out, "UTF-8" );
	}

	public DocWriter( OutputStream out, String encoding )
	{
		writer = new XMLWriter( );
		writer.open( out, encoding );
	}

	public void start( boolean rtl, String creator, String title,
			String description )
	{
		this.rtl = rtl;
		writer.startWriter( );
		writer.literal( "\n" );
		writer.literal( "<?mso-application progid=\"Word.Document\"?>" );
		writer.literal( "\n" );
		writer.openTag( "w:wordDocument" );
		writer.attribute( "xmlns:w",
				"http://schemas.microsoft.com/office/word/2003/wordml" );
		writer.attribute( "xmlns:v", "urn:schemas-microsoft-com:vml" );
		writer.attribute( "xmlns:w10", "urn:schemas-microsoft-com:office:word" );
		writer.attribute( "xmlns:o", "urn:schemas-microsoft-com:office:office" );
		writer.attribute( "xmlns:dt",
				"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" );
		writer.attribute( "xmlns:wx",
				"http://schemas.microsoft.com/office/word/2003/auxHint" );
		writer.attribute( "xmlns:aml",
				"http://schemas.microsoft.com/aml/2001/core" );
		writer.attribute( "xml:space", "preserve" );
		writeCoreProperties( creator, title, description );

		// style for outline
		writer.openTag( "w:styles" );
		writer.openTag( "w:style" );
		writer.attribute( "w:type", "paragraph" );
		writer.attribute( " w:styleId", 4 );
		writer.openTag( "w:name" );
		writer.attribute( "w:val", "toc 4" );
		writer.closeTag( "w:name" );
		writer.openTag( "wx:uiName" );
		writer.attribute( "wx:val", "catalog 4" );
		writer.closeTag( "wx:uiName" );
		writer.openTag( "w:autoRedefine" );
		writer.closeTag( "w:autoRedefine" );
		writer.openTag( "w:semiHidden" );
		writer.closeTag( "w:semiHidden" );
		writer.openTag( "w:rsid" );
		writer.attribute( "w:val", "009B3C8F" );
		writer.closeTag( "w:rsid" );
		writer.openTag( "w:pPr" );
		writer.openTag( "w:pStyle" );
		writer.attribute( "w:val", 4 );
		writer.closeTag( "w:pStyle" );
		writeBidi( rtl ); // bidi_hcg
		writer.closeTag( "w:pPr" );
		writer.openTag( "w:rPr" );
		writer.openTag( "wx:font" );
		writer.attribute( "wx:val", "Times New Roman" );
		writer.closeTag( "wx:font" );
		writer.closeTag( "w:rPr" );
		writer.closeTag( "w:style" );

		writer.openTag( "w:style" );
		writer.attribute( "w:type", "character" );
		writer.attribute( "w:styleId", "Hyperlink" );
		writeAttrTag( "w:name", "Hyperlink" );
		writer.openTag( "w:rPr" );
		writeAttrTag( "w:u", "single" );
		writeAttrTag( "w:color", "0000ff" );
		writer.closeTag( "w:rPr" );
		writer.closeTag( "w:style" );

		writer.openTag( "w:style" );
		writer.attribute( "w:type", "table" );
		writer.attribute( "w:default", "on" );
		writer.attribute( "styleId", "TableNormal" );
		writeAttrTag( "w:name", "Normal Table" );
		writer.openTag( "wx:uiName" );
		writer.attribute( "wx:val", "Table Normal" );
		writer.closeTag( "wx:uiName" );
		writer.openTag( "w:rPr" );
		writer.openTag( "wx:font" );
		writer.attribute( "wx:val", "Calibri" );
		writer.closeTag( "wx:font" );
		writer.openTag( "w:lang" );
		writer.attribute( "w:val", "EN-US" );
		writer.attribute( "w:fareast", "ZH-CN" );
		writer.attribute( "w:bidi", "AR-SA" );
		writer.closeTag( "w:lang" );
		writer.closeTag( "w:rPr" );
		writer.openTag( "w:tblPr" );
		writer.openTag( "w:tblInd" );
		writer.attribute( "w:w", 0 );
		writer.attribute( "w:type", "dxa" );
		writer.closeTag( "w:tblInd" );
		writer.openTag( "w:tblCellMar" );
		writer.openTag( "w:top" );
		writer.attribute( "w:w", 0 );
		writer.attribute( "w:type", "dxa" );
		writer.closeTag( "w:top" );
		writer.openTag( "w:left" );
		writer.attribute( "w:w", 108 );
		writer.attribute( "w:type", "dxa" );
		writer.closeTag( "w:left" );
		writer.openTag( "w:bottom" );
		writer.attribute( "w:w", 0 );
		writer.attribute( "w:type", "dxa" );
		writer.closeTag( "w:bottom" );
		writer.openTag( "w:right" );
		writer.attribute( "w:w", 108 );
		writer.attribute( "w:type", "dxa" );
		writer.closeTag( "w:right" );
		writer.closeTag( "w:tblCellMar" );
		writer.closeTag( "w:tblPr" );
		writer.closeTag( "w:style" );

		writer.closeTag( "w:styles" );

		// For show background
		writer.openTag( "w:displayBackgroundShape" );
		writer.closeTag( "w:displayBackgroundShape" );

		writer.openTag( "w:docPr" );
		writer.openTag( "w:view" );
		writer.attribute( "w:val", "print" );
		writer.closeTag( "w:view" );
		writer.openTag( "w:zoom" );
		writer.attribute( "w:percent", "100" );
		writer.closeTag( "w:zoom" );
		writer.closeTag( "w:docPr" );
{'fraction_non_alphanumeric': 0.19820562116634624, 'fraction_numerical': 0.01327474137141811, 'mean_word_length': 4.798301486199575, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '540439', 'n_tokens_mistral': 4243, 'n_tokens_neox': 3841, 'n_words': 684}