Ejemplo n.º 1
0
 /**
 * Register a RtfParagraphStyle with this RtfStylesheetList.
 *
 * @param rtfParagraphStyle The RtfParagraphStyle to add.
 */
 public void RegisterParagraphStyle(RtfParagraphStyle rtfParagraphStyle)
 {
     RtfParagraphStyle tempStyle = new RtfParagraphStyle(this.document, rtfParagraphStyle);
     tempStyle.SetStyleNumber(this.styleMap.Count);
     tempStyle.HandleInheritance();
     this.styleMap[tempStyle.GetStyleName()] = tempStyle;
 }
        /// <summary>
        /// Register a RtfParagraphStyle with this RtfStylesheetList.
        /// </summary>
        /// <param name="rtfParagraphStyle">The RtfParagraphStyle to add.</param>
        public void RegisterParagraphStyle(RtfParagraphStyle rtfParagraphStyle)
        {
            RtfParagraphStyle tempStyle = new RtfParagraphStyle(Document, rtfParagraphStyle);

            tempStyle.HandleInheritance();
            tempStyle.SetStyleNumber(_styleMap.Count);
            _styleMap[tempStyle.GetStyleName()] = tempStyle;
        }
 /// <summary>
 /// Handles the inheritance of paragraph style settings. All settings that
 /// have not been modified will be inherited from the base RtfParagraphStyle.
 /// If this RtfParagraphStyle is not based on another one, then nothing happens.
 /// </summary>
 public void HandleInheritance()
 {
     if (_basedOnName != null && Document.GetDocumentHeader().GetRtfParagraphStyle(_basedOnName) != null)
     {
         _baseStyle = Document.GetDocumentHeader().GetRtfParagraphStyle(_basedOnName);
         _baseStyle.HandleInheritance();
         if (!((_modified & ModifiedAlignment) == ModifiedAlignment))
         {
             _alignment = _baseStyle.GetAlignment();
         }
         if (!((_modified & ModifiedIndentLeft) == ModifiedIndentLeft))
         {
             _indentLeft = _baseStyle.GetIndentLeft();
         }
         if (!((_modified & ModifiedIndentRight) == ModifiedIndentRight))
         {
             _indentRight = _baseStyle.GetIndentRight();
         }
         if (!((_modified & ModifiedSpacingBefore) == ModifiedSpacingBefore))
         {
             _spacingBefore = _baseStyle.GetSpacingBefore();
         }
         if (!((_modified & ModifiedSpacingAfter) == ModifiedSpacingAfter))
         {
             _spacingAfter = _baseStyle.GetSpacingAfter();
         }
         if (!((_modified & ModifiedFontName) == ModifiedFontName))
         {
             SetFontName(_baseStyle.GetFontName());
         }
         if (!((_modified & ModifiedFontSize) == ModifiedFontSize))
         {
             Size = _baseStyle.GetFontSize();
         }
         if (!((_modified & ModifiedFontStyle) == ModifiedFontStyle))
         {
             SetStyle(_baseStyle.GetFontStyle());
         }
         if (!((_modified & ModifiedFontColor) == ModifiedFontColor))
         {
             SetColor(_baseStyle.Color);
         }
         if (!((_modified & ModifiedLineLeading) == ModifiedLineLeading))
         {
             SetLineLeading(_baseStyle.GetLineLeading());
         }
         if (!((_modified & ModifiedKeepTogether) == ModifiedKeepTogether))
         {
             SetKeepTogether(_baseStyle.GetKeepTogether());
         }
         if (!((_modified & ModifiedKeepTogetherWithNext) == ModifiedKeepTogetherWithNext))
         {
             SetKeepTogetherWithNext(_baseStyle.GetKeepTogetherWithNext());
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Handles the inheritance of paragraph style settings. All settings that
  * have not been modified will be inherited from the base RtfParagraphStyle.
  * If this RtfParagraphStyle is not based on another one, then nothing happens.
  */
 public void HandleInheritance()
 {
     if (this.basedOnName != null && this.document.GetDocumentHeader().GetRtfParagraphStyle(this.basedOnName) != null)
     {
         this.baseStyle = this.document.GetDocumentHeader().GetRtfParagraphStyle(this.basedOnName);
         this.baseStyle.HandleInheritance();
         if (!((this.modified & MODIFIED_ALIGNMENT) == MODIFIED_ALIGNMENT))
         {
             this.alignment = this.baseStyle.GetAlignment();
         }
         if (!((this.modified & MODIFIED_INDENT_LEFT) == MODIFIED_INDENT_LEFT))
         {
             this.indentLeft = this.baseStyle.GetIndentLeft();
         }
         if (!((this.modified & MODIFIED_INDENT_RIGHT) == MODIFIED_INDENT_RIGHT))
         {
             this.indentRight = this.baseStyle.GetIndentRight();
         }
         if (!((this.modified & MODIFIED_SPACING_BEFORE) == MODIFIED_SPACING_BEFORE))
         {
             this.spacingBefore = this.baseStyle.GetSpacingBefore();
         }
         if (!((this.modified & MODIFIED_SPACING_AFTER) == MODIFIED_SPACING_AFTER))
         {
             this.spacingAfter = this.baseStyle.GetSpacingAfter();
         }
         if (!((this.modified & MODIFIED_FONT_NAME) == MODIFIED_FONT_NAME))
         {
             SetFontName(this.baseStyle.GetFontName());
         }
         if (!((this.modified & MODIFIED_FONT_SIZE) == MODIFIED_FONT_SIZE))
         {
             Size = this.baseStyle.GetFontSize();
         }
         if (!((this.modified & MODIFIED_FONT_STYLE) == MODIFIED_FONT_STYLE))
         {
             SetStyle(this.baseStyle.GetFontStyle());
         }
         if (!((this.modified & MODIFIED_FONT_COLOR) == MODIFIED_FONT_COLOR))
         {
             SetColor(this.baseStyle.Color);
         }
         if (!((this.modified & MODIFIED_LINE_LEADING) == MODIFIED_LINE_LEADING))
         {
             SetLineLeading(this.baseStyle.GetLineLeading());
         }
         if (!((this.modified & MODIFIED_KEEP_TOGETHER) == MODIFIED_KEEP_TOGETHER))
         {
             SetKeepTogether(this.baseStyle.GetKeepTogether());
         }
         if (!((this.modified & MODIFIED_KEEP_TOGETHER_WITH_NEXT) == MODIFIED_KEEP_TOGETHER_WITH_NEXT))
         {
             SetKeepTogetherWithNext(this.baseStyle.GetKeepTogetherWithNext());
         }
     }
 }
Ejemplo n.º 5
0
        /**
         * Tests whether two RtfParagraphStyles are equal. Equality
         * is determined via the name.
         */
        public override bool Equals(Object o)
        {
            if (!(o is RtfParagraphStyle))
            {
                return(false);
            }
            RtfParagraphStyle paragraphStyle = (RtfParagraphStyle)o;
            bool result = this.GetStyleName().Equals(paragraphStyle.GetStyleName());

            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Constructs a RtfParagraph belonging to a RtfDocument based on a Paragraph.
        /// </summary>
        /// <param name="doc">The RtfDocument this RtfParagraph belongs to</param>
        /// <param name="paragraph">The Paragraph that this RtfParagraph is based on</param>
        public RtfParagraph(RtfDocument doc, Paragraph paragraph) : base(doc)
        {
            ST.RtfFont baseFont = null;
            if (paragraph.Font is ST.RtfParagraphStyle)
            {
                ParagraphStyle = Document.GetDocumentHeader().GetRtfParagraphStyle(((ST.RtfParagraphStyle)paragraph.Font).GetStyleName());
                baseFont       = ParagraphStyle;
            }
            else
            {
                baseFont       = new ST.RtfFont(Document, paragraph.Font);
                ParagraphStyle = new ST.RtfParagraphStyle(Document, Document.GetDocumentHeader().GetRtfParagraphStyle("Normal"));
                ParagraphStyle.SetAlignment(paragraph.Alignment);
                ParagraphStyle.SetFirstLineIndent((int)(paragraph.FirstLineIndent * TWIPS_FACTOR));
                ParagraphStyle.SetIndentLeft((int)(paragraph.IndentationLeft * TWIPS_FACTOR));
                ParagraphStyle.SetIndentRight((int)(paragraph.IndentationRight * TWIPS_FACTOR));
                ParagraphStyle.SetSpacingBefore((int)(paragraph.SpacingBefore * TWIPS_FACTOR));
                ParagraphStyle.SetSpacingAfter((int)(paragraph.SpacingAfter * TWIPS_FACTOR));
                if (paragraph.HasLeading())
                {
                    ParagraphStyle.SetLineLeading((int)(paragraph.Leading * TWIPS_FACTOR));
                }
                ParagraphStyle.SetKeepTogether(paragraph.KeepTogether);
            }

            for (var i = 0; i < paragraph.Count; i++)
            {
                var chunk = (IElement)paragraph[i];
                if (chunk is Chunk)
                {
                    ((Chunk)chunk).Font = baseFont.Difference(((Chunk)chunk).Font);
                }
                else if (chunk is RtfImage)
                {
                    ((RtfImage)Chunks[i]).SetAlignment(ParagraphStyle.GetAlignment());
                }
                try
                {
                    var rtfElements = doc.GetMapper().MapElement(chunk);
                    for (var j = 0; j < rtfElements.Length; j++)
                    {
                        Chunks.Add(rtfElements[j]);
                    }
                }
                catch (DocumentException)
                {
                }
            }
        }
Ejemplo n.º 7
0
        /**
         * Constructs a RtfParagraph belonging to a RtfDocument based on a Paragraph.
         *
         * @param doc The RtfDocument this RtfParagraph belongs to
         * @param paragraph The Paragraph that this RtfParagraph is based on
         */
        public RtfParagraph(RtfDocument doc, Paragraph paragraph) : base(doc)
        {
            ST.RtfFont baseFont = null;
            if (paragraph.Font is ST.RtfParagraphStyle)
            {
                this.paragraphStyle = this.document.GetDocumentHeader().GetRtfParagraphStyle(((ST.RtfParagraphStyle)paragraph.Font).GetStyleName());
                baseFont            = this.paragraphStyle;
            }
            else
            {
                baseFont            = new ST.RtfFont(this.document, paragraph.Font);
                this.paragraphStyle = new ST.RtfParagraphStyle(this.document, this.document.GetDocumentHeader().GetRtfParagraphStyle("Normal"));
                this.paragraphStyle.SetAlignment(paragraph.Alignment);
                this.paragraphStyle.SetIndentLeft((int)(paragraph.IndentationLeft * RtfElement.TWIPS_FACTOR));
                this.paragraphStyle.SetIndentRight((int)(paragraph.IndentationRight * RtfElement.TWIPS_FACTOR));
                this.paragraphStyle.SetSpacingBefore((int)(paragraph.SpacingBefore * RtfElement.TWIPS_FACTOR));
                this.paragraphStyle.SetSpacingAfter((int)(paragraph.SpacingAfter * RtfElement.TWIPS_FACTOR));
                if (paragraph.LeadingDefined)
                {
                    this.paragraphStyle.SetLineLeading((int)(paragraph.Leading * RtfElement.TWIPS_FACTOR));
                }
                this.paragraphStyle.SetKeepTogether(paragraph.KeepTogether);
            }

            for (int i = 0; i < paragraph.Count; i++)
            {
                IElement chunk = (IElement)paragraph[i];
                if (chunk is Chunk)
                {
                    ((Chunk)chunk).Font = baseFont.Difference(((Chunk)chunk).Font);
                }
                else if (chunk is RtfImage)
                {
                    ((RtfImage)chunks[i]).SetAlignment(this.paragraphStyle.GetAlignment());
                }
                try {
                    chunks.Add(doc.GetMapper().MapElement(chunk));
                } catch (DocumentException) {
                }
            }
        }
Ejemplo n.º 8
0
        /**
         * Constructs a RtfParagraphStyle from another RtfParagraphStyle.
         *
         * INTERNAL USE ONLY
         *
         * @param doc The RtfDocument this RtfParagraphStyle belongs to.
         * @param style The RtfParagraphStyle to copy settings from.
         */
        public RtfParagraphStyle(RtfDocument doc, RtfParagraphStyle style) : base(doc, style)
        {
            this.document             = doc;
            this.styleName            = style.GetStyleName();
            this.alignment            = style.GetAlignment();
            this.indentLeft           = (int)(style.GetIndentLeft() * RtfElement.TWIPS_FACTOR);
            this.indentRight          = (int)(style.GetIndentRight() * RtfElement.TWIPS_FACTOR);
            this.spacingBefore        = (int)(style.GetSpacingBefore() * RtfElement.TWIPS_FACTOR);
            this.spacingAfter         = (int)(style.GetSpacingAfter() * RtfElement.TWIPS_FACTOR);
            this.lineLeading          = (int)(style.GetLineLeading() * RtfElement.TWIPS_FACTOR);
            this.keepTogether         = style.GetKeepTogether();
            this.keepTogetherWithNext = style.GetKeepTogetherWithNext();
            this.basedOnName          = style.basedOnName;
            this.modified             = style.modified;
            this.styleNumber          = style.GetStyleNumber();

            if (this.document != null)
            {
                SetRtfDocument(this.document);
            }
        }
        /// <summary>
        /// Constructs a RtfParagraphStyle from another RtfParagraphStyle.
        /// INTERNAL USE ONLY
        /// </summary>
        /// <param name="doc">The RtfDocument this RtfParagraphStyle belongs to.</param>
        /// <param name="style">The RtfParagraphStyle to copy settings from.</param>
        public RtfParagraphStyle(RtfDocument doc, RtfParagraphStyle style) : base(doc, style)
        {
            Document              = doc;
            _styleName            = style.GetStyleName();
            _alignment            = style.GetAlignment();
            _firstLineIndent      = (int)(style.GetFirstLineIndent() * RtfElement.TWIPS_FACTOR);
            _indentLeft           = (int)(style.GetIndentLeft() * RtfElement.TWIPS_FACTOR);
            _indentRight          = (int)(style.GetIndentRight() * RtfElement.TWIPS_FACTOR);
            _spacingBefore        = (int)(style.GetSpacingBefore() * RtfElement.TWIPS_FACTOR);
            _spacingAfter         = (int)(style.GetSpacingAfter() * RtfElement.TWIPS_FACTOR);
            _lineLeading          = (int)(style.GetLineLeading() * RtfElement.TWIPS_FACTOR);
            _keepTogether         = style.GetKeepTogether();
            _keepTogetherWithNext = style.GetKeepTogetherWithNext();
            _basedOnName          = style._basedOnName;
            _modified             = style._modified;
            _styleNumber          = style.getStyleNumber();

            if (Document != null)
            {
                SetRtfDocument(Document);
            }
        }
Ejemplo n.º 10
0
 /**
 * Handles the inheritance of paragraph style settings. All settings that
 * have not been modified will be inherited from the base RtfParagraphStyle.
 * If this RtfParagraphStyle is not based on another one, then nothing happens.
 */
 public void HandleInheritance()
 {
     if (this.basedOnName != null && this.document.GetDocumentHeader().GetRtfParagraphStyle(this.basedOnName) != null) {
         this.baseStyle = this.document.GetDocumentHeader().GetRtfParagraphStyle(this.basedOnName);
         this.baseStyle.HandleInheritance();
         if (!((this.modified & MODIFIED_ALIGNMENT) == MODIFIED_ALIGNMENT)) {
             this.alignment = this.baseStyle.GetAlignment();
         }
         if (!((this.modified & MODIFIED_INDENT_LEFT) == MODIFIED_INDENT_LEFT)) {
             this.indentLeft = this.baseStyle.GetIndentLeft();
         }
         if (!((this.modified & MODIFIED_INDENT_RIGHT) == MODIFIED_INDENT_RIGHT)) {
             this.indentRight = this.baseStyle.GetIndentRight();
         }
         if (!((this.modified & MODIFIED_SPACING_BEFORE) == MODIFIED_SPACING_BEFORE)) {
             this.spacingBefore = this.baseStyle.GetSpacingBefore();
         }
         if (!((this.modified & MODIFIED_SPACING_AFTER) == MODIFIED_SPACING_AFTER)) {
             this.spacingAfter = this.baseStyle.GetSpacingAfter();
         }
         if (!((this.modified & MODIFIED_FONT_NAME) == MODIFIED_FONT_NAME)) {
             SetFontName(this.baseStyle.GetFontName());
         }
         if (!((this.modified & MODIFIED_FONT_SIZE) == MODIFIED_FONT_SIZE)) {
             Size = this.baseStyle.GetFontSize();
         }
         if (!((this.modified & MODIFIED_FONT_STYLE) == MODIFIED_FONT_STYLE)) {
             SetStyle(this.baseStyle.GetFontStyle());
         }
         if (!((this.modified & MODIFIED_FONT_COLOR) == MODIFIED_FONT_COLOR)) {
             SetColor(this.baseStyle.Color);
         }
         if (!((this.modified & MODIFIED_LINE_LEADING) == MODIFIED_LINE_LEADING)) {
             SetLineLeading(this.baseStyle.GetLineLeading());
         }
         if (!((this.modified & MODIFIED_KEEP_TOGETHER) == MODIFIED_KEEP_TOGETHER)) {
             SetKeepTogether(this.baseStyle.GetKeepTogether());
         }
         if (!((this.modified & MODIFIED_KEEP_TOGETHER_WITH_NEXT) == MODIFIED_KEEP_TOGETHER_WITH_NEXT)) {
             SetKeepTogetherWithNext(this.baseStyle.GetKeepTogetherWithNext());
         }
     }
 }
Ejemplo n.º 11
0
        /**
        * Constructs a RtfParagraphStyle from another RtfParagraphStyle.
        *
        * INTERNAL USE ONLY
        *
        * @param doc The RtfDocument this RtfParagraphStyle belongs to.
        * @param style The RtfParagraphStyle to copy settings from.
        */
        public RtfParagraphStyle(RtfDocument doc, RtfParagraphStyle style)
            : base(doc, style)
        {
            this.document = doc;
            this.styleName = style.GetStyleName();
            this.alignment = style.GetAlignment();
            this.indentLeft = (int) (style.GetIndentLeft() * RtfElement.TWIPS_FACTOR);
            this.indentRight = (int) (style.GetIndentRight() * RtfElement.TWIPS_FACTOR);
            this.spacingBefore = (int) (style.GetSpacingBefore() * RtfElement.TWIPS_FACTOR);
            this.spacingAfter = (int) (style.GetSpacingAfter() * RtfElement.TWIPS_FACTOR);
            this.lineLeading = (int) (style.GetLineLeading() * RtfElement.TWIPS_FACTOR);
            this.keepTogether = style.GetKeepTogether();
            this.keepTogetherWithNext = style.GetKeepTogetherWithNext();
            this.basedOnName = style.basedOnName;
            this.modified = style.modified;
            this.styleNumber = style.GetStyleNumber();

            if (this.document != null) {
                SetRtfDocument(this.document);
            }
        }
Ejemplo n.º 12
0
 /**
 * Registers the RtfParagraphStyle for further use in the document. This does not need to be
 * done for the default styles in the RtfParagraphStyle object. Those are added automatically.
 * 
 * @param rtfParagraphStyle The RtfParagraphStyle to register.
 */
 public void RegisterParagraphStyle(RtfParagraphStyle rtfParagraphStyle) {
     this.document.GetDocumentHeader().RegisterParagraphStyle(rtfParagraphStyle);
 }
Ejemplo n.º 13
0
 /**
 * Registers the RtfParagraphStyle for further use in the document.
 * 
 * @param rtfParagraphStyle The RtfParagraphStyle to register.
 */
 public void RegisterParagraphStyle(RtfParagraphStyle rtfParagraphStyle) {
     this.stylesheetList.RegisterParagraphStyle(rtfParagraphStyle);
 }
Ejemplo n.º 14
0
 /**
 * Constructs a RtfParagraph belonging to a RtfDocument based on a Paragraph.
 * 
 * @param doc The RtfDocument this RtfParagraph belongs to
 * @param paragraph The Paragraph that this RtfParagraph is based on
 */
 public RtfParagraph(RtfDocument doc, Paragraph paragraph) : base(doc) {
     ST.RtfFont baseFont = null;
     if (paragraph.Font is ST.RtfParagraphStyle) {
         this.paragraphStyle = this.document.GetDocumentHeader().GetRtfParagraphStyle(((ST.RtfParagraphStyle) paragraph.Font).GetStyleName());
         baseFont = this.paragraphStyle;
     } else {
         baseFont = new ST.RtfFont(this.document, paragraph.Font);
         this.paragraphStyle = new ST.RtfParagraphStyle(this.document, this.document.GetDocumentHeader().GetRtfParagraphStyle("Normal"));
         this.paragraphStyle.SetAlignment(paragraph.Alignment);
         this.paragraphStyle.SetFirstLineIndent((int) (paragraph.FirstLineIndent * RtfElement.TWIPS_FACTOR));
         this.paragraphStyle.SetIndentLeft((int) (paragraph.IndentationLeft * RtfElement.TWIPS_FACTOR));
         this.paragraphStyle.SetIndentRight((int) (paragraph.IndentationRight * RtfElement.TWIPS_FACTOR));
         this.paragraphStyle.SetSpacingBefore((int) (paragraph.SpacingBefore * RtfElement.TWIPS_FACTOR));
         this.paragraphStyle.SetSpacingAfter((int) (paragraph.SpacingAfter * RtfElement.TWIPS_FACTOR));
         if (paragraph.HasLeading()) {
             this.paragraphStyle.SetLineLeading((int) (paragraph.Leading * RtfElement.TWIPS_FACTOR));
         }
         this.paragraphStyle.SetKeepTogether(paragraph.KeepTogether);
     }
     
     for (int i = 0; i < paragraph.Count; i++) {
         IElement chunk = (IElement) paragraph[i];
         if (chunk is Chunk) {
             ((Chunk) chunk).Font = baseFont.Difference(((Chunk) chunk).Font);
         } else if (chunk is RtfImage) {
             ((RtfImage) chunks[i]).SetAlignment(this.paragraphStyle.GetAlignment());
         }
         try {
             IRtfBasicElement[] rtfElements = doc.GetMapper().MapElement(chunk);
             for(int j = 0; j < rtfElements.Length; j++) {
                 chunks.Add(rtfElements[j]);
             }
         } catch (DocumentException) {
         }
     }
 }