Exemple #1
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
Exemple #2
0
        } // RtfDocument

        // ----------------------------------------------------------------------
        public RtfDocument(
            int rtfVersion,
            IRtfFont defaultFont,
            RtfFontCollection fontTable,
            IList <IRtfColor> colorTable,
            string generator,
            IList <IRtfTextFormat> uniqueTextFormats,
            IRtfDocumentInfo documentInfo,
            IList <IRtfDocumentProperty> userProperties,
            IList <IRtfVisual> 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
Exemple #3
0
        }         // Alignment

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

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.alignment = derivedAlignment;
            return(copy);
        }         // DeriveWithForegroundColor
Exemple #4
0
        }         // IsHidden

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

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.hidden = derivedHidden;
            return(copy);
        }         // DeriveWithHidden
Exemple #5
0
        }         // IsStrikeThrough

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

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.strikeThrough = derivedStrikeThrough;
            return(copy);
        }         // DeriveWithStrikeThrough
Exemple #6
0
        }         // IsUnderline

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

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.underline = derivedUnderline;
            return(copy);
        }         // DeriveWithUnderline
Exemple #7
0
        }         // IsItalic

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

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.italic = derivedItalic;
            return(copy);
        }         // DeriveWithItalic
Exemple #8
0
        }         // IsBold

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

            RtfTextFormat copy = new RtfTextFormat(this);

            copy.bold = derivedBold;
            return(copy);
        }         // DeriveWithBold
Exemple #9
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
Exemple #10
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
Exemple #11
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
Exemple #12
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
Exemple #13
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
Exemple #14
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
Exemple #15
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