You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2011/12/01 17:26:53 UTC
svn commit: r1209140 [11/11] - in
/incubator/ooo/branches/alg/svgreplacement/main: ./
basegfx/inc/basegfx/matrix/ basegfx/inc/basegfx/polygon/
basegfx/source/polygon/ cppcanvas/source/mtfrenderer/ drawinglayer/
drawinglayer/inc/drawinglayer/primitive2d...
Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/outdev.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/outdev.hxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/outdev.hxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/outdev.hxx Thu Dec 1 16:25:17 2011
@@ -40,6 +40,7 @@
#include <basegfx/vector/b2enums.hxx>
#include <com/sun/star/uno/Reference.h>
#include <unotools/fontdefs.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <vector>
@@ -87,7 +88,6 @@ namespace basegfx {
class B2DHomMatrix;
class B2DPolygon;
class B2DPolyPolygon;
- typedef ::std::vector< B2DPolyPolygon > B2DPolyPolygonVector;
}
namespace com {
@@ -104,7 +104,6 @@ namespace vcl
class PDFWriterImpl;
class ExtOutDevData;
class ITextLayout;
- class RenderGraphic;
}
#define OUTDEV_BUFFER_SIZE 128
@@ -813,9 +812,6 @@ public:
bool DrawEPS( const Point& rPt, const Size& rSz,
const GfxLink& rGfxLink, GDIMetaFile* pSubst = NULL );
- void DrawRenderGraphic( const Point& rPt, const Size& rSz,
- const ::vcl::RenderGraphic& rRenderGraphic );
-
Color GetPixel( const Point& rPt ) const;
Color* GetPixel( const Polygon& rPts ) const;
Added: incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/svgdata.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/svgdata.hxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/svgdata.hxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/svgdata.hxx Thu Dec 1 16:25:17 2011
@@ -0,0 +1,77 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+#ifndef _SV_SVGDATA_HXX
+#define _SV_SVGDATA_HXX
+
+#include <basegfx/range/b2drange.hxx>
+#include <boost/shared_array.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
+#include <com/sun/star/graphic/XPrimitive2D.hpp>
+#include <vcl/bitmapex.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+typedef boost::shared_array< sal_uInt8 > SvgDataArray;
+typedef ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive2D > Primitive2DReference;
+typedef ::com::sun::star::uno::Sequence< Primitive2DReference > Primitive2DSequence;
+
+//////////////////////////////////////////////////////////////////////////////
+
+class VCL_DLLPUBLIC SvgData : private boost::noncopyable
+{
+private:
+ // the file and length
+ SvgDataArray maSvgDataArray;
+ sal_uInt32 mnSvgDataArrayLength;
+
+ // on demand created content
+ basegfx::B2DRange maRange;
+ Primitive2DSequence maSequence;
+ BitmapEx maReplacement;
+
+ // on demand creators
+ void ensureReplacement();
+ void ensureSequenceAndRange();
+
+public:
+ SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength);
+
+ /// data read
+ const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; }
+ sal_uInt32 getSvgDataArrayLength() const { return mnSvgDataArrayLength; }
+
+ /// data read and evtl. on demand creation
+ const basegfx::B2DRange& getRange() const;
+ const Primitive2DSequence& getPrimitive2DSequence() const;
+ const BitmapEx& getReplacement() const;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+typedef boost::shared_ptr< SvgData > SvgDataPtr;
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif // _SV_SVGDATA_HXX
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/gdimtf.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/gdimtf.cxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/gdimtf.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/gdimtf.cxx Thu Dec 1 16:25:17 2011
@@ -1445,15 +1445,6 @@ void GDIMetaFile::Rotate( long nAngle10
}
break;
- case( META_RENDERGRAPHIC_ACTION ):
- {
- OSL_TRACE( "Rotate not supported for RenderGraphic MetaActions yet" );
-
- pAction->Duplicate();
- aMtf.AddAction( pAction );
- }
- break;
-
default:
{
pAction->Execute( &aMapVDev );
@@ -1876,14 +1867,6 @@ Rectangle GDIMetaFile::GetBoundRect( Out
}
break;
- case( META_RENDERGRAPHIC_ACTION ):
- {
- MetaRenderGraphicAction* pAct = (MetaRenderGraphicAction*) pAction;
- Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
-
default:
{
pAction->Execute( &aMapVDev );
@@ -2282,15 +2265,6 @@ void GDIMetaFile::ImplExchangeColors( Co
}
break;
- case( META_RENDERGRAPHIC_ACTION ):
- {
- OSL_TRACE( "ExchangeColors not supported for RenderGraphic MetaActions yet" );
-
- pAction->Duplicate();
- aMtf.Insert( pAction, LIST_APPEND );
- }
- break;
-
default:
{
pAction->Duplicate();
@@ -2739,30 +2713,6 @@ sal_uLong GDIMetaFile::GetChecksum() con
}
break;
- case( META_RENDERGRAPHIC_ACTION ):
- {
- MetaRenderGraphicAction* pAct = (MetaRenderGraphicAction*) pAction;
- const ::vcl::RenderGraphic& rRenderGraphic = pAct->GetRenderGraphic();
-
- ShortToSVBT16( pAct->GetType(), aBT16 );
- nCrc = rtl_crc32( nCrc, aBT16, 2 );
-
- nCrc = rtl_crc32( nCrc, rRenderGraphic.GetGraphicData().get(), rRenderGraphic.GetGraphicDataLength() );
-
- UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
-
- UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
-
- UInt32ToSVBT32( pAct->GetSize().Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
-
- UInt32ToSVBT32( pAct->GetSize().Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
- }
- break;
-
default:
{
pAction->Write( aMemStm, &aWriteData );
@@ -2828,8 +2778,6 @@ sal_uLong GDIMetaFile::GetSizeBytes() co
nSizeBytes += ( pTextArrayAction->GetLen() << 2 );
}
break;
-
- case( META_RENDERGRAPHIC_ACTION ): nSizeBytes += ( ( (MetaRenderGraphicAction*) pAction )->GetRenderGraphic() ).GetGraphicDataLength(); break;
}
}
@@ -2857,63 +2805,27 @@ SvStream& operator>>( SvStream& rIStm, G
// new format
VersionCompat* pCompat;
MetaAction* pAction;
- sal_uInt32 nStmCompressMode = 0;
- sal_uInt32 nCount = 0;
- sal_uInt8 bRenderGraphicReplacements = 0;
+ sal_uInt32 nStmCompressMode = 0;
+ sal_uInt32 nCount = 0;
pCompat = new VersionCompat( rIStm, STREAM_READ );
- {
- // version 1
- rIStm >> nStmCompressMode;
- rIStm >> rGDIMetaFile.aPrefMapMode;
- rIStm >> rGDIMetaFile.aPrefSize;
- rIStm >> nCount;
- if( pCompat->GetVersion() >= 2 )
- {
- // version 2
- // =========
- // contains an additional flag to indicate that RenderGraphic
- // actions are immediately followed by a replacement image, that
- // needs to be skipped in case the flag is set (KA 01/2011)
+ rIStm >> nStmCompressMode;
+ rIStm >> rGDIMetaFile.aPrefMapMode;
+ rIStm >> rGDIMetaFile.aPrefSize;
+ rIStm >> nCount;
- rIStm >> bRenderGraphicReplacements;
- }
- }
delete pCompat;
ImplMetaReadData aReadData;
aReadData.meActualCharSet = rIStm.GetStreamCharSet();
- for( sal_uInt32 nAction = 0UL; ( nAction < nCount ) && !rIStm.IsEof(); ++nAction )
+ for( sal_uInt32 nAction = 0UL; ( nAction < nCount ) && !rIStm.IsEof(); nAction++ )
{
pAction = MetaAction::ReadMetaAction( rIStm, &aReadData );
if( pAction )
- {
rGDIMetaFile.AddAction( pAction );
-
- // if the MetaFile was written in RenderGraphics replacement mode
- // and we just read a RenderGraphic action, skip the following
- // META_BMPEXSCALE_ACTION, since this is the replacement image,
- // just needed for old implementations; don't forget to increment
- // the action read counter! (KA 01/2011)
- if( bRenderGraphicReplacements &&
- ( META_RENDERGRAPHIC_ACTION == pAction->GetType() ) &&
- ( ++nAction < nCount ) && !rIStm.IsEof() )
- {
- sal_uInt16 nFollowingType;
-
- // dummy read of the next following META_BMPEXSCALE_ACTION
- // RenderGraphic replacement action (KA 01/2011)
- rIStm >> nFollowingType;
- delete ( new VersionCompat( rIStm, STREAM_READ ) );
-
- OSL_ENSURE( META_BMPEXSCALE_ACTION == nFollowingType, \
-"META_RENDERGRAPHIC_ACTION read in RenderGraphic replacement mode \
-without following META_BMPEXSCALE_ACTION replacement" );
- }
- }
}
}
else
@@ -2980,90 +2892,32 @@ SvStream& GDIMetaFile::Read( SvStream& r
// ------------------------------------------------------------------------
-SvStream& GDIMetaFile::Write( SvStream& rOStm, GDIMetaFileWriteFlags nWriteFlags )
+SvStream& GDIMetaFile::Write( SvStream& rOStm )
{
VersionCompat* pCompat;
- const sal_uInt32 nStmCompressMode = rOStm.GetCompressMode();
- sal_uInt16 nOldFormat = rOStm.GetNumberFormatInt();
- const sal_uInt8 bRenderGraphicReplacements =
- ( ( ( GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC & nWriteFlags ) != 0 ) ? 1 : 0 );
-
- // With the introduction of the META_RENDERGRAPHIC_ACTION, it is neccessary
- // to provide some kind of document backward compatibility:
- //
- // If the flag GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC is set in
- // parameter nWriteFlags, each META_RENDERGRAPHIC_ACTION is followed by
- // an additional META_BMPEXSCALE_ACTION, that contains a replacement
- // image for the new RenderGraphic action.
- //
- // Old implementations, not knowing anything about META_RENDERGRAPHIC_ACTION,
- // will skip this new action and read the META_BMPEXSCALE_ACTION instead
- //
- // Since the current implementation is able to handle the new action, the
- // then following image replacement action needs to be skipped by this
- // implementation, if the metafile was written in the RenderGraphic
- // replacement mode.
- //
- // To be able to detect this compatibility mode, the header needs to
- // be extended by a corresponding flag, resulting in version 2 of
- // the header. The surrounding VersionCompat of the header
- // allows to add such new data without any problems (KA 01/2011)
+ const sal_uInt32 nStmCompressMode = rOStm.GetCompressMode();
+ sal_uInt16 nOldFormat = rOStm.GetNumberFormatInt();
rOStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
rOStm.Write( "VCLMTF", 6 );
- pCompat = new VersionCompat( rOStm, STREAM_WRITE, 2 );
-
- {
- // version 1
- sal_uInt32 nActionCount = 0;
+ pCompat = new VersionCompat( rOStm, STREAM_WRITE, 1 );
- // calculate correct action count and watch for
- // additional RenderGraphic replacement actions, if the
- // GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC is set
- // and META_RENDERGRAPHIC_ACTION are encountered (KA 01/2011)
- for( MetaAction* pAct = static_cast< MetaAction* >( First() ); pAct; pAct = static_cast< MetaAction* >( Next() ) )
- {
- nActionCount += ( bRenderGraphicReplacements && ( META_RENDERGRAPHIC_ACTION == pAct->GetType() ) ? 2 : 1 );
- }
-
- rOStm << nStmCompressMode << aPrefMapMode << aPrefSize << nActionCount;
-
- {
- // version 2
- // =========
- // since version 2, a GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC flag
- // is written, to indicate that each META_BMPEXSCALE_ACTION following
- // a META_RENDERGRAPHIC_ACTION needs to be skipped, in case the flag is
- // set (KA 01/2011)
- rOStm << bRenderGraphicReplacements;
- }
- }
+ rOStm << nStmCompressMode;
+ rOStm << aPrefMapMode;
+ rOStm << aPrefSize;
+ rOStm << (sal_uInt32) GetActionCount();
delete pCompat;
ImplMetaWriteData aWriteData;
-
aWriteData.meActualCharSet = rOStm.GetStreamCharSet();
- aWriteData.mnWriteFlags = nWriteFlags;
- for( MetaAction* pAct = static_cast< MetaAction* >( First() ); pAct; pAct = static_cast< MetaAction* >( Next() ) )
+ MetaAction* pAct = (MetaAction*)First();
+ while ( pAct )
{
pAct->Write( rOStm, &aWriteData );
-
- // write the RenderGraphic replacement image, if the
- // GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC flag is set
- // and if a META_RENDERGRAPHIC_ACTION is encountered (KA 01/2011)
- if( bRenderGraphicReplacements && ( META_RENDERGRAPHIC_ACTION == pAct->GetType() ) )
- {
- MetaRenderGraphicAction* pRenderAction = static_cast< MetaRenderGraphicAction* >( pAct );
- MetaBmpExScaleAction* pBmpExScaleAction = new MetaBmpExScaleAction(
- pRenderAction->GetPoint(), pRenderAction->GetSize(),
- pRenderAction->GetRenderGraphic().GetReplacement() );
-
- pBmpExScaleAction->Write( rOStm, &aWriteData );
- pBmpExScaleAction->Delete();
- }
+ pAct = (MetaAction*)Next();
}
rOStm.SetNumberFormatInt( nOldFormat );
Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/graph.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/graph.cxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/graph.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/graph.cxx Thu Dec 1 16:25:17 2011
@@ -27,11 +27,9 @@
#include <vcl/outdev.hxx>
#include <vcl/svapp.hxx>
#include <vcl/graph.hxx>
-
+#include <vcl/metaact.hxx>
#include <impgraph.hxx>
-
#include <comphelper/processfactory.hxx>
-
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
@@ -244,6 +242,13 @@ Graphic::Graphic( const BitmapEx& rBmpEx
// ------------------------------------------------------------------------
+Graphic::Graphic(const SvgDataPtr& rSvgDataPtr)
+{
+ mpImpGraphic = new ImpGraphic(rSvgDataPtr);
+}
+
+// ------------------------------------------------------------------------
+
Graphic::Graphic( const Animation& rAnimation )
{
mpImpGraphic = new ImpGraphic( rAnimation );
@@ -434,20 +439,6 @@ sal_Bool Graphic::IsEPS() const
// ------------------------------------------------------------------------
-sal_Bool Graphic::IsRenderGraphic() const
-{
- return mpImpGraphic->ImplIsRenderGraphic();
-}
-
-// ------------------------------------------------------------------------
-
-sal_Bool Graphic::HasRenderGraphic() const
-{
- return mpImpGraphic->ImplHasRenderGraphic();
-}
-
-// ------------------------------------------------------------------------
-
Bitmap Graphic::GetBitmap(const GraphicConversionParameters& rParameters) const
{
return mpImpGraphic->ImplGetBitmap(rParameters);
@@ -476,13 +467,6 @@ const GDIMetaFile& Graphic::GetGDIMetaFi
// ------------------------------------------------------------------------
-::vcl::RenderGraphic Graphic::GetRenderGraphic() const
-{
- return mpImpGraphic->ImplGetRenderGraphic();
-}
-
-// ------------------------------------------------------------------------
-
uno::Reference< graphic::XGraphic > Graphic::GetXGraphic() const
{
uno::Reference< graphic::XGraphic > xRet;
@@ -840,3 +824,8 @@ SvStream& operator<<( SvStream& rOStream
{
return rOStream << *rGraphic.mpImpGraphic;
}
+
+const SvgDataPtr& Graphic::getSvgData() const
+{
+ return mpImpGraphic->getSvgData();
+}
Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/impgraph.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/impgraph.cxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/impgraph.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/impgraph.cxx Thu Dec 1 16:25:17 2011
@@ -175,6 +175,8 @@ ImpGraphic::ImpGraphic( const ImpGraphic
}
else
mpAnimation = NULL;
+
+ maSvgData = rImpGraphic.maSvgData;
}
// ------------------------------------------------------------------------
@@ -213,6 +215,23 @@ ImpGraphic::ImpGraphic( const BitmapEx&
// ------------------------------------------------------------------------
+ImpGraphic::ImpGraphic(const SvgDataPtr& rSvgDataPtr)
+: mpAnimation( NULL ),
+ mpContext( NULL ),
+ mpSwapFile( NULL ),
+ mpGfxLink( NULL ),
+ meType( rSvgDataPtr.get() ? GRAPHIC_BITMAP : GRAPHIC_NONE ),
+ mnDocFilePos( 0UL ),
+ mnSizeBytes( 0UL ),
+ mnRefCount( 1UL ),
+ mbSwapOut( sal_False ),
+ mbSwapUnderway( sal_False ),
+ maSvgData(rSvgDataPtr)
+{
+}
+
+// ------------------------------------------------------------------------
+
ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
maEx ( rAnimation.GetBitmapEx() ),
mpAnimation ( new Animation( rAnimation ) ),
@@ -298,6 +317,8 @@ ImpGraphic& ImpGraphic::operator=( const
mpGfxLink = new GfxLink( *rImpGraphic.mpGfxLink );
else
mpGfxLink = NULL;
+
+ maSvgData = rImpGraphic.maSvgData;
}
return *this;
@@ -328,13 +349,35 @@ sal_Bool ImpGraphic::operator==( const I
case( GRAPHIC_BITMAP ):
{
- if( mpAnimation )
+ if(maSvgData.get())
+ {
+ if(maSvgData == rImpGraphic.maSvgData)
+ {
+ bRet = sal_True;
+ }
+ else if(rImpGraphic.maSvgData)
+ {
+ if(maSvgData->getSvgDataArrayLength() == rImpGraphic.maSvgData->getSvgDataArrayLength())
+ {
+ if(0 == memcmp(
+ maSvgData->getSvgDataArray().get(),
+ rImpGraphic.maSvgData->getSvgDataArray().get(),
+ maSvgData->getSvgDataArrayLength()))
+ {
+ bRet = sal_True;
+ }
+ }
+ }
+ }
+ else if( mpAnimation )
{
if( rImpGraphic.mpAnimation && ( *rImpGraphic.mpAnimation == *mpAnimation ) )
bRet = sal_True;
}
else if( !rImpGraphic.mpAnimation && ( rImpGraphic.maEx == maEx ) )
+ {
bRet = sal_True;
+ }
}
break;
@@ -371,6 +414,8 @@ void ImpGraphic::ImplClearGraphics( sal_
delete mpGfxLink;
mpGfxLink = NULL;
}
+
+ maSvgData.reset();
}
// ------------------------------------------------------------------------
@@ -446,12 +491,12 @@ sal_Bool ImpGraphic::ImplIsSupportedGrap
sal_Bool ImpGraphic::ImplIsTransparent() const
{
- sal_Bool bRet;
+ sal_Bool bRet(sal_True);
- if( meType == GRAPHIC_BITMAP )
+ if( meType == GRAPHIC_BITMAP && !maSvgData.get())
+ {
bRet = ( mpAnimation ? mpAnimation->IsTransparent() : maEx.IsTransparent() );
- else
- bRet = sal_True;
+ }
return bRet;
}
@@ -460,12 +505,16 @@ sal_Bool ImpGraphic::ImplIsTransparent()
sal_Bool ImpGraphic::ImplIsAlpha() const
{
- sal_Bool bRet;
+ sal_Bool bRet(sal_False);
- if( meType == GRAPHIC_BITMAP )
+ if(maSvgData.get())
+ {
+ bRet = sal_True;
+ }
+ else if( meType == GRAPHIC_BITMAP )
+ {
bRet = ( NULL == mpAnimation ) && maEx.IsAlpha();
- else
- bRet = sal_False;
+ }
return bRet;
}
@@ -488,45 +537,18 @@ sal_Bool ImpGraphic::ImplIsEPS() const
// ------------------------------------------------------------------------
-sal_Bool ImpGraphic::ImplIsRenderGraphic() const
-{
- return( ( GRAPHIC_GDIMETAFILE == meType ) &&
- ( 1 == maMetaFile.GetActionCount() ) &&
- ( META_RENDERGRAPHIC_ACTION == maMetaFile.GetAction( 0 )->GetType() ) );
-}
-
-// ------------------------------------------------------------------------
-
-sal_Bool ImpGraphic::ImplHasRenderGraphic() const
-{
- sal_Bool bRet = sal_False;
-
- if( GRAPHIC_GDIMETAFILE == meType )
- {
- GDIMetaFile& rMtf = const_cast< ImpGraphic* >( this )->maMetaFile;
-
- for( MetaAction* pAct = rMtf.FirstAction(); pAct && !bRet; pAct = rMtf.NextAction() )
- {
- if( META_RENDERGRAPHIC_ACTION == pAct->GetType() )
- {
- bRet = sal_True;
- }
- }
-
- rMtf.WindStart();
- }
-
- return( bRet );
-}
-
-// ------------------------------------------------------------------------
-
Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters) const
{
Bitmap aRetBmp;
if( meType == GRAPHIC_BITMAP )
{
+ if(maSvgData.get() && maEx.IsEmpty())
+ {
+ // use maEx as local buffer for rendered svg
+ const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
+ }
+
const BitmapEx& rRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx );
const Color aReplaceColor( COL_WHITE );
@@ -605,6 +627,12 @@ BitmapEx ImpGraphic::ImplGetBitmapEx(con
if( meType == GRAPHIC_BITMAP )
{
+ if(maSvgData.get() && maEx.IsEmpty())
+ {
+ // use maEx as local buffer for rendered svg
+ const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
+ }
+
aRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx );
if(rParameters.getSizePixel().Width() || rParameters.getSizePixel().Height())
@@ -633,18 +661,6 @@ Animation ImpGraphic::ImplGetAnimation()
// ------------------------------------------------------------------------
-::vcl::RenderGraphic ImpGraphic::ImplGetRenderGraphic() const
-{
- ::vcl::RenderGraphic aRet;
-
- if( ImplIsRenderGraphic() )
- aRet = static_cast< MetaRenderGraphicAction* >( maMetaFile.GetAction( 0 ) )->GetRenderGraphic();
-
- return( aRet );
-}
-
-// ------------------------------------------------------------------------
-
const GDIMetaFile& ImpGraphic::ImplGetGDIMetaFile() const
{
return maMetaFile;
@@ -668,10 +684,22 @@ Size ImpGraphic::ImplGetPrefSize() const
case( GRAPHIC_BITMAP ):
{
- aSize = maEx.GetPrefSize();
-
- if( !aSize.Width() || !aSize.Height() )
- aSize = maEx.GetSizePixel();
+ if(maSvgData.get() && maEx.IsEmpty())
+ {
+ // svg not yet buffered in maEx, return size derived from range
+ const basegfx::B2DRange& rRange = maSvgData->getRange();
+
+ aSize = Size(basegfx::fround(rRange.getWidth()), basegfx::fround(rRange.getHeight()));
+ }
+ else
+ {
+ aSize = maEx.GetPrefSize();
+
+ if( !aSize.Width() || !aSize.Height() )
+ {
+ aSize = maEx.GetSizePixel();
+ }
+ }
}
break;
@@ -698,12 +726,24 @@ void ImpGraphic::ImplSetPrefSize( const
break;
case( GRAPHIC_BITMAP ):
+ {
// #108077# Push through pref size to animation object,
// will be lost on copy otherwise
- if( ImplIsAnimated() )
- const_cast< BitmapEx& >(mpAnimation->GetBitmapEx()).SetPrefSize( rPrefSize );
+ if(maSvgData.get())
+ {
+ // ignore for Svg. If this is really used (except the grfcache)
+ // it can be extended by using maEx as buffer for maSvgData->getReplacement()
+ }
+ else
+ {
+ if( ImplIsAnimated() )
+ {
+ const_cast< BitmapEx& >(mpAnimation->GetBitmapEx()).SetPrefSize( rPrefSize );
+ }
- maEx.SetPrefSize( rPrefSize );
+ maEx.SetPrefSize( rPrefSize );
+ }
+ }
break;
default:
@@ -733,10 +773,18 @@ MapMode ImpGraphic::ImplGetPrefMapMode()
case( GRAPHIC_BITMAP ):
{
- const Size aSize( maEx.GetPrefSize() );
-
- if ( aSize.Width() && aSize.Height() )
- aMapMode = maEx.GetPrefMapMode();
+ if(maSvgData.get() && maEx.IsEmpty())
+ {
+ // svg not yet buffered in maEx, return default PrefMapMode
+ aMapMode = MapMode(MAP_100TH_MM);
+ }
+ else
+ {
+ const Size aSize( maEx.GetPrefSize() );
+
+ if ( aSize.Width() && aSize.Height() )
+ aMapMode = maEx.GetPrefMapMode();
+ }
}
break;
@@ -763,12 +811,24 @@ void ImpGraphic::ImplSetPrefMapMode( con
break;
case( GRAPHIC_BITMAP ):
- // #108077# Push through pref mapmode to animation object,
- // will be lost on copy otherwise
- if( ImplIsAnimated() )
- const_cast< BitmapEx& >(mpAnimation->GetBitmapEx()).SetPrefMapMode( rPrefMapMode );
+ {
+ if(maSvgData.get())
+ {
+ // ignore for Svg. If this is really used (except the grfcache)
+ // it can be extended by using maEx as buffer for maSvgData->getReplacement()
+ }
+ else
+ {
+ // #108077# Push through pref mapmode to animation object,
+ // will be lost on copy otherwise
+ if( ImplIsAnimated() )
+ {
+ const_cast< BitmapEx& >(mpAnimation->GetBitmapEx()).SetPrefMapMode( rPrefMapMode );
+ }
- maEx.SetPrefMapMode( rPrefMapMode );
+ maEx.SetPrefMapMode( rPrefMapMode );
+ }
+ }
break;
default:
@@ -788,7 +848,14 @@ sal_uLong ImpGraphic::ImplGetSizeBytes()
{
if( meType == GRAPHIC_BITMAP )
{
- mnSizeBytes = mpAnimation ? mpAnimation->GetSizeBytes() : maEx.GetSizeBytes();
+ if(maSvgData.get())
+ {
+ mnSizeBytes = maSvgData->getSvgDataArrayLength();
+ }
+ else
+ {
+ mnSizeBytes = mpAnimation ? mpAnimation->GetSizeBytes() : maEx.GetSizeBytes();
+ }
}
else if( meType == GRAPHIC_GDIMETAFILE )
{
@@ -812,10 +879,20 @@ void ImpGraphic::ImplDraw( OutputDevice*
case( GRAPHIC_BITMAP ):
{
- if ( mpAnimation )
+ if(maSvgData.get() && !maEx)
+ {
+ // use maEx as local buffer for rendered svg
+ const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
+ }
+
+ if ( mpAnimation )
+ {
mpAnimation->Draw( pOutDev, rDestPt );
+ }
else
+ {
maEx.Draw( pOutDev, rDestPt );
+ }
}
break;
@@ -840,10 +917,20 @@ void ImpGraphic::ImplDraw( OutputDevice*
case( GRAPHIC_BITMAP ):
{
- if( mpAnimation )
+ if(maSvgData.get() && maEx.IsEmpty())
+ {
+ // use maEx as local buffer for rendered svg
+ const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
+ }
+
+ if( mpAnimation )
+ {
mpAnimation->Draw( pOutDev, rDestPt, rDestSize );
+ }
else
+ {
maEx.Draw( pOutDev, rDestPt, rDestSize );
+ }
}
break;
@@ -1052,7 +1139,13 @@ sal_Bool ImpGraphic::ImplReadEmbedded( S
{
if( meType == GRAPHIC_BITMAP )
{
- maEx.aBitmapSize = aSize;
+ if(maSvgData.get() && maEx.IsEmpty())
+ {
+ // use maEx as local buffer for rendered svg
+ maEx = maSvgData->getReplacement();
+ }
+
+ maEx.aBitmapSize = aSize;
if( aMapMode != MapMode() )
{
@@ -1510,10 +1603,20 @@ sal_uLong ImpGraphic::ImplGetChecksum()
case( GRAPHIC_BITMAP ):
{
- if( mpAnimation )
+ if(maSvgData.get() && maEx.IsEmpty())
+ {
+ // use maEx as local buffer for rendered svg
+ const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
+ }
+
+ if( mpAnimation )
+ {
nRet = mpAnimation->GetChecksum();
+ }
else
+ {
nRet = maEx.GetChecksum();
+ }
}
break;
@@ -1553,6 +1656,13 @@ sal_Bool ImpGraphic::ImplExportNative( S
// ------------------------------------------------------------------------
+const SvgDataPtr& ImpGraphic::getSvgData() const
+{
+ return maSvgData;
+}
+
+// ------------------------------------------------------------------------
+
SvStream& operator>>( SvStream& rIStm, ImpGraphic& rImpGraphic )
{
if( !rIStm.GetError() )
@@ -1704,10 +1814,18 @@ SvStream& operator<<( SvStream& rOStm, c
case GRAPHIC_BITMAP:
{
- if ( rImpGraphic.ImplIsAnimated() )
+ if(rImpGraphic.getSvgData().get())
+ {
+ rOStm << rImpGraphic.getSvgData()->getReplacement();
+ }
+ else if( rImpGraphic.ImplIsAnimated())
+ {
rOStm << *rImpGraphic.mpAnimation;
+ }
else
+ {
rOStm << rImpGraphic.maEx;
+ }
}
break;
Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/makefile.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/makefile.mk?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/makefile.mk (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/makefile.mk Thu Dec 1 16:25:17 2011
@@ -76,9 +76,7 @@ EXCEPTIONSFILES= $(SLO)$/salmisc.obj \
$(SLO)$/graphictools.obj \
$(SLO)$/textlayout.obj \
$(SLO)$/lineinfo.obj \
- $(SLO)$/svgread.obj \
- $(SLO)$/rendergraphic.obj \
- $(SLO)$/rendergraphicrasterizer.obj
+ $(SLO)$/svgdata.obj
SLOFILES= $(EXCEPTIONSFILES) \
$(SLO)$/animate.obj \
Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/metaact.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/metaact.cxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/metaact.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/metaact.cxx Thu Dec 1 16:25:17 2011
@@ -34,7 +34,8 @@
#include <vcl/salbtype.hxx>
#include <vcl/metaact.hxx>
#include <vcl/graphictools.hxx>
-#include <vcl/rendergraphicrasterizer.hxx>
+//#include <svgio/svgreader/svgreader.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
// ========================================================================
@@ -232,7 +233,6 @@ MetaAction* MetaAction::ReadMetaAction(
case( META_COMMENT_ACTION ): pAction = new MetaCommentAction; break;
case( META_LAYOUTMODE_ACTION ): pAction = new MetaLayoutModeAction; break;
case( META_TEXTLANGUAGE_ACTION ): pAction = new MetaTextLanguageAction; break;
- case( META_RENDERGRAPHIC_ACTION ): pAction = new MetaRenderGraphicAction; break;
default:
{
@@ -2025,7 +2025,7 @@ void MetaBmpExAction::Execute( OutputDev
MetaAction* MetaBmpExAction::Clone()
{
- MetaAction* pClone = (MetaAction*) new MetaBmpExAction( *this );
+ MetaBmpExAction* pClone = new MetaBmpExAction( *this );
pClone->ResetRefCount();
return pClone;
}
@@ -4297,82 +4297,4 @@ void MetaTextLanguageAction::Read( SvStr
rIStm >> meTextLanguage;
}
-// ========================================================================
-
-IMPL_META_ACTION( RenderGraphic, META_RENDERGRAPHIC_ACTION )
-
-// ------------------------------------------------------------------------
-
-MetaRenderGraphicAction::MetaRenderGraphicAction( const Point& rPoint, const Size& rSize,
- const vcl::RenderGraphic& rRenderGraphic,
- double fRotateAngle, double fShearAngleX, double fShearAngleY ) :
- MetaAction( META_RENDERGRAPHIC_ACTION ),
- maRenderGraphic( rRenderGraphic ),
- maPoint( rPoint ),
- maSize( rSize ),
- mfRotateAngle( fRotateAngle ),
- mfShearAngleX( fShearAngleX ),
- mfShearAngleY( fShearAngleY )
-{
-}
-
-// ------------------------------------------------------------------------
-
-void MetaRenderGraphicAction::Execute( OutputDevice* pOut )
-{
- pOut->DrawRenderGraphic( maPoint, maSize, maRenderGraphic );
-}
-
-// ------------------------------------------------------------------------
-
-MetaAction* MetaRenderGraphicAction::Clone()
-{
- MetaAction* pClone = (MetaAction*) new MetaRenderGraphicAction( *this );
- pClone->ResetRefCount();
- return pClone;
-}
-
-// ------------------------------------------------------------------------
-
-void MetaRenderGraphicAction::Move( long nHorzMove, long nVertMove )
-{
- maPoint.Move( nHorzMove, nVertMove );
-}
-
-// ------------------------------------------------------------------------
-
-void MetaRenderGraphicAction::Scale( double fScaleX, double fScaleY )
-{
- Rectangle aRectangle( maPoint, maSize );
- ImplScaleRect( aRectangle, fScaleX, fScaleY );
- maPoint = aRectangle.TopLeft();
- maSize = aRectangle.GetSize();
-}
-
-// ------------------------------------------------------------------------
-
-sal_Bool MetaRenderGraphicAction::Compare( const MetaAction& rMetaAction ) const
-{
- return ( maRenderGraphic.IsEqual( ( (MetaRenderGraphicAction&) rMetaAction).maRenderGraphic ) &&
- ( maPoint == ( (MetaRenderGraphicAction&) rMetaAction).maPoint ) &&
- ( maSize == ( (MetaRenderGraphicAction&) rMetaAction).maSize ) &&
- ( mfRotateAngle == ( (MetaRenderGraphicAction&) rMetaAction).mfRotateAngle ) &&
- ( mfShearAngleX == ( (MetaRenderGraphicAction&) rMetaAction).mfShearAngleX ) &&
- ( mfShearAngleY == ( (MetaRenderGraphicAction&) rMetaAction).mfShearAngleY ) );
-}
-
-// ------------------------------------------------------------------------
-
-void MetaRenderGraphicAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
-{
- WRITE_BASE_COMPAT( rOStm, 1, pData );
- rOStm << maRenderGraphic << maPoint << maSize << mfRotateAngle << mfShearAngleX << mfShearAngleY;
-}
-
-// ------------------------------------------------------------------------
-
-void MetaRenderGraphicAction::Read( SvStream& rIStm, ImplMetaReadData* )
-{
- COMPAT( rIStm );
- rIStm >> maRenderGraphic >> maPoint >> maSize >> mfRotateAngle >> mfShearAngleX >> mfShearAngleY;
-}
+// eof
Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/outdev6.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/outdev6.cxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/outdev6.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/outdev6.cxx Thu Dec 1 16:25:17 2011
@@ -33,7 +33,6 @@
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
#include <vcl/graph.hxx>
-#include <vcl/rendergraphicrasterizer.hxx>
#include <wall2.hxx>
#include <salgdi.hxx>
@@ -1246,25 +1245,3 @@ bool OutputDevice::DrawEPS( const Point&
return bDrawn;
}
-// ------------------------------------------------------------------
-
-void OutputDevice::DrawRenderGraphic( const Point& rPoint, const Size& rSize,
- const ::vcl::RenderGraphic& rRenderGraphic )
-{
- DBG_TRACE( "OutputDevice::DrawRenderGraphic()" );
-
- if( mpMetaFile )
- mpMetaFile->AddAction( new MetaRenderGraphicAction( rPoint, rSize, rRenderGraphic ) );
-
- if( !rRenderGraphic.IsEmpty() )
- {
- ::vcl::RenderGraphicRasterizer aRasterizer( rRenderGraphic );
- BitmapEx aBmpEx;
- const Size aSizePixel( LogicToPixel( rSize ) );
- GDIMetaFile* pOldMetaFile = mpMetaFile;
-
- mpMetaFile = NULL;
- DrawBitmapEx( rPoint, rSize, aRasterizer.Rasterize( aSizePixel ) );
- mpMetaFile = pOldMetaFile;
- }
-}
Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/pdfwriter_impl2.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/pdfwriter_impl2.cxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/pdfwriter_impl2.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/pdfwriter_impl2.cxx Thu Dec 1 16:25:17 2011
@@ -31,7 +31,6 @@
#include "vcl/metaact.hxx"
#include "vcl/bmpacc.hxx"
#include "vcl/graph.hxx"
-#include "vcl/rendergraphicrasterizer.hxx"
#include "svdata.hxx"
@@ -1044,17 +1043,6 @@ void PDFWriterImpl::playMetafile( const
}
break;
- case( META_RENDERGRAPHIC_ACTION ):
- {
- const MetaRenderGraphicAction* pA = static_cast< const MetaRenderGraphicAction* >( pAction );
- const ::vcl::RenderGraphicRasterizer aRasterizer( pA->GetRenderGraphic() );
-
- implWriteBitmapEx( pA->GetPoint(), pA->GetSize(),
- aRasterizer.Rasterize( pDummyVDev->LogicToPixel( pA->GetSize() ) ),
- pDummyVDev, i_rContext );
- }
- break;
-
default:
// #i24604# Made assertion fire only once per
// metafile. The asserted actions here are all
Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/print2.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/print2.cxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/print2.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/print2.cxx Thu Dec 1 16:25:17 2011
@@ -42,7 +42,6 @@
#include <vcl/print.hxx>
#include <vcl/svapp.hxx>
#include <vcl/bmpacc.hxx>
-#include <vcl/rendergraphicrasterizer.hxx>
#include <print.h>
@@ -111,9 +110,6 @@ static bool ImplIsActionSpecial( const M
case META_BMPEXSCALEPART_ACTION:
return static_cast<const MetaBmpExScalePartAction&>(rAct).GetBitmapEx().IsTransparent();
- case META_RENDERGRAPHIC_ACTION:
- return true;
-
default:
return false;
}
@@ -201,16 +197,6 @@ static void ImplConvertTransparentAction
aBmpEx = static_cast<const MetaBmpExScaleAction&>(rAct).GetBitmapEx();
break;
- case META_RENDERGRAPHIC_ACTION:
- {
- const ::vcl::RenderGraphicRasterizer aRasterizer( static_cast<const MetaRenderGraphicAction&>(rAct).
- GetRenderGraphic() );
-
- aBmpEx = aRasterizer.Rasterize( rStateOutDev.LogicToPixel(
- static_cast<const MetaRenderGraphicAction&>(rAct).GetSize() ) );
- break;
- }
-
case META_TRANSPARENT_ACTION:
default:
@@ -278,11 +264,6 @@ static void ImplConvertTransparentAction
static_cast<const MetaBmpExScalePartAction&>(rAct).GetSrcSize(),
aBmp ));
break;
- case META_RENDERGRAPHIC_ACTION:
- o_rMtf.AddAction( new MetaBmpScaleAction(
- static_cast<const MetaRenderGraphicAction&>(rAct).GetPoint(),
- static_cast<const MetaRenderGraphicAction&>(rAct).GetSize(),
- aBmp ));
default:
DBG_ERROR("Unexpected case");
break;
@@ -395,7 +376,6 @@ static bool ImplIsNotTransparent( const
case META_TEXTRECT_ACTION:
case META_STRETCHTEXT_ACTION:
case META_TEXTLINE_ACTION:
- case META_RENDERGRAPHIC_ACTION:
// all other actions: generate non-transparent output
bRet = true;
break;
@@ -650,13 +630,6 @@ static Rectangle ImplCalcActionBounds( c
DBG_ERROR("META_TEXTLINE_ACTION not supported");
break;
- case( META_RENDERGRAPHIC_ACTION ):
- {
- const MetaRenderGraphicAction& rRenderAct = static_cast<const MetaRenderGraphicAction&>(rAct);
- aActionBounds = Rectangle( rRenderAct.GetPoint(), rRenderAct.GetSize() );
- }
- break;
-
default:
break;
}
@@ -682,7 +655,6 @@ static bool ImplIsActionHandlingTranspar
case META_BMPEX_ACTION:
case META_BMPEXSCALE_ACTION:
case META_BMPEXSCALEPART_ACTION:
- case META_RENDERGRAPHIC_ACTION:
return true;
default:
Added: incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/svgdata.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/svgdata.cxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/svgdata.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/svgdata.cxx Thu Dec 1 16:25:17 2011
@@ -0,0 +1,193 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http:\\www.apache.org\licenses\LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_vcl.hxx"
+
+#include <vcl/svgdata.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/graphic/XSvgParser.hpp>
+#include <com/sun/star/graphic/XPrimitive2DRenderer.hpp>
+#include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp>
+#include <vcl/canvastools.hxx>
+#include <comphelper/seqstream.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace ::com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+void SvgData::ensureReplacement()
+{
+ ensureSequenceAndRange();
+
+ if(maReplacement.IsEmpty() && maSequence.hasElements())
+ {
+ // create replacement graphic from maSequence
+ // create XPrimitive2DRenderer
+ uno::Reference< lang::XMultiServiceFactory > xFactory(::comphelper::getProcessServiceFactory());
+ const rtl::OUString aServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.Primitive2DTools"));
+
+ try
+ {
+ const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer(xFactory->createInstance(aServiceName), uno::UNO_QUERY_THROW);
+
+ if(xPrimitive2DRenderer.is())
+ {
+ uno::Sequence< beans::PropertyValue > aViewParameters;
+ const basegfx::B2DRange& rRange(getRange());
+ geometry::RealRectangle2D aRealRect;
+
+ aRealRect.X1 = rRange.getMinX();
+ aRealRect.Y1 = rRange.getMinY();
+ aRealRect.X2 = rRange.getMaxX();
+ aRealRect.Y2 = rRange.getMaxY();
+
+ const uno::Reference< rendering::XBitmap > xBitmap(
+ xPrimitive2DRenderer->rasterize(
+ maSequence,
+ aViewParameters,
+ 72,
+ 72,
+ aRealRect,
+ 500000));
+
+ if(xBitmap.is())
+ {
+ const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW);
+
+ if(xIntBmp.is())
+ {
+ maReplacement = vcl::unotools::bitmapExFromXBitmap(xIntBmp);
+ }
+ }
+ }
+ }
+ catch(const uno::Exception&)
+ {
+ OSL_ENSURE(sal_False, "Got no graphic::XPrimitive2DRenderer (!)" );
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void SvgData::ensureSequenceAndRange()
+{
+ if(!maSequence.hasElements() && mnSvgDataArrayLength)
+ {
+ // import SVG to maSequence, also set maRange
+ maRange.reset();
+
+ // create stream
+ const uno::Sequence< sal_Int8 > aPostData((sal_Int8*)maSvgDataArray.get(), mnSvgDataArrayLength);
+ const uno::Reference< io::XInputStream > myInputStream(new comphelper::SequenceInputStream(aPostData));
+
+ if(myInputStream.is())
+ {
+ // create SVG interpreter
+ uno::Reference< lang::XMultiServiceFactory > xFactory(::comphelper::getProcessServiceFactory());
+ const rtl::OUString aServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.SvgTools"));
+
+ try
+ {
+ const uno::Reference< graphic::XSvgParser > xSvgParser(xFactory->createInstance(aServiceName), uno::UNO_QUERY_THROW);
+
+ if(xSvgParser.is())
+ {
+ maSequence = xSvgParser->getDecomposition(myInputStream);
+ }
+ }
+ catch(const uno::Exception&)
+ {
+ OSL_ENSURE(sal_False, "Got no graphic::XSvgParser (!)" );
+ }
+ }
+
+ if(maSequence.hasElements())
+ {
+ const sal_Int32 nCount(maSequence.getLength());
+ geometry::RealRectangle2D aRealRect;
+ uno::Sequence< beans::PropertyValue > aViewParameters;
+
+ for(sal_Int32 a(0L); a < nCount; a++)
+ {
+ // get reference
+ const Primitive2DReference xReference(maSequence[a]);
+
+ if(xReference.is())
+ {
+ aRealRect = xReference->getRange(aViewParameters);
+
+ maRange.expand(
+ basegfx::B2DRange(
+ aRealRect.X1,
+ aRealRect.Y1,
+ aRealRect.X2,
+ aRealRect.Y2));
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+SvgData::SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength)
+: maSvgDataArray(rSvgDataArray),
+ mnSvgDataArrayLength(nSvgDataArrayLength),
+ maRange(),
+ maSequence(),
+ maReplacement()
+{
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+const basegfx::B2DRange& SvgData::getRange() const
+{
+ const_cast< SvgData* >(this)->ensureSequenceAndRange();
+
+ return maRange;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+const Primitive2DSequence& SvgData::getPrimitive2DSequence() const
+{
+ const_cast< SvgData* >(this)->ensureSequenceAndRange();
+
+ return maSequence;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+const BitmapEx& SvgData::getReplacement() const
+{
+ const_cast< SvgData* >(this)->ensureReplacement();
+
+ return maReplacement;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/util/makefile.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/util/makefile.mk?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/util/makefile.mk (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/util/makefile.mk Thu Dec 1 16:25:17 2011
@@ -99,8 +99,6 @@ HXXDEPNLST= $(INC)$/vcl$/accel.hxx
$(INC)$/vcl$/print.hxx \
$(INC)$/vcl$/prndlg.hxx \
$(INC)$/vcl$/region.hxx \
- $(INC)$/vcl$/rendergraphic.hxx \
- $(INC)$/vcl$/rendergraphicrasterizer.hxx \
$(INC)$/vcl$/salbtype.hxx \
$(INC)$/vcl$/scrbar.hxx \
$(INC)$/vcl$/slider.hxx \
Modified: incubator/ooo/branches/alg/svgreplacement/main/xmloff/Library_xo.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/xmloff/Library_xo.mk?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/xmloff/Library_xo.mk (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/xmloff/Library_xo.mk Thu Dec 1 16:25:17 2011
@@ -119,6 +119,7 @@ $(eval $(call gb_Library_add_exception_o
xmloff/source/core/xmltkmap \
xmloff/source/core/xmltoken \
xmloff/source/core/xmluconv \
+ xmloff/source/core/xmlmultiimagehelper \
xmloff/source/draw/EnhancedCustomShapeToken \
xmloff/source/draw/XMLGraphicsDefaultStyle \
xmloff/source/draw/XMLImageMapContext \
Modified: incubator/ooo/branches/alg/svgreplacement/main/xmloff/Package_inc.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/xmloff/Package_inc.mk?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/xmloff/Package_inc.mk (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/xmloff/Package_inc.mk Thu Dec 1 16:25:17 2011
@@ -129,3 +129,4 @@ $(eval $(call gb_Package_add_file,xmloff
$(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/xmltoken.hxx,xmloff/xmltoken.hxx))
$(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/xmltypes.hxx,xmloff/xmltypes.hxx))
$(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/xmluconv.hxx,xmloff/xmluconv.hxx))
+$(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/xmlmultiimagehelper.hxx,xmloff/xmlmultiimagehelper.hxx))
Modified: incubator/ooo/branches/alg/svgreplacement/main/xmloff/inc/xmloff/txtparae.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/xmloff/inc/xmloff/txtparae.hxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/xmloff/inc/xmloff/txtparae.hxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/xmloff/inc/xmloff/txtparae.hxx Thu Dec 1 16:25:17 2011
@@ -146,6 +146,7 @@ protected:
const ::rtl::OUString sGraphicFilter;
const ::rtl::OUString sGraphicRotation;
const ::rtl::OUString sGraphicURL;
+ const ::rtl::OUString sReplacementGraphicURL;
const ::rtl::OUString sHeight;
const ::rtl::OUString sHoriOrient;
const ::rtl::OUString sHoriOrientPosition;
Added: incubator/ooo/branches/alg/svgreplacement/main/xmloff/inc/xmloff/xmlmultiimagehelper.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/xmloff/inc/xmloff/xmlmultiimagehelper.hxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/xmloff/inc/xmloff/xmlmultiimagehelper.hxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/xmloff/inc/xmloff/xmlmultiimagehelper.hxx Thu Dec 1 16:25:17 2011
@@ -0,0 +1,62 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef _XMLOFF_XMLMULTIIMAGEHELPER_HXX
+#define _XMLOFF_XMLMULTIIMAGEHELPER_HXX
+
+#include <sal/types.h>
+#include <xmloff/xmlimp.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+class multiImageImportHelper
+{
+private:
+ std::vector< SvXMLImportContextRef* > maImplContextVector;
+ bool mbSupportsMultipleContents;
+
+protected:
+ /// helper to get the created xShape instance, needs to be overloaded
+ virtual rtl::OUString getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const = 0;
+ virtual void removeGraphicFromImportContext(const SvXMLImportContext& rContext) const = 0;
+
+public:
+ multiImageImportHelper();
+ ~multiImageImportHelper();
+
+ /// solve multiple imported images. The most valuable one is choosen,
+ /// see imlementation for evtl. changing weights and/or adding filetypes
+ void solveMultipleImages();
+
+ /// add a content to the remembered image import contexts
+ void addContent(const SvXMLImportContext& rSvXMLImportContext);
+
+ /// read/write access to boolean switch
+ bool getSupportsMultipleContents() const { return mbSupportsMultipleContents; }
+ void setSupportsMultipleContents(bool bNew) { mbSupportsMultipleContents = bNew; }
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif // _XMLOFF_XMLMULTIIMAGEHELPER_HXX
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
Added: incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/core/xmlmultiimagehelper.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/core/xmlmultiimagehelper.cxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/core/xmlmultiimagehelper.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/core/xmlmultiimagehelper.cxx Thu Dec 1 16:25:17 2011
@@ -0,0 +1,146 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include <xmloff/xmlmultiimagehelper.hxx>
+#include <rtl/ustring.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace ::com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace
+{
+ sal_uInt32 getQualityIndex(const rtl::OUString& rString)
+ {
+ sal_uInt32 nRetval(0);
+
+ // pixel formats first
+ if(rString.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM(".bmp")))
+ {
+ return 10;
+ }
+ if(rString.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM(".gif")))
+ {
+ return 20;
+ }
+ if(rString.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM(".jpg")))
+ {
+ return 30;
+ }
+ if(rString.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM(".png")))
+ {
+ return 40;
+ }
+
+ // vector formats, prefer always
+ if(rString.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM(".svm")))
+ {
+ return 1000;
+ }
+ if(rString.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM(".wmf")))
+ {
+ return 1010;
+ }
+ if(rString.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM(".emf")))
+ {
+ return 1020;
+ }
+ else if(rString.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM(".svg")))
+ {
+ return 1030;
+ }
+
+ return nRetval;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+multiImageImportHelper::multiImageImportHelper()
+: maImplContextVector(),
+ mbSupportsMultipleContents(false)
+{
+}
+
+multiImageImportHelper::~multiImageImportHelper()
+{
+ while(!maImplContextVector.empty())
+ {
+ delete *(maImplContextVector.end() - 1);
+ maImplContextVector.pop_back();
+ }
+}
+
+void multiImageImportHelper::solveMultipleImages()
+{
+ if(maImplContextVector.size() > 1)
+ {
+ // multiple child contexts were imported, decide which is the most valuable one
+ // and remove the rest
+ sal_uInt32 nIndexOfPreferred(maImplContextVector.size());
+ sal_uInt32 nBestQuality(0), a(0);
+
+ for(a = 0; a < maImplContextVector.size(); a++)
+ {
+ const rtl::OUString aStreamURL(getGraphicURLFromImportContext(**maImplContextVector[a]));
+ const sal_uInt32 nNewQuality(getQualityIndex(aStreamURL));
+
+ if(nNewQuality > nBestQuality)
+ {
+ nBestQuality = nNewQuality;
+ nIndexOfPreferred = a;
+ }
+ }
+
+ // correct if needed, default is to use the last entry
+ if(nIndexOfPreferred >= maImplContextVector.size())
+ {
+ nIndexOfPreferred = maImplContextVector.size() - 1;
+ }
+
+ // Take out the most valuable one
+ const std::vector< SvXMLImportContextRef* >::iterator aRemove(maImplContextVector.begin() + nIndexOfPreferred);
+ delete *aRemove;
+ maImplContextVector.erase(aRemove);
+
+ // remove the rest from parent
+ for(a = 0; a < maImplContextVector.size(); a++)
+ {
+ removeGraphicFromImportContext(**maImplContextVector[a]);
+ }
+ }
+}
+
+void multiImageImportHelper::addContent(const SvXMLImportContext& rSvXMLImportContext)
+{
+ if(dynamic_cast< const SvXMLImportContext* >(&rSvXMLImportContext))
+ {
+ maImplContextVector.push_back(new SvXMLImportContextRef(const_cast< SvXMLImportContext* >(&rSvXMLImportContext)));
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//eof
Modified: incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/draw/shapeexport2.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/draw/shapeexport2.cxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/draw/shapeexport2.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/draw/shapeexport2.cxx Thu Dec 1 16:25:17 2011
@@ -1156,7 +1156,30 @@ void XMLShapeExport::ImpExportGraphicObj
{
if( !bIsEmptyPresObj )
{
- OUString aStreamURL;
+ OUString aReplacementUrl;
+ xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("ReplacementGraphicURL"))) >>= aReplacementUrl;
+
+ // If there is no url, then then graphic is empty
+ if(aReplacementUrl.getLength())
+ {
+ const OUString aStr = mrExport.AddEmbeddedGraphicObject(aReplacementUrl);
+
+ if(aStr.getLength())
+ {
+ mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStr);
+ mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
+ mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
+ mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
+
+ // xlink:href for replacement, only written for Svg content
+ SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, sal_True, sal_True);
+
+ // optional office:binary-data
+ mrExport.AddEmbeddedGraphicObjectAsBase64(aReplacementUrl);
+ }
+ }
+
+ OUString aStreamURL;
OUString aStr;
xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL"))) >>= aStreamURL;
@@ -1189,7 +1212,7 @@ void XMLShapeExport::ImpExportGraphicObj
{
if( aStr[ 0 ] == '#' )
{
- aStreamURL = OUString::createFromAscii( "vnd.sun.star.Package:" );
+ aStreamURL = sPackageURL;
aStreamURL = aStreamURL.concat( aStr.copy( 1, aStr.getLength() - 1 ) );
}
Modified: incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/draw/ximpshap.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/draw/ximpshap.cxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/draw/ximpshap.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/draw/ximpshap.cxx Thu Dec 1 16:25:17 2011
@@ -3328,7 +3328,10 @@ SdXMLFrameShapeContext::SdXMLFrameShapeC
com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
sal_Bool bTemporaryShape)
: SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
- mbSupportsReplacement( sal_False )
+ multiImageImportHelper(),
+ mbSupportsReplacement( sal_False ),
+ mxImplContext(),
+ mxReplImplContext()
{
uno::Reference < util::XCloneable > xClone( xAttrList, uno::UNO_QUERY );
if( xClone.is() )
@@ -3342,6 +3345,67 @@ SdXMLFrameShapeContext::~SdXMLFrameShape
{
}
+void SdXMLFrameShapeContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const
+{
+ const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
+
+ if(pSdXMLGraphicObjectShapeContext)
+ {
+ try
+ {
+ uno::Reference< container::XChild > xChild(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
+
+ if(xChild.is())
+ {
+ uno::Reference< drawing::XShapes > xParent(xChild->getParent(), uno::UNO_QUERY_THROW);
+
+ if(xParent.is())
+ {
+ // remove from parent
+ xParent->remove(pSdXMLGraphicObjectShapeContext->getShape());
+
+ // dispose
+ uno::Reference< lang::XComponent > xComp(pSdXMLGraphicObjectShapeContext->getShape(), UNO_QUERY);
+
+ if(xComp.is())
+ {
+ xComp->dispose();
+ }
+ }
+ }
+ }
+ catch( uno::Exception& )
+ {
+ DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" );
+ }
+ }
+}
+
+rtl::OUString SdXMLFrameShapeContext::getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const
+{
+ rtl::OUString aRetval;
+ const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
+
+ if(pSdXMLGraphicObjectShapeContext)
+ {
+ try
+ {
+ const uno::Reference< beans::XPropertySet > xPropSet(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
+
+ if(xPropSet.is())
+ {
+ xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL"))) >>= aRetval;
+ }
+ }
+ catch( uno::Exception& )
+ {
+ DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" );
+ }
+ }
+
+ return aRetval;
+}
+
SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPrefix,
const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList>& xAttrList )
@@ -3350,13 +3414,30 @@ SvXMLImportContext *SdXMLFrameShapeConte
if( !mxImplContext.Is() )
{
- pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
- GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList );
+ pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
+ GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList);
- mxImplContext = pContext;
- mbSupportsReplacement = IsXMLToken( rLocalName, XML_OBJECT ) ||
- IsXMLToken( rLocalName, XML_OBJECT_OLE );
- }
+ mxImplContext = pContext;
+ mbSupportsReplacement = IsXMLToken(rLocalName, XML_OBJECT ) || IsXMLToken(rLocalName, XML_OBJECT_OLE);
+ setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE));
+
+ if(getSupportsMultipleContents() && dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext))
+ {
+ addContent(*mxImplContext);
+ }
+ }
+ else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == nPrefix && IsXMLToken(rLocalName, XML_IMAGE))
+ {
+ // read another image
+ pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
+ GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList);
+ mxImplContext = pContext;
+
+ if(dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext))
+ {
+ addContent(*mxImplContext);
+ }
+ }
else if( mbSupportsReplacement && !mxReplImplContext &&
XML_NAMESPACE_DRAW == nPrefix &&
IsXMLToken( rLocalName, XML_IMAGE ) )
@@ -3415,6 +3496,9 @@ void SdXMLFrameShapeContext::StartElemen
void SdXMLFrameShapeContext::EndElement()
{
+ /// solve if multiple image child contexts were imported
+ solveMultipleImages();
+
if( !mxImplContext.Is() )
{
// now check if this is an empty presentation object
Modified: incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/draw/ximpshap.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/draw/ximpshap.hxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/draw/ximpshap.hxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/draw/ximpshap.hxx Thu Dec 1 16:25:17 2011
@@ -38,6 +38,7 @@
#include <vector>
#include <xmloff/shapeimport.hxx>
+#include <xmloff/xmlmultiimagehelper.hxx>
//////////////////////////////////////////////////////////////////////////////
// common shape context
@@ -573,13 +574,18 @@ public:
//////////////////////////////////////////////////////////////////////////////
// draw:-frame
-class SdXMLFrameShapeContext : public SdXMLShapeContext
+class SdXMLFrameShapeContext : public SdXMLShapeContext, public multiImageImportHelper
{
private:
sal_Bool mbSupportsReplacement;
SvXMLImportContextRef mxImplContext;
SvXMLImportContextRef mxReplImplContext;
+protected:
+ /// helper to get the created xShape instance, needs to be overloaded
+ virtual rtl::OUString getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const;
+ virtual void removeGraphicFromImportContext(const SvXMLImportContext& rContext) const;
+
public:
TYPEINFO();
Modified: incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/text/XMLTextFrameContext.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/text/XMLTextFrameContext.cxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/text/XMLTextFrameContext.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/text/XMLTextFrameContext.cxx Thu Dec 1 16:25:17 2011
@@ -433,6 +433,7 @@ public:
TYPEINFO();
sal_Bool CreateIfNotThere();
+ const OUString& GetHRef() const { return sHRef; }
XMLTextFrameContext_Impl( SvXMLImport& rImport,
sal_uInt16 nPrfx,
@@ -466,7 +467,7 @@ public:
::com::sun::star::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; }
const ::com::sun::star::uno::Reference <
- ::com::sun::star::beans::XPropertySet >& GetPropSet() { return xPropSet; }
+ ::com::sun::star::beans::XPropertySet >& GetPropSet() const { return xPropSet; }
};
TYPEINIT1( XMLTextFrameContext_Impl, SvXMLImportContext );
@@ -759,8 +760,6 @@ void XMLTextFrameContext_Impl::Create( s
xTextImportHelper->InsertTextContent( xTxtCntnt );
}
- Reference < XShape > xShape( xPropSet, UNO_QUERY );
-
// #107848#
// Make adding the shepe to Z-Ordering dependent from if we are
// inside a inside_deleted_section (redlining). That is necessary
@@ -770,7 +769,9 @@ void XMLTextFrameContext_Impl::Create( s
if(!GetImport().HasTextImport()
|| !GetImport().GetTextImport()->IsInsideDeleteContext())
{
- GetImport().GetShapeImport()->shapeWithZIndexAdded( xShape, nZIndex );
+ Reference < XShape > xShape( xPropSet, UNO_QUERY );
+
+ GetImport().GetShapeImport()->shapeWithZIndexAdded( xShape, nZIndex );
}
if( XML_TEXT_FRAME_TEXTBOX == nType )
@@ -1308,6 +1309,42 @@ void XMLTextFrameContext_Impl::SetDesc(
TYPEINIT1( XMLTextFrameContext, SvXMLImportContext );
+void XMLTextFrameContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const
+{
+ const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext);
+
+ if(pXMLTextFrameContext_Impl)
+ {
+ try
+ {
+ // just dispose to delete
+ uno::Reference< lang::XComponent > xComp(pXMLTextFrameContext_Impl->GetPropSet(), UNO_QUERY);
+
+ if(xComp.is())
+ {
+ xComp->dispose();
+ }
+ }
+ catch( uno::Exception& )
+ {
+ DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" );
+ }
+ }
+}
+
+rtl::OUString XMLTextFrameContext::getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const
+{
+ rtl::OUString aRetval;
+ const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext);
+
+ if(pXMLTextFrameContext_Impl)
+ {
+ return pXMLTextFrameContext_Impl->GetHRef();
+ }
+
+ return aRetval;
+}
+
sal_Bool XMLTextFrameContext::CreateIfNotThere()
{
sal_Bool bRet = sal_False;
@@ -1339,6 +1376,7 @@ XMLTextFrameContext::XMLTextFrameContext
const Reference< XAttributeList > & xAttrList,
TextContentAnchorType eATyp )
: SvXMLImportContext( rImport, nPrfx, rLName )
+, multiImageImportHelper()
, m_xAttrList( new SvXMLAttributeList( xAttrList ) )
, m_pHyperlink( 0 )
// --> OD 2009-07-22 #i73249#
@@ -1396,11 +1434,14 @@ XMLTextFrameContext::XMLTextFrameContext
XMLTextFrameContext::~XMLTextFrameContext()
{
- delete m_pHyperlink;
+ delete m_pHyperlink;
}
void XMLTextFrameContext::EndElement()
{
+ /// solve if multiple image child contexts were imported
+ solveMultipleImages();
+
SvXMLImportContext *pContext = &m_xImplContext;
XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
if( pImpl )
@@ -1505,6 +1546,10 @@ SvXMLImportContext *XMLTextFrameContext:
{
m_bSupportsReplacement = sal_True;
}
+ else if(XML_TEXT_FRAME_GRAPHIC == nFrameType)
+ {
+ setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE));
+ }
if( !pContext )
{
@@ -1517,9 +1562,24 @@ SvXMLImportContext *XMLTextFrameContext:
}
m_xImplContext = pContext;
+
+ if(getSupportsMultipleContents() && XML_TEXT_FRAME_GRAPHIC == nFrameType)
+ {
+ addContent(*m_xImplContext);
+ }
}
}
}
+ else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == p_nPrefix && IsXMLToken(rLocalName, XML_IMAGE))
+ {
+ // read another image
+ pContext = new XMLTextFrameContext_Impl(
+ GetImport(), p_nPrefix, rLocalName, xAttrList,
+ m_eDefaultAnchorType, XML_TEXT_FRAME_GRAPHIC, m_xAttrList);
+
+ m_xImplContext = pContext;
+ addContent(*m_xImplContext);
+ }
else if( m_bSupportsReplacement && !m_xReplImplContext &&
XML_NAMESPACE_DRAW == p_nPrefix &&
IsXMLToken( rLocalName, XML_IMAGE ) )
Modified: incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/text/XMLTextFrameContext.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/text/XMLTextFrameContext.hxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/text/XMLTextFrameContext.hxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/text/XMLTextFrameContext.hxx Thu Dec 1 16:25:17 2011
@@ -28,6 +28,7 @@
#include <com/sun/star/text/TextContentAnchorType.hpp>
#endif
#include <xmloff/xmlictxt.hxx>
+#include <xmloff/xmlmultiimagehelper.hxx>
namespace com { namespace sun { namespace star {
namespace text { class XTextCursor; class XTextContent; }
@@ -36,7 +37,7 @@ namespace com { namespace sun { namespac
class SvXMLAttributeList;
class XMLTextFrameContextHyperlink_Impl;
-class XMLTextFrameContext : public SvXMLImportContext
+class XMLTextFrameContext : public SvXMLImportContext, public multiImageImportHelper
{
::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList > m_xAttrList;
@@ -66,6 +67,11 @@ class XMLTextFrameContext : public SvXML
sal_Bool CreateIfNotThere( ::com::sun::star::uno::Reference <
::com::sun::star::beans::XPropertySet >& rPropSet );
+protected:
+ /// helper to get the created xShape instance, needs to be overloaded
+ virtual rtl::OUString getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const;
+ virtual void removeGraphicFromImportContext(const SvXMLImportContext& rContext) const;
+
public:
TYPEINFO();
Modified: incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/text/txtparae.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/text/txtparae.cxx?rev=1209140&r1=1209139&r2=1209140&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/text/txtparae.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/xmloff/source/text/txtparae.cxx Thu Dec 1 16:25:17 2011
@@ -1223,6 +1223,7 @@ XMLTextParagraphExport::XMLTextParagraph
sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter")),
sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation")),
sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")),
+ sReplacementGraphicURL(RTL_CONSTASCII_USTRINGPARAM("ReplacementGraphicURL")),
sHeight(RTL_CONSTASCII_USTRINGPARAM("Height")),
sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")),
sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")),
@@ -3018,9 +3019,33 @@ void XMLTextParagraphExport::_exportText
sRet.makeStringAndClear() );
}
+ // original content
+ SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_DRAW, XML_FRAME, sal_False, sal_True);
- SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW,
- XML_FRAME, sal_False, sal_True );
+ // replacement graphic for backwards compatibility, but
+ // only for SVG currently
+ OUString sReplacementOrigURL;
+ rPropSet->getPropertyValue( sReplacementGraphicURL ) >>= sReplacementOrigURL;
+
+ if(sReplacementOrigURL.getLength())
+ {
+ const OUString sReplacementURL(GetExport().AddEmbeddedGraphicObject( sReplacementOrigURL ));
+
+ // If there is no url, then then graphic is empty
+ if(sReplacementURL.getLength())
+ {
+ GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sReplacementURL);
+ GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE);
+ GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED);
+ GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD);
+
+ // xlink:href for replacement, only written for Svg content
+ SvXMLElementExport aElement(GetExport(), XML_NAMESPACE_DRAW, XML_IMAGE, sal_False, sal_True);
+
+ // optional office:binary-data
+ GetExport().AddEmbeddedGraphicObjectAsBase64(sReplacementURL);
+ }
+ }
// xlink:href
OUString sOrigURL;