Initial Commit
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using iTextSharp.text.rtf.parser;
|
||||
using iTextSharp.text.rtf.parser.ctrlwords;
|
||||
/*
|
||||
* $Id: IRtfDestinationListener.cs,v 1.2 2008/05/13 11:26:00 psoares33 Exp $
|
||||
*
|
||||
*
|
||||
* Copyright 2007 by Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is 'iText, a free JAVA-PDF library'.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
|
||||
* the Initial Developer are Copyright (C) 1999-2006 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2006 by Paulo Soares. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): all the names of the contributors are added in the source code
|
||||
* where applicable.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
|
||||
* provisions of LGPL are applicable instead of those above. If you wish to
|
||||
* allow use of your version of this file only under the terms of the LGPL
|
||||
* License and not to allow others to use your version of this file under
|
||||
* the MPL, indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by the LGPL.
|
||||
* If you do not delete the provisions above, a recipient may use your version
|
||||
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the MPL as stated above or under the terms of the GNU
|
||||
* Library General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
|
||||
* details.
|
||||
*
|
||||
* If you didn't download this code from the following link, you should check if
|
||||
* you aren't using an obsolete version:
|
||||
* http://www.lowagie.com/iText/
|
||||
*/
|
||||
namespace iTextSharp.text.rtf.parser.destinations {
|
||||
|
||||
/**
|
||||
* <code>RtfDestinationListener</code> interface for handling events.
|
||||
*
|
||||
* @author Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public interface IRtfDestinationListener : IEventListener {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
RtfCtrlWordData BeforeCtrlWord(RtfCtrlWordData ctrlWordData);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
RtfCtrlWordData OnCtrlWord(RtfCtrlWordData ctrlWordData);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
RtfCtrlWordData AfterCtrlWord(RtfCtrlWordData ctrlWordData);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int BeforeCharacter(int ch);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int OnCharacter(int ch);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int AfterCharacter(int ch);
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
bool OnOpenGroup();
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
bool OnCloseGroup();
|
||||
}
|
||||
}
|
@@ -0,0 +1,254 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using iTextSharp.text.rtf.parser;
|
||||
using iTextSharp.text.rtf.parser.ctrlwords;
|
||||
/*
|
||||
* $Id: RtfDestination.cs,v 1.2 2008/05/13 11:26:00 psoares33 Exp $
|
||||
*
|
||||
*
|
||||
* Copyright 2007 by Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is 'iText, a free JAVA-PDF library'.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
|
||||
* the Initial Developer are Copyright (C) 1999-2006 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2006 by Paulo Soares. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): all the names of the contributors are added in the source code
|
||||
* where applicable.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
|
||||
* provisions of LGPL are applicable instead of those above. If you wish to
|
||||
* allow use of your version of this file only under the terms of the LGPL
|
||||
* License and not to allow others to use your version of this file under
|
||||
* the MPL, indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by the LGPL.
|
||||
* If you do not delete the provisions above, a recipient may use your version
|
||||
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the MPL as stated above or under the terms of the GNU
|
||||
* Library General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
|
||||
* details.
|
||||
*
|
||||
* If you didn't download this code from the following link, you should check if
|
||||
* you aren't using an obsolete version:
|
||||
* http://www.lowagie.com/iText/
|
||||
*/
|
||||
namespace iTextSharp.text.rtf.parser.destinations {
|
||||
|
||||
/**
|
||||
* <code>RtfDestination</code> is the base class for destinations according
|
||||
* to the RTF Specification. All destinations must extend from this class.
|
||||
*
|
||||
* @author Howard Shank (hgshank@yahoo.com
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public abstract class RtfDestination {
|
||||
/** Parser object */
|
||||
protected RtfParser rtfParser = null;
|
||||
|
||||
/** Is data in destination modified? */
|
||||
protected bool modified = false;
|
||||
|
||||
/** The last control word handled by this destination */
|
||||
protected RtfCtrlWordData lastCtrlWord = null;
|
||||
|
||||
/** The <code>RtfDestinationListener</code>. */
|
||||
private static ArrayList listeners = new ArrayList();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public RtfDestination() {
|
||||
rtfParser = null;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
* @param parser <code>RtfParser</code> object.
|
||||
*/
|
||||
public RtfDestination(RtfParser parser) {
|
||||
this.rtfParser = parser;
|
||||
}
|
||||
/**
|
||||
* Set the parser to use with the RtfDestination object.
|
||||
*
|
||||
* @param parser The RtfParser object.
|
||||
*/
|
||||
public virtual void SetParser(RtfParser parser) {
|
||||
if (this.rtfParser != null && this.rtfParser.Equals(parser)) return;
|
||||
this.rtfParser = parser;
|
||||
}
|
||||
/**
|
||||
* Clean up when destination is closed.
|
||||
* @return true if handled, false if not handled
|
||||
*/
|
||||
public abstract bool CloseDestination();
|
||||
/**
|
||||
* Handle a new subgroup contained within this group
|
||||
* @return true if handled, false if not handled
|
||||
*/
|
||||
public abstract bool HandleOpeningSubGroup();
|
||||
/**
|
||||
* Clean up when group is closed.
|
||||
* @return true if handled, false if not handled
|
||||
*/
|
||||
public abstract bool HandleCloseGroup();
|
||||
|
||||
/**
|
||||
* Setup when group is opened.
|
||||
* @return true if handled, false if not handled
|
||||
*/
|
||||
public abstract bool HandleOpenGroup();
|
||||
/**
|
||||
* Handle text for this destination
|
||||
* @return true if handled, false if not handled
|
||||
*/
|
||||
public abstract bool HandleCharacter(int ch);
|
||||
/**
|
||||
* Handle control word for this destination
|
||||
* @param ctrlWordData The control word and parameter information object
|
||||
* @return true if handled, false if not handled
|
||||
*/
|
||||
public abstract bool HandleControlWord(RtfCtrlWordData ctrlWordData);
|
||||
/**
|
||||
* Method to set this object to the default values. Must be implemented in child class.
|
||||
*/
|
||||
public abstract void SetToDefaults();
|
||||
|
||||
/**
|
||||
* Method to indicate if data in this destination has changed.
|
||||
* @return true if modified, false if not modified.
|
||||
*/
|
||||
public bool IsModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
// listener methods
|
||||
|
||||
/**
|
||||
* Adds a <CODE>RtfDestinationListener</CODE> to the <CODE>RtfDestinationMgr</CODE>.
|
||||
*
|
||||
* @param listener
|
||||
* the new RtfDestinationListener.
|
||||
*/
|
||||
public bool AddListener(IRtfDestinationListener listener) {
|
||||
listeners.Add(listener);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a <CODE>RtfDestinationListener</CODE> from the <CODE>RtfDestinationMgr</CODE>.
|
||||
*
|
||||
* @param listener
|
||||
* the RtfCtrlWordListener that has to be removed.
|
||||
*/
|
||||
public bool RemoveListener(IRtfDestinationListener listener) {
|
||||
int i = listeners.IndexOf(listener);
|
||||
if (i >= 0) {
|
||||
listeners.RemoveAt(i);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected RtfCtrlWordData BeforeCtrlWord(RtfCtrlWordData ctrlWordData) {
|
||||
foreach (IRtfDestinationListener listener in listeners) {
|
||||
listener.BeforeCtrlWord(ctrlWordData);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected RtfCtrlWordData OnCtrlWord(RtfCtrlWordData ctrlWordData){
|
||||
foreach (IRtfDestinationListener listener in listeners) {
|
||||
listener.OnCtrlWord(ctrlWordData);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected RtfCtrlWordData AfterCtrlWord(RtfCtrlWordData ctrlWordData){
|
||||
foreach (IRtfDestinationListener listener in listeners) {
|
||||
listener.AfterCtrlWord(ctrlWordData);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected int BeforeCharacter(int ch){
|
||||
foreach (IRtfDestinationListener listener in listeners) {
|
||||
listener.BeforeCharacter(ch);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected int OnCharacter(int ch){
|
||||
foreach (IRtfDestinationListener listener in listeners) {
|
||||
listener.OnCharacter(ch);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected int AfterCharacter(int ch){
|
||||
foreach (IRtfDestinationListener listener in listeners) {
|
||||
listener.AfterCharacter(ch);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected bool OnOpenGroup(){
|
||||
foreach (IRtfDestinationListener listener in listeners) {
|
||||
listener.OnOpenGroup();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected bool OnCloseGroup(){
|
||||
foreach (IRtfDestinationListener listener in listeners) {
|
||||
listener.OnCloseGroup();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual int GetNewTokeniserState() {
|
||||
return RtfParser.TOKENISER_IGNORE_RESULT;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,317 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.rtf.parser;
|
||||
using iTextSharp.text.rtf.parser.ctrlwords;
|
||||
using iTextSharp.text.rtf.parser.enumerations;
|
||||
/*
|
||||
* $Id: RtfDestinationColorTable.cs,v 1.2 2008/05/13 11:26:00 psoares33 Exp $
|
||||
*
|
||||
*
|
||||
* Copyright 2007 by Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is 'iText, a free JAVA-PDF library'.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
|
||||
* the Initial Developer are Copyright (C) 1999-2006 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2006 by Paulo Soares. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): all the names of the contributors are added in the source code
|
||||
* where applicable.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
|
||||
* provisions of LGPL are applicable instead of those above. If you wish to
|
||||
* allow use of your version of this file only under the terms of the LGPL
|
||||
* License and not to allow others to use your version of this file under
|
||||
* the MPL, indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by the LGPL.
|
||||
* If you do not delete the provisions above, a recipient may use your version
|
||||
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the MPL as stated above or under the terms of the GNU
|
||||
* Library General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
|
||||
* details.
|
||||
*
|
||||
* If you didn't download this code from the following link, you should check if
|
||||
* you aren't using an obsolete version:
|
||||
* http://www.lowagie.com/iText/
|
||||
*/
|
||||
namespace iTextSharp.text.rtf.parser.destinations {
|
||||
|
||||
/**
|
||||
* <code>RtfDestinationColorTable</code> handles data destined for the color table destination
|
||||
*
|
||||
* @author Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public class RtfDestinationColorTable : RtfDestination {
|
||||
|
||||
/**
|
||||
* The RtfImportHeader to add color mappings to.
|
||||
*/
|
||||
private RtfImportMgr importHeader = null;
|
||||
/**
|
||||
* The number of the current color being parsed.
|
||||
*/
|
||||
private int colorNr = 0;
|
||||
/**
|
||||
* The red component of the current color being parsed.
|
||||
*/
|
||||
private int red = -1;
|
||||
/**
|
||||
* The green component of the current color being parsed.
|
||||
*/
|
||||
private int green = -1;
|
||||
/**
|
||||
* The blue component of the current color being parsed.
|
||||
*/
|
||||
private int blue = -1;
|
||||
/*
|
||||
* Color themes - Introduced Word 2007
|
||||
*/
|
||||
/**
|
||||
* Specifies the tint when specifying a theme color.
|
||||
* RTF control word ctint
|
||||
*
|
||||
* 0 - 255: 0 = full Tint(white), 255 = no tint.
|
||||
* Default value: 255
|
||||
*
|
||||
* If tint is specified and is less than 255, cshade must equal 255.
|
||||
* ctint/cshade are mutually exclusive
|
||||
*
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestinationColorTable#cshade
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestinationColorTable#themeColor
|
||||
*/
|
||||
private int ctint = 255;
|
||||
/**
|
||||
* Specifies the shade when specifying a theme color.
|
||||
* RTF control word cshade
|
||||
*
|
||||
* 0 - 255: 0 = full Shade(black), 255 = no shade.
|
||||
* Default value: 255
|
||||
*
|
||||
* If shade is specified and is less than 255, ctint must equal 255.
|
||||
* cshade/ctint are mutually exclusive
|
||||
*
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestinationColorTable#ctint
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestinationColorTable#themeColor
|
||||
*/
|
||||
private int cshade = 255;
|
||||
/**
|
||||
* Specifies the use of a theme color.
|
||||
*
|
||||
* @see com.lowagie.text.rtf.parser.enumerations.RtfColorThemes
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestinationColorTable#ctint
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestinationColorTable#cshade
|
||||
*/
|
||||
private int themeColor = RtfColorThemes.THEME_UNDEFINED;
|
||||
/**
|
||||
* Color map object for conversions
|
||||
*/
|
||||
private Hashtable colorMap = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public RtfDestinationColorTable() : base(null) {
|
||||
colorMap = new Hashtable();
|
||||
this.colorNr = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new RtfColorTableParser.
|
||||
*
|
||||
* @param importHeader The RtfImportHeader to add the color mappings to.
|
||||
*/
|
||||
public RtfDestinationColorTable(RtfParser parser) : base(parser) {
|
||||
colorMap = new Hashtable();
|
||||
this.colorNr = 0;
|
||||
this.importHeader = parser.GetImportManager();
|
||||
this.SetToDefaults();
|
||||
}
|
||||
|
||||
public override void SetParser(RtfParser parser) {
|
||||
this.rtfParser = parser;
|
||||
colorMap = new Hashtable();
|
||||
this.colorNr = 0;
|
||||
this.importHeader = parser.GetImportManager();
|
||||
this.SetToDefaults();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleOpenNewGroup()
|
||||
*/
|
||||
public override bool HandleOpeningSubGroup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CloseDestination() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleCloseGroup() {
|
||||
ProcessColor();
|
||||
return true;
|
||||
}
|
||||
public override bool HandleOpenGroup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleCharacter(int ch) {
|
||||
// color elements end with a semicolon (;)
|
||||
if ((char)ch == ';') {
|
||||
this.ProcessColor();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleControlWord(RtfCtrlWordData ctrlWordData) {
|
||||
if (ctrlWordData.ctrlWord.Equals("blue")) this.SetBlue(ctrlWordData.IntValue());
|
||||
if (ctrlWordData.ctrlWord.Equals("red")) this.SetRed(ctrlWordData.IntValue());
|
||||
if (ctrlWordData.ctrlWord.Equals("green")) this.SetGreen(ctrlWordData.IntValue());
|
||||
if (ctrlWordData.ctrlWord.Equals("cshade")) this.SetShade(ctrlWordData.IntValue());
|
||||
if (ctrlWordData.ctrlWord.Equals("ctint")) this.SetTint(ctrlWordData.IntValue());
|
||||
//if(ctrlWordData.ctrlWord.Equals("cmaindarkone")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("cmainlightone")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("cmaindarktwo")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("cmainlighttwo")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("caccentone")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("caccenttwo")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("caccentthree")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("caccentfour")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("caccentfive")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("caccentsix")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("chyperlink")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("cfollowedhyperlink")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("cbackgroundone")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("ctextone")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("cbacgroundtwo")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
//if(ctrlWordData.ctrlWord.Equals("ctexttwo")) this.SetThemeColor(ctrlWordData.ctrlWord);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values.
|
||||
*/
|
||||
public override void SetToDefaults() {
|
||||
this.red = -1;
|
||||
this.green = -1;
|
||||
this.blue = -1;
|
||||
this.ctint = 255;
|
||||
this.cshade = 255;
|
||||
this.themeColor = RtfColorThemes.THEME_UNDEFINED;
|
||||
// do not reset colorNr
|
||||
}
|
||||
/**
|
||||
* Processes the color triplet parsed from the document.
|
||||
* Add it to the import mapping so colors can be mapped when encountered
|
||||
* in the RTF import or conversion.
|
||||
*/
|
||||
private void ProcessColor() {
|
||||
if (red != -1 && green != -1 && blue != -1) {
|
||||
if (this.rtfParser.IsImport()) {
|
||||
this.importHeader.ImportColor(this.colorNr.ToString(), new Color(this.red, this.green, this.blue));
|
||||
}
|
||||
|
||||
if (this.rtfParser.IsConvert()) {
|
||||
colorMap[this.colorNr.ToString()] = new Color(this.red, this.green, this.blue);
|
||||
}
|
||||
}
|
||||
this.SetToDefaults();
|
||||
this.colorNr++;
|
||||
}
|
||||
/**
|
||||
* Set the red color to value.
|
||||
* @param value Value to set red to.
|
||||
*/
|
||||
private void SetRed(int value) {
|
||||
if (value >= 0 && value <= 255) {
|
||||
this.red = value;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the green color value.
|
||||
* @param value Value to set green to.
|
||||
*/
|
||||
private void SetGreen(int value) {
|
||||
if (value >= 0 && value <= 255) {
|
||||
this.green = value;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the blue color value.
|
||||
* @param value Value to set blue to.
|
||||
*/
|
||||
private void SetBlue(int value) {
|
||||
if (value >= 0 && value <= 255) {
|
||||
this.blue = value;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the tint value
|
||||
* @param value Value to set the tint to
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestinationColorTable#ctint
|
||||
*/
|
||||
private void SetTint(int value) {
|
||||
if (value >= 0 && value <= 255) {
|
||||
this.ctint = value;
|
||||
if (value >= 0 && value <255) {
|
||||
this.cshade = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the shade value
|
||||
* @param value Value to set the shade to
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestinationColorTable#cshade
|
||||
*/
|
||||
private void SetShade(int value) {
|
||||
if (value >= 0 && value <= 255) {
|
||||
this.cshade = value;
|
||||
if (value >= 0 && value <255) {
|
||||
this.ctint = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the theme color value.
|
||||
* @param value Value to set the theme color to
|
||||
* @see com.lowagie.text.rtf.parser.enumerations.RtfColorThemes
|
||||
*/
|
||||
private void SetThemeColor(int value) {
|
||||
if (value >= RtfColorThemes.THEME_UNDEFINED && value <= RtfColorThemes.THEME_MAX) {
|
||||
this.themeColor = value;
|
||||
} else {
|
||||
this.themeColor = RtfColorThemes.THEME_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
// conversion functions
|
||||
/**
|
||||
* Get the <code>Color</code> object that is mapped to the key.
|
||||
* @param key The map number.
|
||||
* *@return <code>Color</code> object from the map. null if key does not exist.
|
||||
*/
|
||||
public Color GetColor(String key) {
|
||||
return (Color)colorMap[key];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,592 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.rtf.document;
|
||||
using iTextSharp.text.rtf.direct;
|
||||
using iTextSharp.text.rtf.parser;
|
||||
using iTextSharp.text.rtf.parser.ctrlwords;
|
||||
using iTextSharp.text.rtf.parser.properties;
|
||||
/*
|
||||
* $Id: RtfDestinationDocument.cs,v 1.4 2008/05/13 11:26:00 psoares33 Exp $
|
||||
*
|
||||
*
|
||||
* Copyright 2007 by Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is 'iText, a free JAVA-PDF library'.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
|
||||
* the Initial Developer are Copyright (C) 1999-2006 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2006 by Paulo Soares. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): all the names of the contributors are added in the source code
|
||||
* where applicable.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
|
||||
* provisions of LGPL are applicable instead of those above. If you wish to
|
||||
* allow use of your version of this file only under the terms of the LGPL
|
||||
* License and not to allow others to use your version of this file under
|
||||
* the MPL, indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by the LGPL.
|
||||
* If you do not delete the provisions above, a recipient may use your version
|
||||
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the MPL as stated above or under the terms of the GNU
|
||||
* Library General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
|
||||
* details.
|
||||
*
|
||||
* If you didn't download this code from the following link, you should check if
|
||||
* you aren't using an obsolete version:
|
||||
* http://www.lowagie.com/iText/
|
||||
*/
|
||||
namespace iTextSharp.text.rtf.parser.destinations {
|
||||
/**
|
||||
* <code>RtfDestinationDocument</code> handles data destined for the document destination
|
||||
*
|
||||
* @author Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
*/
|
||||
public sealed class RtfDestinationDocument : RtfDestination, IRtfPropertyListener {
|
||||
|
||||
|
||||
/**
|
||||
* The RtfDocument object.
|
||||
*
|
||||
* @see com.lowagie.text.rtf.document.RtfDocument
|
||||
*/
|
||||
private RtfDocument rtfDoc = null;
|
||||
|
||||
/**
|
||||
* The iText Document object.
|
||||
*
|
||||
* @see com.lowagie.text.Document
|
||||
*/
|
||||
private Document doc = null;
|
||||
|
||||
private StringBuilder buffer = null;
|
||||
/**
|
||||
* Indicates the parser action. Import or Conversion.
|
||||
*
|
||||
* @see com.lowagie.text.rtf.direct.RtfParser#TYPE_UNIDENTIFIED
|
||||
* @see com.lowagie.text.rtf.direct.RtfParser#TYPE_CONVERT
|
||||
* @see com.lowagie.text.rtf.direct.RtfParser#TYPE_IMPORT_FRAGMENT
|
||||
* @see com.lowagie.text.rtf.direct.RtfParser#TYPE_IMPORT_FULL
|
||||
*/
|
||||
private int conversionType = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Indicates the current table level being processed
|
||||
*/
|
||||
private int tableLevel = 0;
|
||||
|
||||
private static ArrayList IMPORT_IGNORED_CTRLWORDS = new ArrayList(new string[]{
|
||||
"rtf",
|
||||
"ansicpg",
|
||||
"deff",
|
||||
"ansi",
|
||||
"mac",
|
||||
"pca",
|
||||
"pc",
|
||||
"stshfdbch",
|
||||
"stshfloch",
|
||||
"stshfhich",
|
||||
"stshfbi",
|
||||
"deflang",
|
||||
"deflangfe",
|
||||
"adeflang",
|
||||
"adeflangfe"
|
||||
}
|
||||
);
|
||||
private static ArrayList CONVERT_IGNORED_CTRLWORDS = new ArrayList(new string[]{"rtf"});
|
||||
|
||||
private Paragraph iTextParagraph = null;
|
||||
|
||||
public RtfDestinationDocument() : base(null) {
|
||||
}
|
||||
/**
|
||||
* Constructs a new <code>RtfDestinationDocument</code> using
|
||||
* the parameters to initialize the object.
|
||||
* @param rtfDoc The <code>RtfDocument</code> this works with.
|
||||
* @param doc The iText <code>Document</code> this works with.
|
||||
* @param type The type of conversion being done.
|
||||
*/
|
||||
public RtfDestinationDocument(RtfParser parser) : base (parser){
|
||||
this.rtfDoc = parser.GetRtfDocument();
|
||||
this.doc = parser.GetDocument();
|
||||
this.conversionType = parser.GetConversionType();
|
||||
SetToDefaults();
|
||||
if (this.rtfParser.IsConvert()) {
|
||||
this.rtfParser.GetState().properties.AddRtfPropertyListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetParser(RtfParser parser) {
|
||||
this.rtfParser = parser;
|
||||
this.rtfDoc = parser.GetRtfDocument();
|
||||
this.doc = parser.GetDocument();
|
||||
this.conversionType = parser.GetConversionType();
|
||||
SetToDefaults();
|
||||
if (this.rtfParser.IsConvert()) {
|
||||
this.rtfParser.GetState().properties.AddRtfPropertyListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#closeDestination()
|
||||
*/
|
||||
public override bool CloseDestination() {
|
||||
if (this.rtfParser.IsImport()) {
|
||||
if (this.buffer.Length>0) {
|
||||
WriteBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
this.rtfParser.GetState().properties.RemoveRtfPropertyListener(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupStart()
|
||||
*/
|
||||
public override bool HandleOpenGroup() {
|
||||
this.OnOpenGroup(); // event handler
|
||||
|
||||
if (this.rtfParser.IsImport()) {
|
||||
}
|
||||
if (this.rtfParser.IsConvert()) {
|
||||
if (this.iTextParagraph == null) this.iTextParagraph = new Paragraph();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleOpenNewGroup()
|
||||
*/
|
||||
public override bool HandleOpeningSubGroup() {
|
||||
if (this.rtfParser.IsImport()) {
|
||||
if (this.buffer.Length>0) {
|
||||
WriteBuffer();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
|
||||
*/
|
||||
public override bool HandleCloseGroup() {
|
||||
this.OnCloseGroup(); // event handler
|
||||
|
||||
if (this.rtfParser.IsImport()) {
|
||||
if (this.buffer.Length>0) {
|
||||
WriteBuffer();
|
||||
}
|
||||
WriteText("}");
|
||||
}
|
||||
if (this.rtfParser.IsConvert()) {
|
||||
if (this.buffer.Length > 0 && this.iTextParagraph == null) {
|
||||
this.iTextParagraph = new Paragraph();
|
||||
}
|
||||
if (this.buffer.Length > 0 ) {
|
||||
Chunk chunk = new Chunk();
|
||||
chunk.Append(this.buffer.ToString());
|
||||
this.iTextParagraph.Add(chunk);
|
||||
}
|
||||
if (this.iTextParagraph != null) {
|
||||
AddParagraphToDocument();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleCharacter(int)
|
||||
*/
|
||||
public override bool HandleCharacter(int ch) {
|
||||
bool result = true;
|
||||
this.OnCharacter(ch); // event handler
|
||||
|
||||
if (this.rtfParser.IsImport()) {
|
||||
if (buffer.Length > 254) {
|
||||
this.WriteBuffer();
|
||||
}
|
||||
buffer.Append((char)ch);
|
||||
}
|
||||
if (this.rtfParser.IsConvert()) {
|
||||
buffer.Append((char)ch);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public override bool HandleControlWord(RtfCtrlWordData ctrlWordData) {
|
||||
bool result = false;
|
||||
this.OnCtrlWord(ctrlWordData); // event handler
|
||||
|
||||
if (this.rtfParser.IsImport()) {
|
||||
// map font information
|
||||
if (ctrlWordData.ctrlWord.Equals("f")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapFontNr(ctrlWordData.param);}
|
||||
|
||||
// map color information
|
||||
//colors
|
||||
if (ctrlWordData.ctrlWord.Equals("cb")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
|
||||
if (ctrlWordData.ctrlWord.Equals("cf")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
|
||||
//cells
|
||||
if (ctrlWordData.ctrlWord.Equals("clcbpat")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
|
||||
if (ctrlWordData.ctrlWord.Equals("clcbpatraw")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
|
||||
if (ctrlWordData.ctrlWord.Equals("clcfpat")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
|
||||
if (ctrlWordData.ctrlWord.Equals("clcfpatraw")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
|
||||
//table rows
|
||||
if (ctrlWordData.ctrlWord.Equals("trcfpat")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
|
||||
if (ctrlWordData.ctrlWord.Equals("trcbpat")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
|
||||
//paragraph border
|
||||
if (ctrlWordData.ctrlWord.Equals("brdrcf")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (this.rtfParser.IsConvert()) {
|
||||
if (ctrlWordData.ctrlWord.Equals("par")) { AddParagraphToDocument(); }
|
||||
// Set Font
|
||||
if (ctrlWordData.ctrlWord.Equals("f")) {}
|
||||
|
||||
// color information
|
||||
//colors
|
||||
if (ctrlWordData.ctrlWord.Equals("cb")) {}
|
||||
if (ctrlWordData.ctrlWord.Equals("cf")) {}
|
||||
//cells
|
||||
if (ctrlWordData.ctrlWord.Equals("clcbpat")) {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clcbpatraw")) {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clcfpat")) {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clcfpatraw")) {}
|
||||
//table rows
|
||||
if (ctrlWordData.ctrlWord.Equals("trcfpat")) {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trcbpat")) {}
|
||||
//paragraph border
|
||||
if (ctrlWordData.ctrlWord.Equals("brdrcf")) {}
|
||||
|
||||
/* TABLES */
|
||||
if (ctrlWordData.ctrlWord.Equals("trowd")) /*Beginning of row*/ { tableLevel++;}
|
||||
if (ctrlWordData.ctrlWord.Equals("cell")) /*End of Cell Denotes the end of a table cell*/ {
|
||||
// String ctl = ctrlWordData.ctrlWord;
|
||||
// System.out.Print("cell found");
|
||||
}
|
||||
if (ctrlWordData.ctrlWord.Equals("row")) /*End of row*/ { tableLevel++;}
|
||||
if (ctrlWordData.ctrlWord.Equals("lastrow")) /*Last row of the table*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("row")) /*End of row*/ { tableLevel++;}
|
||||
if (ctrlWordData.ctrlWord.Equals("irow")) /*param is the row index of this row.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("irowband")) /*param is the row index of the row, adjusted to account for header rows. A header row has a value of -1.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tcelld")) /*Sets table cell defaults*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("nestcell")) /*Denotes the end of a nested cell.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("nestrow")) /*Denotes the end of a nested row*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("nesttableprops")) /*Defines the properties of a nested table. This is a destination control word*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("nonesttables")) /*Contains text for readers that do not understand nested tables. This destination should be ignored by readers that support nested tables.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trgaph")) /*Half the space between the cells of a table row in twips.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("cellx")) /*param Defines the right boundary of a table cell, including its half of the space between cells.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clmgf")) /*The first cell in a range of table cells to be merged.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clmrg")) /*Contents of the table cell are merged with those of the preceding cell*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clvmgf")) /*The first cell in a range of table cells to be vertically merged.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clvmrg")) /*Contents of the table cell are vertically merged with those of the preceding cell*/ {}
|
||||
/* TABLE: table row revision tracking */
|
||||
if (ctrlWordData.ctrlWord.Equals("trauth")) /*With revision tracking enabled, this control word identifies the author of changes to a table row's properties. N refers to a value in the revision table*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trdate")) /*With revision tracking enabled, this control word identifies the date of a revision*/ {}
|
||||
/* TABLE: Autoformatting flags */
|
||||
if (ctrlWordData.ctrlWord.Equals("tbllkborder")) /*Flag sets table autoformat to format borders*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tbllkshading")) /*Flag sets table autoformat to affect shading.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tbllkfont")) /*Flag sets table autoformat to affect font*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tbllkcolor")) /*Flag sets table autoformat to affect color*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tbllkbestfit")) /*Flag sets table autoformat to apply best fit*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tbllkhdrrows")) /*Flag sets table autoformat to format the first (header) row*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tbllklastrow")) /*Flag sets table autoformat to format the last row.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tbllkhdrcols")) /*Flag sets table autoformat to format the first (header) column*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tbllklastcol")) /*Flag sets table autoformat to format the last column*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tbllknorowband")) /*Specifies row banding conditional formatting shall not be applied*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tbllknocolband")) /*Specifies column banding conditional formatting shall not be applied.*/ {}
|
||||
/* TABLE: Row Formatting */
|
||||
if (ctrlWordData.ctrlWord.Equals("taprtl")) /*Table direction is right to left*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trautofit")) /*param = AutoFit:
|
||||
0 No AutoFit (default).
|
||||
1 AutoFit is on for the row. Overridden by \clwWidthN and \trwWidthN in any table row.
|
||||
*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trhdr")) /*Table row header. This row should appear at the top of every page on which the current table appears*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trkeep")) /*Keep table row together. This row cannot be split by a page break. This property is assumed to be off unless the control word is present*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trkeepfollow")) /*Keep row in the same page as the following row.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trleft")) /*Position in twips of the leftmost edge of the table with respect to the left edge of its column.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trqc")) /*Centers a table row with respect to its containing column.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trql")) /*Left-justifies a table row with respect to its containing column.*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trqr")) /*Right-justifies a table row with respect to its containing column*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trrh")) /*Height of a table row in twips. When 0, the height is sufficient for all the text in the line; when positive, the height is guaranteed to be at least the specified height; when negative, the absolute value of the height is used, regardless of the height of the text in the line*/ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trpaddb")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trpaddl")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trpaddr")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trpaddt")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trpaddfb")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trpaddfl")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trpaddfr")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trpaddft")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trspdl")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trspdt")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trspdb")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trspdr")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trspdfl")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trspdft")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trspdfb")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trspdfr")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trwWidth")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trftsWidth")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trwWidthB")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trftsWidthB")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trftsWidthB")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trwWidthA")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trftsWidthA")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tblind")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tblindtype")) /* */ {}
|
||||
/*TABLE: Row shading and Background Colors*/
|
||||
if (ctrlWordData.ctrlWord.Equals("trcbpat")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trcfpat")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trpat")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trshdng")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbgbdiag")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbgcross")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbgdcross")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbgdkbdiag")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbgdkcross")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbgdkdcross")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbgdkfdiag")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbgdkhor")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbgdkvert")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbgfdiag")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbghoriz")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbgvert")) /* */ {}
|
||||
/* TABLE: Cell Formatting*/
|
||||
if (ctrlWordData.ctrlWord.Equals("clFitText")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clNoWrap")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clpadl")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clpadt")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clpadb")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clpadr")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clpadfl")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clpadft")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clpadfb")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clpadfr")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clwWidth")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clftsWidth")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clhidemark")) /* */ {}
|
||||
/* TABLE: Compared Table Cells */
|
||||
if (ctrlWordData.ctrlWord.Equals("clins")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("cldel")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clmrgd")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clmrgdr")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clsplit")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clsplitr")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clinsauth")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clinsdttm")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("cldelauth")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("cldeldttm")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clmrgdauth")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clmrgddttm")) /* */ {}
|
||||
/*TABLE: Position Wrapped Tables (The following properties must be the same for all rows in the table.)*/
|
||||
if (ctrlWordData.ctrlWord.Equals("tdfrmtxtLeft")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tdfrmtxtRight")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tdfrmtxtTop")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tdfrmtxtBottom")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tabsnoovrlp")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tphcol")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tphmrg")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tphpg")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposnegx")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposnegy")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposx")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposxc")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposxi")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposxl")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposxo")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposxr")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposy")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposyb")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposyc")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposyil")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposyin")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposyout")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tposyt")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tpvmrg")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tpvpara")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tpvpg")) /* */ {}
|
||||
/* TABLE: Bidirectional Controls */
|
||||
if (ctrlWordData.ctrlWord.Equals("rtlrow")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("ltrrow")) /* */ {}
|
||||
/* TABLE: Row Borders */
|
||||
if (ctrlWordData.ctrlWord.Equals("trbrdrt")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbrdrl")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbrdrb")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbrdrr")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbrdrh")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("trbrdrv")) /* */ {}
|
||||
/* TABLE: Cell Borders */
|
||||
if (ctrlWordData.ctrlWord.Equals("brdrnil")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clbrdrb")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clbrdrt")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clbrdrl")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("clbrdrr")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("cldglu")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("cldgll")) /* */ {}
|
||||
if (ctrlWordData.ctrlWord.Equals("")) /* */ {}
|
||||
}
|
||||
if (ctrlWordData.ctrlWordType == RtfCtrlWordType.TOGGLE) {
|
||||
this.rtfParser.GetState().properties.ToggleProperty(ctrlWordData);//ctrlWordData.specialHandler);
|
||||
}
|
||||
|
||||
if (ctrlWordData.ctrlWordType == RtfCtrlWordType.FLAG ||
|
||||
ctrlWordData.ctrlWordType == RtfCtrlWordType.VALUE) {
|
||||
this.rtfParser.GetState().properties.SetProperty(ctrlWordData);//ctrlWordData.specialHandler, ctrlWordData.param);
|
||||
}
|
||||
|
||||
switch (conversionType) {
|
||||
case RtfParser.TYPE_IMPORT_FULL:
|
||||
if (!IMPORT_IGNORED_CTRLWORDS.Contains(ctrlWordData.ctrlWord)) {
|
||||
WriteBuffer();
|
||||
WriteText(ctrlWordData.ToString());
|
||||
}
|
||||
result = true;
|
||||
break;
|
||||
case RtfParser.TYPE_IMPORT_FRAGMENT:
|
||||
if (!IMPORT_IGNORED_CTRLWORDS.Contains(ctrlWordData.ctrlWord)) {
|
||||
WriteBuffer();
|
||||
WriteText(ctrlWordData.ToString());
|
||||
}
|
||||
result = true;
|
||||
break;
|
||||
case RtfParser.TYPE_CONVERT:
|
||||
if (IMPORT_IGNORED_CTRLWORDS.Contains(ctrlWordData.ctrlWord) == false) {
|
||||
}
|
||||
result = true;
|
||||
break;
|
||||
default: // error because is should be an import or convert
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Write the accumulated buffer to the destination.
|
||||
* Used for direct content
|
||||
*/
|
||||
private void WriteBuffer() {
|
||||
WriteText(this.buffer.ToString());
|
||||
SetToDefaults();
|
||||
}
|
||||
/**
|
||||
* Write the string value to the destiation.
|
||||
* Used for direct content
|
||||
* @param value
|
||||
*/
|
||||
private void WriteText(String value) {
|
||||
if (this.rtfParser.IsNewGroup()) {
|
||||
this.rtfDoc.Add(new RtfDirectContent("{"));
|
||||
this.rtfParser.SetNewGroup(false);
|
||||
}
|
||||
if (value.Length > 0) {
|
||||
this.rtfDoc.Add(new RtfDirectContent(value));
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#setDefaults()
|
||||
*/
|
||||
public override void SetToDefaults() {
|
||||
this.buffer = new StringBuilder();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.properties.RtfPropertyListener#afterChange(java.lang.String)
|
||||
*/
|
||||
public void AfterPropertyChange(String propertyName) {
|
||||
if (propertyName.StartsWith(RtfProperty.CHARACTER)) {
|
||||
} else {
|
||||
if (propertyName.StartsWith(RtfProperty.PARAGRAPH)) {
|
||||
} else {
|
||||
if (propertyName.StartsWith(RtfProperty.SECTION)) {
|
||||
} else {
|
||||
if (propertyName.StartsWith(RtfProperty.DOCUMENT)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.properties.RtfPropertyListener#beforeChange(java.lang.String)
|
||||
*/
|
||||
public void BeforePropertyChange(String propertyName) {
|
||||
// do we have any text to do anything with?
|
||||
// if not, then just return without action.
|
||||
if (this.buffer.Length == 0) return;
|
||||
|
||||
if (propertyName.StartsWith(RtfProperty.CHARACTER)) {
|
||||
// this is a character change,
|
||||
// add a new chunck to the current paragraph using current character settings.
|
||||
Chunk chunk = new Chunk();
|
||||
chunk.Append(this.buffer.ToString());
|
||||
this.buffer = new StringBuilder(255);
|
||||
Hashtable charProperties = this.rtfParser.GetState().properties.GetProperties(RtfProperty.CHARACTER);
|
||||
String defFont = (String)charProperties[RtfProperty.CHARACTER_FONT];
|
||||
if (defFont == null) defFont = "0";
|
||||
RtfDestinationFontTable fontTable = (RtfDestinationFontTable)this.rtfParser.GetDestination("fonttbl");
|
||||
Font currFont = fontTable.GetFont(defFont);
|
||||
int fs = Font.NORMAL;
|
||||
if (charProperties.ContainsKey(RtfProperty.CHARACTER_BOLD)) fs |= Font.BOLD;
|
||||
if (charProperties.ContainsKey(RtfProperty.CHARACTER_ITALIC)) fs |= Font.ITALIC;
|
||||
if (charProperties.ContainsKey(RtfProperty.CHARACTER_UNDERLINE)) fs |= Font.UNDERLINE;
|
||||
Font useFont = FontFactory.GetFont(currFont.Familyname, 12, fs, new Color(0,0,0));
|
||||
|
||||
|
||||
chunk.Font = useFont;
|
||||
if (iTextParagraph == null) this.iTextParagraph = new Paragraph();
|
||||
this.iTextParagraph.Add(chunk);
|
||||
|
||||
} else {
|
||||
if (propertyName.StartsWith(RtfProperty.PARAGRAPH)) {
|
||||
// this is a paragraph change. what do we do?
|
||||
} else {
|
||||
if (propertyName.StartsWith(RtfProperty.SECTION)) {
|
||||
|
||||
} else {
|
||||
if (propertyName.StartsWith(RtfProperty.DOCUMENT)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddParagraphToDocument() {
|
||||
if (this.iTextParagraph != null) {
|
||||
try {
|
||||
this.rtfParser.GetDocument().Add(this.iTextParagraph);
|
||||
} catch {
|
||||
}
|
||||
this.iTextParagraph = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,600 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.rtf.direct;
|
||||
using iTextSharp.text.rtf.parser;
|
||||
using iTextSharp.text.rtf.parser.ctrlwords;
|
||||
/*
|
||||
* $Id: RtfDestinationFontTable.cs,v 1.4 2008/05/13 11:26:00 psoares33 Exp $
|
||||
*
|
||||
*
|
||||
* Copyright 2007 by Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is 'iText, a free JAVA-PDF library'.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
|
||||
* the Initial Developer are Copyright (C) 1999-2006 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2006 by Paulo Soares. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): all the names of the contributors are added in the source code
|
||||
* where applicable.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
|
||||
* provisions of LGPL are applicable instead of those above. If you wish to
|
||||
* allow use of your version of this file only under the terms of the LGPL
|
||||
* License and not to allow others to use your version of this file under
|
||||
* the MPL, indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by the LGPL.
|
||||
* If you do not delete the provisions above, a recipient may use your version
|
||||
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the MPL as stated above or under the terms of the GNU
|
||||
* Library General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
|
||||
* details.
|
||||
*
|
||||
* If you didn't download this code from the following link, you should check if
|
||||
* you aren't using an obsolete version:
|
||||
* http://www.lowagie.com/iText/
|
||||
*/
|
||||
|
||||
namespace iTextSharp.text.rtf.parser.destinations {
|
||||
|
||||
/**
|
||||
* <code>RtfDestinationFontTable</code> handles data destined for the font table destination
|
||||
*
|
||||
* @author Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public sealed class RtfDestinationFontTable : RtfDestination {
|
||||
/**
|
||||
* The RtfImportHeader to add font mappings to.
|
||||
*/
|
||||
private RtfImportMgr importHeader = null;
|
||||
/**
|
||||
* The theme (Office 2007)
|
||||
*/
|
||||
private String themeFont = "";
|
||||
/**
|
||||
* The number of the font being parsed.
|
||||
*/
|
||||
private String fontNr = "";
|
||||
/**
|
||||
* The family of the font being parsed.
|
||||
*/
|
||||
private String fontFamily = "";
|
||||
/**
|
||||
* The \charset value
|
||||
*/
|
||||
private String charset = "";
|
||||
private const String CHARSET_DEFAULT = "0";
|
||||
/**
|
||||
* The \fprq
|
||||
*/
|
||||
private int fprq = 0;
|
||||
/**
|
||||
* The \*\panose font matching value if primary font is not available.
|
||||
*/
|
||||
private String panose = "";
|
||||
/**
|
||||
* The \*\fname
|
||||
*/
|
||||
//private String nontaggedname = "";
|
||||
/**
|
||||
* The name of the font being parsed.
|
||||
*/
|
||||
private String fontName = "";
|
||||
/**
|
||||
* The \falt alternate font if primary font is not available.
|
||||
*/
|
||||
private String falt = "";
|
||||
/**
|
||||
* The \falt alternate font if primary font is not available.
|
||||
*/
|
||||
//private String fontemb = "";
|
||||
/**
|
||||
* The \falt alternate font if primary font is not available.
|
||||
*/
|
||||
//private String fontType = "";
|
||||
/**
|
||||
* The \falt alternate font if primary font is not available.
|
||||
*/
|
||||
//private String fontFile = "";
|
||||
/**
|
||||
* The \falt alternate font if primary font is not available.
|
||||
*/
|
||||
//private String fontFileCpg = "";
|
||||
/**
|
||||
* The \fbias value
|
||||
*/
|
||||
private int fbias = 0;
|
||||
/**
|
||||
* The \cpg value
|
||||
*/
|
||||
private String cpg = "";
|
||||
/**
|
||||
* The \fnil, \fttruetype value
|
||||
*/
|
||||
private String trueType = "";
|
||||
|
||||
/**
|
||||
* state flag to handle different parsing of a font element
|
||||
*/
|
||||
private int state = 0;
|
||||
/* state values */
|
||||
/** Normal */
|
||||
private const int SETTING_NORMAL = 0;
|
||||
/** \falt */
|
||||
private const int SETTING_ALTERNATE = 1;
|
||||
/** \fname */
|
||||
private const int SETTING_FONTNAME = 2;
|
||||
/** \panose */
|
||||
private const int SETTING_PANOSE = 3;
|
||||
/** \fontemb */
|
||||
private const int SETTING_FONT_EMBED = 4;
|
||||
/** \ffile */
|
||||
private const int SETTING_FONT_FILE = 5;
|
||||
|
||||
/**
|
||||
* Convert font mapping to <code>FontFactory</code> font objects.
|
||||
*/
|
||||
private Hashtable fontMap = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public RtfDestinationFontTable() : base(null) {
|
||||
}
|
||||
/**
|
||||
* Constructs a new RtfFontTableParser.
|
||||
*
|
||||
* @param importHeader The RtfImportHeader to add font mappings to.
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public RtfDestinationFontTable(RtfParser parser) : base(parser) {
|
||||
this.Init(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#setParser(com.lowagie.text.rtf.parser.RtfParser)
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public override void SetParser(RtfParser parser) {
|
||||
if (this.rtfParser != null && this.rtfParser.Equals(parser)) return;
|
||||
this.rtfParser = parser;
|
||||
this.Init(true);
|
||||
}
|
||||
/**
|
||||
* Initialize the object.
|
||||
*
|
||||
* @param importFonts true to import the fonts into the FontFactory, false do not load fonts
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
private void Init(bool importFonts) {
|
||||
fontMap = new Hashtable();
|
||||
if (this.rtfParser != null) {
|
||||
this.importHeader = this.rtfParser.GetImportManager();
|
||||
}
|
||||
this.SetToDefaults();
|
||||
if (importFonts) {
|
||||
ImportSystemFonts();
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleOpenNewGroup()
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public override bool HandleOpeningSubGroup() {
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#closeDestination()
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public override bool CloseDestination() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public override bool HandleCloseGroup() {
|
||||
if (this.state == SETTING_NORMAL) {
|
||||
ProcessFont();
|
||||
}
|
||||
this.state = SETTING_NORMAL;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupStart()
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public override bool HandleOpenGroup() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleCharacter(char[])
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public override bool HandleCharacter(int ch) {
|
||||
switch (this.state) {
|
||||
case SETTING_NORMAL:
|
||||
this.fontName += (char)ch;
|
||||
break;
|
||||
case SETTING_ALTERNATE:
|
||||
this.falt += (char)ch;
|
||||
break;
|
||||
case SETTING_PANOSE:
|
||||
this.panose += (char)ch;
|
||||
break;
|
||||
case SETTING_FONT_EMBED:
|
||||
break;
|
||||
case SETTING_FONT_FILE:
|
||||
break;
|
||||
case SETTING_FONTNAME:
|
||||
break;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleControlWord(com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordData)
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public override bool HandleControlWord(RtfCtrlWordData ctrlWordData) {
|
||||
bool result = true;
|
||||
// just let fonttbl fall through and set last ctrl word object.
|
||||
|
||||
if (ctrlWordData.ctrlWord.Equals("f")) { this.SetFontNumber(ctrlWordData.param); result=true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("fcharset")) { this.SetCharset(ctrlWordData.param); result=true; }
|
||||
|
||||
// font families
|
||||
if (ctrlWordData.ctrlWord.Equals("fnil")) { this.SetFontFamily("roman"); result=true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("froman")) { this.SetFontFamily("roman"); result=true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("fswiss")) { this.SetFontFamily("swiss"); result=true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("fmodern")) { this.SetFontFamily("modern"); result=true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("fscript")) { this.SetFontFamily("script"); result=true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("fdecor")) { this.SetFontFamily("decor"); result=true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("ftech")) { this.SetFontFamily("tech"); result=true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("fbidi")) { this.SetFontFamily("bidi"); result=true; }
|
||||
// pitch
|
||||
if (ctrlWordData.ctrlWord.Equals("fprq")) { this.SetPitch(ctrlWordData.param); result=true; }
|
||||
// bias
|
||||
if (ctrlWordData.ctrlWord.Equals("fbias")) { this.SetBias(ctrlWordData.param); result=true; }
|
||||
// theme font information
|
||||
if (ctrlWordData.ctrlWord.Equals("flomajor")) { this.SetThemeFont("flomajor"); result= true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("fhimajor")) { this.SetThemeFont("fhimajor"); result= true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("fdbmajor")) { this.SetThemeFont("fdbmajor"); result= true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("fbimajor")) { this.SetThemeFont("fbimajor"); result= true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("flominor")) { this.SetThemeFont("flominor"); result= true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("fhiminor")) { this.SetThemeFont("fhiminor"); result= true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("fdbminor")) { this.SetThemeFont("fdbminor"); result= true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("fbiminor")) { this.SetThemeFont("fbiminor"); result= true; }
|
||||
|
||||
// panose
|
||||
if (ctrlWordData.ctrlWord.Equals("panose")) {state = SETTING_PANOSE; result = true; }
|
||||
|
||||
// \*\fname
|
||||
// <font name> #PCDATA
|
||||
if (ctrlWordData.ctrlWord.Equals("fname")) {state = SETTING_FONTNAME; result = true; }
|
||||
|
||||
// \*\falt
|
||||
if (ctrlWordData.ctrlWord.Equals("falt")) { state = SETTING_ALTERNATE; result = true; }
|
||||
|
||||
// \*\fontemb
|
||||
if (ctrlWordData.ctrlWord.Equals("fontemb")) { state = SETTING_FONT_EMBED; result = true; }
|
||||
|
||||
// font type
|
||||
if (ctrlWordData.ctrlWord.Equals("ftnil")) { this.SetTrueType("ftnil"); result= true; }
|
||||
if (ctrlWordData.ctrlWord.Equals("fttruetype")) { this.SetTrueType("fttruetype"); result= true; }
|
||||
|
||||
// \*\fontfile
|
||||
if (ctrlWordData.ctrlWord.Equals("fontemb")) { state = SETTING_FONT_FILE; result = true; }
|
||||
|
||||
// codepage
|
||||
if (ctrlWordData.ctrlWord.Equals("cpg")) { this.SetCodePage(ctrlWordData.param); result= true; }
|
||||
|
||||
this.lastCtrlWord = ctrlWordData;
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Set the code page
|
||||
* @param value The code page value
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public void SetCodePage(String value) {
|
||||
this.cpg = value;
|
||||
}
|
||||
/**
|
||||
* Set the TrueTtype type
|
||||
* @param value The type
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public void SetTrueType(String value) {
|
||||
this.trueType = value;
|
||||
}
|
||||
/**
|
||||
* Set the font pitch
|
||||
* @param value Pitch value
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public void SetPitch(String value) {
|
||||
this.fprq = int.Parse(value);
|
||||
}
|
||||
/**
|
||||
* Set the font bias
|
||||
* @param value Bias value
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public void SetBias(String value) {
|
||||
this.fbias = int.Parse(value);
|
||||
}
|
||||
/**
|
||||
* Set the font theme
|
||||
*
|
||||
* @param themeFont Theme value
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public void SetThemeFont(String themeFont) {
|
||||
this.themeFont = themeFont;
|
||||
}
|
||||
/**
|
||||
* Set the font name to the parsed value.
|
||||
*
|
||||
* @param fontName The font name.
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public void SetFontName(String fontName) {
|
||||
this.fontName = fontName;
|
||||
}
|
||||
/**
|
||||
* Set the font family to the parsed value.
|
||||
*
|
||||
* @param fontFamily The font family.
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public void SetFontFamily(String fontFamily) {
|
||||
this.fontFamily = fontFamily;
|
||||
}
|
||||
/**
|
||||
* Set the font number to the parsed value.
|
||||
* This is used for mapping fonts to the new font numbers
|
||||
*
|
||||
* @param fontNr The font number.
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public void SetFontNumber(String fontNr) {
|
||||
this.fontNr = fontNr;
|
||||
}
|
||||
/**
|
||||
* Set the alternate font name.
|
||||
*
|
||||
* @param fontAlternate The falt font value
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public void SetFontAlternate(String fontAlternate) {
|
||||
this.falt = fontAlternate;
|
||||
}
|
||||
/**
|
||||
* Set the character-set to the parsed value.
|
||||
*
|
||||
* @param charset The charset value
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public void SetCharset(String charset) {
|
||||
if (charset.Length == 0) {
|
||||
charset = "0";
|
||||
}
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#setDefaults()
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public override void SetToDefaults() {
|
||||
this.themeFont = "";
|
||||
this.fontNr = "";
|
||||
this.fontName = "";
|
||||
this.fontFamily = "";
|
||||
|
||||
this.charset = "";
|
||||
this.fprq = 0;
|
||||
this.panose = "";
|
||||
//this.nontaggedname = "";
|
||||
this.falt = "";
|
||||
//this.fontemb = "";
|
||||
//this.fontType = "";
|
||||
//this.fontFile = "";
|
||||
//this.fontFileCpg = "";
|
||||
this.fbias = 0;
|
||||
this.cpg = "";
|
||||
this.trueType = "";
|
||||
this.state = SETTING_NORMAL;
|
||||
}
|
||||
/**
|
||||
* Process the font information that was parsed from the input.
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
private void ProcessFont() {
|
||||
this.fontName = this.fontName.Trim();
|
||||
if (fontName.Length == 0) return;
|
||||
if (fontNr.Length == 0) return;
|
||||
|
||||
if (fontName.Length>0 && fontName.IndexOf(';') >= 0) {
|
||||
fontName = fontName.Substring(0,fontName.IndexOf(';'));
|
||||
}
|
||||
|
||||
if (this.rtfParser.IsImport()) {
|
||||
//TODO: If primary font fails, use the alternate
|
||||
//TODO: Problem: RtfFont defaults family to \froman and doesn't allow any other family.
|
||||
// if you set the family, it changes the font name and not the family in the Font.java class.
|
||||
|
||||
// if (this.fontFamily.Length() > 0) {
|
||||
// if (this.importHeader.ImportFont(this.fontNr, this.fontName, this.fontFamily, Integer.ParseInt(this.charset)) == false) {
|
||||
// if (this.falt.Length() > 0) {
|
||||
// this.importHeader.ImportFont(this.fontNr, this.falt, this.fontFamily, Integer.ParseInt(this.charset));
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
if (!this.importHeader.ImportFont(this.fontNr, this.fontName, int.Parse(this.charset==""?CHARSET_DEFAULT:this.charset))) {
|
||||
if (this.falt.Length > 0) {
|
||||
this.importHeader.ImportFont(this.fontNr, this.falt, int.Parse(this.charset==""?CHARSET_DEFAULT:this.charset));
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
if (this.rtfParser.IsConvert()) {
|
||||
// This could probably be written as a better font matching function
|
||||
|
||||
String fName = this.fontName; // work variable for trimming name if needed.
|
||||
Font f1 = Createfont(fName);
|
||||
if (f1.BaseFont == null && this.falt.Length>0)
|
||||
f1 = Createfont(this.falt);
|
||||
|
||||
if (f1.BaseFont == null) {
|
||||
// Did not find a font, let's try a substring of the first name.
|
||||
if (FontFactory.COURIER.IndexOf(fName) > -1 ) {
|
||||
f1 = FontFactory.GetFont(FontFactory.COURIER);
|
||||
} else if (FontFactory.HELVETICA.IndexOf(fName) > -1 ) {
|
||||
f1 = FontFactory.GetFont(FontFactory.HELVETICA);
|
||||
} else if (FontFactory.TIMES.IndexOf(fName) > -1 ) {
|
||||
f1 = FontFactory.GetFont(FontFactory.TIMES);
|
||||
} else if (FontFactory.SYMBOL.IndexOf(fName) > -1 ) {
|
||||
f1 = FontFactory.GetFont(FontFactory.SYMBOL);
|
||||
} else if (FontFactory.ZAPFDINGBATS.IndexOf(fName) > -1 ) {
|
||||
f1 = FontFactory.GetFont(FontFactory.ZAPFDINGBATS);
|
||||
} else {
|
||||
// we did not find a matching font in any form.
|
||||
// default to HELVETICA for now.
|
||||
f1 = FontFactory.GetFont(FontFactory.HELVETICA);
|
||||
}
|
||||
}
|
||||
fontMap[this.fontNr] = f1;
|
||||
//System.out.Println(f1.GetFamilyname());
|
||||
}
|
||||
this.SetToDefaults();
|
||||
}
|
||||
/**
|
||||
* Create a font via the <code>FontFactory</code>
|
||||
*
|
||||
* @param fontName The font name to create
|
||||
* @return The created <code>Font</code> object
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
private Font Createfont(String fontName) {
|
||||
Font f1 = null;
|
||||
int pos=-1;
|
||||
do {
|
||||
f1 = FontFactory.GetFont(fontName);
|
||||
|
||||
if (f1.BaseFont != null) break; // found a font, exit the do/while
|
||||
|
||||
pos = fontName.LastIndexOf(' '); // find the last space
|
||||
if (pos>0) {
|
||||
fontName = fontName.Substring(0, pos ); // truncate it to the last space
|
||||
}
|
||||
} while (pos>0);
|
||||
return f1;
|
||||
}
|
||||
/**
|
||||
* Get a <code>Font</code> object from the font map object
|
||||
*
|
||||
* @param key The font number to get
|
||||
* @return The mapped <code>Font</code> object.
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public Font GetFont(String key) {
|
||||
return (Font) fontMap[key];
|
||||
}
|
||||
/**
|
||||
* Load system fonts into the static <code>FontFactory</code> object
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
private void ImportSystemFonts() {
|
||||
FontFactory.RegisterDirectories();
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to load the environment variables.
|
||||
*
|
||||
* @return Properties object with environment variable information
|
||||
* @throws Throwable
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
// private Properties GetEnvironmentVariables() {
|
||||
// Properties environmentVariables = new Properties();
|
||||
// String operatingSystem = System.GetProperty("os.name").ToLowerCase();
|
||||
// Runtime runtime = Runtime.GetRuntime();
|
||||
// Process process = null;
|
||||
// if (operatingSystem.IndexOf("windows 95") > -1
|
||||
// || operatingSystem.IndexOf("windows 98") > -1
|
||||
// || operatingSystem.IndexOf("me") > -1) {
|
||||
// process = runtime.Exec("command.com /c set");
|
||||
// } else if ((operatingSystem.IndexOf("nt") > -1)
|
||||
// || (operatingSystem.IndexOf("windows 2000") > -1)
|
||||
// || (operatingSystem.IndexOf("windows xp") > -1)
|
||||
// || (operatingSystem.IndexOf("windows 2003") > -1)) {
|
||||
// process = runtime.Exec("cmd.exe /c set");
|
||||
// } else {
|
||||
// process = runtime.Exec("env");
|
||||
// }
|
||||
// BufferedReader environmentStream = new BufferedReader(new InputStreamReader(process.GetInputStream()));
|
||||
// String inputLine = "";
|
||||
// int idx = -1;
|
||||
// while ((inputLine = environmentStream.ReadLine()) != null) {
|
||||
// idx = inputLine.IndexOf('=');
|
||||
// environmentVariables.SetProperty(inputLine.Substring(0, idx),
|
||||
// inputLine.Substring(idx + 1));
|
||||
// }
|
||||
// return environmentVariables;
|
||||
// }
|
||||
}
|
||||
}
|
@@ -0,0 +1,174 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.rtf.document;
|
||||
using iTextSharp.text.rtf.parser;
|
||||
using iTextSharp.text.rtf.parser.ctrlwords;
|
||||
/*
|
||||
* $Id: RtfDestinationInfo.cs,v 1.2 2008/05/13 11:26:00 psoares33 Exp $
|
||||
*
|
||||
*
|
||||
* Copyright 2007 by Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is 'iText, a free JAVA-PDF library'.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
|
||||
* the Initial Developer are Copyright (C) 1999-2006 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2006 by Paulo Soares. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): all the names of the contributors are added in the source code
|
||||
* where applicable.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
|
||||
* provisions of LGPL are applicable instead of those above. If you wish to
|
||||
* allow use of your version of this file only under the terms of the LGPL
|
||||
* License and not to allow others to use your version of this file under
|
||||
* the MPL, indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by the LGPL.
|
||||
* If you do not delete the provisions above, a recipient may use your version
|
||||
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the MPL as stated above or under the terms of the GNU
|
||||
* Library General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
|
||||
* details.
|
||||
*
|
||||
* If you didn't download this code from the following link, you should check if
|
||||
* you aren't using an obsolete version:
|
||||
* http://www.lowagie.com/iText/
|
||||
*/
|
||||
|
||||
namespace iTextSharp.text.rtf.parser.destinations {
|
||||
|
||||
/**
|
||||
* <code>RtfDestinationInfo</code> handles data destined for the info destination
|
||||
*
|
||||
* @author Howard Shank (hgshank@yahoo.com)
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public class RtfDestinationInfo : RtfDestination {
|
||||
private String elementName = "";
|
||||
private String text = "";
|
||||
|
||||
|
||||
public RtfDestinationInfo() : base(null) {
|
||||
}
|
||||
/**
|
||||
* Constructs a new RtfDestinationInfo.
|
||||
*
|
||||
* @param parser The RtfParser object.
|
||||
*/
|
||||
public RtfDestinationInfo(RtfParser parser, String elementname) : base(parser) {
|
||||
SetToDefaults();
|
||||
this.elementName = elementname;
|
||||
}
|
||||
public override void SetParser(RtfParser parser) {
|
||||
this.rtfParser = parser;
|
||||
this.SetToDefaults();
|
||||
}
|
||||
public void SetElementName(String value) {
|
||||
this.elementName = value;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleOpenNewGroup()
|
||||
*/
|
||||
public override bool HandleOpeningSubGroup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#closeDestination()
|
||||
*/
|
||||
public override bool CloseDestination() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
|
||||
*/
|
||||
public override bool HandleCloseGroup() {
|
||||
if (this.text.Length > 0) {
|
||||
Document doc = this.rtfParser.GetDocument();
|
||||
if (doc != null) {
|
||||
if (this.elementName.Equals("author")){
|
||||
doc.AddAuthor(this.text);
|
||||
}
|
||||
if (this.elementName.Equals("title")){
|
||||
doc.AddTitle(this.text);
|
||||
}
|
||||
if (this.elementName.Equals("subject")){
|
||||
doc.AddSubject(this.text);
|
||||
}
|
||||
} else {
|
||||
RtfDocument rtfDoc = this.rtfParser.GetRtfDocument();
|
||||
if (rtfDoc != null) {
|
||||
if (this.elementName.Equals("author")){
|
||||
Meta meta = new Meta(this.elementName, this.text);
|
||||
RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta);
|
||||
rtfDoc.GetDocumentHeader().AddInfoElement(elem);
|
||||
}
|
||||
if (this.elementName.Equals("title")){
|
||||
Meta meta = new Meta(this.elementName, this.text);
|
||||
RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta);
|
||||
rtfDoc.GetDocumentHeader().AddInfoElement(elem);
|
||||
}
|
||||
if (this.elementName.Equals("subject")){
|
||||
Meta meta = new Meta(this.elementName, this.text);
|
||||
RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta);
|
||||
rtfDoc.GetDocumentHeader().AddInfoElement(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.SetToDefaults();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupStart()
|
||||
*/
|
||||
public override bool HandleOpenGroup() {
|
||||
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleCharacter(char[])
|
||||
*/
|
||||
public override bool HandleCharacter(int ch) {
|
||||
this.text += (char)ch;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleControlWord(com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordData)
|
||||
*/
|
||||
public override bool HandleControlWord(RtfCtrlWordData ctrlWordData) {
|
||||
elementName = ctrlWordData.ctrlWord;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#setToDefaults()
|
||||
*/
|
||||
public override void SetToDefaults() {
|
||||
this.text = "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using iTextSharp.text.rtf.parser;
|
||||
using iTextSharp.text.rtf.parser.ctrlwords;
|
||||
/*
|
||||
* $Id: RtfDestinationListTable.cs,v 1.2 2008/05/13 11:26:00 psoares33 Exp $
|
||||
*
|
||||
*
|
||||
* Copyright 2007 by Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is 'iText, a free JAVA-PDF library'.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
|
||||
* the Initial Developer are Copyright (C) 1999-2006 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2006 by Paulo Soares. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): all the names of the contributors are added in the source code
|
||||
* where applicable.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
|
||||
* provisions of LGPL are applicable instead of those above. If you wish to
|
||||
* allow use of your version of this file only under the terms of the LGPL
|
||||
* License and not to allow others to use your version of this file under
|
||||
* the MPL, indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by the LGPL.
|
||||
* If you do not delete the provisions above, a recipient may use your version
|
||||
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the MPL as stated above or under the terms of the GNU
|
||||
* Library General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
|
||||
* details.
|
||||
*
|
||||
* If you didn't download this code from the following link, you should check if
|
||||
* you aren't using an obsolete version:
|
||||
* http://www.lowagie.com/iText/
|
||||
*/
|
||||
|
||||
namespace iTextSharp.text.rtf.parser.destinations {
|
||||
|
||||
/**
|
||||
* <code>RtfDestinationListTable</code> handles data destined for the List Table destination
|
||||
*
|
||||
* @author Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
*/
|
||||
public class RtfDestinationListTable : RtfDestination {
|
||||
/**
|
||||
* The RtfImportHeader to add List mappings to.
|
||||
*/
|
||||
private RtfImportMgr importHeader = null;
|
||||
|
||||
public RtfDestinationListTable() : base(null) {
|
||||
}
|
||||
|
||||
public RtfDestinationListTable(RtfParser parser) : base(parser) {
|
||||
this.importHeader = parser.GetImportManager();
|
||||
}
|
||||
|
||||
public override void SetParser(RtfParser parser) {
|
||||
this.rtfParser = parser;
|
||||
this.importHeader = parser.GetImportManager();
|
||||
this.SetToDefaults();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleOpenNewGroup()
|
||||
*/
|
||||
public override bool HandleOpeningSubGroup() {
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#closeDestination()
|
||||
*/
|
||||
public override bool CloseDestination() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
public override bool HandleControlWord(RtfCtrlWordData ctrlWordData) {
|
||||
bool result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
|
||||
*/
|
||||
public override bool HandleCloseGroup() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupStart()
|
||||
*/
|
||||
public override bool HandleOpenGroup() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleCharacter(int)
|
||||
*/
|
||||
public override bool HandleCharacter(int ch) {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#setToDefaults()
|
||||
*/
|
||||
public override void SetToDefaults() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using iTextSharp.text.rtf.parser;
|
||||
using iTextSharp.text.rtf.parser.ctrlwords;
|
||||
/*
|
||||
* $Id: RtfDestinationMgr.cs,v 1.4 2008/05/13 11:26:00 psoares33 Exp $
|
||||
*
|
||||
*
|
||||
* Copyright 2007 by Howard Shank
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is 'iText, a free JAVA-PDF library'.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
|
||||
* the Initial Developer are Copyright (C) 1999-2006 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2006 by Paulo Soares. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): all the names of the contributors are added in the source code
|
||||
* where applicable.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
|
||||
* provisions of LGPL are applicable instead of those above. If you wish to
|
||||
* allow use of your version of this file only under the terms of the LGPL
|
||||
* License and not to allow others to use your version of this file under
|
||||
* the MPL, indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by the LGPL.
|
||||
* If you do not delete the provisions above, a recipient may use your version
|
||||
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the MPL as stated above or under the terms of the GNU
|
||||
* Library General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
|
||||
* details.
|
||||
*
|
||||
* If you didn't download this code from the following link, you should check if
|
||||
* you aren't using an obsolete version:
|
||||
* http://www.lowagie.com/iText/
|
||||
*/
|
||||
namespace iTextSharp.text.rtf.parser.destinations {
|
||||
|
||||
/**
|
||||
* <code>RtfDestinationMgr</code> manages destination objects for the parser
|
||||
*
|
||||
* @author Howard Shank (hgshank@yahoo.com)
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public sealed class RtfDestinationMgr {
|
||||
/*
|
||||
* Destinations
|
||||
*/
|
||||
private static RtfDestinationMgr instance = null;
|
||||
|
||||
/**
|
||||
* CtrlWord <-> Destination map object.
|
||||
*
|
||||
* Maps control words to their destinations objects.
|
||||
* Null destination is a special destination used for
|
||||
* discarding unwanted data. This is primarily used when
|
||||
* skipping groups, binary data or unwanted/unknown data.
|
||||
*/
|
||||
private static Hashtable destinations = new Hashtable(300, 0.95f);
|
||||
/**
|
||||
* Destination objects.
|
||||
* There is only one of each destination.
|
||||
*/
|
||||
private static Hashtable destinationObjects = new Hashtable(10, 0.95f);
|
||||
|
||||
private static bool ignoreUnknownDestinations = false;
|
||||
|
||||
private static RtfParser rtfParser = null;
|
||||
|
||||
/**
|
||||
* String representation of null destination.
|
||||
*/
|
||||
public const String DESTINATION_NULL = "null";
|
||||
/**
|
||||
* String representation of document destination.
|
||||
*/
|
||||
public const String DESTINATION_DOCUMENT = "document";
|
||||
|
||||
/**
|
||||
* Hidden default constructor becuase
|
||||
*/
|
||||
private RtfDestinationMgr() {
|
||||
}
|
||||
|
||||
public static void SetParser(RtfParser parser) {
|
||||
rtfParser = parser;
|
||||
}
|
||||
public static RtfDestinationMgr GetInstance() {
|
||||
lock(destinations) {
|
||||
if (instance == null) {
|
||||
instance = new RtfDestinationMgr();
|
||||
// 2 required destinations for all documents
|
||||
RtfDestinationMgr.AddDestination(RtfDestinationMgr.DESTINATION_DOCUMENT, new Object[] { "RtfDestinationDocument", "" } );
|
||||
RtfDestinationMgr.AddDestination(RtfDestinationMgr.DESTINATION_NULL, new Object[] { "RtfDestinationNull", "" } );
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
public static RtfDestinationMgr GetInstance(RtfParser parser) {
|
||||
lock(destinations) {
|
||||
RtfDestinationMgr.SetParser(parser);
|
||||
if (instance == null) {
|
||||
instance = new RtfDestinationMgr();
|
||||
// 2 required destinations for all documents
|
||||
RtfDestinationMgr.AddDestination(RtfDestinationMgr.DESTINATION_DOCUMENT, new Object[] { "RtfDestinationDocument", "" } );
|
||||
RtfDestinationMgr.AddDestination(RtfDestinationMgr.DESTINATION_NULL, new Object[] { "RtfDestinationNull", "" } );
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
public static RtfDestination GetDestination(String destination) {
|
||||
RtfDestination dest = null;
|
||||
if (destinations.ContainsKey(destination)) {
|
||||
dest = (RtfDestination)destinations[destination];
|
||||
} else {
|
||||
if (ignoreUnknownDestinations) {
|
||||
dest = (RtfDestination)destinations[DESTINATION_NULL];
|
||||
} else {
|
||||
dest = (RtfDestination)destinations[DESTINATION_DOCUMENT];
|
||||
}
|
||||
}
|
||||
dest.SetParser(RtfDestinationMgr.rtfParser);
|
||||
return dest;
|
||||
}
|
||||
|
||||
public static bool AddDestination(String destination, Object[] args) {
|
||||
if (destinations.ContainsKey(destination)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String thisClass = "iTextSharp.text.rtf.parser.destinations." + (String)args[0];
|
||||
|
||||
if (thisClass.IndexOf("RtfDestinationNull") >= 0) {
|
||||
destinations[destination] = RtfDestinationNull.GetInstance();
|
||||
return true;
|
||||
}
|
||||
|
||||
Type value = null;
|
||||
|
||||
try {
|
||||
value = Type.GetType(thisClass);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
if (value == null)
|
||||
return false;
|
||||
|
||||
RtfDestination c = null;
|
||||
|
||||
if (destinationObjects.ContainsKey(value.Name)) {
|
||||
c = (RtfDestination)destinationObjects[value.Name];
|
||||
} else {
|
||||
try {
|
||||
c = (RtfDestination)value.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, new Type[0], null).Invoke(null);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
c.SetParser(rtfParser);
|
||||
|
||||
if (value.Equals(typeof(RtfDestinationInfo))) {
|
||||
((RtfDestinationInfo)c).SetElementName(destination);
|
||||
}
|
||||
|
||||
if (value.Equals(typeof(RtfDestinationStylesheetTable))) {
|
||||
((RtfDestinationStylesheetTable)c).SetElementName(destination);
|
||||
((RtfDestinationStylesheetTable)c).SetType((String)args[1]);
|
||||
}
|
||||
|
||||
destinations[destination] = c;
|
||||
destinationObjects[value.Name] = c;
|
||||
return true;
|
||||
}
|
||||
|
||||
// listener methods
|
||||
|
||||
/**
|
||||
* Adds a <CODE>RtfDestinationListener</CODE> to the appropriate <CODE>RtfDestination</CODE>.
|
||||
*
|
||||
* @param destination the destination string for the listener
|
||||
* @param listener
|
||||
* the new RtfDestinationListener.
|
||||
*/
|
||||
public static bool AddListener(String destination, IRtfDestinationListener listener) {
|
||||
RtfDestination dest = GetDestination(destination);
|
||||
if (dest != null) {
|
||||
return dest.AddListener(listener);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a <CODE>RtfDestinationListener</CODE> from the appropriate <CODE>RtfDestination</CODE>.
|
||||
*
|
||||
* @param destination the destination string for the listener
|
||||
* @param listener
|
||||
* the RtfCtrlWordListener that has to be removed.
|
||||
*/
|
||||
public static bool RemoveListener(String destination, IRtfDestinationListener listener) {
|
||||
RtfDestination dest = GetDestination(destination);
|
||||
if (dest != null) {
|
||||
return dest.RemoveListener(listener);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using iTextSharp.text.rtf.parser;
|
||||
using iTextSharp.text.rtf.parser.ctrlwords;
|
||||
/*
|
||||
* $Id: RtfDestinationNull.cs,v 1.2 2008/05/13 11:26:00 psoares33 Exp $
|
||||
*
|
||||
*
|
||||
* Copyright 2007 by Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is 'iText, a free JAVA-PDF library'.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
|
||||
* the Initial Developer are Copyright (C) 1999-2006 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2006 by Paulo Soares. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): all the names of the contributors are added in the source code
|
||||
* where applicable.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
|
||||
* provisions of LGPL are applicable instead of those above. If you wish to
|
||||
* allow use of your version of this file only under the terms of the LGPL
|
||||
* License and not to allow others to use your version of this file under
|
||||
* the MPL, indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by the LGPL.
|
||||
* If you do not delete the provisions above, a recipient may use your version
|
||||
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the MPL as stated above or under the terms of the GNU
|
||||
* Library General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
|
||||
* details.
|
||||
*
|
||||
* If you didn't download this code from the following link, you should check if
|
||||
* you aren't using an obsolete version:
|
||||
* http://www.lowagie.com/iText/
|
||||
*/
|
||||
|
||||
namespace iTextSharp.text.rtf.parser.destinations {
|
||||
|
||||
/**
|
||||
* <code>RtfDestinationNull</code> is for discarded entries. They go nowhere.
|
||||
* If a control word destination is unknown or ignored, this is the destination
|
||||
* that should be set.
|
||||
*
|
||||
* All methods return true indicating they were handled.
|
||||
*
|
||||
* This is a unique destination in that it is a singleton.
|
||||
*
|
||||
* @author Howard Shank (hgshank@yahoo.com)
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public sealed class RtfDestinationNull : RtfDestination {
|
||||
private static RtfDestinationNull instance = new RtfDestinationNull();
|
||||
/**
|
||||
* Constructs a new RtfDestinationNull.
|
||||
*
|
||||
* This constructor is hidden for internal use only.
|
||||
*/
|
||||
private RtfDestinationNull() : base() {
|
||||
}
|
||||
/**
|
||||
* Constructs a new RtfDestinationNull.
|
||||
*
|
||||
* This constructor is hidden for internal use only.
|
||||
*
|
||||
* @param parser Unused value
|
||||
*/
|
||||
private RtfDestinationNull(RtfParser parser) : base(null) {
|
||||
}
|
||||
/**
|
||||
* Get the singleton instance of RtfDestinationNull object.
|
||||
*/
|
||||
static public RtfDestinationNull GetInstance() {
|
||||
return instance;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleOpenNewGroup()
|
||||
*/
|
||||
public override bool HandleOpeningSubGroup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#setDefaults()
|
||||
*/
|
||||
public override void SetToDefaults() {
|
||||
}
|
||||
|
||||
// Interface definitions
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#closeDestination()
|
||||
*/
|
||||
public override bool CloseDestination() {
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
|
||||
*/
|
||||
public override bool HandleCloseGroup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupStart()
|
||||
*/
|
||||
public override bool HandleOpenGroup() {
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleCharacter(int)
|
||||
*/
|
||||
public override bool HandleCharacter(int ch) {
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleControlWord(com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordData)
|
||||
*/
|
||||
public override bool HandleControlWord(RtfCtrlWordData ctrlWordData) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String GetName() {
|
||||
return typeof(RtfDestinationNull).Name;
|
||||
}
|
||||
|
||||
public override int GetNewTokeniserState() {
|
||||
return RtfParser.TOKENISER_SKIP_GROUP;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,488 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.pdf;
|
||||
using iTextSharp.text.rtf.direct;
|
||||
using iTextSharp.text.rtf.graphic;
|
||||
using iTextSharp.text.rtf.parser;
|
||||
using iTextSharp.text.rtf.document;
|
||||
using iTextSharp.text.rtf.parser.ctrlwords;
|
||||
/*
|
||||
* $Id: RtfDestinationShppict.cs,v 1.2 2008/05/13 11:26:00 psoares33 Exp $
|
||||
*
|
||||
*
|
||||
* Copyright 2007 by Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is 'iText, a free JAVA-PDF library'.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
|
||||
* the Initial Developer are Copyright (C) 1999-2006 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2006 by Paulo Soares. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): all the names of the contributors are added in the source code
|
||||
* where applicable.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
|
||||
* provisions of LGPL are applicable instead of those above. If you wish to
|
||||
* allow use of your version of this file only under the terms of the LGPL
|
||||
* License and not to allow others to use your version of this file under
|
||||
* the MPL, indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by the LGPL.
|
||||
* If you do not delete the provisions above, a recipient may use your version
|
||||
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the MPL as stated above or under the terms of the GNU
|
||||
* Library General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
|
||||
* details.
|
||||
*
|
||||
* If you didn't download this code from the following link, you should check if
|
||||
* you aren't using an obsolete version:
|
||||
* http://www.lowagie.com/iText/
|
||||
*/
|
||||
|
||||
namespace iTextSharp.text.rtf.parser.destinations {
|
||||
|
||||
/**
|
||||
* <code>RtfDestinationShppict</code> handles data destined for picture destinations
|
||||
*
|
||||
* @author Howard Shank (hgshank@yahoo.com)
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public class RtfDestinationShppict : RtfDestination {
|
||||
private ByteBuffer data = null;
|
||||
|
||||
private StringBuilder hexChars = new StringBuilder(0);
|
||||
private StringBuilder buffer = new StringBuilder();
|
||||
|
||||
/* picttype */
|
||||
private int pictureType = Image.ORIGINAL_NONE;
|
||||
public const int ORIGINAL_NONE = 0;
|
||||
public const int ORIGINAL_GIF = 3;
|
||||
public const int ORIGINAL_TIFF = 5;
|
||||
public const int ORIGINAL_PS = 7;
|
||||
|
||||
// emfblip - EMF (nhanced metafile) - NOT HANDLED
|
||||
// pngblip int ORIGINAL_PNG = 2;
|
||||
// jpegblip Image.ORIGINAL_JPEG = 1; ORIGINAL_JPEG2000 = 8;
|
||||
|
||||
// shppict - Destination
|
||||
// nonshpict - Destination - SKIP THIS
|
||||
// macpict - Mac QuickDraw- NOT HANDLED
|
||||
// pmmetafileN - OS/2 Metafile - NOT HANDLED
|
||||
// N * Meaning
|
||||
// 0x0004 PU_ARBITRARY
|
||||
// 0x0008 PU_PELS
|
||||
// 0x000C PU_LOMETRIC
|
||||
// 0x0010 PU_HIMETRIC
|
||||
// 0x0014 PU_LOENGLISH
|
||||
// 0x0018 PU_HIENGLISH
|
||||
// 0x001C PU_TWIPS
|
||||
//private int pmmetafile = 0;
|
||||
// wmetafileN Image.RIGINAL_WMF = 6;
|
||||
// N * Type
|
||||
// 1 = MM_TEXT
|
||||
// 2 = M_LOMETRIC
|
||||
// 3 = MM_HIMETRIC
|
||||
// 4 = MM_LOENGLISH
|
||||
// 5 = MM_HIENGLISH
|
||||
// 6 = MM_TWIPS
|
||||
// 7 = MM_ISOTROPIC
|
||||
// 8 = MM_ANISOTROPIC
|
||||
// dibitmapN - DIB - Convert to BMP?
|
||||
// wbitmapN Image.ORIGINAL_BMP = 4;
|
||||
|
||||
/* bitapinfo */
|
||||
// wbmbitspixelN - number of bits per pixel - 1 monochrome, 4 16 color, 8 256 color, 24 RGB - Default 1
|
||||
//private int bitsPerPixel = 1;
|
||||
// wbmplanesN - number of color planes - must be 1
|
||||
//private int planes = 1;
|
||||
// wbmwidthbytesN - number of bytes in each raster line
|
||||
//private int widthBytes = 0;
|
||||
|
||||
|
||||
|
||||
/* pictsize */
|
||||
// picwN Ext field if the picture is a Windows metafile; picture width in pixels if the picture is a bitmap or
|
||||
// from quickdraw
|
||||
private long width = 0;
|
||||
// pichN
|
||||
private long height = 0;
|
||||
// picwgoalN
|
||||
private long desiredWidth = 0;
|
||||
// picgoalN
|
||||
private long desiredHeight = 0;
|
||||
// picscalexN
|
||||
private int scaleX = 100;
|
||||
// picscaleyN
|
||||
private int scaleY = 100;
|
||||
// picscaled - macpict setting
|
||||
//private bool scaled = false;
|
||||
// picprop
|
||||
//private bool inlinePicture = false;
|
||||
// defshp
|
||||
//private bool wordArt = false;
|
||||
// piccroptN
|
||||
private int cropTop = 0;
|
||||
// piccropbN
|
||||
private int cropBottom = 0;
|
||||
// piccroplN
|
||||
private int cropLeft = 0;
|
||||
// piccroprN
|
||||
private int cropRight = 0;
|
||||
|
||||
/* metafileinfo */
|
||||
// picbmp
|
||||
//private bool bitmap = false;
|
||||
//picbppN - Valid 1,4,8,24
|
||||
//private int bbp = 1;
|
||||
|
||||
/* data */
|
||||
// binN
|
||||
// 0 = HEX, 1 = BINARY
|
||||
public const int FORMAT_HEXADECIMAL = 0;
|
||||
public const int FORMAT_BINARY = 1;
|
||||
private int dataFormat = FORMAT_HEXADECIMAL;
|
||||
private long binaryLength = 0;
|
||||
// blipupiN
|
||||
//private int unitsPerInch = 0;
|
||||
// bliptagN
|
||||
//private String tag = "";
|
||||
private const int NORMAL = 0;
|
||||
private const int BLIPUID = 1;
|
||||
|
||||
//private int state = NORMAL;
|
||||
/**
|
||||
* Constant for converting pixels to twips
|
||||
*/
|
||||
private const int PIXEL_TWIPS_FACTOR = 15;
|
||||
|
||||
private MemoryStream dataOS = null;
|
||||
|
||||
public RtfDestinationShppict() : base(null) {
|
||||
this.pictureType = pictureType; //get rid of a warning
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new RtfDestinationShppict.
|
||||
*/
|
||||
public RtfDestinationShppict(RtfParser parser) : base(parser) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#closeDestination()
|
||||
*/
|
||||
public override bool CloseDestination() {
|
||||
if (this.rtfParser.IsImport()) {
|
||||
if (this.buffer.Length>0) {
|
||||
WriteBuffer();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
|
||||
*/
|
||||
public override bool HandleCloseGroup() {
|
||||
this.OnCloseGroup(); // event handler
|
||||
|
||||
if (this.rtfParser.IsImport()) {
|
||||
if (this.buffer.Length>0) {
|
||||
WriteBuffer();
|
||||
}
|
||||
if (dataOS != null) {
|
||||
AddImage();
|
||||
dataOS = null;
|
||||
}
|
||||
this.WriteText("}");
|
||||
return true;
|
||||
}
|
||||
if (this.rtfParser.IsConvert()) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool AddImage() {
|
||||
Image img = null;
|
||||
try {
|
||||
img = Image.GetInstance(dataOS.ToArray());
|
||||
} catch {
|
||||
}
|
||||
// if (img != null) {
|
||||
// FileOutputStream out =null;
|
||||
// try {
|
||||
// out = new FileOutputStream("c:\\test.png");
|
||||
// out.Write(img.GetOriginalData());
|
||||
// out.Close();
|
||||
// } catch (FileNotFoundException e1) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e1.PrintStackTrace();
|
||||
// } catch (IOException e1) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e1.PrintStackTrace();
|
||||
// }
|
||||
|
||||
if (img != null) {
|
||||
img.ScaleAbsolute((float)this.desiredWidth/PIXEL_TWIPS_FACTOR, (float)this.desiredHeight/PIXEL_TWIPS_FACTOR);
|
||||
img.ScaleAbsolute((float)this.width/PIXEL_TWIPS_FACTOR, (float)this.height/PIXEL_TWIPS_FACTOR);
|
||||
img.ScalePercent((float)this.scaleX, this.scaleY);
|
||||
|
||||
try {
|
||||
if (this.rtfParser.IsImport()) {
|
||||
RtfDocument rtfDoc = this.rtfParser.GetRtfDocument();
|
||||
RtfImage rtfImage = new RtfImage(rtfDoc, img);
|
||||
rtfDoc.Add(rtfImage);
|
||||
}
|
||||
if (this.rtfParser.IsConvert()) {
|
||||
this.rtfParser.GetDocument().Add(img);
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
dataFormat = FORMAT_HEXADECIMAL;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupStart()
|
||||
*/
|
||||
public override bool HandleOpenGroup() {
|
||||
this.OnOpenGroup(); // event handler
|
||||
|
||||
if (this.rtfParser.IsImport()) {
|
||||
}
|
||||
if (this.rtfParser.IsConvert()) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleOpenNewGroup()
|
||||
*/
|
||||
public override bool HandleOpeningSubGroup() {
|
||||
if (this.rtfParser.IsImport()) {
|
||||
if (this.buffer.Length>0) {
|
||||
WriteBuffer();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleCharacter(int)
|
||||
*/
|
||||
public override bool HandleCharacter(int ch) {
|
||||
|
||||
if (this.rtfParser.IsImport()) {
|
||||
if (buffer.Length > 254)
|
||||
WriteBuffer();
|
||||
}
|
||||
if (data == null) data = new ByteBuffer();
|
||||
switch (dataFormat) {
|
||||
case FORMAT_HEXADECIMAL:
|
||||
hexChars.Append(ch);
|
||||
if (hexChars.Length == 2) {
|
||||
try {
|
||||
data.Append((char)int.Parse(hexChars.ToString(), NumberStyles.HexNumber));
|
||||
} catch {
|
||||
}
|
||||
hexChars = new StringBuilder();
|
||||
}
|
||||
break;
|
||||
case FORMAT_BINARY:
|
||||
if (dataOS == null) {
|
||||
dataOS = new MemoryStream();
|
||||
}
|
||||
// HGS - FIX ME IF PROBLEM!
|
||||
dataOS.WriteByte((byte)ch);
|
||||
// PNG signature should be.
|
||||
// (decimal) 137 80 78 71 13 10 26 10
|
||||
// (hexadecimal) 89 50 4e 47 0d 0a 1a 0a
|
||||
// (ASCII C notation) \211 P N G \r \n \032 \n
|
||||
|
||||
binaryLength--;
|
||||
if (binaryLength == 0) { dataFormat = FORMAT_HEXADECIMAL; }
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleControlWord(RtfCtrlWordData ctrlWordData) {
|
||||
bool result = false;
|
||||
bool skipCtrlWord = false;
|
||||
if (this.rtfParser.IsImport()) {
|
||||
skipCtrlWord = true;
|
||||
if (ctrlWordData.ctrlWord.Equals("shppict")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("nonshppict")) { // never gets here because this is a destination set to null
|
||||
skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;
|
||||
}
|
||||
if (ctrlWordData.ctrlWord.Equals("blipuid")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picprop")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("pict")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("emfblip")) { result = true; pictureType = Image.ORIGINAL_NONE;}
|
||||
if (ctrlWordData.ctrlWord.Equals("pngblip")) { result = true; pictureType = Image.ORIGINAL_PNG;}
|
||||
if (ctrlWordData.ctrlWord.Equals("jepgblip")) { result = true; pictureType = Image.ORIGINAL_JPEG;}
|
||||
if (ctrlWordData.ctrlWord.Equals("macpict")) { result = true; pictureType = Image.ORIGINAL_NONE;}
|
||||
if (ctrlWordData.ctrlWord.Equals("pmmetafile")) { result = true; pictureType = Image.ORIGINAL_NONE;}
|
||||
if (ctrlWordData.ctrlWord.Equals("wmetafile")) { result = true; pictureType = Image.ORIGINAL_WMF;}
|
||||
if (ctrlWordData.ctrlWord.Equals("dibitmap")) { result = true; pictureType = Image.ORIGINAL_NONE;}
|
||||
if (ctrlWordData.ctrlWord.Equals("wbitmap")) { result = true; pictureType = Image.ORIGINAL_BMP;}
|
||||
/* bitmap information */
|
||||
if (ctrlWordData.ctrlWord.Equals("wbmbitspixel")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("wbmplanes")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("wbmwidthbytes")) { result = true;}
|
||||
/* picture size, scaling and cropping */
|
||||
if (ctrlWordData.ctrlWord.Equals("picw")) { this.width = ctrlWordData.LongValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("pich")) { this.height = ctrlWordData.LongValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picwgoal")) { this.desiredWidth = ctrlWordData.LongValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("pichgoal")) { this.desiredHeight = ctrlWordData.LongValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picscalex")) { this.scaleX = ctrlWordData.IntValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picscaley")) { this.scaleY = ctrlWordData.IntValue();result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picscaled")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picprop")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("defshp")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("piccropt")) { this.cropTop = ctrlWordData.IntValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("piccropb")) { this.cropBottom = ctrlWordData.IntValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("piccropl")) { this.cropLeft = ctrlWordData.IntValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("piccropr")) { this.cropRight = ctrlWordData.IntValue(); result = true;}
|
||||
/* metafile information */
|
||||
if (ctrlWordData.ctrlWord.Equals("picbmp")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picbpp")) { result = true;}
|
||||
/* picture data */
|
||||
if (ctrlWordData.ctrlWord.Equals("bin")) {
|
||||
this.dataFormat = FORMAT_BINARY;
|
||||
// set length to param
|
||||
this.binaryLength = ctrlWordData.LongValue();
|
||||
this.rtfParser.SetTokeniserStateBinary(binaryLength);
|
||||
result = true;
|
||||
}
|
||||
if (ctrlWordData.ctrlWord.Equals("blipupi")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("blipuid")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("bliptag")) { result = true;}
|
||||
}
|
||||
if (this.rtfParser.IsConvert()) {
|
||||
if (ctrlWordData.ctrlWord.Equals("shppict")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("nonshppict")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("blipuid")) { result = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("pict")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("emfblip")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("pngblip")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("jepgblip")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("macpict")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("pmmetafile")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("wmetafile")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("dibitmap")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("wbitmap")) { result = true;}
|
||||
/* bitmap information */
|
||||
if (ctrlWordData.ctrlWord.Equals("wbmbitspixel")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("wbmplanes")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("wbmwidthbytes")) { result = true;}
|
||||
/* picture size, scaling and cropping */
|
||||
if (ctrlWordData.ctrlWord.Equals("picw")) { this.width = ctrlWordData.LongValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("pich")) { this.height = ctrlWordData.LongValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picwgoal")) { this.desiredWidth = ctrlWordData.LongValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("pichgoal")) { this.desiredHeight = ctrlWordData.LongValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picscalex")) { this.scaleX = ctrlWordData.IntValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picscaley")) { this.scaleY = ctrlWordData.IntValue();result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picscaled")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picprop")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("defshp")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("piccropt")) { this.cropTop = ctrlWordData.IntValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("piccropb")) { this.cropBottom = ctrlWordData.IntValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("piccropl")) { this.cropLeft = ctrlWordData.IntValue(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("piccropr")) { this.cropRight = ctrlWordData.IntValue(); result = true;}
|
||||
/* metafile information */
|
||||
if (ctrlWordData.ctrlWord.Equals("picbmp")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("picbpp")) { result = true;}
|
||||
/* picture data */
|
||||
if(ctrlWordData.ctrlWord.Equals("bin")) {
|
||||
dataFormat = FORMAT_BINARY; result = true;
|
||||
}
|
||||
if (ctrlWordData.ctrlWord.Equals("blipupi")) { result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("blipuid")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
|
||||
if (ctrlWordData.ctrlWord.Equals("bliptag")) { result = true;}
|
||||
|
||||
}
|
||||
if (!skipCtrlWord) {
|
||||
switch (this.rtfParser.GetConversionType()) {
|
||||
case RtfParser.TYPE_IMPORT_FULL:
|
||||
WriteBuffer();
|
||||
WriteText(ctrlWordData.ToString());
|
||||
result = true;
|
||||
break;
|
||||
case RtfParser.TYPE_IMPORT_FRAGMENT:
|
||||
WriteBuffer();
|
||||
WriteText(ctrlWordData.ToString());
|
||||
result = true;
|
||||
break;
|
||||
case RtfParser.TYPE_CONVERT:
|
||||
result = true;
|
||||
break;
|
||||
default: // error because is should be an import or convert
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#setDefaults()
|
||||
*/
|
||||
public override void SetToDefaults() {
|
||||
|
||||
this.buffer = new StringBuilder();
|
||||
this.data = null;
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
this.desiredWidth = 0;
|
||||
this.desiredHeight = 0;
|
||||
this.scaleX = 100;
|
||||
this.scaleY = 100;
|
||||
//this.scaled = false;
|
||||
//this.inlinePicture = false;
|
||||
//this.wordArt = false;
|
||||
this.cropTop = 0;
|
||||
this.cropBottom = 0;
|
||||
this.cropLeft = 0;
|
||||
this.cropRight = 0;
|
||||
//this.bitmap = false;
|
||||
//this.bbp = 1;
|
||||
this.dataFormat = FORMAT_HEXADECIMAL;
|
||||
this.binaryLength = 0;
|
||||
//this.unitsPerInch = 0;
|
||||
//this.tag = "";
|
||||
}
|
||||
|
||||
private void WriteBuffer() {
|
||||
WriteText(this.buffer.ToString());
|
||||
}
|
||||
private void WriteText(String value) {
|
||||
if (this.rtfParser.GetState().newGroup) {
|
||||
this.rtfParser.GetRtfDocument().Add(new RtfDirectContent("{"));
|
||||
this.rtfParser.GetState().newGroup = false;
|
||||
}
|
||||
if (value.Length > 0) {
|
||||
this.rtfParser.GetRtfDocument().Add(new RtfDirectContent(value));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,585 @@
|
||||
using System;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.rtf.style;
|
||||
using iTextSharp.text.rtf.parser;
|
||||
using iTextSharp.text.rtf.parser.ctrlwords;
|
||||
/*
|
||||
* $Id: RtfDestinationStylesheetTable.cs,v 1.2 2008/05/13 11:26:00 psoares33 Exp $
|
||||
*
|
||||
*
|
||||
* Copyright 2007 by Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is 'iText, a free JAVA-PDF library'.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
|
||||
* the Initial Developer are Copyright (C) 1999-2006 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2006 by Paulo Soares. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): all the names of the contributors are added in the source code
|
||||
* where applicable.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
|
||||
* provisions of LGPL are applicable instead of those above. If you wish to
|
||||
* allow use of your version of this file only under the terms of the LGPL
|
||||
* License and not to allow others to use your version of this file under
|
||||
* the MPL, indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by the LGPL.
|
||||
* If you do not delete the provisions above, a recipient may use your version
|
||||
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the MPL as stated above or under the terms of the GNU
|
||||
* Library General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
|
||||
* details.
|
||||
*
|
||||
* If you didn't download this code from the following link, you should check if
|
||||
* you aren't using an obsolete version:
|
||||
* http://www.lowagie.com/iText/
|
||||
*/
|
||||
|
||||
namespace iTextSharp.text.rtf.parser.destinations {
|
||||
|
||||
/**
|
||||
* <code>RtfDestinationStylesheetTable</code> handles data destined for the
|
||||
* Stylesheet Table destination
|
||||
*
|
||||
* @author Howard Shank (hgshank@yahoo.com)
|
||||
*
|
||||
*/
|
||||
public class RtfDestinationStylesheetTable : RtfDestination {
|
||||
private String styleName = "";
|
||||
/**
|
||||
* <code>RtfParagraphStyle</code> object for setting styleshee values
|
||||
* as they are parsed from the input.
|
||||
*/
|
||||
//private RtfParagraphStyle rtfParagraphStyle = null;
|
||||
|
||||
private String elementName = "";
|
||||
|
||||
/**
|
||||
* RTF Style number from stylesheet table.
|
||||
*/
|
||||
private int styleNr = 0;
|
||||
|
||||
/**
|
||||
* What kind of style is this, Paragraph or Character or Table
|
||||
*/
|
||||
private int styleType = RtfStyleTypes.PARAGRAPH;
|
||||
|
||||
// Alignment
|
||||
/**
|
||||
* Alignment - page 85
|
||||
* \qc, \qj, \ql, \qr, \qd, \qkN, \qt
|
||||
*/
|
||||
private int alignment = Element.ALIGN_LEFT;
|
||||
/**
|
||||
* Percentage of line occupied by Kashida justification (0 <20> low, 10 <20> medium, 20 <20> high).
|
||||
* \qkN
|
||||
*/
|
||||
private int justificationPercentage = 0;
|
||||
|
||||
// Indentation
|
||||
/**
|
||||
* First line indentation.
|
||||
*/
|
||||
private int firstLineIndent = 0;
|
||||
/**
|
||||
* Left indentation
|
||||
*/
|
||||
private int leftIndent = 0;
|
||||
/**
|
||||
* Right indentation
|
||||
*/
|
||||
private int rightIndent = 0;
|
||||
/**
|
||||
* Automatically adjust right indentation when docunent grid is defined
|
||||
*/
|
||||
private int adustRightIndent = 0;
|
||||
/**
|
||||
* Mirror indents?
|
||||
*/
|
||||
private int mirrorIndent = 0;
|
||||
|
||||
// Document Foratting Properties
|
||||
/**
|
||||
* Override orphan/widow control.
|
||||
*/
|
||||
private int overrideWidowControl = -1;
|
||||
|
||||
// Asian Typography
|
||||
/**
|
||||
* auto spacing betwee DBC and English
|
||||
*/
|
||||
private int AutoSpaceBetweenDBCEnglish = 0;
|
||||
/**
|
||||
* auto spacing betwee DBC and numbers
|
||||
*/
|
||||
private int AutoSpaceBetweenDBCNumbers = 0;
|
||||
/**
|
||||
* No Character wrapping
|
||||
*/
|
||||
private int noCharacterWrapping = 0;
|
||||
/**
|
||||
* No Word wrapping
|
||||
*/
|
||||
private int noWordWrapping = 0;
|
||||
/**
|
||||
* No overflow period and comma
|
||||
*/
|
||||
private int noOverflowPeriodComma = 0;
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
/**
|
||||
* The RtfImportHeader to add color mappings to.
|
||||
*/
|
||||
private RtfImportMgr importHeader = null;
|
||||
private String type = "";
|
||||
|
||||
public RtfDestinationStylesheetTable() : base(null) {
|
||||
}
|
||||
|
||||
public RtfDestinationStylesheetTable(RtfParser parser, String type) : base(parser){
|
||||
this.importHeader = parser.GetImportManager();
|
||||
this.type = type;
|
||||
}
|
||||
public override void SetParser(RtfParser parser) {
|
||||
this.rtfParser = parser;
|
||||
this.importHeader = parser.GetImportManager();
|
||||
}
|
||||
public void SetType(String value) {
|
||||
this.type = value;
|
||||
}
|
||||
public void SetElementName(String value) {
|
||||
this.elementName = value;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleOpenNewGroup()
|
||||
*/
|
||||
public override bool HandleOpeningSubGroup() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#closeDestination()
|
||||
*/
|
||||
public override bool CloseDestination() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleControlWord(RtfCtrlWordData ctrlWordData) {
|
||||
bool result = true;
|
||||
this.OnCtrlWord(ctrlWordData); // event handler
|
||||
|
||||
if (this.rtfParser.IsImport()) {
|
||||
// information
|
||||
if (ctrlWordData.ctrlWord.Equals("s")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("cs")) {}
|
||||
if (ctrlWordData.ctrlWord.Equals("ds")) {}
|
||||
if (ctrlWordData.ctrlWord.Equals("ts")) {}
|
||||
if (ctrlWordData.ctrlWord.Equals("tsrowd")) {}
|
||||
|
||||
if (ctrlWordData.ctrlWord.Equals("keycode")) {}
|
||||
if (ctrlWordData.ctrlWord.Equals("shift")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("ctrl")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("alt")) { }
|
||||
//cells
|
||||
if (ctrlWordData.ctrlWord.Equals("fn")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("additive")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("sbasedon")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("snext")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("sautoupd")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("shidden")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("slink")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("slocked")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("spersonal")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("scompose")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("sreply")) { }
|
||||
/* FORMATTING */
|
||||
// brdrdef/parfmt/apoctl/tabdef/shading/chrfmt
|
||||
|
||||
|
||||
|
||||
if (ctrlWordData.ctrlWord.Equals("styrsid")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("ssemihidden")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("sqformat")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("spriority")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("sunhideused")) { }
|
||||
|
||||
/* TABLE STYLES */
|
||||
if (ctrlWordData.ctrlWord.Equals("tscellwidth")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscellwidthfts")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscellpaddt")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscellpaddl")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscellpaddr")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscellpaddb")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscellpaddft"))/*0-auto, 3-twips*/ { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscellpaddfl"))/*0-auto, 3-twips*/ { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscellpaddfr"))/*0-auto, 3-twips*/ { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscellpaddfb"))/*0-auto, 3-twips*/ { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsvertalt")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsvertalc")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsvertalb")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsnowrap")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscellcfpat")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscellcbpat")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbgbdiag")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbgfdiag")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbgcross")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbgdcross")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbgdkcross ")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbgdkdcross")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbghoriz")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbgvert")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbgdkhor")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbgdkvert")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbrdrt")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbrdrb")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbrdrl")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbrdrr")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbrdrh")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbrdrv")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbrdrdgl")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tsbrdrdgr")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscbandsh")) { }
|
||||
if (ctrlWordData.ctrlWord.Equals("tscbandsv")) { }
|
||||
}
|
||||
if (ctrlWordData.ctrlWordType == RtfCtrlWordType.FLAG ||
|
||||
ctrlWordData.ctrlWordType == RtfCtrlWordType.TOGGLE ||
|
||||
ctrlWordData.ctrlWordType == RtfCtrlWordType.VALUE) {
|
||||
this.rtfParser.GetState().properties.SetProperty(ctrlWordData);
|
||||
}
|
||||
|
||||
switch (this.rtfParser.GetConversionType()) {
|
||||
case RtfParser.TYPE_IMPORT_FULL:
|
||||
result = true;
|
||||
break;
|
||||
case RtfParser.TYPE_IMPORT_FRAGMENT:
|
||||
result = true;
|
||||
break;
|
||||
case RtfParser.TYPE_CONVERT:
|
||||
result = true;
|
||||
break;
|
||||
default: // error because is should be an import or convert
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
|
||||
*/
|
||||
public override bool HandleCloseGroup() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupStart()
|
||||
*/
|
||||
public override bool HandleOpenGroup() {
|
||||
|
||||
return true;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.direct.RtfDestination#handleCharacter(int)
|
||||
*/
|
||||
public override bool HandleCharacter(int ch) {
|
||||
styleName += (char)ch;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void CreateNewStyle() {
|
||||
//public RtfParagraphStyle(String styleName, String fontName, int fontSize, int fontStyle, Color fontColor)
|
||||
//this.rtfParagraphStyle = new RtfParagraphStyle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the justification percentage from parsed value.
|
||||
* @param percent The justification percentage
|
||||
* @return The justification percentage
|
||||
*/
|
||||
public int SetJustificationPercentage(int percent) {
|
||||
this.justificationPercentage = percent;
|
||||
return this.justificationPercentage;
|
||||
}
|
||||
/**
|
||||
* Get the justification percentage.
|
||||
* @return The justification percentage value.
|
||||
*/
|
||||
public int GetJustificationPercentage() {
|
||||
return this.justificationPercentage;
|
||||
}
|
||||
/**
|
||||
* Set the alignment value from the parsed value.
|
||||
* @param alignment The alignment value.
|
||||
* @return The alignment value.
|
||||
*/
|
||||
public int SetAlignment(int alignment) {
|
||||
this.alignment = alignment;
|
||||
return this.alignment;
|
||||
}
|
||||
/**
|
||||
* Get the alignment value.
|
||||
* @return The alignment value.
|
||||
*/
|
||||
public int GetAlignment() {
|
||||
return this.alignment;
|
||||
}
|
||||
/**
|
||||
* Get the first line indent value.
|
||||
*
|
||||
* @return the firstLineIndent
|
||||
*/
|
||||
public int GetFirstLineIndent() {
|
||||
return firstLineIndent;
|
||||
}
|
||||
/**
|
||||
* Set the first line indent value.
|
||||
* @param firstLineIndent the firstLineIndent to set
|
||||
*/
|
||||
public void SetFirstLineIndent(int firstLineIndent) {
|
||||
this.firstLineIndent = firstLineIndent;
|
||||
}
|
||||
/**
|
||||
* Get the left indent value
|
||||
* @return the left indent
|
||||
*/
|
||||
public int GetIndent() {
|
||||
return leftIndent;
|
||||
}
|
||||
/**
|
||||
* Set the left indent value from the value parsed.
|
||||
* @param indent the left indent value.
|
||||
*/
|
||||
public void SetIndent(int indent) {
|
||||
this.leftIndent = indent;
|
||||
}
|
||||
/**
|
||||
* Get the right indent adjustment value
|
||||
* @return the adustRightIndent value
|
||||
*/
|
||||
public int GetAdustRightIndent() {
|
||||
return adustRightIndent;
|
||||
}
|
||||
/**
|
||||
* Set the right indent adjustment value
|
||||
* @param adustRightIndent the adustRightIndent to set
|
||||
*/
|
||||
public void SetAdustRightIndent(int adustRightIndent) {
|
||||
this.adustRightIndent = adustRightIndent;
|
||||
}
|
||||
/**
|
||||
* Get the left indent value
|
||||
* @return the leftIndent
|
||||
*/
|
||||
public int GetLeftIndent() {
|
||||
return leftIndent;
|
||||
}
|
||||
/**
|
||||
* Set the left indent value
|
||||
* @param leftIndent the leftIndent to set
|
||||
*/
|
||||
public void SetLeftIndent(int leftIndent) {
|
||||
this.leftIndent = leftIndent;
|
||||
}
|
||||
/**
|
||||
* Get the value indicating if document has mirrored indents.
|
||||
*
|
||||
* @return the mirrorIndent
|
||||
*/
|
||||
public int GetMirrorIndent() {
|
||||
return mirrorIndent;
|
||||
}
|
||||
/**
|
||||
* Set the mirrored indent value from the parsed value.
|
||||
*
|
||||
* @param mirrorIndent the mirrorIndent to set
|
||||
*/
|
||||
public void SetMirrorIndent(int mirrorIndent) {
|
||||
this.mirrorIndent = mirrorIndent;
|
||||
}
|
||||
/**
|
||||
* Get the right indent value.
|
||||
*
|
||||
* @return the rightIndent
|
||||
*/
|
||||
public int GetRightIndent() {
|
||||
return rightIndent;
|
||||
}
|
||||
/**
|
||||
* Set the right indent value.
|
||||
*
|
||||
* @param rightIndent the rightIndent to set
|
||||
*/
|
||||
public void SetRightIndent(int rightIndent) {
|
||||
this.rightIndent = rightIndent;
|
||||
}
|
||||
/**
|
||||
* Get the ovirride widow control value.
|
||||
*
|
||||
* @return the overrideWidowControl
|
||||
*/
|
||||
public int GetOverrideWidowControl() {
|
||||
return overrideWidowControl;
|
||||
}
|
||||
/**
|
||||
* Set the override widow control.
|
||||
*
|
||||
* @param overrideWidowControl the overrideWidowControl to set
|
||||
*/
|
||||
public void SetOverrideWidowControl(int overrideWidowControl) {
|
||||
this.overrideWidowControl = overrideWidowControl;
|
||||
}
|
||||
/**
|
||||
* Get the auto space between DBC and English indicator.
|
||||
*
|
||||
* @return the autoSpaceBetweenDBCEnglish
|
||||
*/
|
||||
public int GetAutoSpaceBetweenDBCEnglish() {
|
||||
return AutoSpaceBetweenDBCEnglish;
|
||||
}
|
||||
/**
|
||||
* Set the auto space between DBC and English indicator.
|
||||
*
|
||||
* @param autoSpaceBetweenDBCEnglish the autoSpaceBetweenDBCEnglish to set
|
||||
*/
|
||||
public void SetAutoSpaceBetweenDBCEnglish(int autoSpaceBetweenDBCEnglish) {
|
||||
AutoSpaceBetweenDBCEnglish = autoSpaceBetweenDBCEnglish;
|
||||
}
|
||||
/**
|
||||
* Get the auto space between DBC and Numbers indicator.
|
||||
* @return the autoSpaceBetweenDBCNumbers
|
||||
*/
|
||||
public int GetAutoSpaceBetweenDBCNumbers() {
|
||||
return AutoSpaceBetweenDBCNumbers;
|
||||
}
|
||||
/**
|
||||
* Set the auto space between DBC and Numbers indicator.
|
||||
* @param autoSpaceBetweenDBCNumbers the autoSpaceBetweenDBCNumbers to set
|
||||
*/
|
||||
public void SetAutoSpaceBetweenDBCNumbers(int autoSpaceBetweenDBCNumbers) {
|
||||
AutoSpaceBetweenDBCNumbers = autoSpaceBetweenDBCNumbers;
|
||||
}
|
||||
/**
|
||||
* Get no character wrapping indicator.
|
||||
*
|
||||
* @return the noCharacterWrapping
|
||||
*/
|
||||
public int GetNoCharacterWrapping() {
|
||||
return noCharacterWrapping;
|
||||
}
|
||||
/**
|
||||
* Set the no character wrapping indicator from parsed value
|
||||
*
|
||||
* @param noCharacterWrapping the noCharacterWrapping to set
|
||||
*/
|
||||
public void SetNoCharacterWrapping(int noCharacterWrapping) {
|
||||
this.noCharacterWrapping = noCharacterWrapping;
|
||||
}
|
||||
/**
|
||||
* Get the no overflow period comma indicator.
|
||||
*
|
||||
* @return the noOverflowPeriodComma
|
||||
*/
|
||||
public int GetNoOverflowPeriodComma() {
|
||||
return noOverflowPeriodComma;
|
||||
}
|
||||
/**
|
||||
* Set the no overflow period comma indicator from the parsed value.
|
||||
*
|
||||
* @param noOverflowPeriodComma the noOverflowPeriodComma to set
|
||||
*/
|
||||
public void SetNoOverflowPeriodComma(int noOverflowPeriodComma) {
|
||||
this.noOverflowPeriodComma = noOverflowPeriodComma;
|
||||
}
|
||||
/**
|
||||
* Get the no word wrapping indicator.
|
||||
*
|
||||
* @return the noWordWrapping
|
||||
*/
|
||||
public int GetNoWordWrapping() {
|
||||
return noWordWrapping;
|
||||
}
|
||||
/**
|
||||
* Set the no word wrapping indicator from the parsed value.
|
||||
*
|
||||
* @param noWordWrapping the noWordWrapping to set
|
||||
*/
|
||||
public void SetNoWordWrapping(int noWordWrapping) {
|
||||
this.noWordWrapping = noWordWrapping;
|
||||
}
|
||||
/**
|
||||
* Get this style number.
|
||||
*
|
||||
* @return the styleNr
|
||||
*/
|
||||
public int GetStyleNr() {
|
||||
return styleNr;
|
||||
}
|
||||
/**
|
||||
* Set this style number from the parsed value.
|
||||
*
|
||||
* @param styleNr the styleNr to set
|
||||
*/
|
||||
public void SetStyleNr(int styleNr) {
|
||||
this.styleNr = styleNr;
|
||||
}
|
||||
/**
|
||||
* Get this style type.
|
||||
* For example Style, Character Style, etc.
|
||||
*
|
||||
* @return the styleType
|
||||
*/
|
||||
public int GetStyleType() {
|
||||
return styleType;
|
||||
}
|
||||
/**
|
||||
* Set the style type.
|
||||
*
|
||||
* @param styleType the styleType to set
|
||||
*/
|
||||
public void SetStyleType(int styleType) {
|
||||
this.styleType = styleType;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.lowagie.text.rtf.parser.destinations.RtfDestination#setToDefaults()
|
||||
*/
|
||||
public override void SetToDefaults() {
|
||||
styleName = "";
|
||||
styleNr = 0;
|
||||
alignment = Element.ALIGN_LEFT;
|
||||
justificationPercentage = 0;
|
||||
firstLineIndent = 0;
|
||||
leftIndent = 0;
|
||||
rightIndent = 0;
|
||||
adustRightIndent = 0;
|
||||
mirrorIndent = 0;
|
||||
overrideWidowControl = -1;
|
||||
AutoSpaceBetweenDBCEnglish = 0;
|
||||
AutoSpaceBetweenDBCNumbers = 0;
|
||||
noCharacterWrapping = 0;
|
||||
noWordWrapping = 0;
|
||||
noOverflowPeriodComma = 0;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user