Source Code Cross Referenced for RtfHyperLink.java in  » Graphic-Library » fop » org » apache » fop » render » rtf » rtflib » rtfdoc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Graphic Library » fop » org.apache.fop.render.rtf.rtflib.rtfdoc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        /* $Id: RtfHyperLink.java 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020:        package org.apache.fop.render.rtf.rtflib.rtfdoc;
021:
022:        /*
023:         * This file is part of the RTF library of the FOP project, which was originally
024:         * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
025:         * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
026:         * the FOP project.
027:         */
028:
029:        import java.io.Writer;
030:        import java.io.IOException;
031:
032:        /**
033:         * Creates an hyperlink.
034:         * This class belongs to the <fo:basic-link> tag processing.
035:         * @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
036:         *
037:         * {\field {\*\fldinst HYPERLINK "http://www.test.de"   }{\fldrslt Joe Smith}}
038:         */
039:        public class RtfHyperLink extends RtfContainer implements 
040:                IRtfTextContainer, IRtfTextrunContainer {
041:
042:            //////////////////////////////////////////////////
043:            // @@ Members
044:            //////////////////////////////////////////////////
045:
046:            /** The url of the image */
047:            protected String url = null;
048:
049:            /** RtfText */
050:            protected RtfText mText = null;
051:
052:            //////////////////////////////////////////////////
053:            // @@ Construction
054:            //////////////////////////////////////////////////
055:
056:            /**
057:             * Default constructor.
058:             *
059:             * @param parent a <code>RtfContainer</code> value
060:             * @param writer a <code>Writer</code> value
061:             * @param str text of the link
062:             * @param attr a <code>RtfAttributes</code> value
063:             * @throws IOException for I/O problems
064:             */
065:            public RtfHyperLink(IRtfTextContainer parent, Writer writer,
066:                    String str, RtfAttributes attr) throws IOException {
067:                super ((RtfContainer) parent, writer, attr);
068:                new RtfText(this , writer, str, attr);
069:            }
070:
071:            public RtfHyperLink(RtfTextrun parent, Writer writer,
072:                    RtfAttributes attr) throws IOException {
073:                super ((RtfContainer) parent, writer, attr);
074:            }
075:
076:            //////////////////////////////////////////////////
077:            // @@ RtfElement implementation
078:            //////////////////////////////////////////////////
079:
080:            /**
081:             * Writes the RTF content to m_writer.
082:             *
083:             * @exception IOException On error
084:             */
085:            public void writeRtfPrefix() throws IOException {
086:                super .writeGroupMark(true);
087:                super .writeControlWord("field");
088:
089:                super .writeGroupMark(true);
090:                super .writeStarControlWord("fldinst");
091:
092:                writer.write("HYPERLINK \"" + url + "\" ");
093:                super .writeGroupMark(false);
094:
095:                super .writeGroupMark(true);
096:                super .writeControlWord("fldrslt");
097:
098:                // start a group for this paragraph and write our own attributes if needed
099:                if (attrib != null && attrib.isSet("cs")) {
100:                    writeGroupMark(true);
101:                    writeAttributes(attrib, new String[] { "cs" });
102:                }
103:            }
104:
105:            /**
106:             * Writes the RTF content to m_writer.
107:             *
108:             * @exception IOException On error
109:             */
110:            public void writeRtfSuffix() throws IOException {
111:                if (attrib != null && attrib.isSet("cs")) {
112:                    writeGroupMark(false);
113:                }
114:                super .writeGroupMark(false);
115:                super .writeGroupMark(false);
116:            }
117:
118:            //////////////////////////////////////////////////
119:            // @@ IRtfContainer implementation
120:            //////////////////////////////////////////////////
121:
122:            /**
123:             * close current text run if any and start a new one with default attributes
124:             * @param str if not null, added to the RtfText created
125:             * @throws IOException for I/O problems
126:             * @return new RtfText object
127:             */
128:            public RtfText newText(String str) throws IOException {
129:                return newText(str, null);
130:            }
131:
132:            /**
133:             * close current text run if any and start a new one
134:             * @param str if not null, added to the RtfText created
135:             * @param attr attributes of text to add
136:             * @throws IOException for I/O problems
137:             * @return the new RtfText object
138:             */
139:            public RtfText newText(String str, RtfAttributes attr)
140:                    throws IOException {
141:                closeAll();
142:                mText = new RtfText(this , writer, str, attr);
143:                return mText;
144:            }
145:
146:            /**
147:             * IRtfTextContainer requirement:
148:             * @return a copy of our attributes
149:             */
150:            public RtfAttributes getTextContainerAttributes() {
151:                if (attrib == null) {
152:                    return null;
153:                }
154:                return (RtfAttributes) this .attrib.clone();
155:            }
156:
157:            /**
158:             * add a line break
159:             * @throws IOException for I/O problems
160:             */
161:            public void newLineBreak() throws IOException {
162:                new RtfLineBreak(this , writer);
163:            }
164:
165:            //////////////////////////////////////////////////
166:            // @@ Common container methods
167:            //////////////////////////////////////////////////
168:
169:            private void closeCurrentText() throws IOException {
170:                if (mText != null) {
171:                    mText.close();
172:                }
173:            }
174:
175:            private void closeAll() throws IOException {
176:                closeCurrentText();
177:            }
178:
179:            //////////////////////////////////////////////////
180:            // @@ Member access
181:            //////////////////////////////////////////////////
182:
183:            /**
184:             * Sets the url of the external link.
185:             *
186:             * @param url Link url like "http://..."
187:             */
188:            public void setExternalURL(String url) {
189:                this .url = url;
190:            }
191:
192:            /**
193:             * Sets the url of the external link.
194:             *
195:             * @param jumpTo Name of the text mark
196:             */
197:            public void setInternalURL(String jumpTo) {
198:                int now = jumpTo.length();
199:                int max = RtfBookmark.MAX_BOOKMARK_LENGTH;
200:                this .url = "#" + jumpTo.substring(0, now > max ? max : now);
201:                this .url = this .url.replace('.', RtfBookmark.REPLACE_CHARACTER);
202:                this .url = this .url.replace(' ', RtfBookmark.REPLACE_CHARACTER);
203:            }
204:
205:            /**
206:             *
207:             * @return false (always)
208:             */
209:            public boolean isEmpty() {
210:                return false;
211:            }
212:
213:            public RtfTextrun getTextrun() throws IOException {
214:                RtfTextrun textrun = RtfTextrun.getTextrun(this, writer, null);
215:                return textrun;
216:            }
217:        }
w_w___w_._j__a___v__a__2_s___.___c__om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.