Inheritance: IRtfTextFormat
コード例 #1
0
        } // DeriveWithSuperScript

        public RtfTextFormat DeriveWithSuperScript(bool super)
        {
            var copy = new RtfTextFormat(this);

            copy.FontSize    = Math.Max(1, FontSize * 2 / 3);
            copy.SuperScript = (super ? 1 : -1) * Math.Max(1, FontSize / 2);
            return(copy);
        } // DeriveWithSuperScript
コード例 #2
0
        }         // DeriveWithSuperScript

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithSuperScript(bool super)
        {
            RtfTextFormat copy = new RtfTextFormat(this);

            copy.fontSize    = Math.Max(1, (fontSize * 2) / 3);
            copy.superScript = (super ? 1 : -1) * Math.Max(1, fontSize / 2);
            return(copy);
        }         // DeriveWithSuperScript
コード例 #3
0
        }         // RtfDocument

        // ----------------------------------------------------------------------
        public RtfDocument(
            int rtfVersion,
            IRtfFont defaultFont,
            IRtfFontCollection fontTable,
            IRtfColorCollection colorTable,
            string generator,
            IRtfTextFormatCollection uniqueTextFormats,
            IRtfDocumentInfo documentInfo,
            IRtfDocumentPropertyCollection userProperties,
            IRtfVisualCollection visualContent
            )
        {
            if (rtfVersion != RtfSpec.RtfVersion1)
            {
                throw new RtfUnsupportedStructureException(Strings.UnsupportedRtfVersion(rtfVersion));
            }
            if (defaultFont == null)
            {
                throw new ArgumentNullException("defaultFont");
            }
            if (fontTable == null)
            {
                throw new ArgumentNullException("fontTable");
            }
            if (colorTable == null)
            {
                throw new ArgumentNullException("colorTable");
            }
            if (uniqueTextFormats == null)
            {
                throw new ArgumentNullException("uniqueTextFormats");
            }
            if (documentInfo == null)
            {
                throw new ArgumentNullException("documentInfo");
            }
            if (userProperties == null)
            {
                throw new ArgumentNullException("userProperties");
            }
            if (visualContent == null)
            {
                throw new ArgumentNullException("visualContent");
            }
            this.rtfVersion        = rtfVersion;
            this.defaultFont       = defaultFont;
            defaultTextFormat      = new RtfTextFormat(defaultFont, RtfSpec.DefaultFontSize);
            this.fontTable         = fontTable;
            this.colorTable        = colorTable;
            this.generator         = generator;
            this.uniqueTextFormats = uniqueTextFormats;
            this.documentInfo      = documentInfo;
            this.userProperties    = userProperties;
            this.visualContent     = visualContent;
        }         // RtfDocument
コード例 #4
0
        } // RtfDocument

        public RtfDocument(
            int rtfVersion,
            IRtfFont defaultFont,
            IRtfFontCollection fontTable,
            IRtfColorCollection colorTable,
            string generator,
            IRtfTextFormatCollection uniqueTextFormats,
            IRtfDocumentInfo documentInfo,
            IRtfDocumentPropertyCollection userProperties,
            IRtfVisualCollection visualContent
            )
        {
            if (rtfVersion != RtfSpec.RtfVersion1)
            {
                throw new RtfUnsupportedStructureException(Strings.UnsupportedRtfVersion(rtfVersion));
            }
            if (defaultFont == null)
            {
                throw new ArgumentNullException(nameof(defaultFont));
            }
            if (fontTable == null)
            {
                throw new ArgumentNullException(nameof(fontTable));
            }
            if (colorTable == null)
            {
                throw new ArgumentNullException(nameof(colorTable));
            }
            if (uniqueTextFormats == null)
            {
                throw new ArgumentNullException(nameof(uniqueTextFormats));
            }
            if (documentInfo == null)
            {
                throw new ArgumentNullException(nameof(documentInfo));
            }
            if (userProperties == null)
            {
                throw new ArgumentNullException(nameof(userProperties));
            }
            if (visualContent == null)
            {
                throw new ArgumentNullException(nameof(visualContent));
            }
            RtfVersion        = rtfVersion;
            DefaultFont       = defaultFont;
            DefaultTextFormat = new RtfTextFormat(defaultFont, RtfSpec.DefaultFontSize);
            FontTable         = fontTable;
            ColorTable        = colorTable;
            Generator         = generator;
            UniqueTextFormats = uniqueTextFormats;
            DocumentInfo      = documentInfo;
            UserProperties    = userProperties;
            VisualContent     = visualContent;
        } // RtfDocument
コード例 #5
0
        }         // SuperScript

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithSuperScript(int deviation)
        {
            if (superScript == deviation)
            {
                return(this);
            }

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.superScript = deviation;
            return(copy);
        }         // DeriveWithSuperScript
コード例 #6
0
        }         // IsHidden

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithHidden(bool derivedHidden)
        {
            if (hidden == derivedHidden)
            {
                return(this);
            }

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.hidden = derivedHidden;
            return(copy);
        }         // DeriveWithHidden
コード例 #7
0
        }         // IsStrikeThrough

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithStrikeThrough(bool derivedStrikeThrough)
        {
            if (strikeThrough == derivedStrikeThrough)
            {
                return(this);
            }

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.strikeThrough = derivedStrikeThrough;
            return(copy);
        }         // DeriveWithStrikeThrough
コード例 #8
0
        }         // Alignment

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithAlignment(RtfTextAlignment derivedAlignment)
        {
            if (alignment == derivedAlignment)
            {
                return(this);
            }

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.alignment = derivedAlignment;
            return(copy);
        }         // DeriveWithForegroundColor
コード例 #9
0
        }         // IsItalic

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithItalic(bool derivedItalic)
        {
            if (italic == derivedItalic)
            {
                return(this);
            }

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.italic = derivedItalic;
            return(copy);
        }         // DeriveWithItalic
コード例 #10
0
        }         // IsUnderline

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithUnderline(bool derivedUnderline)
        {
            if (underline == derivedUnderline)
            {
                return(this);
            }

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.underline = derivedUnderline;
            return(copy);
        }         // DeriveWithUnderline
コード例 #11
0
        }         // IsNormal

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveNormal()
        {
            if (IsNormal)
            {
                return(this);
            }

            RtfTextFormat copy = new RtfTextFormat(font, RtfSpec.DefaultFontSize);

            copy.alignment = alignment; // this is a paragraph property, keep it
            return(copy);
        }                               // DeriveNormal
コード例 #12
0
        }         // IsBold

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithBold(bool derivedBold)
        {
            if (bold == derivedBold)
            {
                return(this);
            }

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.bold = derivedBold;
            return(copy);
        }         // DeriveWithBold
コード例 #13
0
        }         // FontSize

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithFontSize(int derivedFontSize)
        {
            if (derivedFontSize < 0 || derivedFontSize > 0xFFFF)
            {
                throw new ArgumentException(Strings.FontSizeOutOfRange(derivedFontSize));
            }
            if (fontSize == derivedFontSize)
            {
                return(this);
            }

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.fontSize = derivedFontSize;
            return(copy);
        }         // DeriveWithFontSize
コード例 #14
0
        } // DeriveWithHidden

        public RtfTextFormat DeriveWithBackgroundColor(IRtfColor derivedBackgroundColor)
        {
            if (derivedBackgroundColor == null)
            {
                throw new ArgumentNullException(nameof(derivedBackgroundColor));
            }
            if (BackgroundColor.Equals(derivedBackgroundColor))
            {
                return(this);
            }

            var copy = new RtfTextFormat(this);

            copy.BackgroundColor = derivedBackgroundColor;
            return(copy);
        } // DeriveWithBackgroundColor
コード例 #15
0
        }         // Font

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithFont(IRtfFont rtfFont)
        {
            if (rtfFont == null)
            {
                throw new ArgumentNullException("rtfFont");
            }
            if (font.Equals(rtfFont))
            {
                return(this);
            }

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.font = rtfFont;
            return(copy);
        }         // DeriveWithFont
コード例 #16
0
        }         // ForegroundColor

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithForegroundColor(IRtfColor derivedForegroundColor)
        {
            if (derivedForegroundColor == null)
            {
                throw new ArgumentNullException("derivedForegroundColor");
            }
            if (foregroundColor.Equals(derivedForegroundColor))
            {
                return(this);
            }

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.foregroundColor = derivedForegroundColor;
            return(copy);
        }         // DeriveWithForegroundColor
コード例 #17
0
        }         // SuperScript

        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithSuperScript(int deviation)
        {
            if (superScript == deviation)
            {
                return(this);
            }

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.superScript = deviation;
            // reset font size
            if (deviation == 0)
            {
                copy.fontSize = (fontSize / 2) * 3;
            }
            return(copy);
        }         // DeriveWithSuperScript
コード例 #18
0
        } // RtfTextFormat

        public RtfTextFormat(RtfTextFormat copy)
        {
            if (copy == null)
            {
                throw new ArgumentNullException(nameof(copy));
            }
            Font            = copy.Font; // enough because immutable
            FontSize        = copy.FontSize;
            SuperScript     = copy.SuperScript;
            IsBold          = copy.IsBold;
            IsItalic        = copy.IsItalic;
            IsUnderline     = copy.IsUnderline;
            IsStrikeThrough = copy.IsStrikeThrough;
            IsHidden        = copy.IsHidden;
            BackgroundColor = copy.BackgroundColor; // enough because immutable
            ForegroundColor = copy.ForegroundColor; // enough because immutable
            Alignment       = copy.Alignment;
        } // RtfTextFormat
コード例 #19
0
        }         // GetHashCode

        // ----------------------------------------------------------------------
        private bool IsEqual(object obj)
        {
            RtfTextFormat compare = obj as RtfTextFormat;             // guaranteed to be non-null

            return
                (compare != null &&
                 font.Equals(compare.font) &&
                 fontSize == compare.fontSize &&
                 superScript == compare.superScript &&
                 bold == compare.bold &&
                 italic == compare.italic &&
                 underline == compare.underline &&
                 strikeThrough == compare.strikeThrough &&
                 hidden == compare.hidden &&
                 backgroundColor.Equals(compare.backgroundColor) &&
                 foregroundColor.Equals(compare.foregroundColor) &&
                 alignment == compare.alignment);
        }         // IsEqual
コード例 #20
0
 // ----------------------------------------------------------------------
 public RtfTextFormat( RtfTextFormat copy )
 {
     if ( copy == null )
     {
         throw new ArgumentNullException( "copy" );
     }
     font = copy.font; // enough because immutable
     fontSize = copy.fontSize;
     superScript = copy.superScript;
     bold = copy.bold;
     italic = copy.italic;
     underline = copy.underline;
     strikeThrough = copy.strikeThrough;
     hidden = copy.hidden;
     backgroundColor = copy.backgroundColor; // enough because immutable
     foregroundColor = copy.foregroundColor; // enough because immutable
     alignment = copy.alignment;
 }
コード例 #21
0
        }                                           // RtfTextFormat

        // ----------------------------------------------------------------------
        public RtfTextFormat(RtfTextFormat copy)
        {
            if (copy == null)
            {
                throw new ArgumentNullException("copy");
            }
            font            = copy.font;  // enough because immutable
            fontSize        = copy.fontSize;
            superScript     = copy.superScript;
            bold            = copy.bold;
            italic          = copy.italic;
            underline       = copy.underline;
            strikeThrough   = copy.strikeThrough;
            hidden          = copy.hidden;
            backgroundColor = copy.backgroundColor; // enough because immutable
            foregroundColor = copy.foregroundColor; // enough because immutable
            alignment       = copy.alignment;
        }                                           // RtfTextFormat
コード例 #22
0
ファイル: RtfTextFormat.cs プロジェクト: haimon74/KanNaim
		} // SuperScript

		// ----------------------------------------------------------------------
		public RtfTextFormat DeriveWithSuperScript( int deviation )
		{
			if ( this.superScript == deviation )
			{
				return this;
			}

			RtfTextFormat copy = new RtfTextFormat( this );
			copy.superScript = deviation;
			return copy;
		} // DeriveWithSuperScript
コード例 #23
0
        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithUnderline( bool derivedUnderline )
        {
            if ( underline == derivedUnderline )
            {
                return this;
            }

            RtfTextFormat copy = new RtfTextFormat( this );
            copy.underline = derivedUnderline;
            return copy;
        }
コード例 #24
0
 // ----------------------------------------------------------------------
 public RtfTextFormat DeriveWithSuperScript( bool super )
 {
     RtfTextFormat copy = new RtfTextFormat( this );
     copy.fontSize = Math.Max( 1, ( fontSize * 2 ) / 3 );
     copy.superScript = ( super ? 1 : -1 ) * Math.Max( 1, fontSize / 2 );
     return copy;
 }
コード例 #25
0
        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithSuperScript( int deviation )
        {
            if ( superScript == deviation )
            {
                return this;
            }

            RtfTextFormat copy = new RtfTextFormat( this );
            copy.superScript = deviation;
            // reset font size
            if ( deviation == 0 )
            {
                copy.fontSize = ( fontSize / 2 ) * 3;
            }
            return copy;
        }
コード例 #26
0
        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithStrikeThrough( bool derivedStrikeThrough )
        {
            if ( strikeThrough == derivedStrikeThrough )
            {
                return this;
            }

            RtfTextFormat copy = new RtfTextFormat( this );
            copy.strikeThrough = derivedStrikeThrough;
            return copy;
        }
コード例 #27
0
        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithItalic( bool derivedItalic )
        {
            if ( italic == derivedItalic )
            {
                return this;
            }

            RtfTextFormat copy = new RtfTextFormat( this );
            copy.italic = derivedItalic;
            return copy;
        }
コード例 #28
0
        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithHidden( bool derivedHidden )
        {
            if ( hidden == derivedHidden )
            {
                return this;
            }

            RtfTextFormat copy = new RtfTextFormat( this );
            copy.hidden = derivedHidden;
            return copy;
        }
コード例 #29
0
        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithForegroundColor( IRtfColor derivedForegroundColor )
        {
            if ( derivedForegroundColor == null )
            {
                throw new ArgumentNullException( "derivedForegroundColor" );
            }
            if ( foregroundColor.Equals( derivedForegroundColor ) )
            {
                return this;
            }

            RtfTextFormat copy = new RtfTextFormat( this );
            copy.foregroundColor = derivedForegroundColor;
            return copy;
        }
コード例 #30
0
        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithFontSize( int derivedFontSize )
        {
            if ( derivedFontSize < 0 || derivedFontSize > 0xFFFF )
            {
                throw new ArgumentException( Strings.FontSizeOutOfRange( derivedFontSize ) );
            }
            if ( fontSize == derivedFontSize )
            {
                return this;
            }

            RtfTextFormat copy = new RtfTextFormat( this );
            copy.fontSize = derivedFontSize;
            return copy;
        }
コード例 #31
0
        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithFont( IRtfFont rtfFont )
        {
            if ( rtfFont == null )
            {
                throw new ArgumentNullException( "rtfFont" );
            }
            if ( font.Equals( rtfFont ) )
            {
                return this;
            }

            RtfTextFormat copy = new RtfTextFormat( this );
            copy.font = rtfFont;
            return copy;
        }
コード例 #32
0
        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithBold( bool derivedBold )
        {
            if ( bold == derivedBold )
            {
                return this;
            }

            RtfTextFormat copy = new RtfTextFormat( this );
            copy.bold = derivedBold;
            return copy;
        }
コード例 #33
0
        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveWithAlignment( RtfTextAlignment derivedAlignment )
        {
            if ( alignment == derivedAlignment )
            {
                return this;
            }

            RtfTextFormat copy = new RtfTextFormat( this );
            copy.alignment = derivedAlignment;
            return copy;
        }
コード例 #34
0
        // ----------------------------------------------------------------------
        public RtfTextFormat DeriveNormal()
        {
            if ( IsNormal )
            {
                return this;
            }

            RtfTextFormat copy = new RtfTextFormat( font, RtfSpec.DefaultFontSize );
            copy.alignment = alignment; // this is a paragraph property, keep it
            return copy;
        }
 // ----------------------------------------------------------------------
 public void Reset()
 {
     state = RtfInterpreterState.Init;
     rtfVersion = RtfSpec.RtfVersion1;
     defaultFontId = "f0";
     fontTable.Clear();
     colorTable.Clear();
     generator = null;
     uniqueTextFormats.Clear();
     textFormatStack.Clear();
     currentTextFormat = null;
     documentInfo.Reset();
     userProperties.Clear();
 }
 // ----------------------------------------------------------------------
 public void PopCurrentTextFormat()
 {
     if ( textFormatStack.Count == 0 )
     {
         throw new RtfStructureException( Strings.InvalidTextContextState );
     }
     currentTextFormat = (RtfTextFormat)textFormatStack.Pop();
 }