ooo-build r13188 - in trunk: . patches/dev300 patches/test



Author: thorstenb
Date: Mon Jul 14 11:12:22 2008
New Revision: 13188
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13188&view=rev

Log:
	* patches/test/svg-import-rsvg.diff: work in progress, parked here
	for the while.
	* patches/dev300/vcl-pluggable-mtf-renderer.diff:
	Limit exposure to arbitrary binary data to zero existing services,
	some cleanup.



Added:
   trunk/patches/test/svg-import-rsvg.diff
Modified:
   trunk/ChangeLog
   trunk/patches/dev300/vcl-pluggable-mtf-renderer.diff

Modified: trunk/patches/dev300/vcl-pluggable-mtf-renderer.diff
==============================================================================
--- trunk/patches/dev300/vcl-pluggable-mtf-renderer.diff	(original)
+++ trunk/patches/dev300/vcl-pluggable-mtf-renderer.diff	Mon Jul 14 11:12:22 2008
@@ -1,9 +1,16 @@
- vcl/inc/vcl/gdimtf.hxx    |   26 +++++++++++
- vcl/source/gdi/gdimtf.cxx |  107 +++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 132 insertions(+), 1 deletions(-)
+moved here from rsvg renderer
+
+From:  <>
+
+
+---
+
+ vcl/inc/vcl/gdimtf.hxx    |   26 +++++++++
+ vcl/source/gdi/gdimtf.cxx |  129 +++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 154 insertions(+), 1 deletions(-)
 
 diff --git a/vcl/inc/vcl/gdimtf.hxx b/vcl/inc/vcl/gdimtf.hxx
-index 234e127..b336414 100644
+index 234e127..6903acb 100644
 --- vcl/inc/vcl/gdimtf.hxx
 +++ vcl/inc/vcl/gdimtf.hxx
 @@ -41,6 +41,7 @@
@@ -18,7 +25,7 @@
                                                        const PolyPolygon&    rPolyPoly,
                                                        const Gradient&	  	rGrad 		);
  	SAL_DLLPRIVATE bool			   ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, Size rDestSize );
-+    SAL_DLLPRIVATE void          ImplDelegatePluggableRenderer( const MetaCommentAction* pAct, OutputDevice* pOut );
++    SAL_DLLPRIVATE void          ImplDelegate2PluggableRenderer( const MetaCommentAction* pAct, OutputDevice* pOut );
  
  //#endif // __PRIVATE
  
@@ -47,26 +54,27 @@
 + */
 +MetaCommentAction* makePluggableRendererAction( const rtl::OUString& rRendererServiceName,
 +                                                const rtl::OUString& rGraphicServiceName,
-+                                                const BYTE* pData,
++                                                const void* pData,
 +                                                sal_uInt32 nDataSize );
 +
  #endif // _SV_GDIMTF_HXX
  
 diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
-index 92e2acf..24a28ac 100644
+index 92e2acf..8c1c012 100644
 --- vcl/source/gdi/gdimtf.cxx
 +++ vcl/source/gdi/gdimtf.cxx
-@@ -54,6 +54,9 @@
+@@ -54,6 +54,10 @@
  #include <com/sun/star/rendering/MtfRenderer.hpp>
  #include <comphelper/processfactory.hxx>
  #include <com/sun/star/lang/XMultiServiceFactory.hpp>
++#include <com/sun/star/lang/XInitialization.hpp>
 +#include <com/sun/star/awt/XGraphics.hpp>
 +#include <com/sun/star/graphic/XGraphic.hpp>
 +#include <com/sun/star/graphic/XGraphicRenderer.hpp>
  
  using namespace com::sun::star;
  
-@@ -477,7 +480,16 @@ void GDIMetaFile::Play( OutputDevice* pOut, ULONG nPos )
+@@ -477,7 +481,16 @@ void GDIMetaFile::Play( OutputDevice* pOut, ULONG nPos )
  		{
  			if( !Hook() )
  			{
@@ -75,7 +83,7 @@
 +                if( pAction->GetType() == META_COMMENT_ACTION &&
 +                    pCommentAct->GetComment().Equals("DELEGATE_PLUGGABLE_RENDERER") )
 +                {
-+                    ImplDelegatePluggableRenderer(pCommentAct, pOut);
++                    ImplDelegate2PluggableRenderer(pCommentAct, pOut);
 +                }
 +                else
 +                {
@@ -84,11 +92,11 @@
  
  				// flush output from time to time
  				if( i++ > nSyncCount )
-@@ -563,6 +575,58 @@ bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, S
+@@ -563,6 +576,77 @@ bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, S
  
  // ------------------------------------------------------------------------
  
-+void GDIMetaFile::ImplDelegatePluggableRenderer( const MetaCommentAction* pAct, OutputDevice* pOut )
++void GDIMetaFile::ImplDelegate2PluggableRenderer( const MetaCommentAction* pAct, OutputDevice* pOut )
 +{
 +    OSL_ASSERT( pAct->GetComment().Equals("DELEGATE_PLUGGABLE_RENDERER") );
 +
@@ -112,28 +120,47 @@
 +    uno::Reference< lang::XMultiServiceFactory > xFactory = vcl::unohelper::GetMultiServiceFactory();
 +    if( pData<pEndData && xFactory.is() )
 +    {
-+        // instantiate render service
-+        uno::Sequence<uno::Any> aArgs(1);
-+        aArgs[0] = makeAny(uno::Reference<awt::XGraphics>(pOut->CreateUnoGraphics()));
-+        uno::Reference<graphic::XGraphicRenderer> xRenderer(
-+            xFactory->createInstanceWithArguments(
-+                aRendererServiceName,
-+                aArgs),
-+            uno::UNO_QUERY );
-+
-+        // instantiate graphic service
-+        uno::Sequence< sal_Int8 > aSeq( 
-+            (sal_Int8*)&pData, pEndData-pData );
-+        aArgs[0] = makeAny(aSeq);
-+        uno::Reference<graphic::XGraphic> xGraphic(
-+            xFactory->createInstanceWithArguments(
-+                aGraphicServiceName,
-+                aArgs),
-+            uno::UNO_QUERY );
++        try
++        {
++            // instantiate render service
++            uno::Sequence<uno::Any> aRendererArgs(1);
++            aRendererArgs[0] = makeAny(uno::Reference<awt::XGraphics>(pOut->CreateUnoGraphics()));
++            uno::Reference<graphic::XGraphicRenderer> xRenderer(
++                xFactory->createInstanceWithArguments(
++                    aRendererServiceName,
++                    aRendererArgs),
++                uno::UNO_QUERY );
++
++            // instantiate graphic service
++            uno::Reference<graphic::XGraphic> xGraphic(
++                xFactory->createInstance(
++                    aGraphicServiceName),
++                uno::UNO_QUERY );
++
++            uno::Reference<lang::XInitialization> xInit(
++                xGraphic, uno::UNO_QUERY);
++
++            if(xGraphic.is() && xRenderer.is() && xInit.is())
++            {
++                // delay intialization of XGraphic, to only expose
++                // XGraphic-generating services to arbitrary binary data
++                uno::Sequence< sal_Int8 > aSeq( 
++                    (sal_Int8*)&pData, pEndData-pData );
++                uno::Sequence<uno::Any> aGraphicsArgs(1);
++                aGraphicsArgs[0] = makeAny(aSeq);
++                xInit->initialize(aGraphicsArgs);
 +
-+        if(xGraphic.is() && xRenderer.is())
++                xRenderer->render(xGraphic);
++            }
++        }
++        catch( uno::RuntimeException& )
++        {
++            // runtime errors are fatal
++            throw;
++        }
++        catch( uno::Exception& )
 +        {
-+            xRenderer->render(xGraphic);
++            // ignore errors, no way of reporting them here
 +        }
 +    }
 +}
@@ -143,7 +170,7 @@
  void GDIMetaFile::Play( OutputDevice* pOut, const Point& rPos,
  						const Size& rSize, ULONG nPos )
  {
-@@ -2606,3 +2670,44 @@ void GDIMetaFile::UseCanvas( BOOL _bUseCanvas )
+@@ -2606,3 +2690,46 @@ void GDIMetaFile::UseCanvas( BOOL _bUseCanvas )
  {
      bUseCanvas = _bUseCanvas;
  }
@@ -152,9 +179,11 @@
 +
 +MetaCommentAction* makePluggableRendererAction( const rtl::OUString& rRendererServiceName,
 +                                                const rtl::OUString& rGraphicServiceName,
-+                                                const BYTE* pData,
++                                                const void* _pData,
 +                                                sal_uInt32 nDataSize )
 +{
++    const BYTE* pData=(BYTE*)_pData;
++
 +    // data gets copied twice, unfortunately
 +    rtl::OString aRendererServiceName(
 +        rRendererServiceName.getStr(), 

Added: trunk/patches/test/svg-import-rsvg.diff
==============================================================================
--- (empty file)
+++ trunk/patches/test/svg-import-rsvg.diff	Mon Jul 14 11:12:22 2008
@@ -0,0 +1,180 @@
+moving vcl stuff to pluggable render patch
+
+From:  <>
+
+
+---
+
+ .../internalgraphicfilters/svg_Export.xcu          |   10 +++
+ filter/source/svg/exports.map                      |    1 
+ filter/source/svg/svgfilter.cxx                    |    9 ++
+ filter/source/svg/svgfilter.hxx                    |    7 ++
+ filter/source/svg/svgreader.cxx                    |   81 ++++++++++++++++++++
+ 5 files changed, 108 insertions(+), 0 deletions(-)
+
+diff --git a/filter/source/config/fragments/internalgraphicfilters/svg_Export.xcu b/filter/source/config/fragments/internalgraphicfilters/svg_Export.xcu
+index 8b73f15..f0cd69d 100644
+--- filter/source/config/fragments/internalgraphicfilters/svg_Export.xcu
++++ filter/source/config/fragments/internalgraphicfilters/svg_Export.xcu
+@@ -8,3 +8,13 @@
+ 		</prop>
+ 		<prop oor:name="Flags"><value>EXPORT</value></prop>
+ 	</node>
++	<node oor:name="svg_Import" oor:op="replace"  >
++		<prop oor:name="Type"><value>svg_Scalable_Vector_Graphics</value></prop>
++        <prop oor:name="FormatName"><value>svgfilter</value></prop>
++        <prop oor:name="RealFilterName"/>
++		<prop oor:name="UIComponent"/>
++		<prop oor:name="UIName">
++			<value xml:lang="en-US">SVG - Scalable Vector Graphics</value>
++		</prop>
++		<prop oor:name="Flags"><value>IMPORT</value></prop>
++	</node>
+diff --git a/filter/source/svg/exports.map b/filter/source/svg/exports.map
+index acb4748..d56c225 100644
+--- filter/source/svg/exports.map
++++ filter/source/svg/exports.map
+@@ -3,6 +3,7 @@ SVGFILTER_1_0 {
+                 component_getImplementationEnvironment;
+                 component_getFactory;
+                 component_writeInfo;
++                GraphicImport;
+ 
+         local:
+                 *;
+diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
+index 9efbed7..de1e638 100644
+--- filter/source/svg/svgfilter.cxx
++++ filter/source/svg/svgfilter.cxx
+@@ -208,6 +208,14 @@ rtl::OUString SAL_CALL SVGFilter::detect( Sequence< PropertyValue >& io_rDescrip
+ 
+ // -----------------------------------------------------------------------------
+ 
++class FilterConfigItem;
++extern "C" BOOL __LOADONCALLAPI GraphicImport(SvStream & rStream, Graphic & rGraphic, FilterConfigItem*, BOOL )
++{
++	return importSvg( rStream, rGraphic );
++}
++
++// -----------------------------------------------------------------------------
++
+ namespace sdecl = comphelper::service_decl;
+  sdecl::class_<SVGFilter> serviceImpl;
+  const sdecl::ServiceDecl svgFilter(
+@@ -219,3 +227,4 @@ namespace sdecl = comphelper::service_decl;
+ 
+ // The C shared lib entry points
+ COMPHELPER_SERVICEDECL_EXPORTS1(svgFilter)
++
+diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
+index dcb8065..b057a5e 100644
+--- filter/source/svg/svgfilter.hxx
++++ filter/source/svg/svgfilter.hxx
+@@ -271,4 +271,11 @@ sal_Bool SAL_CALL SVGFilter_supportsService( const ::rtl::OUString& ServiceName
+ SAL_CALL SVGFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+ 	throw ( ::com::sun::star::uno::Exception );
+ 
++// -----------------------------------------------------------------------------
++
++class SvStream;
++class Graphic;
++
++bool importSvg(SvStream & rStream, Graphic & rGraphic );
++
+ #endif // SVGFILTER_HXX
+diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
+index 2525999..56c5269 100644
+--- filter/source/svg/svgreader.cxx
++++ filter/source/svg/svgreader.cxx
+@@ -41,6 +41,18 @@
+ #include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
+ #include <com/sun/star/xml/dom/NodeType.hpp>
+ 
++#include <comphelper/processfactory.hxx>
++#include <basegfx/polygon/b2dpolygoncutandtouch.hxx>
++#include <basegfx/polygon/b2dpolypolygontools.hxx>
++#include <unotools/streamwrap.hxx>
++#include <xmloff/xmluconv.hxx>
++#include <vcl/graph.hxx>
++#include <vcl/virdev.hxx>
++#include <vcl/metaact.hxx>
++#include <vcl/gradient.hxx>
++#include <svx/impgrf.hxx>
++#include <tools/zcodec.hxx>
++
+ #include <boost/bind.hpp>
+ #include <hash_set>
+ #include <map>
+@@ -1874,3 +1886,72 @@ sal_Bool SVGReader::parseAndConvert()
+ }
+ 
+ } // namespace svgi
++
++/////////////////////////////////////////////////////////////////////
++
++bool importSvg(SvStream & rStream, Graphic & rGraphic )
++{
++    // TODO(P2): need to peek into svg to determine dimensions. but no
++    // need to load the _whole_ document! Better use librsvg to
++    // generate a preview bitmap and grab size from there
++    const uno::Reference<lang::XMultiServiceFactory> xServiceFactory(
++        ::comphelper::getProcessServiceFactory());    
++
++	uno::Reference<xml::dom::XDocumentBuilder> xDomBuilder( 
++        xServiceFactory->createInstance( 
++            rtl::OUString::createFromAscii("com.sun.star.xml.dom.DocumentBuilder")), 
++        uno::UNO_QUERY );
++
++    uno::Reference<io::XInputStream> xStream(
++        new utl::OInputStreamWrapper(rStream) );
++
++    uno::Reference<xml::dom::XDocument> xDom(
++        xDomBuilder->parse(xStream),
++        uno::UNO_QUERY_THROW );
++
++    uno::Reference<xml::dom::XElement> xDocElem( xDom->getDocumentElement(),
++                                                 uno::UNO_QUERY_THROW );
++    
++    // get the document dimensions
++
++    // if the "width" and "height" attributes are missing, inkscape fakes
++    // A4 portrait for. Let's do the same.
++    double nWidth(21000.0);
++    double nHeight(29700.0);
++    svgi::State aInitialState;
++	if (xDocElem->hasAttribute(USTR("width")))
++        nWidth = svgi::pt100thmm(svgi::convLength(xDocElem->getAttribute(USTR("width")),
++                                                  aInitialState,'h')); 
++	if (xDocElem->hasAttribute(USTR("height")))
++        nHeight = svgi::pt100thmm(svgi::convLength(xDocElem->getAttribute(USTR("height")),
++                                                   aInitialState,'v'));
++    GDIMetaFile aMtf;
++
++    // rewind stream & extract binary blob
++    const sal_Size nBytes(rStream.Tell());
++    rStream.Seek(STREAM_SEEK_TO_BEGIN);
++    void* const pBuf=rtl_allocateMemory(nBytes);
++    if( rStream.Read(pBuf,nBytes) != nBytes )
++    {
++        rtl_freeMemory(pBuf);
++        return sal_False;
++    }
++    aMtf.AddAction( 
++        makePluggableRendererAction(
++            USTR("com.sun.star.comp.SVGRenderer"),
++            USTR("com.sun.star.comp.SVGGraphic"),
++            pBuf,nBytes));
++    rtl_freeMemory(pBuf);
++
++    aMtf.SetPrefMapMode( MAP_100TH_MM );
++
++    aMtf.SetPrefSize( 
++        Size( basegfx::fround(nWidth), 
++              basegfx::fround(nHeight)));
++
++    rGraphic = aMtf;
++    
++    return sal_True;
++}
++
++



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]