Xwriterlib text editor middleware software technical whitepaper

Source: Internet
Author: User
Tags bmp image

 

 

 

 

 

Xwriterlib text editor middleware software

Technical whitepaper

(Draft)

 

 

 

Yuan Yongfu

2007-11-5

 

 

 

 

 

 

Preface

Xwriterlib text editor middleware is an advanced graphics software component developed by xdesigner graphics software studio. It provides a powerful foundation for developers to develop professional Rich Text Editor software, this document describes the technical aspects of the xwriterlib text editor middleware software, so that readers can have a basic understanding of the xwriterlib software to facilitate in-depth understanding and development.

The xwriterlib text editor middleware software is referred to as xwriterlib.

 

This document is suitable for readers.

This document is suitable for readers who want to learn about xwriterlib's computer software developers. This document mainly describes the basic technology of xwriterlib and does not detail the development interfaces and processes of xwriterlib. For more information about the xwriterlib programming interfaces, see the xwriterlib user manual.

Contact information of the author

If you are interested in xwriterlib, contact the author through the following contact information:

MSNYyf9989@hotmail.com

Email Yyf9989@sohu.com 

OICQ 28348092

Yuan Yongfu personal website Http://www.xdesigner.cn 

Author's blog website Http://xdesigner.cnblogs.com(By blog Http://www.cnblogs.com Provide)

 

Basic Concepts

This chapter describes some concepts involved in xwriterlib to help readers better read and understand this document. This chapter involves the basic concepts of Rich Text Editor, graphic development of MS dot. net, Document Object Model, RTF document format and other concepts, if the reader has understood this content can skip this chapter.

Text Editor/Rich Text Editor

The biggest purpose of a computer is to process information. It is very important to process text information. Text processing mainly includes the input, edit, save, and print functions of text documents, in addition, the user interface also provides a WYSIWYG user experience. These functions are required by professional text editors.

In addition, in many cases, a text document is not limited to plain text content, but a so-called rich text document content. In rich text documents, you can set the color of the text, font style. You can also set the alignment, line spacing, and Character spacing of the document content. In addition, you can insert images and other non-text content. The Rich Text Editor can be called Rich Text Editor. The text editor mentioned below is a rich text editor.

There are already many professional text editor software, such as Microsoft Word, Kingsoft WPS, and other large-scale generic text processing software. There are also some small text editor software, such as Windows wordpad.

The text editor is widely used and is the most widely used software except the operating system. Most computer operators need to use a text editor to edit various text documents. Software developers need to useCodeText Editor to inputProgramCode. It is foreseeable that, for a long time to come, the text editor software type is still one of the main types of computer software and is a basic software.

The text editor is also a software type with high technical content. The development of Text Editor involves many computer software development technologies, including file loading and storage, Document Object Model, advanced graphics software technology, high-performance graphics programming, text typographical technology, and so on. Therefore, the text editor has a high technical threshold and is difficult to develop. Therefore, it must be developed by excellent software developers.

In the domestic software industry, most software developers develop industrial application software. Some customers need text editor software modules, the use of MS Word components, IE browser components, and other text editor components for development due to the functional limitations of these components and lackSource codeIn-depth secondary development, it is difficult for some customers to meet or cannot meet their needs. According to Microsoft's consistent business strategy, Microsoft is unlikely to provide more powerful text editor components than standard RichTextBox in the future, so developers have to face the task of developing complex software such as text editor.

Therefore, xwriterlib provides a new choice for these developers. It provides the basic functions of a Rich Text Editor and can develop various text editor modules at a low cost, and can obtain its source code through authorization, so that it can carry out in-depth secondary development with almost no limit to expand its functions, so as to meet the various needs of the customer.

Microsoft. NetGraphic Development

Microsoft. NET platform is a software development platform dominated by Microsoft. To some extent, it represents the advanced productivity of the international software industry. NET provides many advanced features, including strong graphic development functions.

Compared with the traditional WIN32API/GDI graphics development mode, Microsoft. NET provides stronger support for graph development and more friendly development interfaces. In the class library provided by it, the namespace system. drawing is a graphic programming interface. You can use object-oriented programming to develop graphics. This makes it easier to develop complex graphics software such as text editors.

Although Microsoft. NET provides stronger support for graph development and retains support for traditional WIN32API/GDI. In rare cases, you can still call WIN32API/GDI to achieve some graphic effects, for example, the screen pixel reversed color, the processing of the cursor, and the control of the text input method.

In most cases, Microsoft. NET provides the standard graphic development interface. In a few cases, we can develop a text editor software in WIN32API/GDI mode, in addition, the workload is much less than the full use of WIN32API/GDI.

Document Object Model

The text editor needs to process Rich Text documents. This document is a complex data structure, which may have a hierarchical structure and contains multiple document elements, in addition, the organization and sorting of various document elements are relatively free. For this complex data structure, the traditional process-orientedAlgorithmOr relational algorithms that are good at processing databases are difficult to process. In this case, it is more appropriate to use a fully object-oriented Document Object Model Technology for processing.

The Document Object Model is an example of object-oriented programming ideas in processing complex documents. Its basic working principle is to map programming objects in one memory to a part or element in the document, for example, a character element object is mapped to a character in the document, and an image Element Object is mapped to an image in the document. The application reads and modifies the data of programming objects in the memory. After these mappings, the application converts the data into reading and modifying the document content.

Document Object Model is a relatively advanced software design model. It fully utilizes various content of object-oriented programming ideas, including encapsulation, inheritance, and overloading, therefore, the development process is complicated, but it can process some complex data structures. In particular, it is suitable for processing complex Rich Text document data structures. Therefore, the Document Object Model must be used to process text documents in the text editor.CompositionIn this document, the Document Object Model of a text document is a core module in the text editor.

RTFDocument Format

The RTF document format is the Rich Text Document storage format proposed by Microsoft in the last century. It is a document format that stores a variety of information based on the ANSI character set dependency mark. This document format has a long history and is widely used. Currently, a large number of software programs support this document format. Windows operating systems also support the RTF format. Therefore, it is necessary to develop a Rich Text Document editor to support the RTF document format. If the RTF format is supported, the text editor can exchange text documents with a large number of other software.

The storage format of the RTF document is relatively simple, but there are many contents. It uses a pair of curly braces to define a tag group. The tag group can be embedded and defined, use a slash (\) to start defining a tag or command. This simple label format is used in the RTF document to define text, paragraphs, pictures, and other information.

For details about the RTF document format, refer to the Technical Manual of the RTF document provided by Microsoft.

 

XwriterlibIntroduction

XwriterlibDevelopment Background

With the rapid development of the software industry in China, more and more information systems are being implemented and put into operation, and customers' requirements are getting higher and higher. It has begun to fall short of conventional relational database-based information systems, more and more advanced requirements for software systems, including new and higher requirements for user interfaces. In some cases, the customer may require the text editor software to be customized. In addition to the conventional text editing functions, you also need to add its own features based on your business needs.

Software developers can be relatively simple secondary development on some existing text editor components to achieve these functions, such as RichTextBox, MS word, IE browser and other components for development, to some extent, this can meet the functional requirements of custom text editors. However, these text editor components do not have flexible programming interfaces and do not have source code or detailed technical support, it is difficult to conduct in-depth secondary development involving the underlying components, so there are still a considerable number of customers who need functions that cannot be implemented. According to Microsoft's consistent business strategy, Microsoft is unlikely to provide more powerful text editor components than standard RichTextBox in the future.

If the existing text editor components cannot meet the requirements, developers can develop their own text editor components. However, the text editor components are quite advanced graphics software components and involve many software technologies, it is difficult to develop, and it takes a long time to develop. In addition, advanced software such as the text editor relies on the full development of excellent software developers. The conventional human tactics cannot complete such a development task. Therefore, a large number of developers do not have the ability or time to develop their own text editor components, which leads to the loss of some business opportunities due to technical reasons.

In view of this, xdesigner's graphic software studio has developed the xwriterlib text editor component after long-term research. This component is a fully functional Rich Text Editor first, in addition, a flexible and all-round programming interface is provided according to the actual needs of software developers, and developers can obtain the source code through authorization and perform further secondary development. Develop your own text editor based on xwriterlib to avoid complicated graphic software programming, reduce the workload, reduce development costs, and quickly meet customer needs.

XwriterlibIntroduction

Xwriterlib is a rich text editor component independently developed by xdesigner graphics software. It has full proprietary intellectual property rights for software developers at Microsoft. the development of highly customized text editor software on the. NET platform provides a solid foundation. With the support of xwriterlib, developers can obtain the following capabilities:

  1. It is easy to develop professional text editor software capabilities. Xwriterlib integrates the basic functions of the Rich Text Editor, encapsulates all software details, and provides friendly programming interfaces, developers can easily use the powerful xwriterlib functions and implement their own text editors without having to have strong software development capabilities.
  2. The ability to develop highly customized text editor software. In addition to implementing the common text editor functions, xwriterlib also provides a flexible and all-round Object-Oriented Programming Interface for development needs, in particular, a scalable Rich Text Document Object Model is provided, on which developers can implement their own text document functions. The xwriterlib function can be comprehensively modified, including editing features, typographical features, document saving formats, and print control. In addition, you can add your own document element types, which can be seamlessly integrated into xwriterlib document processing.
  3. In-depth secondary development capabilities. After authorization, developers can obtain the source code and technical support of xwriterlib, so that they can conduct in-depth secondary development and implement some special functions. For example, you can achieve hierarchical and dynamic locking of documents, logical deletion of documents, automatic and precise Modification Trace retention and viewing, and scattered saving and loading of documents, the WebService of document processing is open to other application systems, which are difficult or cannot be implemented by traditional text editor components such as RichTextBox and MS word.
  4. The ability to process documents quickly and efficiently in any type of software. In some software that does not have a graphical user interface and does not allow access to the desktop, such as ASP. net or Windows Services, the use of conventional text editor components is limited, such as RichTextBox or text editor based on IE browser components can not run, MS Word uses OLE automation technology, which consumes system resources and is an unstable cross-process operation. Xwriterlib directly provides the document processing programming interface. developers can.. net programs or Windows Services can use xwriterlib to quickly process documents. For example, you can provide snapshots of document views to other software and print output files.
  5. Seamless integration with Microsoft. NET software. Xwriterlib is fully developed using C # and implemented using managed code. Therefore, xwriterlib can be seamlessly integrated with any software based on the. NET platform for close collaboration. Application systems can be developed using C #, VB. NET, C ++. net, Delphi. net, or other languages that support. net, but xwriterlib can be easily called. Xwriterlib currently does not support mono.
  6. Easy deployment. Xwriterlib is a lightweight text editor component that only depends on Microsoft. the standard library provided by the. NET Framework does not rely on any third-party components. All parts are contained in a DLL file, which facilitates developers to deploy application software systems.

 

XwriterlibTechnical description

Xwriterlib involves many computer software development technologies, including many advanced development technologies. Some of these technologies are described here to help developers understand some technical details inside xwriterlib, so that xwriterlib can be fully called.

XwriterlibDocument Object Model

The xwriterlib Document Object Model (xdom) is the core module of xwriterlib. It is a scalable Document Object Model for rich text documents and fully considering the needs of secondary development. Developers can operate on this Document Object Model to operate on xwriter documents, or expand it to add new document element types to xwriter documents.

Xdom internally creates a tree structure to describe the document structure in detail, including the document structure framework and various details. In addition, considering secondary development, xdom opens a wide range of programming interfaces, this interface is much more open than the programming interface of MS Word or RichTextBox. Developers can use the xdom interface to access any information in the document and derive a custom document element type from the standard xdom, the new document element type can be used to extend or redefine the content, graphic styles, and operational features of standard document elements.

Important Document element types in xdom include:

Basic Types of xtextelement document elements

This type is the basic type of document elements. All document element types, including the document element types defined in xwriterlib or custom element types of future developers, it must be inherited directly or indirectly from xtextelement. This type defines common interfaces for some document elements and basic information such as the location and size of document elements. Developers can use this type to traverse any object in the document.

This type is an abstract type (in C #, it is an abstract type). Therefore, it cannot be instantiated. You can only derive the actually used document element type from it, the derived type needs to overload some of the Members to support their own painting process and operation features.

Xtextelementcontainer container element type

This type is an element type derived directly from xtextelement. It can contain several other document elements and other container elements.

Xtextdocument type

This type is derived from xtextelementcontainer and is used to represent text document objects and is the top-level node of xdom. It defines some information of the entire document and is the entry point for external programs to access the xdom structure.

Xtextelement, xtextelementcontainer, and xtextdocument constitute the basic framework of xdom, forming a tree structure with xtextdocument as the root node. The external program uses xtextdocument as the entry point to access the entire xdom.

 

In the basic framework of xdom, xwriterlib also defines some common document element types, mainly including

Xtextchar character type

The element type of xtextchar indicates a character in the document, including blank characters. All characters in the document correspond to an xtextchar object, therefore, the application can use the xtextchar type to quickly and accurately access any character in the document, and obtain and modify the display style of a single character, including the font, color, and upper/lower mark settings.

Xtextimage image type

The xtextimage document element type indicates an image in the document. You can drag the image to change the image size.

Xtextbookmark bookmark element type

The xtextbookmark element type is inserted somewhere in the document. It is used for users to quickly switch to the text section where the bookmarks are located.

Xtextparagraph paragraph element, xtextparagrapheof paragraph end type

Xtextparagraph and xtextparagrapheof section elements indicate the information of a paragraph in the document. In xdom, each element belongs to a paragraph (except the paragraph element itself ), the section object to which an element belongs dynamically changes with the editing operation. Therefore, the section structure of the document object changes dynamically during the editing process. In this case, to facilitate development, xdom constructs a paragraph structure based on xtextparagrapheof in real time.

 

Programming Interface

An obvious feature of xwriterlib is that it provides an all-round and highly transparent programming interface, which takes xdom as the core and covers all aspects of xwriterlib. Developers can use this programming interface to quickly and accurately access any part of the document, and this programming interface can be applied to any type. net Program, including winform. net, Asp.. net, command line program, and Windows service program.

With this programming interface, developers can also easily expand xwriterlib, customize the document element type, customize the document storage format, save the process, and add various editing user experience.

After authorization, the developer can also obtain a copy of the xwriterlib source code. The developer can expand the xwriterlib function almost without restrictions based on the xwriterlib source code.

 

Document typographical features

Xdom is a Text Document Object Model. Therefore, its content adopts a stream typographical style, that is, the document elements are arranged from left to right from top to bottom in order of order, currently, xdom only supports the arrangement from left to right from top to bottom, and does not support other stream typographical styles. For example, xdom does not support the arrangement style from right to left from top to bottom in the Middle East.

When xwriterlib loads a new document, it will typeset the entire document, calculate the document line for the entire document, and calculate the page. When the user edits the document and changes the document content, xwriterlib calculates the document lines and pages of some documents as needed. This reduces the document typographical workload caused by an editing operation, increases the speed at which the editor responds to the user editing operation, and reduces the user interface flickering during document editing.

Xwriterlib does not simply arrange document elements from left to right from top to bottom, but is accompanied by a considerable number of rules. The typographical process mainly includes the following rules:

  1. As agreed, some characters cannot start or end with the beginning or end of a document line. It is not allowed to appear at the beginning of the line.!),. :;?]} Too many then D ‖'"... ,. Legal disclaimer> "']. "'),.:;?] Bytes | }~ Bytes"; The character at the end of a row cannot be a front-end punctuation. Generally,"([{· '"[[[[. [{¥". When xwriterlib is typographical, if the first character of a text line is a post-punctuation, the last character of the previous text line needs to be put into the currently processed text line, therefore, the last line of text needs to be re-formatted. If the last character of a text line is a pre-punctuation and there is no space left to accommodate the next character, the line ends before it ends, place the punctuation in the next text line.
  2. If a document contains a consecutive English letter (26 letters, including uppercase and lowercase) and Arabic numerals, there are no other or non-character document elements in the middle, in typographical mode, the text is arranged as much as possible to the same document line, so that the text is kept as whole as possible without being separated. If the remaining space of the document line is insufficient to accommodate this part of the text, the line breaks in advance, which leads to a large blank area in the text line. However, in a few cases, if the length of a consecutive character exceeds the display width of the document, the rule is abandoned and the line feed is still unchanged.
  3. Right edge correction of the document. The width of a text line is generally equal to the display width of a document. It is a fixed value, but the sum of the display width of all document elements is not fixed, the element width is not necessarily equal to the width of the text line. As a result, the right edge of the document line looks uneven and affects the appearance. Therefore, you need to modify the right edge of the text line. The xwriterlib method is to subtract the width of the text line from the width of the document element and the resulting width, that is, the remaining width of the text line, try to evenly spread to the header of each element in the text line, and each element has a display width correction. In this way, the right edge of the text line is corrected, so that the Left and Right lines of the text lines are aligned.
    If the number of elements in a text line is large and the correction of the width of each element is small, the user will not notice the correction of the width. If the number of elements in a text line is small, the correction of the width of each element is relatively large, and the user will notice the correction of the element width. At this time, the elements in the text line look very loose.
    When aligning the right edge of a document, xwriterlib considers consecutive English letters and Arabic numerals. If the document contains consecutive English and Arabic numerals, then, the elements are not inserted between these characters. At this time, the width corrections they should undertake are transferred to other elements, and the tabs do not receive width corrections. This process also takes into account the appearance of the document.
    If a text line has only one document element or its last character is a line break (soft carriage return and hard carriage return), the right edge of the text line is not corrected.

 

WYSIWYG editing interface

Xwrtierlib implements the WYSIWYG editing interface, which integrates the editing interface and the print preview interface. The edit interface is the print preview interface. The document style displayed in the xwriterlib text editor is exactly the same as that displayed in the actual print output. When editing and modifying a document, xwriterlib dynamically typeset and pagination the document so that the editing interface is consistent with the output style. Xwriterlib adopts various internal optimization algorithms, so that xwriterlib dynamically maintains this WYSIWYG capability without affecting users' smooth document editing.

The WYSIWYG function of xwriterlib is based on the graphic display and printing capabilities provided by the Microsoft. NET Framework. Xwriterlib uses "system. drawing. graphicsunit. document "graphic measurement unit. The scale of this unit is 1/300 inch, which is an abstract measurement unit independent of hardware. Therefore, xwriterlib can output devices (including monitors and printers) in any image) the above implementation documents are output accurately.

When a document is displayed on a computer screen, you need to respond to mouse and keyboard events on the user interface because editing is also required. The computer screen is in pixels, pixel units are hardware-dependent measurement units. Therefore, xwriterlib converts these two units. When processing mouse data, you need to convert the pixel coordinates to the document coordinates, when displaying a document, you also need to convert the document coordinates into pixel coordinates. This operation is quite complex, but it is automatically completed within xwriterlib. Developers do not have to worry about specific algorithms.

Xwriterlib also supports the continuous playing function. When the text editor is in the continuous playing mode, you can click the mouse to set the continued position. The entire document is split into two parts, the continued position is covered by the Blue translucent area, while the continued position is normally displayed. During actual printing and output, some documents that are covered by the semi-blue transparent area are not printed, regardless of the text, image, or custom document elements, only the Document section at the bottom of the continued position will be printed and output, and the document page where the continued position is located will not output the header and footer. Xwriterlib provides a special printing method, which is suitable for printing certain log types of documents. In some applications, this function is required.

 

PairRTFDocument format support

The RTF document format is a widely used Rich Text document format. xwriterlib supports the RTF document format. xwriterlib can load and save the RTF document and copy and paste the RTF document fragments, you can also use OLE drag to drag an RTF document segment from another program to the document being edited. Compared with the standard RichTextBox component, xwriterlib enhances the support for RTF documents, and can load and save some document features not supported by standard RichTextBox, such as text background color and better support for hyperlinks.

Xwriterlib processes the RTF document internally and does not rely on other components to process the RTF document. xwriterlib implements the RTF document parser and generator internally, and integrates the RTF function into xdom.

 

PairHtmlDocument format support

Xwriterlib can output documents in HTML format. The generated HTML document code is very concise and complies with international standards without spam code, when outputting HTML documents, you can also output images included in the documents in PNG format. Therefore, you can complete the output of illustrated documents.

Xwriterlib implements the HTML document generator internally. Therefore, xwriterlib can independently output HTML documents without relying on other components.

 

Document loading and saving

Xwriterlib supports multiple methods to load and save documents. Xwriterlib supports the RTF format internally. Therefore, you can call its interface to load and save documents in the RTF format. Developers can also use plain text format to load and save unformatted text content.

Xwriterlib uses an internal XML serialization mechanism to serialize a document into an XML document or generate a document from an XML document deserialization. Therefore, developers can load and save the document in XML format.

Xwriterlib provides very transparent programming interfaces. Therefore, developers can directly traverse and access xdom to obtain all the information contained in the documents. Then, they can design their own document formats and save the documents in xwriterlib as custom formats, this process can also be designed for reverse execution to load documents according to custom document formats. This custom document format can be plain text, XML or binary.

Xwriterlib does not limit the document storage format. developers can save the document to a local file system, store it in a database, or directly upload it to a Web server. They can also use local files, databases, or load the document on the web server.

 

Collaboration with other software

Xwriterlib supports OLE drag-and-drop operations, and the windows clipboard communicates data with other software for collaborative work.

Xwriterlib supports OLE drag and drop operations to insert data into documents. Multiple data formats are supported. For example, if you drag a file with the extension BMP, PNG, JPG, JPEG, GIF, and EMF to the file in Windows Resource Manager, xwriterlib loads the file as an image file, if the image is loaded successfully, an image element is inserted in the document. If the drag and drop data is in BMP format, an image element is inserted in the document. The displayed image is the drag and drop BMP image. If the dragged data is in the RTF format, the RTF data will be parsed, and an RTF document segment will be inserted in the document. Therefore, you can drag a document segment from word to the xwriterlib document. If the dragged data is plain text, a text content is inserted into the document based on the plain text.

Xwriterlib supports the system clipboard to obtain document data. For example, if you copy a file with the extension BMP, PNG, JPG, JPEG, GIF, and EMF in Windows resource manager, an image element will be inserted in the document when xwriterlib is pasted, when the Clipboard contains a BMP image, the pasting operation inserts an image element in the document. When the Clipboard contains an RTF document segment, the paste operation inserts an RTF document in the document. If the Clipboard contains plain text data, the paste operation inserts a plain text content in the document.

Xwriterlib supports setting data to the system clipboard. Xwriterlib saves the plain text data and RTF data in the selected part of the document to the system clipboard at the same time. In this way, other software can use different versions of data. For example, a text editor such as NotePad can paste plain text data, and MS Word can also paste the RTF document data.

 

Running Environment

The xwriterlib runtime environment is as follows:

Operating SystemWindows2000,Windows XPOr later

Microsoft.NetFramework and version1.1Or later

Mouse support is required.

 

Development Language Support

VB. NET,C #Or other development languages that support the Microsoft. NET platform.

 

Copyright description

Xwriterlib does not use any open source code. All program design and programming are completely completed independently by Yuan Yongfu and have full proprietary intellectual property rights. Respect the author's intellectual property rights. Do not pirated, crack, or decompile the software. Please support original Chinese software. For more information, visit Http://xdesigner.cnblogs.com .

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.