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; }
private void UpdateImagePart(string imageFilePath, PartBookmark bookmark, string variant) { // 1. find image part foreach (Part imgPart in _imageParts) { if (imgPart.Content.Location.Trim().EndsWith(imageFilePath)) { // replace for (int lineIndex = 0; lineIndex < imgPart.Lines.Count; lineIndex++) { string line = imgPart.Lines[lineIndex]; if (string.IsNullOrEmpty(line) || line.StartsWith(Mime.StartPart) || line.StartsWith(PartContent.ContentTransferEncoding) || line.StartsWith(PartContent.ContentType)) { continue; } if (line.StartsWith(PartContent.ContentLocation)) { int lastDotIndex = line.LastIndexOf(Mime.Dot); line = line.Insert(lastDotIndex, variant); imgPart.Lines[lineIndex] = line; continue; } imgPart.RemoveLine(lineIndex); } // insert for-each tag string startLine = string.Empty; string endLine = string.Empty; if (_isAddSection) { startLine = XslContent.XslStartForeachTag(GetSectionPath(), Core.MarkupConstant.XslVariableSection, Core.MarkupConstant.XslPosition); endLine = XslContent.XslFormat.XslEndForeach; } foreach (ForeachItem fItem in _foreach) { startLine = startLine + fItem.XslString; endLine = endLine + XslContent.XslFormat.XslEndForeach; } if (!string.IsNullOrEmpty(startLine)) { imgPart.Lines.Insert(0, XslContent.InsertBreakLine(startLine, true)); } imgPart.Lines.Add(bookmark.XslString); if (!string.IsNullOrEmpty(endLine)) { imgPart.Lines.Add(XslContent.InsertBreakLine(endLine, false)); } return; } } }
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; } } } }