override protected void HandleStartElement(XmlNodeInformation nodeInfo) { if (nodeInfo.NodeName == "rcc") { //m_inRevisionText = true; m_currentrId = nodeInfo.GetAttributeValue("rId"); m_currentsId = nodeInfo.GetAttributeValue("sId"); } else if (nodeInfo.NodeName == "rm" && nodeInfo.EmptyElement) { base.HandleStartElement(nodeInfo); PostProcessMovedTrackChangeElement(); return; } else if (nodeInfo.NodeName == "rrc") { SetRowColRevisionTypeType(nodeInfo.GetAttributeValue("action")); if (nodeInfo.EmptyElement) { base.HandleStartElement(nodeInfo); PostProcessRowColTrackChangeElement(); m_currentRevisionType = RowColRevisionType.none; return; } } base.HandleStartElement(nodeInfo); }
private void HandleDefinedName(XmlNodeInformation nodeInfo) { m_currentDefinedName = new DefinedName(); m_currentDefinedName.m_name = nodeInfo.GetAttributeValue("name"); m_currentDefinedName.m_state = nodeInfo.GetAttributeValue("hidden"); m_currentDefinedName.m_localSheetId = nodeInfo.GetAttributeValue("localSheetId"); if (!string.IsNullOrEmpty(m_currentDefinedName.m_localSheetId))//get this with some external links - so we will extract the sheet name later { int sheetId = Int32.Parse(m_currentDefinedName.m_localSheetId); int i = 0; foreach (KeyValuePair<string, WorkSheet> kvp in m_worksheets) { if (i == sheetId) { m_currentDefinedName.m_sheetId = kvp.Value.m_sheetId; break; } i++; } } else { m_currentDefinedName.m_sheetId = ""; } }
protected override void HandleStartElement(XmlNodeInformation nodeInfo) { if (nodeInfo.Is(NamespaceId.w, NormalizedVersion("style"))) { Style newStyle = new Style(nodeInfo); newStyle.StyleType = nodeInfo.GetAttributeValue(NormalizedVersion("type")); m_styles.Add(newStyle.Id, newStyle); m_activeStyle = newStyle; m_bSendAllToActiveStyle = false; } else if (nodeInfo.Is(NamespaceId.w, NormalizedVersion("basedOn"))) { m_activeStyle.BasedOn = nodeInfo.GetAttributeValue(NormalizedVersion("val")); } else if (nodeInfo.Is(NamespaceId.w, NormalizedVersion("name"))) { m_activeStyle.Name = nodeInfo.GetAttributeValue(NormalizedVersion("val")); } else if (nodeInfo.Is(NamespaceId.w, NormalizedVersion("rPr"))) { m_bSendAllToActiveStyle = true; } else if (m_bSendAllToActiveStyle) { if (m_activeStyle != null) { nodeInfo.GetAttributes(); // force them to be loaded m_activeStyle.AddProperty(nodeInfo); } } }
public static ColourData ResolveColour(XmlNodeInformation nodeInfo) { string tintValue = nodeInfo.GetAttributeValue("tint"); string colourValue = nodeInfo.GetAttributeValue("indexed"); if (colourValue.Length > 0) { return GetColourData(colourValue, tintValue, ColourType.Indexed); } colourValue = nodeInfo.GetAttributeValue("rgb"); if (colourValue.Length > 0) { return GetColourData(colourValue, tintValue, ColourType.RGB); } colourValue = nodeInfo.GetAttributeValue("theme"); if (colourValue.Length > 0) { return GetColourData(colourValue, tintValue, ColourType.Theme); } colourValue = nodeInfo.GetAttributeValue("auto"); return GetColourData(colourValue, tintValue, ColourType.Auto); }
override protected void HandleStartElement(XmlNodeInformation nodeInfo) { m_bLastNodeWasStartATNode = false; if (nodeInfo.Is(NamespaceId.p, NormalizeString("sld"))) { string sShow = nodeInfo.GetAttributeValue(NormalizeString("Show")); if(sShow == "0") m_bHiddenSlide = true; } else if (nodeInfo.Is(NamespaceId.p, NormalizeString("sp"))) { if (m_iPostItNoteCommentDepth == 0) { m_iPostItNoteCommentDepth = nodeInfo.Depth; m_listbShapeWithPostItNoteComment.Add(false); ++m_iPostItNoteCommentIndex; } } else if (nodeInfo.Is(NamespaceId.p, NormalizeString("cNvPr")) && nodeInfo.GetAttributeValue("name").StartsWith("Comment ")) { if (m_iPostItNoteCommentDepth > 0) m_listbShapeWithPostItNoteComment[m_iPostItNoteCommentIndex] = true; } else if (nodeInfo.Is(NamespaceId.a, NormalizeString("t"))) { m_bLastNodeWasStartATNode = true; } base.HandleStartElement(nodeInfo); }
override protected void HandleStartElement(XmlNodeInformation nodeInfo) { #region switch (nodeInfo.NodeName) switch (nodeInfo.NodeName) { case "font": { m_currentFont = new FontData(); m_inFont = true; break; } case "sz": { if (m_inFont) { m_currentFont.FontSize = Decimal.Parse(nodeInfo.GetAttributeValue("val")); } break; } case "fill": { m_currentFill = new FillData(); m_inFill = true; break; } case "patternFill": { m_currentFill.SetPatternFill(nodeInfo.GetAttributeValue("patternType")); break; } case "color": case "fgColor": case "bgColor": { HandleColourElement(nodeInfo); break; } case "cellStyleXfs": { m_inStyleXf = true; break; } case "xf": { HandleFormatInfo(nodeInfo); break; } } #endregion base.HandleStartElement(nodeInfo); }
public GenericEffect(int iDepth, XmlNodeInformation ni, EffectDescriptor td, List<NodeInfo> additionalInfo) : base(iDepth) { m_effectDescriptor = td; m_contentType = td.ContentType; if (( (td.Reversible) && (ni.GetAttributeValue("val") == "0")) || !td.DefaultPolarity || !td.DeleteNode) { m_bBlockPolarity = false; m_bConsumePolarity = false; } if (!td.DeleteNodeContent) { m_bBlockPolarity = false; m_bBlocksAtStartDepth = true; } if (td.AttributeBlockType != AttributeBlockType.None) { m_attributeBlockType = td.AttributeBlockType; } this.m_blockType = td.BlockType; BuildAdditionalInfo(ni, td, additionalInfo); }
override protected void HandleStartElement(XmlNodeInformation nodeInfo) { if (nodeInfo.Is(NamespaceId.a, NormalizeString("br"))) m_stateMachine.AddSeparationSpace(); else if (nodeInfo.Is(NamespaceId.a, NormalizeString("pPr"))) { if(nodeInfo.GetAttributeValue("eaLnBrk") == "1") m_stateMachine.AddSeparationSpace(); } else if (m_listbGraphicFrameHasOLEObject != null && nodeInfo.Is(NamespaceId.p, NormalizeString("graphicFrame"))) { if (m_iGraphicFrameDepth == 0) { m_iGraphicFrameDepth = nodeInfo.Depth; ++m_iGFHOOIndex; m_bPreviousForceBlockStructure = ForceBlockStructure; ForceBlockStructure = ShouldBlockThisGraphicFrame(); if (nodeInfo.EmptyElement) { System.Diagnostics.Debug.Assert(false); // as well as being illogical for the algorithm an empty element would also break the written XML. Unless... ForceBlockStructure = false; } } } base.HandleStartElement(nodeInfo); }
private void ResolveCellState(XmlNodeInformation nodeInfo) { string sheetIndex = nodeInfo.GetAttributeValue("i"); if (!string.IsNullOrEmpty(sheetIndex)) { m_isFirstCellRefForSheet = true; m_lastSheetIndex = sheetIndex; foreach (string key in m_worksheetLookup.Keys) { WorkSheet ws = m_worksheetLookup[key]; if (ws.m_sheetId == sheetIndex) { if (ws.m_state == "hidden") { if (nodeInfo.EmptyElement) { return; } m_inHiddenSheet = true; return; } else m_allFormulaAreHidden = false; break; } } } }
private bool ShouldRemoveThisSlideFromSlideList(XmlNodeInformation nodeInfo) { if (m_dictRelatedSlideIsHidden == null) return false; string rId = nodeInfo.GetAttributeValue(NamespaceId.r, "id"); bool shouldRemove; return (m_dictRelatedSlideIsHidden.TryGetValue(rId, out shouldRemove) && shouldRemove); }
override protected void HandleStartElement(XmlNodeInformation nodeInfo) { if (nodeInfo.Is(NamespaceId.p, NormalizeString("sldId"))) { string srId = nodeInfo.GetAttributeValue(NamespaceId.r, NormalizeString("id")); m_listSlideRelsInOrder.Add(srId); } base.HandleStartElement(nodeInfo); }
public NodeInfo BuildAdditionalInfo(XmlNodeInformation ni, EffectDescriptor td) { switch (Mapping) { case AdditionalInfoDescriptor.MappingType.FixedValue: return (BuildNodeInfo(Name, Value)); case AdditionalInfoDescriptor.MappingType.AttribValue: return (BuildNodeInfo(Name, ni.GetAttributeValue(Value))); case AdditionalInfoDescriptor.MappingType.AttribNameAndValue: return (BuildNodeInfo(ni.GetAttributeValue(Name), ni.GetAttributeValue(Value))); case AdditionalInfoDescriptor.MappingType.StringToStringLookup: return (BuildNodeInfo(Name, LookupAttributeValueIntToString(ni, td))); case AdditionalInfoDescriptor.MappingType.AttribValueInDifferentNamespace: return (BuildNodeInfo(Name, LookupAttributeInAnotherNamespace(ni, td))); } throw new InvalidOperationException(); }
private void HandleSheetStart(XmlNodeInformation nodeInfo) { WorkSheet next = new WorkSheet(); next.m_rid = nodeInfo.GetAttributeValue("r:id"); next.m_sheetId = nodeInfo.GetAttributeValue("sheetId"); next.m_sheetTitle = nodeInfo.GetAttributeValue("name"); next.m_state = nodeInfo.GetAttributeValue("state"); PartInfo pi; if (m_piDictSheets.TryGetValue(next.m_rid, out pi)) { next.m_targetName = pi.Target; next.m_type = pi.Type; m_worksheets.Add(next.m_targetName, next); } else {//have seen this only with veryHidden sheets m_worksheets.Add(next.m_sheetTitle, next); } }
override protected void HandleStartElement(XmlNodeInformation nodeInfo) { #region switch (nodeInfo.NodeName) switch (nodeInfo.NodeName) { case "oleLink": { m_currentLinkProgId = nodeInfo.GetAttributeValue("progid"); string id = nodeInfo.GetAttributeValue(NamespaceId.r, "id"); OleLinkData oleData; if (id.Length > 0 && m_oleObjectData.TryGetValue(id, out oleData)) { m_currentLinkTargetPath = oleData.m_targetPath; } break; } case "externalBook": { string id = nodeInfo.GetAttributeValue(NamespaceId.r, "id"); OleLinkData oleData; if (id.Length > 0 && m_oleObjectData.TryGetValue(id, out oleData)) { m_currentLinkProgId = "Document"; m_currentLinkTargetPath = oleData.m_targetPath; HandleOleLinks(nodeInfo, oleData); } break; } case "oleItem": { m_currentOleItemNames.Add(nodeInfo.GetAttributeValue("name")); break; } } #endregion base.HandleStartElement(nodeInfo); }
private string LookupAttributeValueIntToString(XmlNodeInformation ni, EffectDescriptor td) { Dictionary<string, string> strings = td.DictStringToStringLookup; if (strings != null) { string sKeyName = Value; string sKey; if (LookupIsInAnotherNamespace) { sKey = ni.GetAttributeValue(LookupNamespace, sKeyName); } else { sKey = ni.GetAttributeValue(sKeyName); } string stringValue; if (!string.IsNullOrEmpty(sKey) && strings.TryGetValue(sKey, out stringValue)) { return stringValue; } } return "Unknown"; }
override protected void HandleStartElement(XmlNodeInformation nodeInfo) { if (NameTableUtils.Equals(nodeInfo.NodeName, m_sheet) && HandleSheetStart(nodeInfo)) return; if (NameTableUtils.Equals(nodeInfo.NodeName, m_externalRef)) { if (IsCleaning && m_interestedInExternalLinks) { m_inExternalLinks = true; return; } else { m_inExternalLinks = false; } } else if (NameTableUtils.Equals(nodeInfo.NodeName, m_definedName)) { if (IsCleaning && (m_interestedInExternalLinks || m_interestedInHiddenData)) { SetFlagsForCleaning(nodeInfo); } else { m_inHiddenData = false; m_inExternalLinks = false; } } else if (nodeInfo.NodeName == "workbookView" && IsCleaning && ShouldWriteStartNode(nodeInfo)) { string currentValue = nodeInfo.GetAttributeValue("activeTab"); if (!string.IsNullOrEmpty(currentValue) && GetPositionOfSheetsToBeDeleted().Count != 0) {//if we remove any sheets because they are hidden this value can corrupt the document //so we default reset it to the first sheet - seems to be the simplest solution nodeInfo.ResetAttributeValue("", "activeTab", "", "0"); } ResetFirstSheet(nodeInfo); } if (m_inHiddenSheet || m_inExternalLinks || m_inHiddenData) return; base.HandleStartElement(nodeInfo); }
private string LookupAttributeInAnotherNamespace(XmlNodeInformation ni, EffectDescriptor td) { string sKeyName = Value; string sKey = ni.GetAttributeValue(LookupNamespace, sKeyName); if (string.IsNullOrEmpty(sKey)) return "Unknown"; return sKey; }
override protected void HandleStartElement(XmlNodeInformation nodeInfo) { if (m_bBuildLookupTable && nodeInfo.Is(NamespaceId.p, NormalizeString("cmAuthor"))) { int iIndex = Int32.Parse(nodeInfo.GetAttributeValue( NormalizeString("id"))); string sName = nodeInfo.GetAttributeValue( NormalizeString("name")); int iMaxCommentIndex = Int32.Parse(nodeInfo.GetAttributeValue( NormalizeString("lastidx"))); AddAuthor(iIndex, sName, iMaxCommentIndex); } base.HandleStartElement(nodeInfo); }
private bool ShouldResolveCellStateBasedOnTableStyle(XmlNodeInformation nodeInfo, XlsxProcessingDictionaries processingDictionaries, out PredefinedTableData ptd) { string cellRef = nodeInfo.GetAttributeValue("r"); if (!string.IsNullOrEmpty(cellRef)) { if (m_targetHasChanged) { if (processingDictionaries.GetActualTableData(m_currentTarget, out m_currentTableData)) { foreach (KeyValuePair<string, PredefinedTableData> kvp in m_currentTableData) { ptd = kvp.Value; if (ptd.ResolveCurrentCellState(cellRef)) { m_inTable = true; return true; } } } } else { if (m_currentTableData != null) { return IsInTable(cellRef, out ptd); } } } ptd = null; return false; }
private void HandleSizeElement(XmlNodeInformation nodeInfo) { if (m_interestedInSmallText) { string nSizeValue = nodeInfo.GetAttributeValue("val"); if (Decimal.Parse(nSizeValue) <= 8) { m_partialStringStateIsSmallText = true; } else { m_partialStringStateIsSmallText = false; } } }
private void HandleShapeStart(XmlNodeInformation nodeInfo) { m_stateTracker.InShape = true; m_currentModelId = nodeInfo.GetAttributeValue("modelId"); m_resolvedColorState = new DiagramColorState(); m_currentBaseColorState = m_DiagramHelper.GetBaseColorStateForThisShape(m_currentModelId); m_resolvedColorState.Background = m_currentBaseColorState.Background; m_resolvedColorState.Foreground = m_currentBaseColorState.Foreground; m_resolvedColorState.Outline = m_currentBaseColorState.Outline; m_resolvedColorState.BaseSchemeName = m_currentBaseColorState.BaseSchemeName; m_paragraphPassedThrough = false; }
private void ResolveCellCleanableState(XmlNodeInformation nodeInfo, bool m_isFirstCellRefForSheet) { string cellRef = nodeInfo.GetAttributeValue("r"); Dictionary<string, byte> actualCellRefs; if(m_processingDictionaries.GetActualCleanableCellRefs(m_lastSheetIndex, out actualCellRefs)) { SetCleanableStateFlags(actualCellRefs, cellRef); } else { m_inCleanableFormulaCell = false; if (m_addSheetIndexToNextValidCellRef) { string sheetIndex = nodeInfo.GetAttributeValue("i"); if (string.IsNullOrEmpty(sheetIndex))//if it isn't then we have moved to cell refs for another sheet so we don't add this one { nodeInfo.CreateNewAttribute("", "i", "", m_lastSheetIndex); } m_addSheetIndexToNextValidCellRef = false; } } }
private void SetHiddenCellState(XmlNodeInformation nodeInfo) { string columnId = XlsxParsingUtilities.GetColId(nodeInfo.GetAttributeValue("r")); m_inHiddenCell = m_currentHiddenColumns.ContainsKey(columnId); }
private void SetCurrentCellFormatData(XmlNodeInformation nodeInfo, Dictionary<string, CellFormatData> cellFormatsLookup) { m_currentCellStyleBasedCFD = null; string styleIndex = nodeInfo.GetAttributeValue("s"); if(!cellFormatsLookup.TryGetValue(styleIndex, out m_currentCellStyleBasedCFD)) { //System.Diagnostics.Debug.WriteLine("Invalid styleIndex passed to StateTracker"); } }
public void SetRowHiddenState(XmlNodeInformation nodeInfo, MinMaxFilterRowRefs filterRefs) { string state = nodeInfo.GetAttributeValue("hidden"); if (state == "1") { string rowRef = nodeInfo.GetAttributeValue("r"); int row = Int32.Parse(rowRef); if (row >= filterRefs.m_minRow) { if (row <= filterRefs.m_maxRow) { //this row is a filter row, so we ignore any hidden state and reset the row to unhidden m_inHiddenRow = false; nodeInfo.ResetAttributeValue("", "hidden", "", "0"); return; } } } SetRowHiddenState(state); }
//this method is satsifactory for the moment - if we ever have a workbook where we are //going to delete all the sheet content we will need some additional handling //in several places including this private void ResetFirstSheet(XmlNodeInformation nodeInfo) { string currentFirstSheet = nodeInfo.GetAttributeValue("firstSheet"); if (string.IsNullOrEmpty(currentFirstSheet))//this attribute isn't always set return; List<int> deletingSheetPositions = GetPositionOfSheetsToBeDeleted(); if (deletingSheetPositions.Count > 0) { bool resetFirstSheet = false; int current = Int32.Parse(currentFirstSheet); while (deletingSheetPositions.Contains(current)) { current++; resetFirstSheet = true; } if (resetFirstSheet) nodeInfo.ResetAttributeValue("", "firstSheet", "", current.ToString()); } }
private void SetFlagsForCleaning(XmlNodeInformation nodeInfo) { string hidden = nodeInfo.GetAttributeValue(m_hidden); if (hidden == "1") { m_inHiddenData = true; return; } string name = nodeInfo.GetAttributeValue("name"); string localSheetId = nodeInfo.GetAttributeValue("localSheetId"); foreach (KeyValuePair<DefinedName, byte> kvp in m_foundDefinedNames) { if (kvp.Key.m_externalLink == true) { if (kvp.Key.m_name == name && localSheetId == kvp.Key.m_localSheetId) { { m_inExternalLinks = true; } } break; } } }
private bool ResolveStateBasedOnTableTheme(XmlNodeInformation nodeInfo, XlsxProcessingDictionaries processingDictionaries) { PredefinedTableData ptd; if (ShouldResolveCellStateBasedOnTableStyle(nodeInfo, processingDictionaries, out ptd)) { ResolveCurrentCellStyle(nodeInfo.GetAttributeValue("r"), ptd); return true; } return false; }
override protected void HandleStartElement(XmlNodeInformation nodeInfo) { switch (nodeInfo.NodeName) { case "pt": { HandleShapeStart(nodeInfo); break; } case "p": { if (HandleParagraphStart(nodeInfo)) return; break; } case "t": { if (!nodeInfo.EmptyElement && nodeInfo.Prefix == "a") { m_stateTracker.InContent = true; } break; } case "spPr"://shape properties { if (!nodeInfo.EmptyElement) m_stateTracker.InShapeProperties = true; break; } case "rPr"://text run properties { if (!nodeInfo.EmptyElement) { m_stateTracker.InTextProperties = true; } ResolveTextSize(nodeInfo); break; } case "noFill": { SetFillFlag(false); break; } case "solidFill": { SetFillFlag(true); break; } case "srgbClr": { SetFillColor(nodeInfo.GetAttributeValue("val")); break; } case "ln": { if (!nodeInfo.EmptyElement) m_stateTracker.InOutlineProperties = true; break; } case "effectLst": { if (!nodeInfo.EmptyElement) m_stateTracker.InEffectProperties = true; break; } case "hlinkClick": { if (IsCleaning && m_stateTracker.InterestedInHyperlinks) { if (!nodeInfo.EmptyElement) { m_stateTracker.InHyperlink = true; } return; } break; } } if (!IsCleaning && m_stateTracker.InParagraphData) { AddNodeToParagraphRun(nodeInfo); return; } base.HandleStartElement(nodeInfo); }
private void ProcessNode(XmlNodeInformation xni) { if (xni.NodeType == NodeType.content) { if (inInstruction && !passedInstruction) instructionText.Append(xni.ContentValue); if (passedInstruction && !inInstruction) resultText.Append(xni.ContentValue); return; } if (!xni.IsInNamespace(NamespaceId.w)) return; // not interested if (xni.Is(NamespaceId.w, "instrText")) { inInstruction = xni.NodeType == NodeType.start; } if (xni.Is(NamespaceId.w, "fldChar")) { ProcessFldChar(xni.GetAttributeValue("fldCharType")); passedInstruction = true; } }