[Libreoffice-commits] .: 3 commits - filter/source
Fridrich Strba
fridrich at kemper.freedesktop.org
Sun Apr 29 05:13:11 PDT 2012
filter/source/svg/svgreader.cxx | 164 +++++++++++++++++-----------------------
1 file changed, 70 insertions(+), 94 deletions(-)
New commits:
commit 1ac100610860a17792713afe948fa961c5f7cbe4
Author: Chr. Rossmanith <Chr.Rossmanith at gmx.de>
Date: Sat Apr 28 20:20:54 2012 +0200
Move polygon creation from rect attrs into helper method
diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
index 563060b..dfb33c8 100644
--- a/filter/source/svg/svgreader.cxx
+++ b/filter/source/svg/svgreader.cxx
@@ -75,6 +75,56 @@ namespace svgi
namespace
{
+void lcl_RectAttrs2Polygon( const uno::Reference<xml::dom::XNamedNodeMap>& xAttributes, const State& rCurrState, basegfx::B2DPolygon& rPoly )
+{
+ // collect attributes
+ const sal_Int32 nNumAttrs( xAttributes->getLength() );
+ rtl::OUString sAttributeValue;
+ bool bRxSeen=false, bRySeen=false;
+ double x=0.0,y=0.0,width=0.0,height=0.0,rx=0.0,ry=0.0;
+ for( sal_Int32 i=0; i<nNumAttrs; ++i )
+ {
+ sAttributeValue = xAttributes->item(i)->getNodeValue();
+ const sal_Int32 nAttribId(
+ getTokenId(xAttributes->item(i)->getNodeName()));
+ switch(nAttribId)
+ {
+ case XML_X:
+ x = convLength(sAttributeValue,rCurrState,'h');
+ break;
+ case XML_Y:
+ y = convLength(sAttributeValue,rCurrState,'v');
+ break;
+ case XML_WIDTH:
+ width = convLength(sAttributeValue,rCurrState,'h');
+ break;
+ case XML_HEIGHT:
+ height = convLength(sAttributeValue,rCurrState,'v');
+ break;
+ case XML_RX:
+ rx = convLength(sAttributeValue,rCurrState,'h');
+ bRxSeen=true;
+ break;
+ case XML_RY:
+ ry = convLength(sAttributeValue,rCurrState,'v');
+ bRySeen=true;
+ break;
+ default:
+ // skip
+ break;
+ }
+ }
+
+ if( bRxSeen && !bRySeen )
+ ry = rx;
+ else if( bRySeen && !bRxSeen )
+ rx = ry;
+
+ rPoly = basegfx::tools::createPolygonFromRect(
+ basegfx::B2DRange(x,y,x+width,y+height),
+ rx/(0.5*width), ry/(0.5*height) );
+}
+
/** visits all children of the specified type with the given functor
*/
template<typename Func> void visitChildren(const Func& rFunc,
@@ -1305,54 +1355,9 @@ struct ShapeWritingVisitor
}
case XML_RECT:
{
- // collect attributes
- const sal_Int32 nNumAttrs( xAttributes->getLength() );
- rtl::OUString sAttributeValue;
- bool bRxSeen=false, bRySeen=false;
- double x=0.0,y=0.0,width=0.0,height=0.0,rx=0.0,ry=0.0;
- for( sal_Int32 i=0; i<nNumAttrs; ++i )
- {
- sAttributeValue = xAttributes->item(i)->getNodeValue();
- const sal_Int32 nAttribId(
- getTokenId(xAttributes->item(i)->getNodeName()));
- switch(nAttribId)
- {
- case XML_X:
- x = convLength(sAttributeValue,maCurrState,'h');
- break;
- 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;
- case XML_RX:
- rx = convLength(sAttributeValue,maCurrState,'h');
- bRxSeen=true;
- break;
- case XML_RY:
- ry = convLength(sAttributeValue,maCurrState,'v');
- bRySeen=true;
- break;
- default:
- // skip
- break;
- }
- }
-
- if( bRxSeen && !bRySeen )
- ry = rx;
- else if( bRySeen && !bRxSeen )
- rx = ry;
-
basegfx::B2DPolygon aPoly;
- aPoly = basegfx::tools::createPolygonFromRect(
- basegfx::B2DRange(x,y,x+width,y+height),
- rx/(0.5*width), ry/(0.5*height) );
+ lcl_RectAttrs2Polygon( xAttributes, maCurrState, aPoly );
writePathShape(xAttrs,
xUnoAttrs,
xElem,
@@ -2149,54 +2154,9 @@ struct ShapeRenderingVisitor
}
case XML_RECT:
{
- // collect attributes
- const sal_Int32 nNumAttrs( xAttributes->getLength() );
- rtl::OUString sAttributeValue;
- bool bRxSeen=false, bRySeen=false;
- double x=0.0,y=0.0,width=0.0,height=0.0,rx=0.0,ry=0.0;
- for( sal_Int32 i=0; i<nNumAttrs; ++i )
- {
- sAttributeValue = xAttributes->item(i)->getNodeValue();
- const sal_Int32 nAttribId(
- getTokenId(xAttributes->item(i)->getNodeName()));
- switch(nAttribId)
- {
- case XML_X:
- x = convLength(sAttributeValue,maCurrState,'h');
- break;
- 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;
- case XML_RX:
- rx = convLength(sAttributeValue,maCurrState,'h');
- bRxSeen=true;
- break;
- case XML_RY:
- ry = convLength(sAttributeValue,maCurrState,'v');
- bRySeen=true;
- break;
- default:
- // skip
- break;
- }
- }
-
- if( bRxSeen && !bRySeen )
- ry = rx;
- else if( bRySeen && !bRxSeen )
- rx = ry;
-
basegfx::B2DPolygon aPoly;
- aPoly = basegfx::tools::createPolygonFromRect(
- basegfx::B2DRange(x,y,x+width,y+height),
- rx/(0.5*width), ry/(0.5*height) );
+ lcl_RectAttrs2Polygon( xAttributes, maCurrState, aPoly );
renderPathShape(basegfx::B2DPolyPolygon(aPoly));
break;
}
commit df094fbfbdcf64493f1c337df81d77452333bd86
Author: Chr. Rossmanith <Chr.Rossmanith at gmx.de>
Date: Sat Apr 28 19:41:35 2012 +0200
Correct handling of corner radii of rectangles
diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
index 4e6f9f1..563060b 100644
--- a/filter/source/svg/svgreader.cxx
+++ b/filter/source/svg/svgreader.cxx
@@ -1351,7 +1351,7 @@ struct ShapeWritingVisitor
basegfx::B2DPolygon aPoly;
aPoly = basegfx::tools::createPolygonFromRect(
basegfx::B2DRange(x,y,x+width,y+height),
- rx/width, ry/height );
+ rx/(0.5*width), ry/(0.5*height) );
writePathShape(xAttrs,
xUnoAttrs,
@@ -2195,7 +2195,7 @@ struct ShapeRenderingVisitor
basegfx::B2DPolygon aPoly;
aPoly = basegfx::tools::createPolygonFromRect(
basegfx::B2DRange(x,y,x+width,y+height),
- rx, ry );
+ rx/(0.5*width), ry/(0.5*height) );
renderPathShape(basegfx::B2DPolyPolygon(aPoly));
break;
commit 884a5ca1716704249bbd108519c64001258eb0fe
Author: Chr. Rossmanith <Chr.Rossmanith at gmx.de>
Date: Sat Apr 28 20:36:54 2012 +0200
enable rendering of text without any attributes
diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
index f6dc668..4e6f9f1 100644
--- a/filter/source/svg/svgreader.cxx
+++ b/filter/source/svg/svgreader.cxx
@@ -157,8 +157,24 @@ struct AnnotatingVisitor
maParentStates.push_back(rInitialState);
}
- void operator()( const uno::Reference<xml::dom::XElement>& )
- {}
+ void operator()( const uno::Reference<xml::dom::XElement>& xElem)
+ {
+ const sal_Int32 nTagId(getTokenId(xElem->getTagName()));
+ if (nTagId != XML_TEXT)
+ return;
+
+ 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);
+ }
void operator()( const uno::Reference<xml::dom::XElement>& xElem,
const uno::Reference<xml::dom::XNamedNodeMap>& xAttributes )
More information about the Libreoffice-commits
mailing list