[Libreoffice-commits] .: 3 commits - filter/source
Christina Rossmanith
crossmanith at kemper.freedesktop.org
Tue May 1 07:57:58 PDT 2012
filter/source/svg/gfxtypes.hxx | 2 -
filter/source/svg/svgreader.cxx | 64 +++++++++++++---------------------------
2 files changed, 22 insertions(+), 44 deletions(-)
New commits:
commit 82850c932054a5a1549c3cfbfc61e8e3dcb6e0fb
Author: Chr. Rossmanith <ChrRossmanith at gmx.de>
Date: Tue May 1 16:44:37 2012 +0200
SVG: use scale in font size and text baseline heuristic
diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
index f0d3fde..062c73f 100644
--- a/filter/source/svg/svgreader.cxx
+++ b/filter/source/svg/svgreader.cxx
@@ -507,8 +507,16 @@ struct AnnotatingVisitor
rtl::Reference<SvXMLAttributeList> xAttrs( new SvXMLAttributeList() );
uno::Reference<xml::sax::XAttributeList> xUnoAttrs( xAttrs.get() );
- if (XML_TEXT == nTagId)
+ if (XML_TEXT == nTagId) {
rState.mbIsText = true;
+ basegfx::B2DTuple aScale, aTranslate;
+ double fRotate, fShearX;
+ if (rState.maCTM.decompose(aScale, aTranslate, fRotate, fShearX))
+ {
+ rState.mnFontSize *= aScale.getX();
+ }
+ }
+
std::pair<StatePool::iterator,
bool> aRes = mrStates.insert(rState);
SAL_INFO ("svg", "size " << mrStates.size() << " id " << const_cast<State&>(*aRes.first).mnStyleId);
@@ -1519,18 +1527,26 @@ struct ShapeWritingVisitor
// 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;
if (maCurrState.maCTM.decompose(aScale, aTranslate, fRotate, fShearX))
{
+ // some heuristic attempts to have text output
+ // baseline-relative
+ y -= 2.0*maCurrState.mnFontSize/aScale.getX()/3.0;
+ // apply transform
+ x *= aScale.getX();
+ y *= aScale.getY();
x += aTranslate.getX();
y += aTranslate.getY();
}
+ else {
+ // some heuristic attempts to have text output
+ // baseline-relative
+ y -= 2.0*maCurrState.mnFontSize/3.0;
+ }
xAttrs->AddAttribute( USTR( "svg:x" ), rtl::OUString::valueOf(pt2mm(x))+USTR("mm"));
xAttrs->AddAttribute( USTR( "svg:y" ), rtl::OUString::valueOf(pt2mm(y))+USTR("mm"));
commit 9c9bf9a3adf6b885289a698ed270f51554bca86a
Author: Chr. Rossmanith <ChrRossmanith at gmx.de>
Date: Tue May 1 16:38:52 2012 +0200
SVG: remove unused code in svgreader.cxx
diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
index 1cd7c54..f0d3fde 100644
--- a/filter/source/svg/svgreader.cxx
+++ b/filter/source/svg/svgreader.cxx
@@ -1496,7 +1496,7 @@ struct ShapeWritingVisitor
// collect attributes
const sal_Int32 nNumAttrs( xAttributes->getLength() );
rtl::OUString sAttributeValue;
- double x=0.0,y=0.0,width=0.0,height=0.0;
+ double x=0.0,y=0.0;
for( sal_Int32 i=0; i<nNumAttrs; ++i )
{
sAttributeValue = xAttributes->item(i)->getNodeValue();
@@ -1510,12 +1510,6 @@ struct ShapeWritingVisitor
case XML_Y:
y = convLength(sAttributeValue,maCurrState,'v');
break;
- case XML_WIDTH:
- width = convLength(sAttributeValue,maCurrState,'h');
- break;
- case XML_HEIGHT:
- height = convLength(sAttributeValue,maCurrState,'v');
- break;
default:
// skip
break;
@@ -1532,31 +1526,14 @@ struct ShapeWritingVisitor
// extract basic transformations out of CTM
basegfx::B2DTuple aScale, aTranslate;
double fRotate, fShearX;
- ::rtl::OUString sTransformValue;
if (maCurrState.maCTM.decompose(aScale, aTranslate, fRotate, fShearX))
{
- rtl::OUString sTransform;
x += aTranslate.getX();
y += aTranslate.getY();
-
- sTransform +=
- USTR("scale(") +
- rtl::OUString::valueOf(aScale.getX()) +
- USTR(", ") +
- rtl::OUString::valueOf(aScale.getX()) +
- USTR(")");
-
- if( fRotate )
- sTransform += USTR(" rotate(") + rtl::OUString::valueOf(fRotate*180.0/M_PI) + USTR(")");
-
- if( fShearX )
- sTransform += USTR(" skewX(") + rtl::OUString::valueOf(fShearX*180.0/M_PI) + USTR(")");
}
xAttrs->AddAttribute( USTR( "svg:x" ), rtl::OUString::valueOf(pt2mm(x))+USTR("mm"));
xAttrs->AddAttribute( USTR( "svg:y" ), rtl::OUString::valueOf(pt2mm(y))+USTR("mm"));
- (void)width;
- (void)height;
xAttrs->AddAttribute( USTR( "draw:style-name" ), USTR("svggraphicstyle")+sStyleId );
mxDocumentHandler->startElement(USTR("draw:frame"),xUnoAttrs);
commit 5977a8d415bc205947f8276d16288203ed93594a
Author: Chr. Rossmanith <ChrRossmanith at gmx.de>
Date: Tue May 1 16:30:32 2012 +0200
SVG: move default font size into state ctor
diff --git a/filter/source/svg/gfxtypes.hxx b/filter/source/svg/gfxtypes.hxx
index daca2be..68463c8 100644
--- a/filter/source/svg/gfxtypes.hxx
+++ b/filter/source/svg/gfxtypes.hxx
@@ -175,7 +175,7 @@ struct State
maViewBox(),
mbIsText(false),
maFontFamily(), // app-default
- mnFontSize(0),
+ mnFontSize(12),
maFontStyle("normal"),
maFontVariant("normal"),
mnFontWeight(400.0),
diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
index 2c0c09b..1cd7c54 100644
--- a/filter/source/svg/svgreader.cxx
+++ b/filter/source/svg/svgreader.cxx
@@ -194,7 +194,6 @@ struct AnnotatingVisitor
StateMap& rStateMap,
const State& rInitialState,
const uno::Reference<xml::sax::XDocumentHandler>& xDocumentHandler) :
- mbSeenText(false),
mnCurrStateId(0),
maCurrState(),
maParentStates(),
@@ -216,12 +215,6 @@ struct AnnotatingVisitor
maCurrState = maParentStates.back();
maCurrState.maTransform.identity();
maCurrState.maViewBox.reset();
- // set default font size here to ensure writing styles for text
- if( !mbSeenText && XML_TEXT == nTagId )
- {
- maCurrState.mnFontSize = 12.0;
- mbSeenText = true;
- }
// if necessary, serialize to automatic-style section
writeStyle(xElem,nTagId);
}
@@ -330,13 +323,6 @@ struct AnnotatingVisitor
maCurrState.maTransform.identity();
maCurrState.maViewBox.reset();
- // set default font size here to ensure writing styles for text
- if( !mbSeenText && XML_TEXT == nTagId )
- {
- maCurrState.mnFontSize = 12.0;
- mbSeenText = true;
- }
-
// scan for style info
const sal_Int32 nNumAttrs( xAttributes->getLength() );
rtl::OUString sAttributeValue;
@@ -1240,7 +1226,6 @@ struct AnnotatingVisitor
}
}
- bool mbSeenText;
sal_Int32 mnCurrStateId;
State maCurrState;
std::vector<State> maParentStates;
More information about the Libreoffice-commits
mailing list