DrawTextBox represent a draw text box which could be e.g. used to host graphic frame
Inheritance: IContent, IContentContainer
Example #1
0
 public void DrawTextBox()
 {
     //New TextDocument
     TextDocument textdocument = new TextDocument();
     textdocument.New();
     //Standard Paragraph
     Paragraph paragraphOuter = new Paragraph(textdocument, ParentStyles.Standard.ToString());
     //Create Frame for DrawTextBox
     Frame frameOuter = new Frame(textdocument, "frame1");
     //Create DrawTextBox
     DrawTextBox drawTextBox = new DrawTextBox(textdocument);
     //Create a paragraph for the drawing frame
     Paragraph paragraphInner = new Paragraph(textdocument, ParentStyles.Standard.ToString());
     //Create the frame with the Illustration resp. Graphic
     Frame frameIllustration = new Frame(textdocument, "frame2", "graphic1", _imagefile);
     //Add Illustration frame to the inner Paragraph
     paragraphInner.Content.Add(frameIllustration);
     //Add inner Paragraph to the DrawTextBox
     drawTextBox.Content.Add(paragraphInner);
     //Add the DrawTextBox to the outer Frame
     frameOuter.Content.Add(drawTextBox);
     //Add the outer Frame to the outer Paragraph
     paragraphOuter.Content.Add(frameOuter);
     //Add the outer Paragraph to the TextDocument
     textdocument.Content.Add(paragraphOuter);
     //Save the document
     textdocument.SaveTo(_framefile2);
 }
 void Example4()
 {
     string imagePath = @"Assets\ODFSample\Examples\example3.png";
     TextDocument textdocument = new TextDocument();
     textdocument.New();
     Paragraph pOuter = ParagraphBuilder.CreateStandardTextParagraph(textdocument);
     DrawTextBox drawTextBox = new DrawTextBox(textdocument);
     Frame frameTextBox = new Frame(textdocument, "fr_txt_box");
     frameTextBox.DrawName = "fr_txt_box";
     frameTextBox.ZIndex = "0";
     Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(textdocument);
     p.StyleName = "Illustration";
     Frame frame = new Frame(textdocument, "frame1", "graphic1", imagePath);
     frame.ZIndex = "1";
     p.Content.Add(frame);
     p.TextContent.Add(new SimpleText(textdocument, "Illustration"));
     drawTextBox.Content.Add(p);
     frameTextBox.SvgWidth = frame.SvgWidth;
     drawTextBox.MinWidth = frame.SvgWidth;
     drawTextBox.MinHeight = frame.SvgHeight;
     frameTextBox.Content.Add(drawTextBox);
     pOuter.Content.Add(frameTextBox);
     textdocument.Content.Add(pOuter);
     textdocument.SaveTo("example4_drawTextbox.odt");
 }
Example #3
0
        /// <summary>
        /// Builds the illustration frame.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="frameStyleName">Name of the frame style.</param>
        /// <param name="graphicName">Name of the graphic.</param>
        /// <param name="pathToGraphic">The path to graphic.</param>
        /// <param name="illustrationText">The illustration text.</param>
        /// <param name="illustrationNumber">The illustration number.</param>
        /// <returns>
        /// A new Frame object containing a DrawTextBox which contains the
        /// illustration Graphic object and a text sequence representing
        /// the displayed illustration text.
        /// </returns>
        public static Frame BuildIllustrationFrame(IDocument document, string frameStyleName, string graphicName,
                                                   string pathToGraphic, string illustrationText, int illustrationNumber)
        {
            DrawTextBox drawTextBox  = new DrawTextBox(document);
            Frame       frameTextBox = new Frame(document, frameStyleName);

            frameTextBox.DrawName = frameStyleName + "_" + graphicName;
            frameTextBox.ZIndex   = "0";

            Paragraph pIllustration = ParagraphBuilder.CreateStandardTextParagraph(document);

            pIllustration.StyleName = "Illustration";
            Frame frame = new Frame(document, "InnerFrame_" + frameStyleName,
                                    graphicName, pathToGraphic);

            frame.ZIndex = "1";

            pIllustration.Content.Add(frame);
            //add Illustration as text
            pIllustration.TextContent.Add(new SimpleText(document, "Illustration"));
            //add TextSequence
            TextSequence textSequence = new TextSequence(document);

            textSequence.Name      = "Illustration";
            textSequence.NumFormat = "1";
            textSequence.RefName   = "refIllustration" + illustrationNumber.ToString();
            textSequence.Formula   = "ooow:Illustration+1";
            textSequence.TextContent.Add(new SimpleText(document, illustrationNumber.ToString()));
            pIllustration.TextContent.Add(textSequence);
            //add the ilustration text
            pIllustration.TextContent.Add(new SimpleText(document, illustrationText));
            //add the Paragraph to the DrawTextBox
            drawTextBox.Content.Add(pIllustration);

            frameTextBox.SvgWidth = frame.SvgWidth;
            drawTextBox.MinWidth  = frame.SvgWidth;
            drawTextBox.MinHeight = frame.SvgHeight;
            frameTextBox.Content.Add(drawTextBox);

            return(frameTextBox);
        }
		/// <summary>
		/// Builds the illustration frame.
		/// </summary>
		/// <param name="document">The document.</param>
		/// <param name="frameStyleName">Name of the frame style.</param>
		/// <param name="graphicName">Name of the graphic.</param>
		/// <param name="pathToGraphic">The path to graphic.</param>
		/// <param name="illustrationText">The illustration text.</param>
		/// <param name="illustrationNumber">The illustration number.</param>
		/// <returns>
		/// A new Frame object containing a DrawTextBox which contains the
		/// illustration Graphic object and a text sequence representing
		/// the displayed illustration text.
		/// </returns>
		public static Frame BuildIllustrationFrame(IDocument document, string frameStyleName, string graphicName, 
			string pathToGraphic, string illustrationText, int illustrationNumber)
		{
			DrawTextBox drawTextBox			= new DrawTextBox(document);
			Frame frameTextBox				= new Frame(document, frameStyleName);
			frameTextBox.DrawName			= frameStyleName+"_"+graphicName;
			frameTextBox.ZIndex				= "0"; 

			Paragraph pIllustration			= ParagraphBuilder.CreateStandardTextParagraph(document);
			pIllustration.StyleName			= "Illustration";
			Frame frame						= new Frame(document, "InnerFrame_"+frameStyleName, 
				graphicName, pathToGraphic);
			frame.ZIndex					= "1";

			pIllustration.Content.Add(frame);
			//add Illustration as text
			pIllustration.TextContent.Add(new SimpleText(document, "Illustration"));			
			//add TextSequence
			TextSequence textSequence		= new TextSequence(document);
			textSequence.Name				= "Illustration";
			textSequence.NumFormat			= "1";
			textSequence.RefName			= "refIllustration"+illustrationNumber.ToString();
			textSequence.Formula			= "ooow:Illustration+1";
			textSequence.TextContent.Add(new SimpleText(document, illustrationNumber.ToString()));
			pIllustration.TextContent.Add(textSequence);
			//add the ilustration text
			pIllustration.TextContent.Add(new SimpleText(document, illustrationText));
			//add the Paragraph to the DrawTextBox
			drawTextBox.Content.Add(pIllustration);
			
			frameTextBox.SvgWidth			= frame.SvgWidth;
			drawTextBox.MinWidth			= frame.SvgWidth;
			drawTextBox.MinHeight			= frame.SvgHeight;
			frameTextBox.Content.Add(drawTextBox);

			return frameTextBox;
		}
		/// <summary>
		/// Creates the draw text box.
		/// </summary>
		/// <param name="drawTextBoxNode">The draw text box node.</param>
		/// <returns></returns>
		private DrawTextBox CreateDrawTextBox(XmlNode drawTextBoxNode)
		{
			try
			{
				DrawTextBox drawTextBox		= new DrawTextBox(this._document, drawTextBoxNode);
				ContentCollection iColl	= new ContentCollection();

				foreach(XmlNode nodeChild in drawTextBox.Node.ChildNodes)
				{
					IContent iContent				= this.CreateContent(nodeChild);
					if (iContent != null)
						//iColl.Add(iContent);
						AddToCollection(iContent, iColl);
					else
					{
						this.OnWarning(new AODLWarning("Couldn't create a IContent object for a DrawTextBox.", nodeChild));
					}
				}

				drawTextBox.Node.InnerXml					= "";

				foreach(IContent iContent in iColl)
					AddToCollection(iContent, drawTextBox.Content);
				//drawTextBox.Content.Add(iContent);

				return drawTextBox;
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to create a Graphic.", ex);
			}
		}
		/// <summary>
		/// Gets the draw text box as HTML.
		/// </summary>
		/// <param name="drawTextBox">The draw text box.</param>
		/// <returns></returns>
		public string GetDrawTextBoxAsHtml(DrawTextBox drawTextBox)
		{
			string html					= "";

			try
			{
				if (drawTextBox != null)
				{
					if (drawTextBox.Content != null)
					{
						html			+= this.GetIContentCollectionAsHtml(drawTextBox.Content);
					}
				}

				html					+= "\n";
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to build a HTML string from a ImageMap object.", ex);
			}

			return html;
		}
Example #7
0
		public void DrawTextBoxTest()
		{
			TextDocument textdocument		= new TextDocument();
			textdocument.New();
			Paragraph pOuter				= ParagraphBuilder.CreateStandardTextParagraph(textdocument);
			DrawTextBox drawTextBox			= new DrawTextBox(textdocument);
			Frame frameTextBox				= new Frame(textdocument, "fr_txt_box");
			frameTextBox.DrawName			= "fr_txt_box";
			frameTextBox.ZIndex				= "0";
			//			Paragraph pTextBox				= ParagraphBuilder.CreateStandardTextParagraph(textdocument);
			//			pTextBox.StyleName				= "Illustration";
			Paragraph p						= ParagraphBuilder.CreateStandardTextParagraph(textdocument);
			p.StyleName						= "Illustration";
			Frame frame						= new Frame(textdocument, "frame1",
				"graphic1", _imagefile);
			frame.ZIndex					= "1";
			p.Content.Add(frame);
			p.TextContent.Add(new SimpleText(textdocument, "Illustration"));
			drawTextBox.Content.Add(p);
			
			frameTextBox.SvgWidth			= frame.SvgWidth;
			drawTextBox.MinWidth			= frame.SvgWidth;
			drawTextBox.MinHeight			= frame.SvgHeight;
			frameTextBox.Content.Add(drawTextBox);
			pOuter.Content.Add(frameTextBox);
			textdocument.Content.Add(pOuter);
			textdocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+"drawTextbox.odt");
		}
        /// <summary>
        /// Creates the draw text box.
        /// </summary>
        /// <param name="drawTextBoxNode">The draw text box node.</param>
        /// <returns></returns>
        private DrawTextBox CreateDrawTextBox(XmlNode drawTextBoxNode)
        {
            try
            {
                DrawTextBox drawTextBox		= new DrawTextBox(this._document, drawTextBoxNode);
                IContentCollection iColl	= new IContentCollection();

                foreach(XmlNode nodeChild in drawTextBox.Node.ChildNodes)
                {
                    IContent iContent				= this.CreateContent(nodeChild);
                    if(iContent != null)
                        iColl.Add(iContent);
                    else
                    {
                        if(this.OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("Couldn't create a IContent object for a DrawTextBox.");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= nodeChild;
                            this.OnWarning(warning);
                        }
                    }
                }

                drawTextBox.Node.InnerXml					= "";

                foreach(IContent iContent in iColl)
                    drawTextBox.Content.Add(iContent);

                return drawTextBox;
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to create a Graphic.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node				= drawTextBoxNode;
                exception.OriginalException	= ex;

                throw exception;
            }
        }
Example #9
0
        /// <summary>
        /// Gets the draw text box as HTML.
        /// </summary>
        /// <param name="drawTextBox">The draw text box.</param>
        /// <returns></returns>
        public string GetDrawTextBoxAsHtml(DrawTextBox drawTextBox)
        {
            string html					= "";

            try
            {
                if(drawTextBox != null)
                {
                    if(drawTextBox.Content != null)
                    {
                        html			+= this.GetIContentCollectionAsHtml(drawTextBox.Content);
                    }
                }

                html					+= "\n";
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to build a HTML string from a ImageMap object.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.OriginalException	= ex;

                throw exception;
            }

            return html;
        }