[Okular-devel] [patch] Implement missing alignment types (was Re: [Bug 154980] Bad ODT rendering)
Brad Hards
bradh at frogmouth.net
Sun Jan 4 00:37:01 CET 2009
On Saturday 03 January 2009 06:36:35 pm Brad Hards wrote:
> http://bugs.kde.org/show_bug.cgi?id=154980
> 2. We don't support the start, end and justify alignment types.
This is in section 14.5.4 "Text Align" of my ODF spec (which is
version 1.0)
OK, first patch. I have tested the Left-to-Right path, but not the
Right-to-Left path. Seems obvious though. Recommend inclusion
for 4.2.
Brad
Index: formatproperty.h
===================================================================
--- formatproperty.h (revision 903994)
+++ formatproperty.h (working copy)
@@ -60,6 +60,8 @@
void setTextAlignment( Qt::Alignment alignment );
void setBackgroundColor( const QColor &color );
+ bool writingModeIsRightToLeft() const;
+
private:
int mPageNumber;
WritingMode mWritingMode;
Index: formatproperty.cpp
===================================================================
--- formatproperty.cpp (revision 903994)
+++ formatproperty.cpp (working copy)
@@ -64,6 +64,11 @@
mWritingMode = mode;
}
+bool ParagraphFormatProperty::writingModeIsRightToLeft() const
+{
+ return ( ( mWritingMode == RLTB ) || ( mWritingMode == TBRL ) || ( mWritingMode == RL ) );
+}
+
void ParagraphFormatProperty::setTextAlignment( Qt::Alignment alignment )
{
mHasAlignment = true;
Index: styleparser.cpp
===================================================================
--- styleparser.cpp (revision 903994)
+++ styleparser.cpp (working copy)
@@ -291,6 +291,15 @@
alignMap.insert( "center", Qt::AlignCenter );
alignMap.insert( "left", Qt::AlignLeft );
alignMap.insert( "right", Qt::AlignRight );
+ alignMap.insert( "justify", Qt::AlignJustify );
+ if ( property.writingModeIsRightToLeft() ) {
+ alignMap.insert( "start", Qt::AlignRight );
+ alignMap.insert( "end", Qt::AlignLeft );
+ } else {
+ // not right to left
+ alignMap.insert( "start", Qt::AlignLeft );
+ alignMap.insert( "end", Qt::AlignRight );
+ }
}
if ( parent.hasAttribute( "text-align" ) ) {
property.setTextAlignment( alignMap[ parent.attribute( "text-align", "left" ) ] );
More information about the Okular-devel
mailing list