<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;

import org.eclipse.birt.report.engine.content.IStyle;
import org.eclipse.birt.report.engine.ir.DimensionType;

public class WordUtil
{	
	public final static double INCH_PX = java.awt.Toolkit.getDefaultToolkit ( ).getScreenResolution ( );
	
	public final static double INCH_PT = 72;
	
	public final static double PT_TWIPS = 20;
	
	public final static double INCH_TWIPS = INCH_PT * PT_TWIPS;
	
	public final static double PX_TWIPS = INCH_TWIPS / INCH_PX;
	
	public final static double PX_PT = INCH_PT / INCH_PX;	
	
	public static String validBookmarkName(String name)
	{
		String bookmark = name.replaceAll ( " ", "_" );
        bookmark = bookmark.replaceAll("\"", "_");
        return bookmark;
	}
	
	public static int convertTo ( DimensionType value, int prefValue )
	{
		if (DimensionType.UNITS_PERCENTAGE
				.equalsIgnoreCase ( value.getUnits ( ) ))
		{
			return (int) (prefValue * value.getMeasure ( ) / 100);
		}

		return (int) convertTo ( value );<commit_msg>Fix 181113 NPE throws out when preview crosstab in doc on BIRT RCP<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;

import org.eclipse.birt.report.engine.content.IStyle;
import org.eclipse.birt.report.engine.ir.DimensionType;

public class WordUtil
{	
	public final static double INCH_PX = java.awt.Toolkit.getDefaultToolkit ( ).getScreenResolution ( );
	
	public final static double INCH_PT = 72;
	
	public final static double PT_TWIPS = 20;
	
	public final static double INCH_TWIPS = INCH_PT * PT_TWIPS;
	
	public final static double PX_TWIPS = INCH_TWIPS / INCH_PX;
	
	public final static double PX_PT = INCH_PT / INCH_PX;	
	
	public static String validBookmarkName(String name)
	{
		String bookmark = name.replaceAll ( " ", "_" );
        bookmark = bookmark.replaceAll("\"", "_");
        return bookmark;
	}
	
	public static int convertTo ( DimensionType value, int prefValue )
	{
		if(value == null)
		{
			return 0;
		}	
		
		if (DimensionType.UNITS_PERCENTAGE
				.equalsIgnoreCase ( value.getUnits ( ) ))
		{
			return (int) (prefValue * value.getMeasure ( ) / 100);
		}

		return (int) convertTo ( value );
{'fraction_non_alphanumeric': 0.18039336201598033, 'fraction_numerical': 0.011370620774431468, 'mean_word_length': 4.224719101123595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, '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': '6005718', 'n_tokens_mistral': 1039, 'n_tokens_neox': 924, 'n_words': 270}