public FrameSequence(IStreamReader reader) : base(reader) { // FRAME = Frame Begin LineFormat AreaFormat [GELFRAME] [SHAPEPROPS] End // Frame this.Frame = (Frame)BiffRecord.ReadRecord(reader); // Begin this.Begin = (Begin)BiffRecord.ReadRecord(reader); // LineFormat this.LineFormat = (LineFormat)BiffRecord.ReadRecord(reader); // AreaFormat this.AreaFormat = (AreaFormat)BiffRecord.ReadRecord(reader); // [GELFRAME] if (BiffRecord.GetNextRecordType(reader) == RecordType.GelFrame) { this.GelFrameSequence = new GelFrameSequence(reader); } // [SHAPEPROPS] if (BiffRecord.GetNextRecordType(reader) == RecordType.ShapePropsStream) { this.ShapePropsSequence = new ShapePropsSequence(reader); } // End this.End = (End)BiffRecord.ReadRecord(reader); }
public AxsSequence(IStreamReader reader) : base(reader) { //AXS = [IFmtRecord] [Tick] [FontX] *4(AxisLine LineFormat) [AreaFormat] [GELFRAME] *4SHAPEPROPS [TextPropsStream *ContinueFrt12] //[IFmtRecord] if (BiffRecord.GetNextRecordType(reader) == RecordType.IFmtRecord) { this.IFmtRecord = (IFmtRecord)BiffRecord.ReadRecord(reader); } //[Tick] if (BiffRecord.GetNextRecordType(reader) == RecordType.Tick) { this.Tick = (Tick)BiffRecord.ReadRecord(reader); } //[FontX] if (BiffRecord.GetNextRecordType(reader) == RecordType.FontX) { this.FontX = (FontX)BiffRecord.ReadRecord(reader); } //*4(AxisLine LineFormat) this.AxisLineFormatGroups = new List <AxisLineFormatGroup>(); while (BiffRecord.GetNextRecordType(reader) == RecordType.AxisLine) { this.AxisLineFormatGroups.Add(new AxisLineFormatGroup(reader)); } //[AreaFormat] if (BiffRecord.GetNextRecordType(reader) == RecordType.AreaFormat) { this.AreaFormat = (AreaFormat)BiffRecord.ReadRecord(reader); } //[GELFRAME] if (BiffRecord.GetNextRecordType(reader) == RecordType.GelFrame) { this.GelFrame = (GelFrame)BiffRecord.ReadRecord(reader); } //*4SHAPEPROPS this.ShapePropsSequences = new List <ShapePropsSequence>(); while (BiffRecord.GetNextRecordType(reader) == RecordType.ShapePropsStream) { this.ShapePropsSequences.Add(new ShapePropsSequence(reader)); } //[TextPropsStream *ContinueFrt12] if (BiffRecord.GetNextRecordType(reader) == RecordType.TextPropsStream) { this.TextPropsStream = (TextPropsStream)BiffRecord.ReadRecord(reader); while (BiffRecord.GetNextRecordType(reader) == RecordType.ContinueFrt12) { this.ContinueFrt12s.Add((ContinueFrt12)BiffRecord.ReadRecord(reader)); } } }
private static void ProcessAreaFormat(AreaFormat af, XmlWriter xmlw) { xmlw.WriteStartElement("AreaFormat"); xmlw.WriteAttributeString("EnableHideForDrillDown", af.EnableHideForDrillDown.ToStringSafe()); xmlw.WriteAttributeString("EnableKeepTogether", af.EnableKeepTogether.ToStringSafe()); xmlw.WriteAttributeString("EnableNewPageAfter", af.EnableNewPageAfter.ToStringSafe()); xmlw.WriteAttributeString("EnableNewPageBefore", af.EnableNewPageBefore.ToStringSafe()); xmlw.WriteAttributeString("EnablePrintAtBottomOfPage", af.EnablePrintAtBottomOfPage.ToStringSafe()); xmlw.WriteAttributeString("EnableResetPageNumberAfter", af.EnableResetPageNumberAfter.ToStringSafe()); xmlw.WriteAttributeString("EnableSuppress", af.EnableSuppress.ToStringSafe()); xmlw.WriteEndElement(); }
private static void GetAreaFormat(AreaFormat areaFormat, XmlWriter writer) { WriteAndTraceStartElement(writer, "AreaFormat"); writer.WriteAttributeString("EnableHideForDrillDown", areaFormat.EnableHideForDrillDown.ToString()); writer.WriteAttributeString("EnableKeepTogether", areaFormat.EnableKeepTogether.ToString()); writer.WriteAttributeString("EnableNewPageAfter", areaFormat.EnableNewPageAfter.ToString()); writer.WriteAttributeString("EnableNewPageBefore", areaFormat.EnableNewPageBefore.ToString()); writer.WriteAttributeString("EnablePrintAtBottomOfPage", areaFormat.EnablePrintAtBottomOfPage.ToString()); writer.WriteAttributeString("EnableResetPageNumberAfter", areaFormat.EnableResetPageNumberAfter.ToString()); writer.WriteAttributeString("EnableSuppress", areaFormat.EnableSuppress.ToString()); writer.WriteEndElement(); }
private void insertFillProperties(AreaFormat areaFormat, GelFrameSequence gelFrameSequence) { // EG_FillProperties (from AreaFormat) if (areaFormat != null) { if (gelFrameSequence != null && gelFrameSequence.GelFrames.Count > 0) { insertDrawingFillProperties(areaFormat, (ShapeOptions)gelFrameSequence.GelFrames[0].OPT1); } else { if (areaFormat.fls == 0x0000) { // a:noFill (CT_NoFillProperties) this._writer.WriteElementString(Dml.Prefix, Dml.ShapeEffects.ElNoFill, Dml.Ns, string.Empty); } else if (areaFormat.fls == 0x0001) { RGBColor fillColor; if (this.ChartSheetContentSequence.Palette != null && areaFormat.icvFore >= 0x0000 && areaFormat.icvFore <= 0x0041) { // there is a valid palette color set fillColor = this.ChartSheetContentSequence.Palette.rgbColorList[areaFormat.icvFore]; } else { fillColor = areaFormat.rgbFore; } // a:solidFill (CT_SolidColorFillProperties) this._writer.WriteStartElement(Dml.Prefix, Dml.ShapeEffects.ElSolidFill, Dml.Ns); writeValueElement(Dml.Prefix, Dml.BaseTypes.ElSrgbClr, Dml.Ns, fillColor.SixDigitHexCode.ToUpper()); this._writer.WriteEndElement(); // a:solidFill } // a:gradFill (CT_GradientFillProperties) // a:blipFill (CT_BlipFillProperties) // a:pattFill (CT_PatternFillProperties) // a:grpFill (CT_GroupFillProperties) } } }
get => string.Format(AreaFormat, Area);
private void insertDrawingFillProperties(AreaFormat areaFormat, ShapeOptions so) { var rgbFore = areaFormat.rgbFore; var rgbBack = areaFormat.rgbBack; uint fillType = 0; if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillType)) { fillType = so.OptionsByID[ShapeOptions.PropertyId.fillType].op; } switch (fillType) { case 0x0: //solid // a:solidFill (CT_SolidColorFillProperties) this._writer.WriteStartElement(Dml.Prefix, Dml.ShapeEffects.ElSolidFill, Dml.Ns); { // a:srgbColor this._writer.WriteStartElement(Dml.Prefix, Dml.BaseTypes.ElSrgbClr, Dml.Ns); this._writer.WriteAttributeString(Dml.BaseTypes.AttrVal, rgbFore.SixDigitHexCode.ToUpper()); this._writer.WriteEndElement(); // a:srgbColor } this._writer.WriteEndElement(); // a:solidFill break; case 0x1: //pattern //uint blipIndex1 = so.OptionsByID[ShapeOptions.PropertyId.fillBlip].op; //DrawingGroup gr1 = (DrawingGroup)this._ctx.Ppt.DocumentRecord.FirstChildWithType<PPDrawingGroup>().Children[0]; //BlipStoreEntry bse1 = (BlipStoreEntry)gr1.FirstChildWithType<BlipStoreContainer>().Children[(int)blipIndex1 - 1]; //BitmapBlip b1 = (BitmapBlip)_ctx.Ppt.PicturesContainer._pictures[bse1.foDelay]; //_writer.WriteStartElement(Dml.Prefix, "pattFill", Dml.Ns); //_writer.WriteAttributeString("prst", Utils.getPrstForPatternCode(b1.m_bTag)); //Utils.getPrstForPattern(blipNamePattern)); //_writer.WriteStartElement(Dml.Prefix, "fgClr", Dml.Ns); //_writer.WriteStartElement(Dml.Prefix, "srgbClr", Dml.Ns); //_writer.WriteAttributeString("val", Utils.getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[ShapeOptions.PropertyId.fillColor].op, slide, so)); //_writer.WriteEndElement(); //_writer.WriteEndElement(); //_writer.WriteStartElement(Dml.Prefix, "bgClr", Dml.Ns); //_writer.WriteStartElement(Dml.Prefix, "srgbClr", Dml.Ns); //if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillBackColor)) //{ // colorval = Utils.getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[ShapeOptions.PropertyId.fillBackColor].op, slide, so); //} //else //{ // colorval = "ffffff"; //TODO: find out which color to use in this case //} //_writer.WriteAttributeString("val", colorval); //_writer.WriteEndElement(); //_writer.WriteEndElement(); //_writer.WriteEndElement(); break; case 0x2: //texture case 0x3: //picture //uint blipIndex = 0; //if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillBlip)) //{ // blipIndex = so.OptionsByID[ShapeOptions.PropertyId.fillBlip].op; //} //else //{ // blipIndex = so.OptionsByID[ShapeOptions.PropertyId.Pib].op; //} ////string blipName = Encoding.UTF8.GetString(so.OptionsByID[ShapeOptions.PropertyId.fillBlipName].opComplex); //string rId = ""; //DrawingGroup gr = (DrawingGroup)this._ctx.Ppt.DocumentRecord.FirstChildWithType<PPDrawingGroup>().Children[0]; //if (blipIndex <= gr.FirstChildWithType<BlipStoreContainer>().Children.Count) //{ // BlipStoreEntry bse = (BlipStoreEntry)gr.FirstChildWithType<BlipStoreContainer>().Children[(int)blipIndex - 1]; // if (_ctx.Ppt.PicturesContainer._pictures.ContainsKey(bse.foDelay)) // { // Record rec = _ctx.Ppt.PicturesContainer._pictures[bse.foDelay]; // ImagePart imgPart = null; // if (rec is BitmapBlip) // { // BitmapBlip b = (BitmapBlip)_ctx.Ppt.PicturesContainer._pictures[bse.foDelay]; // imgPart = _parentSlideMapping.targetPart.AddImagePart(ShapeTreeMapping.getImageType(b.TypeCode)); // imgPart.TargetDirectory = "..\\media"; // System.IO.Stream outStream = imgPart.GetStream(); // outStream.Write(b.m_pvBits, 0, b.m_pvBits.Length); // } // else // { // MetafilePictBlip b = (MetafilePictBlip)_ctx.Ppt.PicturesContainer._pictures[bse.foDelay]; // imgPart = _parentSlideMapping.targetPart.AddImagePart(ShapeTreeMapping.getImageType(b.TypeCode)); // imgPart.TargetDirectory = "..\\media"; // System.IO.Stream outStream = imgPart.GetStream(); // byte[] decompressed = b.Decrompress(); // outStream.Write(decompressed, 0, decompressed.Length); // } // rId = imgPart.RelIdToString; // _writer.WriteStartElement(Dml.Prefix, "blipFill", Dml.Ns); // _writer.WriteAttributeString("dpi", "0"); // _writer.WriteAttributeString("rotWithShape", "1"); // _writer.WriteStartElement(Dml.Prefix, "blip", Dml.Ns); // _writer.WriteAttributeString("r", "embed", OpenXmlNamespaces.Relationships, rId); // _writer.WriteEndElement(); // _writer.WriteElementString(Dml.Prefix, "srcRect", Dml.Ns, ""); // if (fillType == 0x3) // { // _writer.WriteStartElement(Dml.Prefix, "stretch", Dml.Ns); // _writer.WriteElementString(Dml.Prefix, "fillRect", Dml.Ns, ""); // _writer.WriteEndElement(); // } // else // { // _writer.WriteStartElement(Dml.Prefix, "tile", Dml.Ns); // _writer.WriteAttributeString("tx", "0"); // _writer.WriteAttributeString("ty", "0"); // _writer.WriteAttributeString("sx", "100000"); // _writer.WriteAttributeString("sy", "100000"); // _writer.WriteAttributeString("flip", "none"); // _writer.WriteAttributeString("algn", "tl"); // _writer.WriteEndElement(); // } // _writer.WriteEndElement(); // } //} break; case 0x4: //shade case 0x5: //shadecenter case 0x6: //shadeshape case 0x7: //shadescale this._writer.WriteStartElement(Dml.Prefix, "gradFill", Dml.Ns); this._writer.WriteAttributeString("rotWithShape", "1"); { this._writer.WriteStartElement(Dml.Prefix, "gsLst", Dml.Ns); { this._writer.WriteStartElement(Dml.Prefix, "gs", Dml.Ns); this._writer.WriteAttributeString("pos", "0"); this._writer.WriteStartElement(Dml.Prefix, "srgbClr", Dml.Ns); this._writer.WriteAttributeString("val", rgbFore.SixDigitHexCode.ToUpper()); //if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillOpacity)) //{ // _writer.WriteStartElement(Dml.Prefix, "alpha", Dml.Ns); // _writer.WriteAttributeString("val", Math.Round(((decimal)so.OptionsByID[ShapeOptions.PropertyId.fillOpacity].op / 65536 * 100000)).ToString()); //we need the percentage of the opacity (65536 means 100%) // _writer.WriteEndElement(); //} this._writer.WriteEndElement(); this._writer.WriteEndElement(); this._writer.WriteStartElement(Dml.Prefix, "gs", Dml.Ns); this._writer.WriteAttributeString("pos", "100000"); this._writer.WriteStartElement(Dml.Prefix, "srgbClr", Dml.Ns); this._writer.WriteAttributeString("val", rgbBack.SixDigitHexCode.ToUpper()); //if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillBackOpacity)) //{ // _writer.WriteStartElement(Dml.Prefix, "alpha", Dml.Ns); // _writer.WriteAttributeString("val", Math.Round(((decimal)so.OptionsByID[ShapeOptions.PropertyId.fillBackOpacity].op / 65536 * 100000)).ToString()); //we need the percentage of the opacity (65536 means 100%) // _writer.WriteEndElement(); //} this._writer.WriteEndElement(); this._writer.WriteEndElement(); } this._writer.WriteEndElement(); //gsLst switch (fillType) { case 0x5: case 0x6: this._writer.WriteStartElement(Dml.Prefix, "path", Dml.Ns); this._writer.WriteAttributeString("path", "shape"); this._writer.WriteStartElement(Dml.Prefix, "fillToRect", Dml.Ns); this._writer.WriteAttributeString("l", "50000"); this._writer.WriteAttributeString("t", "50000"); this._writer.WriteAttributeString("r", "50000"); this._writer.WriteAttributeString("b", "50000"); this._writer.WriteEndElement(); this._writer.WriteEndElement(); //path break; case 0x7: decimal angle = 90; if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillAngle)) { if (so.OptionsByID[ShapeOptions.PropertyId.fillAngle].op != 0) { var bytes = BitConverter.GetBytes(so.OptionsByID[ShapeOptions.PropertyId.fillAngle].op); int integral = BitConverter.ToInt16(bytes, 0); uint fractional = BitConverter.ToUInt16(bytes, 2); decimal result = integral + ((decimal)fractional / (decimal)65536); angle = 65536 - fractional; //I have no idea why this works!! angle = angle - 90; if (angle < 0) { angle += 360; } } } this._writer.WriteStartElement(Dml.Prefix, "lin", Dml.Ns); angle *= 60000; if (angle > 5400000) { angle = 5400000; } this._writer.WriteAttributeString("ang", angle.ToString()); this._writer.WriteAttributeString("scaled", "1"); this._writer.WriteEndElement(); break; default: this._writer.WriteStartElement(Dml.Prefix, "path", Dml.Ns); this._writer.WriteAttributeString("path", "rect"); this._writer.WriteStartElement(Dml.Prefix, "fillToRect", Dml.Ns); this._writer.WriteAttributeString("r", "100000"); this._writer.WriteAttributeString("b", "100000"); this._writer.WriteEndElement(); this._writer.WriteEndElement(); //path break; } } this._writer.WriteEndElement(); //gradFill break; case 0x8: //shadetitle case 0x9: //background break; } }
public SsSequence(IStreamReader reader) : base(reader) { // SS = DataFormat Begin [Chart3DBarShape] [LineFormat AreaFormat PieFormat] // [SerFmt] [GELFRAME] [MarkerFormat] [AttachedLabel] *2SHAPEPROPS [CRTMLFRT] End //// SS = DataFormat Begin [Chart3DBarShape] [LineFormat AreaFormat PieFormat] //// [SerFmt] [LineFormat] [AreaFormat] [GELFRAME] [MarkerFormat] [AttachedLabel] *2SHAPEPROPS [CRTMLFRT] End // DataFormat this.DataFormat = (DataFormat)BiffRecord.ReadRecord(reader); // Begin this.Begin = (Begin)BiffRecord.ReadRecord(reader); // [Chart3DBarShape] if (BiffRecord.GetNextRecordType(reader) == RecordType.Chart3DBarShape) { this.Chart3DBarShape = (Chart3DBarShape)BiffRecord.ReadRecord(reader); } // [LineFormat AreaFormat PieFormat] if (BiffRecord.GetNextRecordType(reader) == RecordType.LineFormat) { this.LineFormat = (LineFormat)BiffRecord.ReadRecord(reader); } if (BiffRecord.GetNextRecordType(reader) == RecordType.AreaFormat) { this.AreaFormat = (AreaFormat)BiffRecord.ReadRecord(reader); } if (BiffRecord.GetNextRecordType(reader) == RecordType.PieFormat) { this.PieFormat = (PieFormat)BiffRecord.ReadRecord(reader); } //// this is for the case that LineFormat and AreaFormat //// exists and is behind the SerFmt which doesn't exists //if (this.PieFormat == null) //{ // if (this.LineFormat1 != null) // { // this.LineFormat2 = this.LineFormat1; // this.LineFormat1 = null; // } // if (this.AreaFormat1 != null) // { // this.AreaFormat2 = this.AreaFormat1; // this.AreaFormat1 = null; // } //} // [SerFmt] if (BiffRecord.GetNextRecordType(reader) == RecordType.SerFmt) { this.SerFmt = (SerFmt)BiffRecord.ReadRecord(reader); } // [LineFormat] [AreaFormat] [GELFRAME] [MarkerFormat] [AttachedLabel] End //if (BiffRecord.GetNextRecordType(reader) == RecordType.LineFormat) //{ // this.LineFormat2 = (LineFormat)BiffRecord.ReadRecord(reader); //} //// [AreaFormat] //if (BiffRecord.GetNextRecordType(reader) == // RecordType.AreaFormat) //{ // this.AreaFormat2 = (AreaFormat)BiffRecord.ReadRecord(reader); //} // [GELFRAME] if (BiffRecord.GetNextRecordType(reader) == RecordType.GelFrame) { this.GelFrameSequence = new GelFrameSequence(reader); } // [MarkerFormat] if (BiffRecord.GetNextRecordType(reader) == RecordType.MarkerFormat) { this.MarkerFormat = (MarkerFormat)BiffRecord.ReadRecord(reader); } // [AttachedLabel] if (BiffRecord.GetNextRecordType(reader) == RecordType.AttachedLabel) { this.AttachedLabel = (AttachedLabel)BiffRecord.ReadRecord(reader); } // *2SHAPEPROPS this.ShapePropsSequences = new List <ShapePropsSequence>(); while (BiffRecord.GetNextRecordType(reader) == RecordType.ShapePropsStream) { this.ShapePropsSequences.Add(new ShapePropsSequence(reader)); } // [CRTMLFRT] if (BiffRecord.GetNextRecordType(reader) == RecordType.CrtMlFrt) { this.CrtMlfrtSequence = new CrtMlfrtSequence(reader); } // End this.End = (End)BiffRecord.ReadRecord(reader); }
private void insertDrawingFillProperties(AreaFormat areaFormat, ShapeOptions so) { RGBColor rgbFore = areaFormat.rgbFore; RGBColor rgbBack = areaFormat.rgbBack; uint fillType = 0; if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillType)) { fillType = so.OptionsByID[ShapeOptions.PropertyId.fillType].op; } switch (fillType) { case 0x0: //solid // a:solidFill (CT_SolidColorFillProperties) _writer.WriteStartElement(Dml.Prefix, Dml.ShapeEffects.ElSolidFill, Dml.Ns); { // a:srgbColor _writer.WriteStartElement(Dml.Prefix, Dml.BaseTypes.ElSrgbClr, Dml.Ns); _writer.WriteAttributeString(Dml.BaseTypes.AttrVal, rgbFore.SixDigitHexCode.ToUpper()); _writer.WriteEndElement(); // a:srgbColor } _writer.WriteEndElement(); // a:solidFill break; case 0x1: //pattern //uint blipIndex1 = so.OptionsByID[ShapeOptions.PropertyId.fillBlip].op; //DrawingGroup gr1 = (DrawingGroup)this._ctx.Ppt.DocumentRecord.FirstChildWithType<PPDrawingGroup>().Children[0]; //BlipStoreEntry bse1 = (BlipStoreEntry)gr1.FirstChildWithType<BlipStoreContainer>().Children[(int)blipIndex1 - 1]; //BitmapBlip b1 = (BitmapBlip)_ctx.Ppt.PicturesContainer._pictures[bse1.foDelay]; //_writer.WriteStartElement(Dml.Prefix, "pattFill", Dml.Ns); //_writer.WriteAttributeString("prst", Utils.getPrstForPatternCode(b1.m_bTag)); //Utils.getPrstForPattern(blipNamePattern)); //_writer.WriteStartElement(Dml.Prefix, "fgClr", Dml.Ns); //_writer.WriteStartElement(Dml.Prefix, "srgbClr", Dml.Ns); //_writer.WriteAttributeString("val", Utils.getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[ShapeOptions.PropertyId.fillColor].op, slide, so)); //_writer.WriteEndElement(); //_writer.WriteEndElement(); //_writer.WriteStartElement(Dml.Prefix, "bgClr", Dml.Ns); //_writer.WriteStartElement(Dml.Prefix, "srgbClr", Dml.Ns); //if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillBackColor)) //{ // colorval = Utils.getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[ShapeOptions.PropertyId.fillBackColor].op, slide, so); //} //else //{ // colorval = "ffffff"; //TODO: find out which color to use in this case //} //_writer.WriteAttributeString("val", colorval); //_writer.WriteEndElement(); //_writer.WriteEndElement(); //_writer.WriteEndElement(); break; case 0x2: //texture case 0x3: //picture //uint blipIndex = 0; //if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillBlip)) //{ // blipIndex = so.OptionsByID[ShapeOptions.PropertyId.fillBlip].op; //} //else //{ // blipIndex = so.OptionsByID[ShapeOptions.PropertyId.Pib].op; //} ////string blipName = Encoding.UTF8.GetString(so.OptionsByID[ShapeOptions.PropertyId.fillBlipName].opComplex); //string rId = ""; //DrawingGroup gr = (DrawingGroup)this._ctx.Ppt.DocumentRecord.FirstChildWithType<PPDrawingGroup>().Children[0]; //if (blipIndex <= gr.FirstChildWithType<BlipStoreContainer>().Children.Count) //{ // BlipStoreEntry bse = (BlipStoreEntry)gr.FirstChildWithType<BlipStoreContainer>().Children[(int)blipIndex - 1]; // if (_ctx.Ppt.PicturesContainer._pictures.ContainsKey(bse.foDelay)) // { // Record rec = _ctx.Ppt.PicturesContainer._pictures[bse.foDelay]; // ImagePart imgPart = null; // if (rec is BitmapBlip) // { // BitmapBlip b = (BitmapBlip)_ctx.Ppt.PicturesContainer._pictures[bse.foDelay]; // imgPart = _parentSlideMapping.targetPart.AddImagePart(ShapeTreeMapping.getImageType(b.TypeCode)); // imgPart.TargetDirectory = "..\\media"; // System.IO.Stream outStream = imgPart.GetStream(); // outStream.Write(b.m_pvBits, 0, b.m_pvBits.Length); // } // else // { // MetafilePictBlip b = (MetafilePictBlip)_ctx.Ppt.PicturesContainer._pictures[bse.foDelay]; // imgPart = _parentSlideMapping.targetPart.AddImagePart(ShapeTreeMapping.getImageType(b.TypeCode)); // imgPart.TargetDirectory = "..\\media"; // System.IO.Stream outStream = imgPart.GetStream(); // byte[] decompressed = b.Decrompress(); // outStream.Write(decompressed, 0, decompressed.Length); // } // rId = imgPart.RelIdToString; // _writer.WriteStartElement(Dml.Prefix, "blipFill", Dml.Ns); // _writer.WriteAttributeString("dpi", "0"); // _writer.WriteAttributeString("rotWithShape", "1"); // _writer.WriteStartElement(Dml.Prefix, "blip", Dml.Ns); // _writer.WriteAttributeString("r", "embed", OpenXmlNamespaces.Relationships, rId); // _writer.WriteEndElement(); // _writer.WriteElementString(Dml.Prefix, "srcRect", Dml.Ns, ""); // if (fillType == 0x3) // { // _writer.WriteStartElement(Dml.Prefix, "stretch", Dml.Ns); // _writer.WriteElementString(Dml.Prefix, "fillRect", Dml.Ns, ""); // _writer.WriteEndElement(); // } // else // { // _writer.WriteStartElement(Dml.Prefix, "tile", Dml.Ns); // _writer.WriteAttributeString("tx", "0"); // _writer.WriteAttributeString("ty", "0"); // _writer.WriteAttributeString("sx", "100000"); // _writer.WriteAttributeString("sy", "100000"); // _writer.WriteAttributeString("flip", "none"); // _writer.WriteAttributeString("algn", "tl"); // _writer.WriteEndElement(); // } // _writer.WriteEndElement(); // } //} break; case 0x4: //shade case 0x5: //shadecenter case 0x6: //shadeshape case 0x7: //shadescale _writer.WriteStartElement(Dml.Prefix, "gradFill", Dml.Ns); _writer.WriteAttributeString("rotWithShape", "1"); { _writer.WriteStartElement(Dml.Prefix, "gsLst", Dml.Ns); { _writer.WriteStartElement(Dml.Prefix, "gs", Dml.Ns); _writer.WriteAttributeString("pos", "0"); _writer.WriteStartElement(Dml.Prefix, "srgbClr", Dml.Ns); _writer.WriteAttributeString("val", rgbFore.SixDigitHexCode.ToUpper()); //if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillOpacity)) //{ // _writer.WriteStartElement(Dml.Prefix, "alpha", Dml.Ns); // _writer.WriteAttributeString("val", Math.Round(((decimal)so.OptionsByID[ShapeOptions.PropertyId.fillOpacity].op / 65536 * 100000)).ToString()); //we need the percentage of the opacity (65536 means 100%) // _writer.WriteEndElement(); //} _writer.WriteEndElement(); _writer.WriteEndElement(); _writer.WriteStartElement(Dml.Prefix, "gs", Dml.Ns); _writer.WriteAttributeString("pos", "100000"); _writer.WriteStartElement(Dml.Prefix, "srgbClr", Dml.Ns); _writer.WriteAttributeString("val", rgbBack.SixDigitHexCode.ToUpper()); //if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillBackOpacity)) //{ // _writer.WriteStartElement(Dml.Prefix, "alpha", Dml.Ns); // _writer.WriteAttributeString("val", Math.Round(((decimal)so.OptionsByID[ShapeOptions.PropertyId.fillBackOpacity].op / 65536 * 100000)).ToString()); //we need the percentage of the opacity (65536 means 100%) // _writer.WriteEndElement(); //} _writer.WriteEndElement(); _writer.WriteEndElement(); } _writer.WriteEndElement(); //gsLst switch (fillType) { case 0x5: case 0x6: _writer.WriteStartElement(Dml.Prefix, "path", Dml.Ns); _writer.WriteAttributeString("path", "shape"); _writer.WriteStartElement(Dml.Prefix, "fillToRect", Dml.Ns); _writer.WriteAttributeString("l", "50000"); _writer.WriteAttributeString("t", "50000"); _writer.WriteAttributeString("r", "50000"); _writer.WriteAttributeString("b", "50000"); _writer.WriteEndElement(); _writer.WriteEndElement(); //path break; case 0x7: decimal angle = 90; if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillAngle)) { if (so.OptionsByID[ShapeOptions.PropertyId.fillAngle].op != 0) { byte[] bytes = BitConverter.GetBytes(so.OptionsByID[ShapeOptions.PropertyId.fillAngle].op); int integral = BitConverter.ToInt16(bytes, 0); uint fractional = BitConverter.ToUInt16(bytes, 2); decimal result = integral + ((decimal)fractional / (decimal)65536); angle = 65536 - fractional; //I have no idea why this works!! angle = angle - 90; if (angle < 0) { angle += 360; } } } _writer.WriteStartElement(Dml.Prefix, "lin", Dml.Ns); angle *= 60000; if (angle > 5400000) { angle = 5400000; } _writer.WriteAttributeString("ang", angle.ToString()); _writer.WriteAttributeString("scaled", "1"); _writer.WriteEndElement(); break; default: _writer.WriteStartElement(Dml.Prefix, "path", Dml.Ns); _writer.WriteAttributeString("path", "rect"); _writer.WriteStartElement(Dml.Prefix, "fillToRect", Dml.Ns); _writer.WriteAttributeString("r", "100000"); _writer.WriteAttributeString("b", "100000"); _writer.WriteEndElement(); _writer.WriteEndElement(); //path break; } } _writer.WriteEndElement(); //gradFill break; //case 0x7: //shadescale //_writer.WriteStartElement(Dml.Prefix, "gradFill", Dml.Ns); //_writer.WriteAttributeString("rotWithShape", "1"); //_writer.WriteStartElement(Dml.Prefix, "gsLst", Dml.Ns); //bool switchColors = false; //decimal angle = 90; //if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillAngle)) //{ // if (so.OptionsByID[ShapeOptions.PropertyId.fillAngle].op != 0) // { // byte[] bytes = BitConverter.GetBytes(so.OptionsByID[ShapeOptions.PropertyId.fillAngle].op); // int integral = BitConverter.ToInt16(bytes, 0); // uint fractional = BitConverter.ToUInt16(bytes, 2); // decimal result = integral + ((decimal)fractional / (decimal)65536); // angle = 65536 - fractional; //I have no idea why this works!! // angle = angle - 90; // if (angle < 0) // { // angle += 360; // switchColors = true; // } // } //} //Dictionary<int, string> shadeColorsDic = new Dictionary<int, string>(); //List<string> shadeColors = new List<string>(); //if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillShadeColors)) //{ // uint length = so.OptionsByID[ShapeOptions.PropertyId.fillShadeColors].op; // //An IMsoArray record that specifies colors and their relative positions. // //Each element of the array contains an OfficeArtCOLORREF record color and a FixedPoint, as specified in [MS-OSHARED] // //section 2.2.1.6, that specifies its relative position along the gradient vector. // byte[] data = so.OptionsByID[ShapeOptions.PropertyId.fillShadeColors].opComplex; // int pos = 0; // string colval; // FixedPointNumber fixedpoint; // UInt16 nElems = BitConverter.ToUInt16(data, pos); // pos += 2; // UInt16 nElemsAlloc = BitConverter.ToUInt16(data, pos); // pos += 2; // UInt16 cbElem = BitConverter.ToUInt16(data, pos); // pos += 2; // if (cbElem == 0xFFF0) // { // //If this value is 0xFFF0 then this record is an array of truncated 8 byte elements. Only the 4 low-order bytes are recorded. Each element's 4 high-order bytes equal 0x00000000 and each element's 4 low-order bytes are contained in data. // } // else // { // while (pos < length) // { // colval = Utils.getRGBColorFromOfficeArtCOLORREF(BitConverter.ToUInt32(data, pos), slide, so); // pos += 4; // fixedpoint = new FixedPointNumber(BitConverter.ToUInt16(data, pos), BitConverter.ToUInt16(data, pos + 2)); // shadeColors.Insert(0, colval); // pos += 4; // } // } //} //else //{ // bool switchcolors = false; // if (switchColors & so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillBackColor)) // { // colorval = Utils.getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[ShapeOptions.PropertyId.fillBackColor].op, slide, so); // } // else // { // if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillColor)) // { // colorval = Utils.getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[ShapeOptions.PropertyId.fillColor].op, slide, so); // } // else // { // colorval = "FFFFFF"; //TODO: find out which color to use in this case // switchcolors = true; // } // } // if (switchColors | !so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillBackColor)) // { // colorval2 = Utils.getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[ShapeOptions.PropertyId.fillColor].op, slide, so); // } // else // { // colorval2 = Utils.getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[ShapeOptions.PropertyId.fillBackColor].op, slide, so); // } // if (switchcolors) // { // //this is a workaround for a bug. Further analysis necessarry // string dummy = colorval; // colorval = colorval2; // colorval2 = dummy; // } // shadeColors.Add(colorval); // shadeColors.Add(colorval2); //} //int gspos; //string col; //for (int i = 0; i < shadeColors.Count; i++) //{ // col = shadeColors[i]; // if (i == 0) // { // gspos = 0; // } // else if (i == shadeColors.Count - 1) // { // gspos = 100000; // } // else // { // gspos = i * 100000 / shadeColors.Count; // } // _writer.WriteStartElement(Dml.Prefix, "gs", Dml.Ns); // _writer.WriteAttributeString("pos", gspos.ToString()); // _writer.WriteStartElement(Dml.Prefix, "srgbClr", Dml.Ns); // _writer.WriteAttributeString("val", col); // if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillOpacity)) // { // _writer.WriteStartElement(Dml.Prefix, "alpha", Dml.Ns); // decimal alpha = Math.Round(((decimal)so.OptionsByID[ShapeOptions.PropertyId.fillOpacity].op / 65536 * 100000)); //we need the percentage of the opacity (65536 means 100%) // _writer.WriteAttributeString("val", alpha.ToString(CultureInfo.InvariantCulture)); // _writer.WriteEndElement(); // } // if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillShadeType)) // { // uint flags = so.OptionsByID[ShapeOptions.PropertyId.fillShadeType].op; // bool none = Tools.Utils.BitmaskToBool(flags, 0x1); // bool gamma = Tools.Utils.BitmaskToBool(flags, 0x1 << 1); // bool sigma = Tools.Utils.BitmaskToBool(flags, 0x1 << 2); // bool band = Tools.Utils.BitmaskToBool(flags, 0x1 << 3); // bool onecolor = Tools.Utils.BitmaskToBool(flags, 0x1 << 4); // if (gamma) _writer.WriteElementString(Dml.Prefix, "gamma", Dml.Ns, ""); // if (band) // { // _writer.WriteStartElement(Dml.Prefix, "shade", Dml.Ns); // _writer.WriteAttributeString("val", "37255"); // _writer.WriteEndElement(); // } // if (gamma) _writer.WriteElementString(Dml.Prefix, "invGamma", Dml.Ns, ""); // } // _writer.WriteEndElement(); // _writer.WriteEndElement(); //} //////new colorval ////_writer.WriteStartElement(Dml.Prefix, "gs", Dml.Ns); ////_writer.WriteAttributeString("pos", "100000"); ////_writer.WriteStartElement(Dml.Prefix, "srgbClr", Dml.Ns); ////_writer.WriteAttributeString("val", colorval2); ////if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillBackOpacity)) ////{ //// _writer.WriteStartElement(Dml.Prefix, "alpha", Dml.Ns); //// _writer.WriteAttributeString("val", Math.Round(((decimal)so.OptionsByID[ShapeOptions.PropertyId.fillBackOpacity].op / 65536 * 100000)).ToString()); //we need the percentage of the opacity (65536 means 100%) //// _writer.WriteEndElement(); ////} ////_writer.WriteEndElement(); ////_writer.WriteEndElement(); //_writer.WriteEndElement(); //gsLst //_writer.WriteStartElement(Dml.Prefix, "lin", Dml.Ns); //angle *= 60000; //if (angle > 5400000) angle = 5400000; //_writer.WriteAttributeString("ang", angle.ToString()); //_writer.WriteAttributeString("scaled", "1"); //_writer.WriteEndElement(); //_writer.WriteEndElement(); break; case 0x8: //shadetitle case 0x9: //background break; } }