aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorFinn Bock <bckfnn@apache.org>2004-10-01 09:05:23 +0000
committerFinn Bock <bckfnn@apache.org>2004-10-01 09:05:23 +0000
commitad45fbe4262eee476acf4053fbae823c17c6cd76 (patch)
treec703c86daa9fd5fcc89c0a58b3afa18ebf677ce4 /src/java/org/apache
parentf15702fe6f16559c78c1d5231a12b8a014f2903b (diff)
downloadxmlgraphics-fop-ad45fbe4262eee476acf4053fbae823c17c6cd76.tar.gz
xmlgraphics-fop-ad45fbe4262eee476acf4053fbae823c17c6cd76.zip
Helper class which supports FOP datatypes as values.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197991 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rwxr-xr-xsrc/java/org/apache/fop/render/rtf/FOPRtfAttributes.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java b/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java
new file mode 100755
index 000000000..381d33940
--- /dev/null
+++ b/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.rtf;
+
+import org.apache.fop.datatypes.ColorType;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.fo.properties.ColorTypeProperty;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable;
+
+
+/**
+ * A RtfAttributes subclass that adds some helper set methods.
+ */
+public class FOPRtfAttributes extends RtfAttributes {
+ /**
+ * Set an attribute that has a Length value
+ * @param name name of attribute
+ * @param value value of attribute
+ * @return this (which now contains the new entry)
+ */
+ public RtfAttributes set(String name, Length value) {
+ set(name, value.getValue() / (1000 / 20));
+ return this;
+ }
+
+ public RtfAttributes set(String name, ColorType color) {
+ int redComponent = ColorTypeProperty.convertChannelToInteger (color.getRed());
+ int greenComponent = ColorTypeProperty.convertChannelToInteger (color.getGreen());
+ int blueComponent = ColorTypeProperty.convertChannelToInteger (color.getBlue());
+ set(name, RtfColorTable.getInstance().getColorNumber(
+ redComponent,greenComponent, blueComponent).intValue());
+ return this;
+ }
+}