ooo-build r14375 - in trunk: . patches/dev300
- From: thorstenb svn gnome org
- To: svn-commits-list gnome org
- Subject: ooo-build r14375 - in trunk: . patches/dev300
- Date: Tue, 21 Oct 2008 16:50:17 +0000 (UTC)
Author: thorstenb
Date: Tue Oct 21 16:50:17 2008
New Revision: 14375
URL: http://svn.gnome.org/viewvc/ooo-build?rev=14375&view=rev
Log:
* patches/dev300/apply:
* patches/dev300/svg-import-textimport.diff: much improved svg
text import (correct baseline, size, styles etc.)
Added:
trunk/patches/dev300/svg-import-textimport.diff
Modified:
trunk/ChangeLog
trunk/patches/dev300/apply
Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply (original)
+++ trunk/patches/dev300/apply Tue Oct 21 16:50:17 2008
@@ -2060,6 +2060,9 @@
# improves parsing of paint fragments
svg-import-painturi-fix.diff, thorsten
+# much improved text import
+svg-import-textimport.diff, thorsten
+
[ NovellOnlyWin32 < dev300m30 < ooo300-m2 ]
novell-win32-msi-patchability-m1.diff, tml
Added: trunk/patches/dev300/svg-import-textimport.diff
==============================================================================
--- (empty file)
+++ trunk/patches/dev300/svg-import-textimport.diff Tue Oct 21 16:50:17 2008
@@ -0,0 +1,285 @@
+--- filter/source/svg/gfxtypes.hxx.old2 2008-10-21 18:47:16.000000000 +0200
++++ filter/source/svg/gfxtypes.hxx 2008-10-21 17:57:49.000000000 +0200
+@@ -155,19 +155,6 @@
+ ROUND
+ };
+
+-enum FontStyle
+-{
+- STYLE_NORMAL,
+- STYLE_OBLIQUE,
+- STYLE_ITALIC
+-};
+-
+-enum FontVariant
+-{
+- VARIANT_NORMAL,
+- VARIANT_SMALLCAPS
+-};
+-
+ struct State
+ {
+ State() :
+@@ -177,8 +164,8 @@
+ maViewBox(),
+ maFontFamily(), // app-default
+ mnFontSize(12.0),
+- meFontStyle(STYLE_NORMAL),
+- meFontVariant(VARIANT_NORMAL),
++ maFontStyle(RTL_CONSTASCII_USTRINGPARAM("normal")),
++ maFontVariant(RTL_CONSTASCII_USTRINGPARAM("normal")),
+ mnFontWeight(400.0),
+ meTextAnchor(BEFORE),
+ meTextDisplayAlign(BEFORE),
+@@ -220,8 +207,8 @@
+
+ */
+ double mnFontSize;
+- FontStyle meFontStyle;
+- FontVariant meFontVariant;
++ rtl::OUString maFontStyle;
++ rtl::OUString maFontVariant;
+ double mnFontWeight;
+
+ TextAlign meTextAnchor; // text-anchor
+@@ -265,8 +252,8 @@
+ rLHS.maViewBox==rRHS.maViewBox &&
+ rLHS.maFontFamily==rRHS.maFontFamily &&
+ rLHS.mnFontSize==rRHS.mnFontSize &&
+- rLHS.meFontStyle==rRHS.meFontStyle &&
+- rLHS.meFontVariant==rRHS.meFontVariant &&
++ rLHS.maFontStyle==rRHS.maFontStyle &&
++ rLHS.maFontVariant==rRHS.maFontVariant &&
+ rLHS.mnFontWeight==rRHS.mnFontWeight &&
+ rLHS.meTextAnchor==rRHS.meTextAnchor &&
+ rLHS.meTextDisplayAlign==rRHS.meTextDisplayAlign &&
+@@ -310,8 +297,8 @@
+ ^ size_t(rState.maViewBox.getHeight())
+ ^ size_t(rState.maFontFamily.hashCode())
+ ^ size_t(rState.mnFontSize)
+- ^ size_t(rState.meFontStyle)
+- ^ size_t(rState.meFontVariant)
++ ^ size_t(rState.maFontStyle.hashCode())
++ ^ size_t(rState.maFontVariant.hashCode())
+ ^ size_t(rState.mnFontWeight)
+ ^ size_t(rState.meTextAnchor)
+ ^ size_t(rState.meTextDisplayAlign)
+--- filter/source/svg/svgreader.cxx.old2 2008-10-21 16:36:18.000000000 +0200
++++ filter/source/svg/svgreader.cxx 2008-10-21 18:40:22.000000000 +0200
+@@ -415,6 +415,24 @@
+ return aBuf.makeStringAndClear();
+ }
+
++ rtl::OUString getOdfAlign( TextAlign eAlign )
++ {
++ static ::rtl::OUString aStart(USTR("start"));
++ static ::rtl::OUString aEnd(USTR("end"));
++ // static ::rtl::OUString aJustify(USTR("justify"));
++ static ::rtl::OUString aCenter(USTR("center"));
++ switch(eAlign)
++ {
++ default:
++ case BEFORE:
++ return aStart;
++ case CENTER:
++ return aCenter;
++ case AFTER:
++ return aEnd;
++ }
++ }
++
+ bool writeStyle(State& rState, const sal_Int32 nTagId)
+ {
+ rtl::Reference<SvXMLAttributeList> xAttrs( new SvXMLAttributeList() );
+@@ -443,7 +461,7 @@
+ // do we have a gradient fill? then write out gradient as well
+ if( rState.meFillType == GRADIENT && rState.maFillGradient.maStops.size() > 1 )
+ {
+- // TODO(F3): ODF12 supposedly also groks svg:linear/radialGradient
++ // TODO(F3): ODF12 supposedly also groks svg:linear/radialGradient. But CL says: nope.
+ xAttrs->AddAttribute( USTR( "draw:name" ), getStyleName("svggradient", rState.maFillGradient.mnId) );
+ if( rState.maFillGradient.meType == Gradient::LINEAR )
+ {
+@@ -515,6 +533,47 @@
+ }
+
+ // serialize to automatic-style section
++ if( nTagId == XML_TEXT )
++ {
++ // write paragraph style attributes
++ xAttrs->Clear();
++
++ xAttrs->AddAttribute( USTR( "style:name" ), getStyleName("svgparagraphstyle", mnCurrStateId) );
++ xAttrs->AddAttribute( USTR( "style:family" ), USTR("paragraph") );
++ mxDocumentHandler->startElement( USTR("style:style"),
++ xUnoAttrs );
++
++ xAttrs->Clear();
++ xAttrs->AddAttribute( USTR( "fo:text-align"), getOdfAlign(rState.meTextAnchor));
++
++ mxDocumentHandler->startElement( USTR("style:paragraph-properties"),
++ xUnoAttrs );
++ mxDocumentHandler->endElement( USTR("style:paragraph-properties") );
++ mxDocumentHandler->endElement( USTR("style:style") );
++
++ // write text style attributes
++ xAttrs->Clear();
++
++ xAttrs->AddAttribute( USTR( "style:name" ), getStyleName("svgtextstyle", mnCurrStateId) );
++ xAttrs->AddAttribute( USTR( "style:family" ), USTR("text") );
++ mxDocumentHandler->startElement( USTR("style:style"),
++ xUnoAttrs );
++ xAttrs->Clear();
++ xAttrs->AddAttribute( USTR( "fo:font-family"), rState.maFontFamily);
++ xAttrs->AddAttribute( USTR( "fo:font-size"),
++ rtl::OUString::valueOf(pt2mm(rState.mnFontSize))+USTR("mm"));
++ xAttrs->AddAttribute( USTR( "fo:font-style"), rState.maFontStyle);
++ xAttrs->AddAttribute( USTR( "fo:font-variant"), rState.maFontVariant);
++ xAttrs->AddAttribute( USTR( "fo:font-weight"),
++ rtl::OUString::valueOf(rState.mnFontWeight));
++ xAttrs->AddAttribute( USTR( "fo:color"), getOdfColor(rState.maFillColor));
++
++ mxDocumentHandler->startElement( USTR("style:text-properties"),
++ xUnoAttrs );
++ mxDocumentHandler->endElement( USTR("style:text-properties") );
++ mxDocumentHandler->endElement( USTR("style:style") );
++ }
++
+ xAttrs->Clear();
+ xAttrs->AddAttribute( USTR( "style:name" ), getStyleName("svggraphicstyle", mnCurrStateId) );
+ xAttrs->AddAttribute( USTR( "style:family" ), USTR("graphic") );
+@@ -928,13 +987,16 @@
+ maCurrState.mnFontSize=convLength(sValue,maCurrState,'v');
+ break;
+ case XML_FONT_STYLE:
+- maCurrState.meFontStyle=STYLE_ITALIC; // TODO: sValue.toStyleId();
++ parseFontStyle(maCurrState,sValue,aValueUtf8.getStr());
+ break;
+ case XML_FONT_WEIGHT:
+ maCurrState.mnFontWeight=sValue.toDouble();
+ break;
+ case XML_FONT_VARIANT:
+- maCurrState.meFontVariant=VARIANT_SMALLCAPS; // TODO: sValue.toDouble();
++ parseFontVariant(maCurrState,sValue,aValueUtf8.getStr());
++ break;
++ case XML_TEXT_ANCHOR:
++ parseTextAlign(maCurrState,aValueUtf8.getStr());
+ break;
+ case XML_STOP_COLOR:
+ if( maGradientVector.empty() ||
+@@ -987,6 +1049,34 @@
+ while( nIndex != -1 );
+ }
+
++ void parseFontStyle( State& io_rInitialState,
++ const rtl::OUString& rValue,
++ const char* sValue )
++ {
++ if( strcmp(sValue,"inherit") != 0 )
++ io_rInitialState.maFontStyle = rValue;
++ }
++
++ void parseFontVariant( State& io_rInitialState,
++ const rtl::OUString& rValue,
++ const char* sValue )
++ {
++ if( strcmp(sValue,"inherit") != 0 )
++ io_rInitialState.maFontVariant = rValue;
++ }
++
++ void parseTextAlign( State& io_rInitialState,
++ const char* sValue )
++ {
++ if( strcmp(sValue,"start") == 0 )
++ io_rInitialState.meTextAnchor = BEFORE;
++ else if( strcmp(sValue,"middle") == 0 )
++ io_rInitialState.meTextAnchor = CENTER;
++ else if( strcmp(sValue,"end") == 0 )
++ io_rInitialState.meTextAnchor = AFTER;
++ // keep current val for sValue == "inherit"
++ }
++
+ void parsePaint( const rtl::OUString& rValue,
+ const char* sValue,
+ PaintType& rType,
+@@ -1391,6 +1481,10 @@
+ // actually export text
+ xAttrs->Clear();
+
++ // some heuristic attempts to have text output
++ // baseline-relative
++ y -= 2.0*maCurrState.mnFontSize/3.0;
++
+ // extract basic transformations out of CTM
+ basegfx::B2DTuple aScale, aTranslate;
+ double fRotate, fShearX;
+@@ -1423,9 +1517,16 @@
+
+ xAttrs->Clear();
+ mxDocumentHandler->startElement(USTR("draw:text-box"),xUnoAttrs);
+- // TODO: put text style in here
++ xAttrs->AddAttribute( USTR( "text:style-name" ), USTR("svgparagraphstyle")+sStyleId);
+ mxDocumentHandler->startElement(USTR("text:p"),xUnoAttrs);
++
++ xAttrs->Clear();
++ xAttrs->AddAttribute( USTR( "text:style-name" ), USTR("svgtextstyle")+sStyleId);
++ mxDocumentHandler->startElement(USTR("text:span"),xUnoAttrs);
++
++ xAttrs->Clear();
+ mxDocumentHandler->characters(sText.makeStringAndClear());
++ mxDocumentHandler->endElement(USTR("text:span"));
+ mxDocumentHandler->endElement(USTR("text:p"));
+ mxDocumentHandler->endElement(USTR("draw:text-box"));
+ mxDocumentHandler->endElement(USTR("draw:frame"));
+@@ -2292,6 +2393,14 @@
+ Font aFont(maCurrState.maFontFamily,
+ Size(0,
+ basegfx::fround(pt100thmm(maCurrState.mnFontSize))));
++ aFont.SetAlign(ALIGN_BASELINE);
++ aFont.SetColor(getVclColor(maCurrState.maFillColor));
++ aFont.SetFillColor(getVclColor(maCurrState.maFillColor));
++
++ if( !maCurrState.maFontStyle.equalsAscii("normal") )
++ aFont.SetItalic(ITALIC_NORMAL); // TODO: discriminate
++ if( !maCurrState.mnFontWeight != 400.0 )
++ aFont.SetWeight(WEIGHT_BOLD); // TODO: discriminate
+
+ // extract basic transformations out of CTM
+ basegfx::B2DTuple aScale, aTranslate;
+@@ -2313,9 +2422,27 @@
+
+ // TODO(F2): update bounds
+ mrOutDev.SetFont(aFont);
++ const ::rtl::OUString aText( sText.makeStringAndClear() );
++ switch( maCurrState.meTextAnchor )
++ {
++ default:
++ case BEFORE:
++ break;
++
++ case CENTER:
++ {
++ const long nWidth=mrOutDev.GetTextWidth(aText);
++ x -= nWidth/2;
++ }
++ break;
++
++ case AFTER:
++ x -= mrOutDev.GetTextWidth(aText);
++ break;
++ }
+ mrOutDev.DrawText(Point(basegfx::fround(pt100thmm(x)),
+ basegfx::fround(pt100thmm(y))),
+- sText.makeStringAndClear());
++ aText);
+ break;
+ }
+ }
+@@ -2585,6 +2712,7 @@
+
+ aVDev.EnableOutput( FALSE );
+ aMtf.Record( &aVDev );
++ aVDev.SetTextAlign(ALIGN_BASELINE);
+
+ // parse styles and fill state stack
+ svgi::State aInitialState;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]