Beispiel #1
0
        /// <summary>
        /// Writes a slide master.
        ///
        /// A slide master can either be a main master (type MainMaster) or title master (type Slide).
        /// <param name="ppt">PowerpointDocument record</param>
        /// <param name="m">Main master record</param>
        private void WriteMainMaster(PowerpointDocument ppt, MainMaster m)
        {
            _writer.WriteStartElement("p", "sldMasterId", OpenXmlNamespaces.PresentationML);

            MasterMapping mapping = _ctx.GetOrCreateMasterMappingByMasterId(m.PersistAtom.SlideId);

            mapping.Write();

            string relString = mapping.targetPart.RelIdToString;

            _writer.WriteAttributeString("r", "id", OpenXmlNamespaces.Relationships, relString);

            _writer.WriteEndElement();
        }
Beispiel #2
0
        public void ApplyHandoutMaster(RegularContainer handoutMaster)
        {
            _Master = handoutMaster;
            MainMaster m = this._ctx.Ppt.MainMasterRecords[0];
            List <TextMasterStyleAtom> atoms = m.AllChildrenWithType <TextMasterStyleAtom>();

            foreach (TextMasterStyleAtom atom in atoms)
            {
                if (atom.Instance == 2)
                {
                    noteAtoms.Add(atom);
                }
            }

            _writer.WriteStartElement("p", "handoutStyle", OpenXmlNamespaces.PresentationML);

            ParagraphRun9 pr9 = null;

            foreach (TextMasterStyleAtom atom in noteAtoms)
            {
                lastSpaceBefore = 0;
                lastBulletFont  = "";
                lastBulletChar  = "";
                lastBulletColor = "";
                lastColor       = "";
                lastSize        = "";
                for (int i = 0; i < atom.IndentLevelCount; i++)
                {
                    pr9 = null;
                    writepPr(atom.CRuns[i], atom.PRuns[i], pr9, i, true);
                }
                for (int i = atom.IndentLevelCount; i < 9; i++)
                {
                    pr9 = null;
                    writepPr(atom.CRuns[0], atom.PRuns[0], pr9, i, true);
                }
            }

            _writer.WriteEndElement();
        }
Beispiel #3
0
    /**
     * Constructs a SlideMaster from the MainMaster record,
     *
     */
    public SlideMaster(MainMaster record, int sheetNo) {
        base(record, sheetNo);

        _Runs = FindTextRuns(getPPDrawing());
        for (int i = 0; i < _Runs.Length; i++) _Runs[i].SetSheet(this);
    }
Beispiel #4
0
        /**
         * Display Message Box
         */
        public static void displayMessageBox(Page objThis, string strMessage, string strURLToRedirect)
        {
            MainMaster objMasterPage = (MainMaster)objThis.Master;

            objMasterPage.showMessage(strMessage, strURLToRedirect);
        }
Beispiel #5
0
        override public void Apply(RegularContainer slide)
        {
            this.Slide = (Slide)slide;
            TraceLogger.DebugInternal("SlideMapping.Apply");

            // Associate slide with slide layout
            SlideAtom           slideAtom     = slide.FirstChildWithType <SlideAtom>();
            UInt32              mainMasterId  = GetMainMasterId(slideAtom);
            MasterLayoutManager layoutManager = _ctx.GetOrCreateLayoutManagerByMasterId(mainMasterId);

            SlideLayoutPart            layoutPart = null;
            RoundTripContentMasterId12 masterInfo = slide.FirstChildWithType <RoundTripContentMasterId12>();

            // PPT2007 OOXML-Layout
            if (masterInfo != null)
            {
                layoutPart = layoutManager.GetLayoutPartByInstanceId(masterInfo.ContentMasterInstanceId);
            }
            // Pre-PPT2007 Title master layout
            else if (mainMasterId != slideAtom.MasterId)
            {
                layoutPart = layoutManager.GetOrCreateLayoutPartForTitleMasterId(slideAtom.MasterId);
            }
            // Pre-PPT2007 SSlideLayoutAtom primitive SlideLayoutType layout
            else
            {
                MainMaster m = (MainMaster)_ctx.Ppt.FindMasterRecordById(slideAtom.MasterId);
                if (m.Layouts.Count == 1 && slideAtom.Layout.Geom == SlideLayoutType.Blank)
                {
                    foreach (string layout in m.Layouts.Values)
                    {
                        string output = Tools.Utils.replaceOutdatedNamespaces(layout);
                        layoutPart = layoutManager.GetOrCreateLayoutPartByCode(output);
                    }
                }
                else
                {
                    layoutPart = layoutManager.GetOrCreateLayoutPartByLayoutType(slideAtom.Layout.Geom, slideAtom.Layout.PlaceholderTypes);
                }
            }

            this.targetPart.ReferencePart(layoutPart);

            // Start the document
            _writer.WriteStartDocument();
            _writer.WriteStartElement("p", "sld", OpenXmlNamespaces.PresentationML);

            // Force declaration of these namespaces at document start
            _writer.WriteAttributeString("xmlns", "a", null, OpenXmlNamespaces.DrawingML);
            // Force declaration of these namespaces at document start
            _writer.WriteAttributeString("xmlns", "r", null, OpenXmlNamespaces.Relationships);


            if (Tools.Utils.BitmaskToBool(slideAtom.Flags, 0x1 << 0) == false)
            {
                _writer.WriteAttributeString("showMasterSp", "0");
            }

            // TODO: Write slide data of master slide
            _writer.WriteStartElement("p", "cSld", OpenXmlNamespaces.PresentationML);

            ShapeContainer sc = slide.FirstChildWithType <PPDrawing>().FirstChildWithType <DrawingContainer>().FirstChildWithType <ShapeContainer>();

            if (sc != null)
            {
                Shape        sh = sc.FirstChildWithType <Shape>();
                ShapeOptions so = sc.FirstChildWithType <ShapeOptions>();

                if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.FillStyleBooleanProperties))
                {
                    bool ignore = false;
                    if (sc.AllChildrenWithType <ShapeOptions>().Count > 1)
                    {
                        ShapeOptions so2 = sc.AllChildrenWithType <ShapeOptions>()[1];
                        if (so2.OptionsByID.ContainsKey(ShapeOptions.PropertyId.FillStyleBooleanProperties))
                        {
                            FillStyleBooleanProperties p2 = new FillStyleBooleanProperties(so2.OptionsByID[ShapeOptions.PropertyId.FillStyleBooleanProperties].op);
                            if (!p2.fUsefFilled || !p2.fFilled)
                            {
                                ignore = true;
                            }
                        }
                    }

                    SlideAtom sa = slide.FirstChildWithType <SlideAtom>();
                    if (Tools.Utils.BitmaskToBool(sa.Flags, 0x1 << 2))
                    {
                        ignore = true;                                                //this means the slide gets its background from the master
                    }
                    if (!ignore)
                    {
                        _writer.WriteStartElement("p", "bg", OpenXmlNamespaces.PresentationML);
                        _writer.WriteStartElement("p", "bgPr", OpenXmlNamespaces.PresentationML);
                        FillStyleBooleanProperties p = new FillStyleBooleanProperties(so.OptionsByID[ShapeOptions.PropertyId.FillStyleBooleanProperties].op);
                        if (p.fUsefFilled & p.fFilled) //  so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.fillType))
                        {
                            new FillMapping(_ctx, _writer, this).Apply(so);
                        }
                        _writer.WriteElementString("a", "effectLst", OpenXmlNamespaces.DrawingML, "");
                        _writer.WriteEndElement(); //p:bgPr
                        _writer.WriteEndElement(); //p:bg
                    }
                }
            }


            _writer.WriteStartElement("p", "spTree", OpenXmlNamespaces.PresentationML);

            shapeTreeMapping = new ShapeTreeMapping(_ctx, _writer);
            shapeTreeMapping.parentSlideMapping = this;
            shapeTreeMapping.Apply(slide.FirstChildWithType <PPDrawing>());

            checkHeaderFooter(shapeTreeMapping);

            _writer.WriteEndElement(); //spTree
            _writer.WriteEndElement(); //cSld

            // TODO: Write clrMapOvr

            if (slide.FirstChildWithType <SlideShowSlideInfoAtom>() != null)
            {
                new SlideTransitionMapping(_ctx, _writer).Apply(slide.FirstChildWithType <SlideShowSlideInfoAtom>());
            }

            if (slide.FirstChildWithType <ProgTags>() != null)
            {
                if (slide.FirstChildWithType <ProgTags>().FirstChildWithType <ProgBinaryTag>() != null)
                {
                    if (slide.FirstChildWithType <ProgTags>().FirstChildWithType <ProgBinaryTag>().FirstChildWithType <ProgBinaryTagDataBlob>() != null)
                    {
                        new AnimationMapping(_ctx, _writer).Apply(slide.FirstChildWithType <ProgTags>().FirstChildWithType <ProgBinaryTag>().FirstChildWithType <ProgBinaryTagDataBlob>(), this, shapeTreeMapping.animinfos, shapeTreeMapping);
                    }
                }
            }


            // End the document
            _writer.WriteEndElement(); //sld
            _writer.WriteEndDocument();

            _writer.Flush();
        }