Example #1
0
        public static ParagraphSpacing Override(
            this ParagraphSpacing defaultSpacing,
            Word.SpacingBetweenLines spacingBetweenLines,
            params Word.SpacingBetweenLines[] prioritized)
        {
            StringValue before = null;
            StringValue after  = null;
            StringValue line   = null;
            EnumValue <Word.LineSpacingRuleValues> lineRule = null;

            foreach (var spacing in new[] { spacingBetweenLines }.Union(prioritized).Where(s => s != null))
            {
                before   = before ?? spacing.Before;
                after    = after ?? spacing.After;
                line     = line ?? spacing.Line;
                lineRule = lineRule ?? spacing.LineRule;

                if (before != null && after != null && line != null)
                {
                    break;
                }
            }

            var bf = before?.ToPoint() ?? defaultSpacing.Before;
            var af = after?.ToPoint() ?? defaultSpacing.After;
            var ls = line?.GetLineSpacing(lineRule) ?? defaultSpacing.Line;

            return(new ParagraphSpacing(ls, bf, af));
        }
        /// <summary>
        /// Adds the style for provided heading type if it's not already added.
        /// </summary>
        /// <param name="headingType"></param>
        public static void AddHeadingStyle(Model.HeadingType headingType)
        {
            if (IsStylePresent(StyleIds.GetStyleId(headingType))) {
                return;
            }

            int outlineLevel;

            switch (headingType)
            {
                case DocGen.ObjectModel.HeadingType.H1:
                    outlineLevel = 0;
                    break;
                case DocGen.ObjectModel.HeadingType.H2:
                    outlineLevel = 1;
                    break;
                case DocGen.ObjectModel.HeadingType.H3:
                    outlineLevel = 2;
                    break;
                case DocGen.ObjectModel.HeadingType.H4:
                    outlineLevel = 3;
                    break;
                case DocGen.ObjectModel.HeadingType.H5:
                    outlineLevel = 4;
                    break;
                case DocGen.ObjectModel.HeadingType.H6:
                    outlineLevel = 5;
                    break;
                default:
                    throw new NotImplementedException(headingType + ": Enum value not added");
            }

            Word.Styles styles =  DocumentPackager.GetInstance().GetStylePart().Styles;

            Word.Style style1 = new Word.Style() { Type = Word.StyleValues.Paragraph, StyleId = StyleIds.GetStyleId(headingType) };
            Word.BasedOn basedOn1 = new Word.BasedOn() { Val = "Normal" };

            Word.StyleParagraphProperties styleParagraphProperties1 = new Word.StyleParagraphProperties();
            Word.KeepNext keepNext1 = new Word.KeepNext();
            Word.KeepLines keepLines1 = new Word.KeepLines();
            Word.SpacingBetweenLines spacingBetweenLines1 = new Word.SpacingBetweenLines() { Before = "480", After = "0" };
            Word.OutlineLevel outlineLevel1 = new Word.OutlineLevel() { Val = outlineLevel };

            styleParagraphProperties1.Append(keepNext1);
            styleParagraphProperties1.Append(keepLines1);
            styleParagraphProperties1.Append(spacingBetweenLines1);
            styleParagraphProperties1.Append(outlineLevel1);

            style1.Append(basedOn1);
            style1.Append(styleParagraphProperties1);

            // Add the style to the styles part.
            styles.Append(style1);
        }
Example #3
0
        public static ParagraphSpacing ToParagraphSpacing(
            this Word.SpacingBetweenLines spacingXml,
            ParagraphSpacing ifNull)
        {
            if (spacingXml == null)
            {
                return(ifNull);
            }

            var before = spacingXml.Before.ToPoint();
            var after  = spacingXml.After.ToPoint();
            var line   = spacingXml.GetLineSpacing();

            return(new ParagraphSpacing(line, before, after));
        }
Example #4
0
        public static Wordprocessing.TableCell AddCell(this Wordprocessing.TableRow tableRow, string value)
        {
            Wordprocessing.TableCell tableCell = new Wordprocessing.TableCell();
            Wordprocessing.Paragraph par = new Wordprocessing.Paragraph();
            Wordprocessing.ParagraphProperties parprop = new Wordprocessing.ParagraphProperties();
            Wordprocessing.Justification justification1 = new Wordprocessing.Justification() { Val = Wordprocessing.JustificationValues.Center };
            Wordprocessing.SpacingBetweenLines spacingBetweenLines2 = new Wordprocessing.SpacingBetweenLines() { After = "0"};
            parprop.Append(spacingBetweenLines2);
            parprop.Append(justification1);
            par.Append(parprop);

            Wordprocessing.Run run = new Wordprocessing.Run() ;
            Wordprocessing.Text text = new Wordprocessing.Text(value);
            run.Append(text);
            par.Append(run);
            tableCell.Append(par);
            tableRow.Append(tableCell);

            return tableCell;
        }
Example #5
0
 private Wordprocessing.Paragraph retText(int r, int c)
 {
     string value="";
     if (r == 0 && c == 0) value = "Подпись преподавателя";
     if (r == 1 && c == 1) value = "1.Факультет составляет ведомость в 1 экз.";
     if (r == 2 && c == 1) value = "2.Экзаменатор лично получает ведомость в деканате.";
     if (r == 3 && c == 1) value = "3.По окончании экзамена экзаменатор лично сдает";
     if (r == 4 && c == 1) value = "ведомость в деканат.";
     if (r == 1 && c == 2) value = "ИТОГО";
     if (r == 1 && c == 3) value = "отлично";
     if (r == 2 && c == 3) value = "хорошо";
     if (r == 3 && c == 3) value = "удовлетворительно";
     if (r == 4 && c == 3) value = "плохо";
     if (r == 5 && c == 3) value = "не явился";
     Wordprocessing.Run run = new Wordprocessing.Run();
     Wordprocessing.Text text = new Wordprocessing.Text(value);
     run.Append(text);
     Wordprocessing.Paragraph par = new Wordprocessing.Paragraph();
     Wordprocessing.ParagraphProperties parprop = new Wordprocessing.ParagraphProperties();
     Wordprocessing.SpacingBetweenLines spacingBetweenLines = new Wordprocessing.SpacingBetweenLines() { After = "0" };
     parprop.Append(spacingBetweenLines);
     par.Append(parprop);
     par.Append(run);
     return par;
 }
Example #6
0
 private Wordprocessing.Table doptable(Wordprocessing.Table table)
 {
     //Строка подпись декана
     Wordprocessing.TableRow tableRow2 = new Wordprocessing.TableRow() { RsidTableRowAddition = "00FF67BF", RsidTableRowProperties = "008E2483" };
     Wordprocessing.TableCell tableCell = new Wordprocessing.TableCell();
     Wordprocessing.TableCellProperties tableCellProperties = new Wordprocessing.TableCellProperties();
     Wordprocessing.TableCellWidth tableCellWidth = new Wordprocessing.TableCellWidth() { Width = "0", Type = Wordprocessing.TableWidthUnitValues.Auto };
     Wordprocessing.GridSpan gridSpan = new Wordprocessing.GridSpan() { Val = 6 };
     Wordprocessing.TableCellVerticalAlignment tableCellVerticalAlignment = new Wordprocessing.TableCellVerticalAlignment() { Val = Wordprocessing.TableVerticalAlignmentValues.Center };
     tableCellProperties.Append(tableCellWidth);
     tableCellProperties.Append(gridSpan);
     tableCellProperties.Append(tableCellVerticalAlignment);
     Wordprocessing.Paragraph paragraph = new Wordprocessing.Paragraph();
     Wordprocessing.ParagraphProperties parprop = new Wordprocessing.ParagraphProperties();
     Wordprocessing.SpacingBetweenLines spacingBetweenLines2 = new Wordprocessing.SpacingBetweenLines() { After = "0" };
     parprop.Append(spacingBetweenLines2);
     paragraph.Append(parprop);
     Wordprocessing.Run run = new Wordprocessing.Run();
     Wordprocessing.Text text = new Wordprocessing.Text();
     text.Text = "Подпись декана";
     run.Append(text);
     paragraph.Append(run);
     tableCell.Append(tableCellProperties);
     tableCell.Append(paragraph);
     tableRow2.Append(tableCell);
     table.Append(tableRow2);
     return table;
 }
Example #7
0
        public Wordprocessing.Body insertinform()
        {
            Wordprocessing.Body body = new Wordprocessing.Body();
            //Параграф1
            Wordprocessing.Paragraph paragraph1 = new Wordprocessing.Paragraph();
            Wordprocessing.ParagraphProperties paragraphProperties1 = new Wordprocessing.ParagraphProperties();
            Wordprocessing.SpacingBetweenLines spacingBetweenLines1 = new Wordprocessing.SpacingBetweenLines() { After = "0" };
            Wordprocessing.Justification justification1 = new Wordprocessing.Justification() { Val = Wordprocessing.JustificationValues.Center };
            paragraphProperties1.Append(spacingBetweenLines1);
            paragraphProperties1.Append(justification1);
            Wordprocessing.Run run1 = new Wordprocessing.Run();
            Wordprocessing.RunProperties runProperties1 = new Wordprocessing.RunProperties();
            Wordprocessing.RunFonts runFonts2 = new Wordprocessing.RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
            Wordprocessing.Bold bold2 = new Wordprocessing.Bold();
            Wordprocessing.FontSize fontSize2 = new Wordprocessing.FontSize() { Val = "24" };
            runProperties1.Append(runFonts2);
            runProperties1.Append(bold2);
            runProperties1.Append(fontSize2);
            Wordprocessing.Text text1 = new Wordprocessing.Text();
            text1.Text = "ФГБОУВПО \"ПЕРМСКИЙ ГОСУДАРСТВЕННЫЙ НАЦИОНАЛЬНЫЙ ИССЛЕДОВАТЕЛЬСКИЙ УНИВЕРСИТЕТ\"";
            run1.Append(runProperties1);
            run1.Append(text1);
            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);

            //Параграф2
            Wordprocessing.Paragraph paragraph2 = new Wordprocessing.Paragraph();

            Wordprocessing.ParagraphProperties paragraphProperties2 = new Wordprocessing.ParagraphProperties();
            Wordprocessing.SpacingBetweenLines spacingBetweenLines2 = new Wordprocessing.SpacingBetweenLines() { After = "0" };
            Wordprocessing.Justification justification2 = new Wordprocessing.Justification() { Val = Wordprocessing.JustificationValues.Center };
            paragraphProperties2.Append(spacingBetweenLines2);
            paragraphProperties2.Append(justification2);
            Wordprocessing.Run run2 = new Wordprocessing.Run();

            Wordprocessing.RunProperties runProperties2 = new Wordprocessing.RunProperties();
            Wordprocessing.RunFonts runFonts4 = new Wordprocessing.RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
            Wordprocessing.FontSize fontSize4 = new Wordprocessing.FontSize() { Val = "24" };

            runProperties2.Append(runFonts4);
            runProperties2.Append(fontSize4);
            Wordprocessing.Text text2 = new Wordprocessing.Text();
            text2.Text = "Механико-математический факультет ";

            run2.Append(runProperties2);
            run2.Append(text2);

            Wordprocessing.Run run3 = new Wordprocessing.Run();

            Wordprocessing.RunProperties runProperties3 = new Wordprocessing.RunProperties();
            Wordprocessing.RunFonts runFonts5 = new Wordprocessing.RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
            Wordprocessing.FontSize fontSize5 = new Wordprocessing.FontSize() { Val = "24" };
            runProperties3.Append(runFonts5);
            runProperties3.Append(fontSize5);
            Wordprocessing.Break break1 = new Wordprocessing.Break();
            Wordprocessing.Text text3 = new Wordprocessing.Text();
            text3.Text = "очная форма обучения";

            run3.Append(runProperties3);
            run3.Append(break1);
            run3.Append(text3);

            paragraph2.Append(paragraphProperties2);
            paragraph2.Append(run2);
            paragraph2.Append(run3);

            //Параграф2
            Wordprocessing.Paragraph paragraph3 = new Wordprocessing.Paragraph() { RsidParagraphAddition = "004D49E1", RsidParagraphProperties = "004D49E1", RsidRunAdditionDefault = "004D49E1" };

            Wordprocessing.ParagraphProperties paragraphProperties3 = new Wordprocessing.ParagraphProperties();
            Wordprocessing.SpacingBetweenLines spacingBetweenLines3 = new Wordprocessing.SpacingBetweenLines() { After = "0" };
            Wordprocessing.Justification justification3 = new Wordprocessing.Justification() { Val = Wordprocessing.JustificationValues.Center };
            paragraphProperties3.Append(spacingBetweenLines3);
            paragraphProperties3.Append(justification3);
            Wordprocessing.Run run4 = new Wordprocessing.Run();

            Wordprocessing.RunProperties runProperties4 = new Wordprocessing.RunProperties();
            Wordprocessing.RunFonts runFonts7 = new Wordprocessing.RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
            Wordprocessing.Bold bold4 = new Wordprocessing.Bold();

            runProperties4.Append(runFonts7);
            runProperties4.Append(bold4);
            Wordprocessing.Text text4 = new Wordprocessing.Text();
            text4.Text = "ЭКЗАМЕНАЦИОННАЯ ВЕДОМОСТЬ";
            run4.Append(runProperties4);
            run4.Append(text4);

            Wordprocessing.Run run5 = new Wordprocessing.Run();
            Wordprocessing.Break break2 = new Wordprocessing.Break();
            run5.Append(break2);

            paragraph3.Append(paragraphProperties3);
            paragraph3.Append(run4);
            paragraph3.Append(run5);

            body.Append(paragraph1);
            body.Append(paragraph2);
            body.Append(paragraph3);
            return body;
        }
        private static void AddNewStyle(StyleDefinitionsPart styleDefinitionsPart, string styleid, string stylename)
        {
            // Get access to the root element of the styles part.
            Word.Styles styles = styleDefinitionsPart.Styles;

            Word.Style style1 = new Word.Style() { Type = Word.StyleValues.Paragraph, StyleId = "Heading1" };
            Word.StyleName styleName1 = new Word.StyleName() { Val = "heading 1" };
            Word.BasedOn basedOn1 = new Word.BasedOn() { Val = "Normal" };

            Word.StyleParagraphProperties styleParagraphProperties1 = new Word.StyleParagraphProperties();
            Word.KeepNext keepNext1 = new Word.KeepNext();
            Word.KeepLines keepLines1 = new Word.KeepLines();
            Word.SpacingBetweenLines spacingBetweenLines1 = new Word.SpacingBetweenLines() { Before = "480", After = "0" };
            Word.OutlineLevel outlineLevel1 = new Word.OutlineLevel() { Val = 0 };

            styleParagraphProperties1.Append(keepNext1);
            styleParagraphProperties1.Append(keepLines1);
            styleParagraphProperties1.Append(spacingBetweenLines1);
            styleParagraphProperties1.Append(outlineLevel1);

            style1.Append(styleName1);
            style1.Append(basedOn1);
            style1.Append(styleParagraphProperties1);

            // Add the style to the styles part.
            styles.Append(style1);
        }