Attached patches implement import of CSS text-transform property and extend 
the import and export to work with all HTML browser compatibility options.

Contributed under LGPLv3+ and MPL.

Harri
From 8eea1bf955f6f2cb7c0e0622b0b2fa6975cee3db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Harri=20Pitk=C3=A4nen?= <hatap...@iki.fi>
Date: Sat, 18 Jun 2011 15:57:14 +0300
Subject: [PATCH 1/2] Import and export character case transformations
 unconditionally to/from HTML

Import small caps and export small caps, lowecase, uppercase and titlecase
transformations unconditionally to/from HTML. Previously import and export
was limited by browser compatibility settings but all mainstream browsers
released within last 5 years or so should support the relevant CSS attributes.
---
 sw/source/filter/html/css1atr.cxx |    3 ---
 sw/source/filter/html/htmlatr.cxx |    4 ++--
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index 92a149b..d980b55 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -2561,9 +2561,6 @@ static Writer& OutCSS1_SvxCaseMap( Writer& rWrt, const SfxPoolItem& rHt )
 {
     SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
 
-    if( !rHTMLWrt.IsHTMLMode(HTMLMODE_SMALL_CAPS) )
-        return rWrt;
-
     switch( ((const SvxCaseMapItem&)rHt).GetCaseMap() )
     {
     case SVX_CASEMAP_NOT_MAPPED:
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 2d10e6f..f7a0ec1 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -1505,8 +1505,8 @@ HTMLOnOffState HTMLEndPosLst::GetHTMLItemState( const SfxPoolItem& rItem )
         break;
 
     case RES_CHRATR_CASEMAP:
-        if( IsHTMLMode(HTMLMODE_SMALL_CAPS) )
-            eState = HTML_STYLE_VALUE;
+        eState = HTML_STYLE_VALUE;
+        break;
 
     case RES_CHRATR_KERNING:
         if( IsHTMLMode(HTMLMODE_FULL_STYLES) )
-- 
1.7.5.4

From e0d8e9114c6778bb534a61ee0f50dcf11a393ad0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Harri=20Pitk=C3=A4nen?= <hatap...@iki.fi>
Date: Sat, 18 Jun 2011 21:12:01 +0300
Subject: [PATCH 2/2] Support CSS text-transform property in HTML import

---
 sw/source/filter/html/svxcss1.cxx |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx
index 117ef4e..2fcf673 100644
--- a/sw/source/filter/html/svxcss1.cxx
+++ b/sw/source/filter/html/svxcss1.cxx
@@ -128,6 +128,14 @@ static CSS1PropertyEnum const aFontVariantTable[] =
     { 0,					0					}
 };
 
+static CSS1PropertyEnum const aTextTransformTable[] =
+{
+    { sCSS1_PV_uppercase,  SVX_CASEMAP_VERSALIEN },
+    { sCSS1_PV_lowercase,  SVX_CASEMAP_GEMEINE   },
+    { sCSS1_PV_capitalize, SVX_CASEMAP_TITEL     },
+    { 0,                   0                     }
+};
+
 static CSS1PropertyEnum const aDirectionTable[] =
 {
     { sCSS1_PV_ltr,			FRMDIR_HORI_LEFT_TOP		},
@@ -1314,6 +1322,32 @@ static void ParseCSS1_font_variant( const CSS1Expression *pExpr,
     }
 }
 
+static void ParseCSS1_text_transform( const CSS1Expression *pExpr,
+                                    SfxItemSet &rItemSet,
+                                    SvxCSS1PropertyInfo& /*rPropInfo*/,
+                                    const SvxCSS1Parser& /*rParser*/ )
+{
+    OSL_ENSURE( pExpr, "no expression" );
+
+    // none | capitalize | uppercase | lowercase
+
+    switch( pExpr->GetType() )
+    {
+    case CSS1_IDENT:
+        {
+            sal_uInt16 nCaseMap;
+            if( SvxCSS1Parser::GetEnum( aTextTransformTable, pExpr->GetString(),
+                                        nCaseMap ) )
+            {
+                rItemSet.Put( SvxCaseMapItem( (SvxCaseMap)nCaseMap,
+                                                aItemIds.nCaseMap ) );
+            }
+        }
+    default:
+        ;
+    }
+}
+
 /*  */
 
 static void ParseCSS1_color( const CSS1Expression *pExpr,
@@ -3140,6 +3174,7 @@ static CSS1PropEntry aCSS1PropFnTab[] =
     CSS1_PROP_ENTRY(text_align),
     CSS1_PROP_ENTRY(text_decoration),
     CSS1_PROP_ENTRY(text_indent),
+    CSS1_PROP_ENTRY(text_transform),
     CSS1_PROP_ENTRY(margin_left),
     CSS1_PROP_ENTRY(margin_right),
     CSS1_PROP_ENTRY(margin_top),
-- 
1.7.5.4

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to