[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: [PATCH] underlines in RTF import
From: Nicolas Goutte <nicolasg () snafu ! de>
Date: 2003-08-29 16:53:29
[Download RAW message or body]
The attached patch is for the directory koffice/filter/kword/rtf/import.
It changes the handling of underlines ( \ul ) by putting it in an enumeration.
(As the table export in RTF has not gone well, I have switched back to this
problem first.)
However, I have still a little problem: strikeout. There too exist two
keywords: \strike and \striked. So is the current implementation wrong too?
Do we need an enum there too?
Have a nice day!
["patch_ul.diff" (text/x-diff)]
Index: rtfimport.cpp
===================================================================
RCS file: /home/kde/koffice/filters/kword/rtf/import/rtfimport.cpp,v
retrieving revision 1.56
diff -u -r1.56 rtfimport.cpp
--- rtfimport.cpp 22 Aug 2003 21:54:36 -0000 1.56
+++ rtfimport.cpp 29 Aug 2003 16:46:01 -0000
@@ -212,18 +212,18 @@
PROP( 0L, "tx", insertTabDef, 0L, 0 ),
MEMBER( 0L, "u", insertUnicodeSymbol, state.format.uc, 0 ),
MEMBER( 0L, "uc", setNumericProperty, state.format.uc, 0 ),
- MEMBER( 0L, "ul", setToggleProperty, state.format.underline, 0 ),
- MEMBER( 0L, "uld", setFlagProperty, state.format.underlineDot, true ),
- MEMBER( 0L, "uldash", setFlagProperty, state.format.underlineDash, true ),
- MEMBER( 0L, "uldashd", setFlagProperty, state.format.underlineDashDot, true ),
- MEMBER( 0L, "uldashdd", setFlagProperty, state.format.underlineDashDotDot, true ),
- MEMBER( 0L, "uldb", setFlagProperty, state.format.underlineDouble, true ),
- MEMBER( 0L, "ulnone", setFlagProperty, state.format.underline, false ),
- MEMBER( 0L, "ulth", setFlagProperty, state.format.underlineThick, true ),
- MEMBER( 0L, "ulw", setFlagProperty, state.format.underlineWordByWord, true ),
- MEMBER( 0L, "ulwave", setFlagProperty, state.format.underlineWave, true ),
- MEMBER( 0L, "ulhwave", setFlagProperty, state.format.underlineWave, true ),
- MEMBER( 0L, "ululdbwave", setFlagProperty, state.format.underlineWave, true ),
+ MEMBER( 0L, "ul", setUnderlineProperty, state.format.underline, 0 ),
+ MEMBER( 0L, "uld", setEnumProperty, state.format.underline, \
RTFFormat::UnderlineDouble ), \
+ MEMBER( 0L, "uldash", setEnumProperty, state.format.underline, \
RTFFormat::UnderlineDash ), \
+ MEMBER( 0L, "uldashd", setEnumProperty, state.format.underline, \
RTFFormat::UnderlineDashDot ), \
+ MEMBER( 0L, "uldashdd", setEnumProperty, state.format.underline, \
RTFFormat::UnderlineDashDotDot ), \
+ MEMBER( 0L, "uldb", setEnumProperty, state.format.underline, \
RTFFormat::UnderlineDouble ), \
+ MEMBER( 0L, "ulnone", setEnumProperty, state.format.underline, \
RTFFormat::UnderlineNone ), \
+ MEMBER( 0L, "ulth", setEnumProperty, state.format.underline, \
RTFFormat::UnderlineThick ), \
+ MEMBER( 0L, "ulw", setEnumProperty, state.format.underline, \
RTFFormat::UnderlineWordByWord ), \
+ MEMBER( 0L, "ulwave", setEnumProperty, state.format.underline, \
RTFFormat::UnderlineWave ), \
+ MEMBER( 0L, "ulhwave", setEnumProperty, state.format.underline, \
RTFFormat::UnderlineWave ), \
+ MEMBER( 0L, "ululdbwave", setEnumProperty, state.format.underline, \
RTFFormat::UnderlineWave ), \
MEMBER( 0L, "up", setUpProperty, state.format.baseline, 6 ), \
MEMBER( 0L, "v", setToggleProperty, state.format.hidden, 0 ), \
MEMBER( "@pict", "wbitmap", setEnumProperty, picture.type, RTFPicture::BMP ), @@ \
-712,6 +712,21 @@
*((int *)(((char *)this) + property->offset)) = property->value;
}
+
+/**
+ * Sets the enumaration value for \ul-type keywords
+ * \ul switches on simple underline
+ * \ul0 switches off all underlines
+ * @param property the property to set
+ */
+void RTFImport::setUnderlineProperty( RTFProperty *property )
+{
+ *((int *)(((char *)this) + property->offset))
+ = (!token.hasParam || token.value != 0)
+ ? RTFFormat::UnderlineSimple : RTFFormat::UnderlineNone;
+}
+
+
/**
* Sets the value of a border property specified by token.
* @param property the property to set
@@ -780,15 +795,7 @@
format.caps = false;
format.smallCaps = false;
- format.underline = false;
- format.underlineDash = false;
- format.underlineDot = false;
- format.underlineDashDot = false;
- format.underlineDashDotDot = false;
- format.underlineDouble = false;
- format.underlineThick = false;
- format.underlineWordByWord = false;
- format.underlineWave = false;
+ format.underline = RTFFormat::UnderlineNone;
// Do not reset format.uc !
}
@@ -1873,60 +1880,75 @@
node.setAttribute( "value", format.fmt.italic );
node.closeNode( "ITALIC" );
}
- if (!baseFormat || format.fmt.underline != baseFormat->underline
- || format.fmt.underlineDash != baseFormat->underlineDash
- || format.fmt.underlineDot != baseFormat->underlineDot
- || format.fmt.underlineDashDot != baseFormat->underlineDashDot
- || format.fmt.underlineDashDotDot != baseFormat->underlineDashDotDot
- || format.fmt.underlineDouble != baseFormat->underlineDouble
- || format.fmt.underlineThick != baseFormat->underlineThick
- || format.fmt.underlineWave != baseFormat->underlineWave
- || format.fmt.underlineWordByWord != baseFormat->underlineWordByWord )
+ if (!baseFormat || format.fmt.underline != baseFormat->underline )
{
node.addNode( "UNDERLINE" );
QCString st,styleline,wordbyword("0");
st.setNum(format.fmt.underline);
- if ( format.fmt.underlineDash )
- {
- st="1";
- styleline="dash";
- }
- else if (format.fmt.underlineDot )
- {
- st="1";
- styleline="dot";
- }
- else if (format.fmt.underlineDashDot )
- {
- st="1";
- styleline="dashdot";
- }
- else if (format.fmt.underlineDashDotDot )
- {
- st="1";
- styleline="dashdotdot";
- }
- else if ( format.fmt.underlineDouble )
- {
- st="double";
- }
- else if (format.fmt.underlineThick )
- {
- st="single-bold";
- styleline="solid";
- }
- else if (format.fmt.underlineWordByWord )
- {
- st="1";
- styleline="solid";
- wordbyword="1";
- }
- else if (format.fmt.underlineWave )
+ switch (format.fmt.underline)
{
- st="1";
- styleline="wave";
- }
+ case RTFFormat::UnderlineNone:
+ default:
+ {
+ st="0";
+ break;
+ }
+ case RTFFormat::UnderlineSimple:
+ {
+ st="1";
+ break;
+ }
+ case RTFFormat::UnderlineDouble:
+ {
+ st="double";
+ break;
+ }
+ case RTFFormat::UnderlineThick:
+ {
+ st="single-bold";
+ styleline="solid";
+ break;
+ }
+
+ case RTFFormat::UnderlineWordByWord:
+ {
+ st="1";
+ styleline="solid";
+ wordbyword="1";
+ break;
+ }
+ case RTFFormat::UnderlineDash:
+ {
+ st="1";
+ styleline="dash";
+ break;
+ }
+ case RTFFormat::UnderlineDot:
+ {
+ st="1";
+ styleline="dot";
+ break;
+ }
+ case RTFFormat::UnderlineDashDot:
+ {
+ st="1";
+ styleline="dashdot";
+ break;
+ }
+ case RTFFormat::UnderlineDashDotDot:
+ {
+ st="1";
+ styleline="dashdotdot";
+ break;
+ }
+ case RTFFormat::UnderlineWave:
+ {
+ st="1";
+ styleline="wave";
+ break;
+ }
+ } // end of switch
node.setAttribute( "value", st );
node.setAttribute( "wordbyword", wordbyword );
if ( !styleline.isEmpty() )
Index: rtfimport.h
===================================================================
RCS file: /home/kde/koffice/filters/kword/rtf/import/rtfimport.h,v
retrieving revision 1.19
diff -u -r1.19 rtfimport.h
--- rtfimport.h 13 Jan 2003 16:15:47 -0000 1.19
+++ rtfimport.h 29 Aug 2003 16:46:02 -0000
@@ -127,14 +127,15 @@
struct RTFFormat
{
enum VertAlign { Normal = 0, SubScript, SuperScript };
+ enum Underline { UnderlineNone=0, UnderlineSimple, UnderlineThick, \
UnderlineDouble, UnderlineWordByWord, + UnderlineWave, UnderlineDash, \
UnderlineDot, UnderlineDashDot, UnderlineDashDotDot };
VertAlign vertAlign;
+ Underline underline;
int font, fontSize, baseline;
int color, bgcolor;
int uc;
- bool underline, bold, italic, strike, striked, hidden, caps, smallCaps;
- bool underlineDash, underlineDot, underlineDashDot, underlineDashDotDot;
- bool underlineDouble, underlineThick, underlineWave, underlineWordByWord;
+ bool bold, italic, strike, striked, hidden, caps, smallCaps;
};
// Style sheet entry
@@ -222,6 +223,7 @@
void setFlagProperty( RTFProperty *property );
void setNumericProperty( RTFProperty *property );
void setEnumProperty( RTFProperty *property );
+ void setUnderlineProperty( RTFProperty *property );
void setBorderProperty( RTFProperty *property );
void setBorderStyle( RTFProperty *property );
void setUpProperty( RTFProperty * );
_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic