예제 #1
0
 private void DropCapsParagraph()
 {
     string currentParentStyle = _paragraphName;
     _writer.WriteStartElement("text:p");
     int noOfChar = _reader.Value.Length;
     string currentStyle = _className + noOfChar;
     ModifyLOStyles oom = new ModifyLOStyles();
     oom.CreateDropCapStyle(_styleFilePath, _className, currentStyle, currentParentStyle, noOfChar);
     _writer.WriteAttributeString("text:style-name", currentStyle);
 }
예제 #2
0
        /// -------------------------------------------------------------------------------------------
        /// <summary>
        /// Generate last block of Content.xml
        /// 
        /// <list> 
        /// </list>
        /// </summary>
        /// <returns> </returns>
        /// -------------------------------------------------------------------------------------------
        private void CloseFile(string targetPath)
        {
            try
            {
                string targetFile = targetPath + "content.xml";
                _writer.WriteEndElement();
                _writer.WriteEndDocument();
                _writer.Flush();
                _writer.Close();

                if (_dictColumnGapEm != null && _dictColumnGapEm.Count > 0)
                {
                    var xmlDoc = new XmlDocument { PreserveWhitespace = true };
                    var nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
                    nsmgr.AddNamespace("st", "urn:oasis:names:tc:opendocument:xmlns:style:1.0");
                    nsmgr.AddNamespace("fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
                    xmlDoc.Load(targetFile);
                    XmlElement root = xmlDoc.DocumentElement;

                    ModifyLOStyles modifyIDStyles = new ModifyLOStyles();
                    Dictionary<string, XmlNode> ColumnGap = modifyIDStyles.SetColumnGap(targetFile, _dictColumnGapEm);
                    foreach (KeyValuePair<string, XmlNode> secName in ColumnGap)
                    {
                        string style = "//st:style[@st:name='" + secName.Key + "']//st:columns";
                        if (root != null)
                        {
                            XmlNode ele = root.SelectSingleNode(style, nsmgr);
                            if (ele != null)
                            {
                                for (int i = ele.ChildNodes.Count - 1; i >= 0; i--)
                                {
                                    if (ele.ChildNodes[i].Name == "style:column" || ele.ChildNodes[i].Name == "#whitespace")
                                    {
                                        ele.RemoveChild(ele.ChildNodes[i]);
                                    }
                                }
                                XmlNode colNode = ColumnGap[secName.Key];
                                XmlDocumentFragment styleNode = xmlDoc.CreateDocumentFragment();
                                styleNode.InnerXml = colNode.InnerXml;
                                ele.AppendChild(styleNode);
                            }
                        }
                    }
                    xmlDoc.Save(targetFile);
                }
            }
            catch
            {
            }
        }
예제 #3
0
        private void CreatingLogoFrame(string strFrameStyCount, string strFrameCount, string wrapSide, string HoriAlignment,
                                       string rectWidth, string rectHeight, string strGraphicsCount, string fileName)
        {
            // 1st frame
            _writer.WriteStartElement("draw:frame");
            _writer.WriteAttributeString("draw:style-name", strFrameStyCount);
            _writer.WriteAttributeString("draw:name", strFrameCount);

            string imgWUnit = "pt";
            string anchorType = string.Empty;
            if (_imagePreviousFinished)
            {
                anchorType = "char";
                _writer.WriteAttributeString("text:anchor-type", anchorType);
                _writer.WriteAttributeString("draw:z-index", "2");
                wrapSide = "both";
                HoriAlignment = "center";
            }
            else if (HoriAlignment.Length > 0)
            {
                anchorType = "paragraph";
                if (_allStyle.Peek().IndexOf("logo") != 0 && (HoriAlignment == "top" || HoriAlignment == "bottom"))
                    anchorType = "page";
                _writer.WriteAttributeString("text:anchor-type", anchorType);
                _writer.WriteAttributeString("draw:z-index", "1");
            }
            else
            {
                anchorType = "as-char";
                _writer.WriteAttributeString("text:anchor-type", anchorType);
                _writer.WriteAttributeString("draw:z-index", "0");
            }

            string width = rectWidth;
            if (rectWidth.IndexOf("%") == -1)
                width = rectWidth + imgWUnit;

            string height = rectHeight;
            if (rectHeight.IndexOf("%") == -1)
                height = rectHeight + imgWUnit;

            if (_allStyle.Peek().IndexOf("logo") == 0)
            {
                _writer.WriteAttributeString("svg:width", "2.3063in");
            }
            else if (_allStyle.Peek().IndexOf("LText_FrontMatter") == 0)
            {
                _writer.WriteAttributeString("svg:width", ".7in");
            }
            else
            {
                if (width != "100%")
                    _writer.WriteAttributeString("svg:width", width);
                _writer.WriteAttributeString("svg:height", height);
            }

            //TD-349(width:auto)
            if (_isAutoWidthforCaption)
            {
                _writer.WriteAttributeString("fo:min-width", rectWidth + imgWUnit);
            }

            //1st textbox
            _writer.WriteStartElement("draw:text-box");
            _writer.WriteAttributeString("fo:min-height", _allStyle.Peek().IndexOf("logo") == 0 ? "1in" : "0in");


            _frameCount++;

            if (_allStyle.Peek().ToLower().IndexOf("picturenone") == 0)
            {
                HoriAlignment = "center";
                wrapSide = "none";
            }
            else if (_allStyle.Peek().IndexOf("LText_FrontMatter") == 0)
            {
                HoriAlignment = "left";
                wrapSide = "center";
            }

            ModifyLOStyles modifyIDStyles = new ModifyLOStyles();
            modifyIDStyles.CreateGraphicsStyleLogo(_styleFilePath, strGraphicsCount, _util.ParentName, HoriAlignment,
                                                   wrapSide);
            if (_allStyle.Peek().IndexOf("LText_FrontMatter") == 0)
            {
                wrapSide = "logo";
            }
            modifyIDStyles.CreateFrameStyleLogo(_styleFilePath, strFrameStyCount, _util.ParentName, HoriAlignment,
                                                wrapSide, strGraphicsCount);

            _writer.WriteStartElement("draw:frame");
            _writer.WriteAttributeString("draw:style-name", "gr" + (_frameCount));
            _writer.WriteAttributeString("draw:name", strGraphicsCount);
            _writer.WriteAttributeString("text:anchor-type", "paragraph");

            if (rectWidth.IndexOf("%") == -1)
            {
                width = rectWidth + imgWUnit;
                _writer.WriteAttributeString("svg:width", width);
            }
            if (rectHeight.IndexOf("%") == -1)
            {
                height = rectHeight + imgWUnit;
                _writer.WriteAttributeString("svg:height", height);
            }

            _writer.WriteStartElement("draw:image");
            _writer.WriteAttributeString("xlink:type", "simple");
            _writer.WriteAttributeString("xlink:show", "embed");
            _writer.WriteAttributeString("xlink:actuate", "onLoad");
            _writer.WriteAttributeString("xlink:href", "Pictures/" + fileName);
            _writer.WriteEndElement();
            _writer.WriteStartElement("svg:title");
            _writer.WriteString(fileName);
            _writer.WriteEndElement();
            _writer.WriteEndElement();
        }
예제 #4
0
 private void UpdateRelativeInStylesXML()
 {
     ModifyLOStyles modifyIDStyles = new ModifyLOStyles();
     modifyIDStyles.ModifyStylesXML(_projectPath, _newProperty, _usedStyleName, _languageStyleName, "", IsHeadword, ParentClass, _projInfo.HeaderFontName);
 }
예제 #5
0
        private void WritingDrawPictureStyle(string width, string height, string strGraphicsCount, string strFrameStyCount, string rectWidth, string imgWUnit,
                                             string rectHeight, string fileName)
        {
            
            ModifyLOStyles modifyIDStyles = new ModifyLOStyles();
            modifyIDStyles.CreateGraphicsStyle(_styleFilePath, strGraphicsCount, _util.ParentName, _displayProperty);
            modifyIDStyles.CreateFrameStyle(_styleFilePath, strFrameStyCount, _util.ParentName, _displayProperty,
                                            strGraphicsCount);

            _writer.WriteStartElement("draw:frame");
            _writer.WriteAttributeString("draw:style-name", "gr" + (_frameCount));
            _writer.WriteAttributeString("draw:name", strGraphicsCount);
            _writer.WriteAttributeString("text:anchor-type", "paragraph");

            if (rectWidth.IndexOf("%") == -1)
            {
                width = rectWidth + imgWUnit;
                _writer.WriteAttributeString("svg:width", width);
            }
            if (rectHeight.IndexOf("%") == -1)
            {
                height = rectHeight + imgWUnit;
                _writer.WriteAttributeString("svg:height", height);
            }

            _writer.WriteStartElement("draw:image");
            _writer.WriteAttributeString("xlink:type", "simple");
            _writer.WriteAttributeString("xlink:show", "embed");
            _writer.WriteAttributeString("xlink:actuate", "onLoad");
            _writer.WriteAttributeString("xlink:href", "Pictures/" + fileName);
            _writer.WriteEndElement();
            _writer.WriteStartElement("svg:title");
            _writer.WriteString(fileName);
            _writer.WriteEndElement();
            _writer.WriteEndElement();
        }