Beispiel #1
0
        private void AddApplicationBeforeDocument(int lineIndex)
        {
            // find end of tag
            int    index = lineIndex;
            string line  = _htmlPart.Lines[lineIndex];

            while (!string.IsNullOrEmpty(line) && !line.EndsWith(Mime.EndTag))
            {
                index++;
                line = _htmlPart.Lines[index];
            }

            // add before document
            line = line + XslContent.XslValueOfTag(ProntoDoc.Framework.CoreObject.FrameworkConstants.PdwApplication + "/"
                                                   + ProntoDoc.Framework.CoreObject.FrameworkConstants.PdwBeforeDocumet);

            // add multi-section
            if (_isAddSection)
            {
                line = line + XslContent.XslStartForeachTag(GetSectionPath(),
                                                            Core.MarkupConstant.XslVariableSection, Core.MarkupConstant.XslPosition);
            }

            // update line
            _htmlPart.Lines[lineIndex] = line;
        }
Beispiel #2
0
        private void UpdateImageBookmark(PartBookmark bookmark)
        {
            //1. Find src=3D" attribute
            int    index = bookmark.StartLineIndex;
            string line  = _htmlPart.Lines[index];

            while (index < _htmlPart.Lines.Count && !line.Contains(Mime.SourceImage))
            {
                index++;
                line = _htmlPart.Lines[index];
            }
            if (index >= _htmlPart.Lines.Count)
            {
                return;
            }

            //2. Find end of src3D attribute (Char: '"'), last position of Dot ('.')
            int    dotLineIndex = index;
            int    dotCharIndex = line.LastIndexOf(Mime.Dot);
            string imagePath    = string.Empty;

            line = line.Substring(line.IndexOf(Mime.SourceImage) + Mime.SourceImage.Length);
            while (index < _htmlPart.Lines.Count && !string.IsNullOrEmpty(line) && !line.Contains(Mime.EndAttribute))
            {
                imagePath += line.TrimEnd(new char[] { Mime.Equal });
                index++;
                line = _htmlPart.Lines[index];

                if (line.Contains(Mime.Dot))
                {
                    dotLineIndex = index;
                    dotCharIndex = line.LastIndexOf(Mime.Dot);
                }
            }
            if (index >= _htmlPart.Lines.Count)
            {
                return;
            }

            //3. Insert xsl string and get result
            string variant = string.Empty;

            if (_foreach.Count > 0)
            {
                variant = _foreach[_foreach.Count - 1].VariantName;
            }
            if (!string.IsNullOrEmpty(variant))
            {
                variant = XslContent.XslValueOfTag(variant, false, true);
            }
            if (_isAddSection)
            {
                variant = XslContent.XslValueOfTag(Core.MarkupConstant.XslVariableSection, false) + variant;
            }
            _htmlPart.Lines[dotLineIndex] = _htmlPart.Lines[dotLineIndex].Insert(dotCharIndex, variant);
            imagePath += line.Substring(0, line.IndexOf(Mime.EndAttribute));
            UpdateImagePart(imagePath, bookmark, variant);
        }
Beispiel #3
0
        private void AddApplicationHeader(int lineIndex)
        {
            string line = _htmlPart.Lines[lineIndex];

            line = XslContent.XslValueOfTag(ProntoDoc.Framework.CoreObject.FrameworkConstants.PdwApplication + "/"
                                            + ProntoDoc.Framework.CoreObject.FrameworkConstants.PdwHeader) + line;

            _htmlPart.Lines[lineIndex] = line;
        }
Beispiel #4
0
        private void AddApplicationAfterDocument(int lineIndex)
        {
            string line = _htmlPart.Lines[lineIndex];

            // add after document
            line = XslContent.XslValueOfTag(ProntoDoc.Framework.CoreObject.FrameworkConstants.PdwApplication + "/"
                                            + ProntoDoc.Framework.CoreObject.FrameworkConstants.PdwAfterDocument) + line;

            // add multi-section
            if (_isAddSection)
            {
                line = XslContent.XslFormat.XslEndForeach + line;
            }

            // update line
            _htmlPart.Lines[lineIndex] = line;
        }
Beispiel #5
0
        private void ReplaceBookmarkTag()
        {
            _foreach = new List <ForeachItem>();
            for (int index = 0; index < _bookmarks.Count; index++)
            {
                PartBookmark  bookmark      = _bookmarks[index];
                List <string> selectedTable = GetSelectedTables(bookmark);
                Relations     relations     = GetRelations(bookmark);
                if (!bookmark.IsDelete)
                {
                    string xslPath = string.Empty;
                    switch (bookmark.Type)
                    {
                    case Core.BookmarkType.EndForeach:
                        bookmark.XslString = XslContent.XslFormat.XslEndForeach;
                        if (_foreach.Count > 0)
                        {
                            _foreach.RemoveAt(_foreach.Count - 1);
                        }
                        UpdateBookmarkPart(bookmark, index);
                        break;

                    case Core.BookmarkType.EndIf:
                        bookmark.XslString = XslContent.XslFormat.XslEndIf;
                        UpdateBookmarkPart(bookmark, index);
                        break;

                    case Core.BookmarkType.Image:
                        xslPath            = GetXslPath(bookmark, bookmark.BizName, false, selectedTable, relations);
                        bookmark.XslString = XslContent.XslValueOfTag(xslPath);
                        UpdateImageBookmark(bookmark);
                        break;

                    case Core.BookmarkType.Select:
                        xslPath            = GetXslPath(bookmark, bookmark.BizName, false, selectedTable, relations);
                        bookmark.XslString = XslContent.XslValueOfTag(xslPath,
                                                                      bookmark.BizName == ProntoDoc.Framework.CoreObject.FrameworkConstants.PdwWatermark ? false : true);
                        UpdateBookmarkPart(bookmark, index);
                        break;

                    case Core.BookmarkType.StartIf:
                        xslPath            = GetXslPath(bookmark, bookmark.BizName, true, selectedTable, relations);
                        bookmark.XslString = XslContent.XslStartIfTag(xslPath);
                        UpdateBookmarkPart(bookmark, index);
                        break;

                    case Core.BookmarkType.StartForeach:
                        int    indexForeach = _foreach.Count + 1;
                        string variant      = Core.MarkupConstant.XslVariableImage + index.ToString();
                        InternalBookmarkDomain ibmDomain = _ibm.GetInternalBookmarkDomainByItemKey(bookmark.Key);
                        ForeachItem            fItem     = new ForeachItem(index, _bookmarks.Cast <Base.BaseBookmark>(),
                                                                           relations, ibmDomain.SelectedTables, indexForeach, variant, string.Empty);
                        _foreach.Add(fItem);

                        xslPath = GetXslPath(bookmark, string.Empty, false, selectedTable, relations);
                        InternalBookmarkItem ibmItem = _ibm.GetInternalBookmarkItem(bookmark.Key);
                        string sort = GetSortXsl(bookmark.BizName, ibmItem.DomainName, selectedTable, relations, true);
                        bookmark.XslString = XslContent.XslStartForeachTag(xslPath,
                                                                           variant, Core.MarkupConstant.XslMultiPosition, sort);
                        fItem.XslString = bookmark.XslString;

                        UpdateBookmarkPart(bookmark, index);
                        break;

                    default:
                        break;
                    }
                }
            }
        }