/// <summary>
        ///   Renders the paragraph content to RTF.
        /// </summary>
        private void RenderContent()
        {
            DocumentElements elements = DocumentRelations.GetParent(_paragraph) as DocumentElements;

            //First paragraph of a footnote writes the reference symbol:
            if (DocumentRelations.GetParent(elements) is Footnote && _paragraph == elements.First)
            {
                FootnoteRenderer ftntRenderer = new FootnoteRenderer(DocumentRelations.GetParent(elements) as Footnote,
                                                                     _docRenderer);
                ftntRenderer.RenderReference();
            }
            foreach (DocumentObject docObj in _paragraph.Elements)
            {
                if (docObj == _paragraph.Elements.LastObject)
                {
                    if (docObj is Character)
                    {
                        if (((Character)docObj).SymbolName == SymbolName.LineBreak)
                        {
                            continue; //Ignore last linebreak.
                        }
                    }
                }
                RendererBase rndrr = RendererFactory.CreateRenderer(docObj, _docRenderer);
                if (rndrr != null)
                {
                    rndrr.Render();
                }
            }
        }
        /// <inheritdoc />
        public async Task <MemoryStream> Save()
        {
            MemoryStream stream = DocxFilePath.Create();

            stream = await Document.WriteInto(stream, "word/document.xml");

            stream = await Footnotes.WriteInto(stream, "word/footnotes.xml");

            stream = await ContentTypes.WriteInto(stream, ContentTypesInfo.Path);

            stream = await DocumentRelations.WriteInto(stream, DocumentRelsInfo.Path);

            stream = await FootnoteRelations.WriteInto(stream, "word/_rels/footnotes.xml.rels");

            stream = await Styles.WriteInto(stream, "word/styles.xml");

            stream = await Numbering.WriteInto(stream, "word/numbering.xml");

            stream = await Theme1.WriteInto(stream, "word/theme/theme1.xml");

            foreach (ChartInformation item in Charts)
            {
                stream = await item.Chart.WriteInto(stream, $"word/{item.Name}");
            }

            return(stream);
        }
        /// <summary>
        ///   Renders the paragraph to RTF.
        /// </summary>
        internal override void Render()
        {
            _useEffectiveValue = true;
            DocumentElements elements = DocumentRelations.GetParent(_paragraph) as DocumentElements;

            _rtfWriter.WriteControl("pard");
            bool isCellParagraph     = DocumentRelations.GetParent(elements) is Cell;
            bool isFootnoteParagraph = isCellParagraph ? false : DocumentRelations.GetParent(elements) is Footnote;

            if (isCellParagraph)
            {
                _rtfWriter.WriteControl("intbl");
            }

            RenderStyleAndFormat();
            if (!_paragraph.IsNull("Elements"))
            {
                RenderContent();
            }
            EndStyleAndFormatAfterContent();

            if ((!isCellParagraph && !isFootnoteParagraph) || _paragraph != elements.LastObject)
            {
                _rtfWriter.WriteControl("par");
            }
        }
Exemple #4
0
 internal ChartRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _chart    = (Chart)domObj;
     _isInline = DocumentRelations.HasParentOfType(_chart, typeof(Paragraph)) ||
                 RenderInParagraph();
 }
Exemple #5
0
        /// <summary>
        /// Renders an image to RTF.
        /// </summary>
        internal override void Render()
        {
            bool             renderInParagraph = RenderInParagraph();
            DocumentElements elms = DocumentRelations.GetParent(this.image) as DocumentElements;

            if (elms != null && !renderInParagraph && !(DocumentRelations.GetParent(elms) is Section || DocumentRelations.GetParent(elms) is HeaderFooter))
            {
                Trace.WriteLine(Messages.ImageFreelyPlacedInWrongContext(this.image.Name), "warning");
                return;
            }
            if (renderInParagraph)
            {
                StartDummyParagraph();
            }

            if (!this.isInline)
            {
                StartShapeArea();
            }

            RenderImage();
            if (!this.isInline)
            {
                EndShapeArea();
            }

            if (renderInParagraph)
            {
                EndDummyParagraph();
            }
        }
        /// <summary>
        /// Renders a TextFrame to RTF.
        /// </summary>
        internal override void Render()
        {
            DocumentElements elms = DocumentRelations.GetParent(_textFrame) as DocumentElements;
            bool             renderInParagraph = RenderInParagraph();

            if (renderInParagraph)
            {
                StartDummyParagraph();
            }

            StartShapeArea();

            //Properties
            RenderNameValuePair("shapeType", "202");//202 entspr. Textrahmen.

            TranslateAsNameValuePair("MarginLeft", "dxTextLeft", RtfUnit.EMU, "0");
            TranslateAsNameValuePair("MarginTop", "dyTextTop", RtfUnit.EMU, "0");
            TranslateAsNameValuePair("MarginRight", "dxTextRight", RtfUnit.EMU, "0");
            TranslateAsNameValuePair("MarginBottom", "dyTextBottom", RtfUnit.EMU, "0");

            if (_textFrame.IsNull("Elements") ||
                !CollectionContainsObjectAssignableTo(_textFrame.Elements,
                                                      typeof(Shape), typeof(Table)))
            {
                TranslateAsNameValuePair("Orientation", "txflTextFlow", RtfUnit.Undefined, null);
            }
            else
            {
                TextOrientation orient = _textFrame.Orientation;
                if (orient != TextOrientation.Horizontal && orient != TextOrientation.HorizontalRotatedFarEast)
                {
                    Debug.WriteLine(Messages2.TextframeContentsNotTurned, "warning");
                }
            }
            _rtfWriter.StartContent();
            _rtfWriter.WriteControl("shptxt");
            _rtfWriter.StartContent();
            foreach (DocumentObject docObj in _textFrame.Elements)
            {
                RendererBase rndrr = RendererFactory.CreateRenderer(docObj, _docRenderer);
                if (rndrr != null)
                {
                    rndrr.Render();
                }
            }
            //Text fields need to close with a paragraph.
            RenderTrailingParagraph(_textFrame.Elements);

            _rtfWriter.EndContent();
            _rtfWriter.EndContent();
            EndShapeArea();
            if (renderInParagraph)
            {
                RenderLayoutPicture();
                EndDummyParagraph();
            }
        }
Exemple #7
0
        internal ImageRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
            : base(domObj, docRenderer)
        {
            this.image    = domObj as Image;
            this.filePath = this.image.GetFilePath(this.docRenderer.WorkingDirectory);
            this.isInline = DocumentRelations.HasParentOfType(this.image, typeof(Paragraph)) ||
                            RenderInParagraph();

            CalculateImageDimensions();
        }
        /// <summary>
        /// Renders a section to RTF
        /// </summary>
        internal override void Render()
        {
            this.useEffectiveValue = true;

            Sections secs = DocumentRelations.GetParent(this.section) as Sections;

            if (this.section != secs.First)
            {
                this.rtfWriter.WriteControl("pard");
                this.rtfWriter.WriteControl("sect");
            }
            this.rtfWriter.WriteControl("sectd");

            //Rendering some footnote attributes:
            this.docRenderer.RenderSectionProperties();

            object pageStp = this.section.PageSetup;

            if (pageStp != null)
            {
                RendererFactory.CreateRenderer((PageSetup)pageStp, this.docRenderer).Render();
            }

            object hdrs = GetValueAsIntended("Headers");

            if (hdrs != null)
            {
                HeadersFootersRenderer hfr = new HeadersFootersRenderer(hdrs as HeadersFooters, this.docRenderer);
                //PageSetup muss hier gesetzt werden, da die HeaderFooter anderem Abschnitt gehören können als das PageSetup
                hfr.PageSetup = (PageSetup)pageStp;
                hfr.Render();
            }

            object ftrs = GetValueAsIntended("Footers");

            if (ftrs != null)
            {
                HeadersFootersRenderer hfr = new HeadersFootersRenderer(ftrs as HeadersFooters, this.docRenderer);
                hfr.PageSetup = (PageSetup)pageStp;
                hfr.Render();
            }

            if (!section.IsNull("Elements"))
            {
                foreach (DocumentObject docObj in this.section.Elements)
                {
                    RendererBase rndrr = RendererFactory.CreateRenderer(docObj, this.docRenderer);
                    if (rndrr != null)
                    {
                        rndrr.Render();
                    }
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Renders the dummy paragraph's attributes.
        /// </summary>
        protected virtual void RenderParagraphAttributes()
        {
            bool isInCell = DocumentRelations.HasParentOfType(this.shape, typeof(Cell));

            //if (isInCell)
            //  this.csvWriter.WriteControl("intbl");

            RenderParagraphAlignment();
            RenderParagraphIndents();
            RenderParagraphDistances();
        }
Exemple #10
0
        /// <summary>
        /// Renders a section to RTF
        /// </summary>
        internal override void Render()
        {
            _useEffectiveValue = true;

            Sections secs = DocumentRelations.GetParent(_section) as Sections;

            if (_section != secs.First)
            {
                _rtfWriter.WriteControl("pard");
                _rtfWriter.WriteControl("sect");
            }
            _rtfWriter.WriteControl("sectd");

            //Rendering some footnote attributes:
            _docRenderer.RenderSectionProperties();

            object pageStp = _section.PageSetup;

            if (pageStp != null)
            {
                RendererFactory.CreateRenderer((PageSetup)pageStp, _docRenderer).Render();
            }

            object hdrs = GetValueAsIntended("Headers");

            if (hdrs != null)
            {
                HeadersFootersRenderer hfr = new HeadersFootersRenderer(hdrs as HeadersFooters, _docRenderer);
                // PageSetup has to be set here, because HeaderFooter could be from a different section than PageSetup.
                hfr.PageSetup = (PageSetup)pageStp;
                hfr.Render();
            }

            object ftrs = GetValueAsIntended("Footers");

            if (ftrs != null)
            {
                HeadersFootersRenderer hfr = new HeadersFootersRenderer(ftrs as HeadersFooters, _docRenderer);
                hfr.PageSetup = (PageSetup)pageStp;
                hfr.Render();
            }

            if (!_section.IsNull("Elements"))
            {
                foreach (DocumentObject docObj in _section.Elements)
                {
                    RendererBase rndrr = RendererFactory.CreateRenderer(docObj, _docRenderer);
                    if (rndrr != null)
                    {
                        rndrr.Render();
                    }
                }
            }
        }
Exemple #11
0
        /// <summary>
        /// Renders a Table to RTF.
        /// </summary>
        internal override void Render()
        {
            DocumentElements elms         = DocumentRelations.GetParent(_table) as DocumentElements;
            MergedCellList   mrgdCellList = new MergedCellList(_table);

            foreach (Row row in _table.Rows)
            {
                RowRenderer rowRenderer = new RowRenderer(row, _docRenderer);
                rowRenderer.CellList = mrgdCellList;
                rowRenderer.Render();
            }
        }
Exemple #12
0
        private ParagraphIterator GetParentIterator()
        {
            if (this.positionIndices.Count == 0)
            {
                return(null);
            }

            ArrayList indices = (ArrayList)this.positionIndices.Clone();

            indices.RemoveAt(indices.Count - 1);
            DocumentObject parent = DocumentRelations.GetParentOfType(this.current, typeof(ParagraphElements));

            return(new ParagraphIterator(this.rootNode, parent, indices));
        }
        private ParagraphIterator GetParentIterator()
        {
            if (_positionIndices.Count == 0)
            {
                return(null);
            }

            List <int> indices = new List <int>(_positionIndices);

            indices.RemoveAt(indices.Count - 1);
            DocumentObject parent = DocumentRelations.GetParentOfType(_current, typeof(ParagraphElements));

            return(new ParagraphIterator(_rootNode, parent, indices));
        }
        /// <summary>
        /// Renders a TextFrame to CSV.
        /// </summary>
        internal override void Render()
        {
            DocumentElements elms = DocumentRelations.GetParent(this.textFrame) as DocumentElements;
            bool             renderInParagraph = RenderInParagraph();

            if (renderInParagraph)
            {
                StartDummyParagraph();
            }

            StartShapeArea();

            //Properties
            RenderNameValuePair("shapeType", "202");//202 entspr. Textrahmen.

            if (this.textFrame.IsNull("Elements") ||
                !CollectionContainsObjectAssignableTo(this.textFrame.Elements,
                                                      typeof(Shape), typeof(Table)))
            {
            }
            else
            {
                TextOrientation orient = this.textFrame.Orientation;
                if (orient != TextOrientation.Horizontal && orient != TextOrientation.HorizontalRotatedFarEast)
                {
                    Trace.WriteLine(Messages.TextframeContentsNotTurned, "warning");
                }
            }
            csvWriter.StartContent();
            csvWriter.StartContent();
            foreach (DocumentObject docObj in this.textFrame.Elements)
            {
                RendererBase rndrr = RendererFactory.CreateRenderer(docObj, this.docRenderer);
                if (rndrr != null)
                {
                    rndrr.Render();
                }
            }
            //Text fields need to close with a paragraph.
            RenderTrailingParagraph(this.textFrame.Elements);

            this.csvWriter.EndContent();
            this.csvWriter.EndContent();
            EndShapeArea();
            if (renderInParagraph)
            {
                RenderLayoutPicture();
                EndDummyParagraph();
            }
        }
        /// <summary>
        /// A shape that shall be placed between its predecessor and its successor must be embedded in a paragraph.
        /// </summary>
        protected virtual bool RenderInParagraph()
        {
            if (_shape.IsNull("RelativeVertical") || _shape.RelativeVertical == RelativeVertical.Line || _shape.RelativeVertical == RelativeVertical.Paragraph)
            {
                DocumentObjectCollection docObjects = DocumentRelations.GetParent(_shape) as DocumentObjectCollection;
                if (DocumentRelations.GetParent(docObjects) is Paragraph)//don't embed it twice!
                {
                    return(false);
                }

                return(_shape.IsNull("WrapFormat.Style") || _shape.WrapFormat.Style == WrapStyle.TopBottom);
            }

            return(false);
        }
        /// <summary>
        /// Render a Row to CSV.
        /// </summary>
        internal override void Render()
        {
            this.useEffectiveValue = true;
            new RowsRenderer(DocumentRelations.GetParent(this.row) as Rows, this.docRenderer).Render();

            int thisRowIdx = this.row.Index;

            foreach (Cell cell in this.row.Cells)
            {
                CellRenderer cellRndrr = new CellRenderer(cell, this.docRenderer);
                cellRndrr.CellList = this.cellList;
                cellRndrr.Render();
            }

            this.csvWriter.WriteNewLine();
        }
        /// <summary>
        /// Renders (and calculates) the \shptop and \shpbottom controls in RTF.
        /// </summary>
        private void RenderTopBottom()
        {
            Unit height = GetShapeHeight();
            Unit top    = 0;
            Unit bottom = height;

            if (!RenderInParagraph())
            {
                RelativeVertical relVert = (RelativeVertical)GetValueOrDefault("RelativeVertical", RelativeVertical.Paragraph);
                TopPosition      topPos  = (TopPosition)GetValueOrDefault("Top", new TopPosition());
                //REM: Will not work like this in table cells.
                //=>The shape would have to be put in a paragraph there.
                Section sec = (Section)DocumentRelations.GetParentOfType(_shape, typeof(Section));

                PageSetup pgStp    = sec.PageSetup;
                Unit      topMrg   = (Unit)pgStp.GetValue("TopMargin", GV.ReadOnly);
                Unit      btmMrg   = (Unit)pgStp.GetValue("BottomMargin", GV.ReadOnly);
                Unit      pgHeight = pgStp.PageHeight;
                Unit      pgWidth  = pgStp.PageWidth;

                if (topPos.ShapePosition == ShapePosition.Undefined)
                {
                    top    = topPos.Position;
                    bottom = top + height;
                }

                else
                {
                    switch (relVert)
                    {
                    case RelativeVertical.Line:
                        AlignVertically(topPos.ShapePosition, height, out top, out bottom);
                        break;

                    case RelativeVertical.Margin:
                        AlignVertically(topPos.ShapePosition, pgHeight.Point - topMrg.Point - btmMrg.Point, out top, out bottom);
                        break;

                    case RelativeVertical.Page:
                        AlignVertically(topPos.ShapePosition, pgHeight, out top, out bottom);
                        break;
                    }
                }
            }
            RenderUnit("shptop", top);
            RenderUnit("shpbottom", bottom);
        }
Exemple #18
0
        protected Font GetParentFont(DocumentObject obj)
        {
            DocumentObject parentElements = DocumentRelations.GetParent(obj);
            DocumentObject parentObject   = DocumentRelations.GetParent(parentElements);
            Font           parentFont     = null;

            if (parentObject is Paragraph)
            {
                ParagraphFormat format = ((Paragraph)parentObject).Format;
                parentFont = format.font;
            }
            else //Hyperlink or FormattedText
            {
                parentFont = parentObject.GetValue("Font") as Font;
            }
            return(parentFont);
        }
        /// <summary>
        /// Renders (and calculates) the \shpleft and \shpright controls in RTF.
        /// </summary>
        private void RenderLeftRight()
        {
            Unit width = GetShapeWidth();
            Unit left  = 0;
            Unit right = width;

            if (!RenderInParagraph())
            {
                RelativeHorizontal relHor  = (RelativeHorizontal)GetValueOrDefault("RelativeHorizontal", RelativeHorizontal.Margin);
                LeftPosition       leftPos = (LeftPosition)GetValueOrDefault("Left", new LeftPosition());
                //REM: Will not work like this in table cells.
                //=>The shape would have to be put in a paragraph there.

                Section   sec      = (Section)DocumentRelations.GetParentOfType(_shape, typeof(Section));
                PageSetup pgStp    = sec.PageSetup;
                Unit      leftMrg  = (Unit)pgStp.GetValue("LeftMargin", GV.ReadOnly);
                Unit      rgtMrg   = (Unit)pgStp.GetValue("RightMargin", GV.ReadOnly);
                Unit      pgHeight = pgStp.PageHeight;
                Unit      pgWidth  = pgStp.PageWidth;

                if (leftPos.ShapePosition == ShapePosition.Undefined)
                {
                    left  = leftPos.Position;
                    right = left + width;
                }

                else
                {
                    switch (relHor)
                    {
                    case RelativeHorizontal.Column:
                    case RelativeHorizontal.Character:
                    case RelativeHorizontal.Margin:
                        AlignHorizontally(leftPos.ShapePosition, pgWidth.Point - leftMrg.Point - rgtMrg.Point, out left, out right);
                        break;

                    case RelativeHorizontal.Page:
                        AlignHorizontally(leftPos.ShapePosition, pgWidth, out left, out right);
                        break;
                    }
                }
            }
            RenderUnit("shpleft", left);
            RenderUnit("shpright", right);
        }
Exemple #20
0
        /// <summary>
        /// Renders an image to RTF.
        /// </summary>
        internal override void Render()
        {
            string fileName = Path.GetTempFileName();

            if (!StoreTempImage(fileName))
            {
                return;
            }

            bool             renderInParagraph = RenderInParagraph();
            DocumentElements elms = DocumentRelations.GetParent(_chart) as DocumentElements;

            if (elms != null && !renderInParagraph && !(DocumentRelations.GetParent(elms) is Section || DocumentRelations.GetParent(elms) is HeaderFooter))
            {
                Debug.WriteLine(Messages2.ChartFreelyPlacedInWrongContext, "warning");
                return;
            }
            if (renderInParagraph)
            {
                StartDummyParagraph();
            }

            if (!_isInline)
            {
                StartShapeArea();
            }

            RenderImage(fileName);

            if (!_isInline)
            {
                EndShapeArea();
            }

            if (renderInParagraph)
            {
                EndDummyParagraph();
            }

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
        }
        /// <summary>
        /// Renders the paragraph to CSV.
        /// </summary>
        internal override void Render()
        {
            useEffectiveValue = true;
            DocumentElements elements = DocumentRelations.GetParent(this.paragraph) as DocumentElements;


            bool isCellParagraph     = DocumentRelations.GetParent(elements) is Cell;
            bool isFootnoteParagraph = isCellParagraph ? false : DocumentRelations.GetParent(elements) is Footnote;

            if (!this.paragraph.IsNull("Elements"))
            {
                RenderContent();
            }

            if ((!isCellParagraph && !isFootnoteParagraph) || this.paragraph != elements.LastObject)
            {
                this.csvWriter.WriteNewLine();
            }
        }
Exemple #22
0
        /// <summary>
        /// Render a Row to RTF.
        /// </summary>
        internal override void Render()
        {
            _useEffectiveValue = true;
            _rtfWriter.WriteControl("trowd");
            new RowsRenderer(DocumentRelations.GetParent(_row) as Rows, _docRenderer).Render();
            RenderRowHeight();
            //MigraDoc always keeps together table rows.
            _rtfWriter.WriteControl("trkeep");
            Translate("HeadingFormat", "trhdr");

            // trkeepfollow is intended to keep table rows together.
            // Unfortunalte, this does not work in word.
            int thisRowIdx = _row.Index;

            for (int rowIdx = 0; rowIdx <= _row.Index; ++rowIdx)
            {
                object keepWith = _row.Table.Rows[rowIdx].GetValue("KeepWith");
                if (keepWith != null && (int)keepWith + rowIdx > thisRowIdx)
                {
                    _rtfWriter.WriteControl("trkeepfollow");
                }
            }
            RenderTopBottomPadding();

            //Cell borders etc. are written before the contents.
            for (int idx = 0; idx < _row.Table.Columns.Count; ++idx)
            {
                Cell cell = _row.Cells[idx];
                CellFormatRenderer cellFrmtRenderer =
                    new CellFormatRenderer(cell, _docRenderer);
                cellFrmtRenderer.CellList = _cellList;
                cellFrmtRenderer.Render();
            }
            foreach (Cell cell in _row.Cells)
            {
                CellRenderer cellRndrr = new CellRenderer(cell, _docRenderer);
                cellRndrr.CellList = _cellList;
                cellRndrr.Render();
            }

            _rtfWriter.WriteControl("row");
        }
        /// <inheritdoc />
        public void Save(DocxFilePath result)
        {
            if (result is null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            Document.WriteInto(result, "word/document.xml");
            Footnotes.WriteInto(result, "word/footnotes.xml");
            ContentTypes.WriteInto(result, ContentTypesInfo.Path);
            DocumentRelations.WriteInto(result, DocumentRelsInfo.Path);
            FootnoteRelations.WriteInto(result, "word/_rels/footnotes.xml.rels");
            Styles.WriteInto(result, "word/styles.xml");
            Numbering.WriteInto(result, "word/numbering.xml");
            Theme1.WriteInto(result, "word/theme/theme1.xml");

            foreach (ChartInformation item in Charts)
            {
                item.Chart.WriteInto(result, $"word/{item.Name}");
            }
        }
        /// <summary>
        /// Renders the dummy paragraph's left indent.
        /// </summary>
        void RenderParagraphIndents()
        {
            object relHor   = GetValueAsIntended("RelativeHorizontal");
            double leftInd  = 0;
            double rightInd = 0;

            if (relHor != null && (RelativeHorizontal)relHor == RelativeHorizontal.Page)
            {
                Section parentSec = (Section)DocumentRelations.GetParentOfType(_shape, typeof(Section));
                Unit    leftPgMrg = (Unit)parentSec.PageSetup.GetValue("LeftMargin", GV.ReadOnly);
                leftInd = -leftPgMrg.Point;
                Unit rightPgMrg = (Unit)parentSec.PageSetup.GetValue("RightMargin", GV.ReadOnly);
                rightInd = -rightPgMrg;
            }

            LeftPosition leftPos = (LeftPosition)GetValueOrDefault("Left", new LeftPosition());

            switch (leftPos.ShapePosition)
            {
            case ShapePosition.Undefined:
                leftInd += leftPos.Position;
                leftInd += ((Unit)GetValueOrDefault("WrapFormat.DistanceLeft", (Unit)0)).Point;
                break;

            case ShapePosition.Left:
                leftInd += ((Unit)GetValueOrDefault("WrapFormat.DistanceLeft", (Unit)0)).Point;
                break;

            case ShapePosition.Right:
                rightInd += ((Unit)GetValueOrDefault("WrapFormat.DistanceRight", (Unit)0)).Point;
                break;
            }
            RenderUnit("li", leftInd);
            RenderUnit("lin", leftInd);
            RenderUnit("ri", rightInd);
            RenderUnit("rin", rightInd);
        }
        /// <summary>
        /// Renders attributes that belong to a shape.
        /// </summary>
        private void RenderShapeAttributes()
        {
            RenderTopPosition();
            RenderLeftPosition();

            if (DocumentRelations.HasParentOfType(_shape, typeof(HeaderFooter)))
            {
                _rtfWriter.WriteControl("shpfhdr", "1");
            }
            else
            {
                _rtfWriter.WriteControl("shpfhdr", "0");
            }
            RenderWrapFormat();
            RenderRelativeHorizontal();
            RenderRelativeVertical();
            if (RenderInParagraph())
            {
                _rtfWriter.WriteControl("shplockanchor");
                RenderNameValuePair("fPseudoInline", "1");
            }
            RenderLineFormat();
            RenderFillFormat();
        }
        /// <summary>
        /// Formats (measures) the table.
        /// </summary>
        /// <param name="area">The area on which to fit the table.</param>
        /// <param name="previousFormatInfo"></param>
        internal override void Format(Area area, FormatInfo previousFormatInfo)
        {
            DocumentElements elements = DocumentRelations.GetParent(this.table) as DocumentElements;

            if (elements != null)
            {
                Section section = DocumentRelations.GetParent(elements) as Section;
                if (section != null)
                {
                    this.doHorizontalBreak = section.PageSetup.HorizontalPageBreak;
                }
            }

            this.renderInfo = new TableRenderInfo();
            InitFormat(area, previousFormatInfo);

            // Don't take any Rows higher then MaxElementHeight
            XUnit topHeight   = this.CalcStartingHeight();
            XUnit probeHeight = topHeight;
            XUnit offset      = 0;

            if (this.startRow > this.lastHeaderRow + 1 &&
                this.startRow < this.table.Rows.Count)
            {
                offset = (XUnit)this.bottomBorderMap[this.startRow] - topHeight;
            }
            else
            {
                offset = -CalcMaxTopBorderWidth(0);
            }

            int   probeRow       = this.startRow;
            XUnit currentHeight  = 0;
            XUnit startingHeight = 0;
            bool  isEmpty        = false;

            while (probeRow < this.table.Rows.Count)
            {
                bool firstProbe = probeRow == this.startRow;
                probeRow = (int)this.connectedRowsMap[probeRow];
                // Don't take any Rows higher then MaxElementHeight
                probeHeight = (XUnit)this.bottomBorderMap[probeRow + 1] - offset;
                if (firstProbe && probeHeight > MaxElementHeight - Tolerance)
                {
                    probeHeight = MaxElementHeight - Tolerance;
                }

                //The height for the first new row(s) + headerrows:
                if (startingHeight == 0)
                {
                    if (probeHeight > area.Height)
                    {
                        isEmpty = true;
                        break;
                    }
                    startingHeight = probeHeight;
                }

                if (probeHeight > area.Height)
                {
                    break;
                }

                else
                {
                    this.currRow  = probeRow;
                    currentHeight = probeHeight;
                    ++probeRow;
                }
            }
            if (!isEmpty)
            {
                TableFormatInfo formatInfo = (TableFormatInfo)this.renderInfo.FormatInfo;
                formatInfo.startRow = this.startRow;
                formatInfo.isEnding = currRow >= this.table.Rows.Count - 1;
                formatInfo.endRow   = this.currRow;
            }
            FinishLayoutInfo(area, currentHeight, startingHeight);
        }
Exemple #27
0
 internal ShadingRenderer(DocumentObject domObj, CsvDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.shading       = domObj as Shading;
     this.isCellShading = !(DocumentRelations.GetParent(shading) is ParagraphFormat);
 }
Exemple #28
0
        /// <summary>
        ///   Formats (measures) the table.
        /// </summary>
        /// <param name="area"> The area on which to fit the table. </param>
        /// <param name="previousFormatInfo"> </param>
        internal override void Format(Area area, FormatInfo previousFormatInfo)
        {
            DocumentElements elements = DocumentRelations.GetParent(_table) as DocumentElements;

            if (elements != null)
            {
                Section section = DocumentRelations.GetParent(elements) as Section;
                if (section != null)
                {
                    _doHorizontalBreak = section.PageSetup.HorizontalPageBreak;
                }
            }

            _renderInfo = new TableRenderInfo();
            InitFormat(area, previousFormatInfo);

            // Don't take any Rows higher then MaxElementHeight
            XUnit topHeight   = CalcStartingHeight();
            XUnit probeHeight = topHeight;
            XUnit offset;

            if (_startRow > _lastHeaderRow + 1 &&
                _startRow < _table.Rows.Count)
            {
                offset = _bottomBorderMap[_startRow] - topHeight;
            }
            else
            {
                offset = -CalcMaxTopBorderWidth(0);
            }

            int   probeRow       = _startRow;
            XUnit currentHeight  = 0;
            XUnit startingHeight = 0;
            bool  isEmpty        = false;

            while (probeRow < _table.Rows.Count)
            {
                bool firstProbe = probeRow == _startRow;
                probeRow = _connectedRowsMap[probeRow];
                // Don't take any Rows higher then MaxElementHeight
                probeHeight = _bottomBorderMap[probeRow + 1] - offset;
                // First test whether MaxElementHeight has been set.
                if (MaxElementHeight > 0 && firstProbe && probeHeight > MaxElementHeight - Tolerance)
                {
                    probeHeight = MaxElementHeight - Tolerance;
                }
                //if (firstProbe && probeHeight > MaxElementHeight - Tolerance)
                //    probeHeight = MaxElementHeight - Tolerance;

                //The height for the first new row(s) + headerrows:
                if (startingHeight == 0)
                {
                    if (probeHeight > area.Height)
                    {
                        isEmpty = true;
                        break;
                    }
                    startingHeight = probeHeight;
                }

                if (probeHeight > area.Height)
                {
                    break;
                }

                else
                {
                    _currRow      = probeRow;
                    currentHeight = probeHeight;
                    ++probeRow;
                }
            }
            if (!isEmpty)
            {
                TableFormatInfo formatInfo = (TableFormatInfo)_renderInfo.FormatInfo;
                formatInfo.StartRow  = _startRow;
                formatInfo._isEnding = _currRow >= _table.Rows.Count - 1;
                formatInfo.EndRow    = _currRow;

                UpdateThisPagesBookmarks(_startRow, _currRow);
            }
            FinishLayoutInfo(area, currentHeight, startingHeight);
        }
Exemple #29
0
 internal ShadingRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _shading       = domObj as Shading;
     _isCellShading = !(DocumentRelations.GetParent(_shading) is ParagraphFormat);
 }
 internal StyleRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _style  = domObj as Style;
     _styles = DocumentRelations.GetParent(_style) as Styles;
 }