incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1167638 - in /incubator/ooo/trunk/main/filter: inc/filter/msfilter/msdffimp.hxx source/msfilter/dffpropset.cxx source/msfilter/msdffimp.cxx
Date Sat, 10 Sep 2011 22:48:46 GMT
Author: erack
Date: Sat Sep 10 22:48:45 2011
New Revision: 1167638

URL: http://svn.apache.org/viewvc?rev=1167638&view=rev
Log:
impress212: #158494# fixed excel import (text rotation)

# User sj <sj@openoffice.org>

Modified:
    incubator/ooo/trunk/main/filter/inc/filter/msfilter/msdffimp.hxx
    incubator/ooo/trunk/main/filter/source/msfilter/dffpropset.cxx
    incubator/ooo/trunk/main/filter/source/msfilter/msdffimp.cxx

Modified: incubator/ooo/trunk/main/filter/inc/filter/msfilter/msdffimp.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/inc/filter/msfilter/msdffimp.hxx?rev=1167638&r1=1167637&r2=1167638&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/inc/filter/msfilter/msdffimp.hxx (original)
+++ incubator/ooo/trunk/main/filter/inc/filter/msfilter/msdffimp.hxx Sat Sep 10 22:48:45 2011
@@ -75,6 +75,7 @@ class MSFILTER_DLLPUBLIC DffPropertyRead
 	DffPropSet*				pDefaultPropSet;
 
 	void		ApplyCustomShapeTextAttributes( SfxItemSet& rSet ) const;
+	void		CheckAndCorrectExcelTextRotation( SvStream& rIn, SfxItemSet& rSet, DffObjData&
rObjData ) const;
 	void		ApplyCustomShapeAdjustmentAttributes( SfxItemSet& rSet ) const;
 	void		ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxItemSet& rSet, const
DffObjData& rObjData ) const;
 	void		ApplyLineAttributes( SfxItemSet& rSet, const MSO_SPT eShapeType ) const; // #i28269#
@@ -96,7 +97,7 @@ public:
 
 	void		SetDefaultPropSet( SvStream& rIn, sal_uInt32 nOffDgg ) const;
 	void		ApplyAttributes( SvStream& rIn, SfxItemSet& rSet ) const;
-	void		ApplyAttributes( SvStream& rIn, SfxItemSet& rSet, const DffObjData& rObjData
) const;
+	void		ApplyAttributes( SvStream& rIn, SfxItemSet& rSet, DffObjData& rObjData
) const;
 };
 
 
@@ -290,12 +291,14 @@ struct DffObjData
 	sal_uInt32		nSpFlags;
 	MSO_SPT		eShapeType;
 
-	sal_Bool bShapeType		: 1;
-	sal_Bool bClientAnchor	: 1;
-	sal_Bool bClientData	: 1;
-	sal_Bool bChildAnchor	: 1;
-	sal_Bool bOpt			: 1;
-	sal_Bool bIsAutoText	: 1;
+	sal_Bool bShapeType				: 1;
+	sal_Bool bClientAnchor			: 1;
+	sal_Bool bClientData			: 1;
+	sal_Bool bChildAnchor			: 1;
+	sal_Bool bOpt					: 1;
+	sal_Bool bOpt2					: 1;
+	sal_Bool bIsAutoText			: 1;
+	sal_Bool bRotateTextWithShape	: 1;
 
 	int nCalledByGroup;
 
@@ -312,7 +315,9 @@ struct DffObjData
 		bClientData( sal_False ),
 		bChildAnchor( sal_False ),
 		bOpt( sal_False ),
+		bOpt2( sal_False ),
 		bIsAutoText( sal_False ),
+		bRotateTextWithShape( sal_True ),
 		nCalledByGroup(	nClByGroup ){}
 };
 
@@ -500,7 +505,7 @@ public:
 
 	void*				pSvxMSDffDummy1;
 	void*				pSvxMSDffDummy2;
-	void*				pSvxMSDffDummy3;
+	DffPropertyReader*	pSecPropSet;
 	List*				pEscherBlipCache;
 
 	DffRecordManager	maShapeRecords;

Modified: incubator/ooo/trunk/main/filter/source/msfilter/dffpropset.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/msfilter/dffpropset.cxx?rev=1167638&r1=1167637&r2=1167638&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/msfilter/dffpropset.cxx (original)
+++ incubator/ooo/trunk/main/filter/source/msfilter/dffpropset.cxx Sat Sep 10 22:48:45 2011
@@ -1154,7 +1154,6 @@ void DffPropSet::ReadPropSet( SvStream& 
 		}
 		else
 		{
-
 			bool bSetProperty = !bSetUninitializedOnly || ( !IsProperty( nRecType ) || !IsHardAttribute(
nRecType ) );
 
 			DffPropFlags aPropFlag = { 1, 0, 0, 0 };
@@ -1209,10 +1208,10 @@ void DffPropSet::ReadPropSet( SvStream& 
 						mpPropSetEntries[ nRecType ].nComplexIndexOrFlagsHAttr = static_cast< sal_uInt16
>( maOffsets.size() );
 						maOffsets.push_back( nComplexDataFilePos );		// insert the filepos of this property;
		
 					}
-					nComplexDataFilePos += nContent;				// store filepos, that is used for the next complex
property
+					nComplexDataFilePos += nContent;					// store filepos, that is used for the next complex
property
                 }
-                else                                    // a complex property needs content
-                    aPropFlag.bSet = sal_False;         // otherwise something is wrong
+                else													// a complex property needs content
+                    aPropFlag.bSet = sal_False;							// otherwise something is wrong
 			}
 			if ( bSetProperty )
 			{

Modified: incubator/ooo/trunk/main/filter/source/msfilter/msdffimp.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/msfilter/msdffimp.cxx?rev=1167638&r1=1167637&r2=1167638&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/msfilter/msdffimp.cxx (original)
+++ incubator/ooo/trunk/main/filter/source/msfilter/msdffimp.cxx Sat Sep 10 22:48:45 2011
@@ -41,6 +41,8 @@
 #include <toolkit/helper/vclunohelper.hxx>
 #include <unotools/streamwrap.hxx>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/storagehelper.hxx>
 #include <sot/exchange.hxx>
 #include <sot/storinfo.hxx>
 #include <vcl/cvtgrf.hxx>
@@ -2679,7 +2681,7 @@ void DffPropertyReader::ApplyAttributes(
 	ApplyAttributes( rIn, rSet, aDffObjTemp );
 }
 
-void DffPropertyReader::ApplyAttributes( SvStream& rIn, SfxItemSet& rSet, const DffObjData&
rObjData ) const
+void DffPropertyReader::ApplyAttributes( SvStream& rIn, SfxItemSet& rSet, DffObjData&
rObjData ) const
 {
 	sal_Bool bHasShadow = sal_False;
 	if ( IsProperty( DFF_Prop_gtextSize ) )
@@ -2781,6 +2783,105 @@ void DffPropertyReader::ApplyAttributes(
 	{
 		ApplyCustomShapeGeometryAttributes( rIn, rSet, rObjData );
 		ApplyCustomShapeTextAttributes( rSet );
+		if ( rManager.GetSvxMSDffSettings() & SVXMSDFF_SETTINGS_IMPORT_EXCEL )
+		{
+			if ( mnFix16Angle || ( rObjData.nSpFlags & SP_FFLIPV ) )
+				CheckAndCorrectExcelTextRotation( rIn, rSet, rObjData );
+		}
+	}
+}
+
+void DffPropertyReader::CheckAndCorrectExcelTextRotation( SvStream& rIn, SfxItemSet&
rSet, DffObjData& rObjData ) const
+{
+	sal_Bool bRotateTextWithShape = rObjData.bRotateTextWithShape;
+	if ( rObjData.bOpt2 )		// sj: #158494# is the second property set available ? if then we
have to check the xml data of
+	{							// the shape, because the textrotation of Excel 2003 and greater versions is stored
there
+								// (upright property of the textbox)
+		if ( rManager.pSecPropSet->SeekToContent( DFF_Prop_metroBlob, rIn ) )
+		{
+			sal_uInt32 nLen = rManager.pSecPropSet->GetPropertyValue( DFF_Prop_metroBlob );
+			if ( nLen )
+			{
+				::com::sun::star::uno::Sequence< sal_Int8 > aXMLDataSeq( nLen );
+				rIn.Read( aXMLDataSeq.getArray(), nLen );
+				::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream
+					( new ::comphelper::SequenceInputStream( aXMLDataSeq ) );
+				try
+				{
+					::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
xFactory( ::comphelper::getProcessServiceFactory() );
+					if ( xFactory.is() )
+					{
+						::com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage
+							( ::comphelper::OStorageHelper::GetStorageOfFormatFromInputStream(
+								OFOPXML_STORAGE_FORMAT_STRING, xInputStream, xFactory, sal_True ) );
+						if ( xStorage.is() )
+						{
+							const rtl::OUString sDRS( RTL_CONSTASCII_USTRINGPARAM ( "drs" ) );
+							::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+								xStorageDRS( xStorage->openStorageElement( sDRS, ::com::sun::star::embed::ElementModes::SEEKABLEREAD
) );
+							if ( xStorageDRS.is() )
+							{
+								const rtl::OUString sShapeXML( RTL_CONSTASCII_USTRINGPARAM ( "shapexml.xml" ) );
+								::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > xShapeXMLStream(
xStorageDRS->openStreamElement( sShapeXML, ::com::sun::star::embed::ElementModes::SEEKABLEREAD
) );
+								if ( xShapeXMLStream.is() )
+								{
+									::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xShapeXMLInputStream(
xShapeXMLStream->getInputStream() );
+									if ( xShapeXMLInputStream.is() )
+									{
+										::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
+										sal_Int32 nBytesRead = xShapeXMLInputStream->readBytes( aSeq, 0x7fffffff );
+										if ( nBytesRead )
+										{	// for only one property I spare to use a XML parser at this point, this
+											// should be enhanced if needed
+
+											bRotateTextWithShape = sal_True;	// using the correct xml default
+											const char* pArry = reinterpret_cast< char* >( aSeq.getArray() );
+											const char* pUpright = "upright=";
+											const char* pEnd = pArry + nBytesRead;
+											const char* pPtr = pArry;
+											while( ( pPtr + 12 ) < pEnd )
+											{
+												if ( !memcmp( pUpright, pPtr, 8 ) )
+												{
+													bRotateTextWithShape = ( pPtr[ 9 ] != '1' ) && ( pPtr[ 9 ] != 't' );
+													break;
+												}
+												else
+													pPtr++;
+											}
+										}
+									}
+								}
+							}
+						}
+					}
+				}
+				catch( com::sun::star::uno::Exception& )
+				{
+				}
+			}
+		}
+	}
+	if ( !bRotateTextWithShape )
+	{
+		const com::sun::star::uno::Any* pAny, aAny;
+		SdrCustomShapeGeometryItem aGeometryItem((SdrCustomShapeGeometryItem&)rSet.Get( SDRATTR_CUSTOMSHAPE_GEOMETRY
));
+		const rtl::OUString sTextRotateAngle( RTL_CONSTASCII_USTRINGPARAM ( "TextRotateAngle" )
);
+		pAny = aGeometryItem.GetPropertyValueByName( sTextRotateAngle );
+		double fExtraTextRotateAngle = 0.0;
+		if ( pAny )
+			*pAny >>= fExtraTextRotateAngle;
+
+		if ( rManager.mnFix16Angle )
+			fExtraTextRotateAngle += mnFix16Angle / 100.0;
+		if ( rObjData.nSpFlags & SP_FFLIPV )
+			fExtraTextRotateAngle -= 180.0;
+
+		com::sun::star::beans::PropertyValue aTextRotateAngle;
+		aTextRotateAngle.Name = sTextRotateAngle;
+		aTextRotateAngle.Value <<= fExtraTextRotateAngle;
+		aGeometryItem.SetPropertyValue( aTextRotateAngle );
+		rSet.Put( aGeometryItem );
 	}
 }
 
@@ -4105,6 +4206,7 @@ SdrObject* SvxMSDffManager::ImportShape(
 
 	rHd.SeekToBegOfRecord( rSt );
 	DffObjData aObjData( rHd, rClientRect, nCalledByGroup );
+	aObjData.bRotateTextWithShape = ( GetSvxMSDffSettings() & SVXMSDFF_SETTINGS_IMPORT_EXCEL
) == 0;
 	maShapeRecords.Consume( rSt, sal_False );
 	aObjData.bShapeType = maShapeRecords.SeekToContent( rSt, DFF_msofbtSp, SEEK_FROM_BEGINNING
);
 	if ( aObjData.bShapeType )
@@ -4143,6 +4245,13 @@ SdrObject* SvxMSDffManager::ImportShape(
 		InitializePropSet( DFF_msofbtOPT );		// get the default PropSet
 		( (DffPropertyReader*) this )->mnFix16Angle = 0;
 	}
+	aObjData.bOpt2 = maShapeRecords.SeekToContent( rSt, DFF_msofbtUDefProp, SEEK_FROM_CURRENT_AND_RESTART
);
+	if ( aObjData.bOpt2 )
+	{
+		maShapeRecords.Current()->SeekToBegOfRecord( rSt );
+		pSecPropSet = new DffPropertyReader( *this );
+		pSecPropSet->ReadPropSet( rSt, NULL );
+	}
 
 	aObjData.bChildAnchor = maShapeRecords.SeekToContent( rSt, DFF_msofbtChildAnchor, SEEK_FROM_CURRENT_AND_RESTART
);
 	if ( aObjData.bChildAnchor )
@@ -5434,6 +5543,7 @@ SvxMSDffManager::SvxMSDffManager(SvStrea
 	 pStData2( pStData2_ ),
 	 nSvxMSDffSettings( 0 ),
 	 nSvxMSDffOLEConvFlags( 0 ),
+	 pSecPropSet( NULL ),
      pEscherBlipCache( NULL ),
 	 mnDefaultColor( mnDefaultColor_),
 	 mpTracer( pTracer ),
@@ -5486,6 +5596,7 @@ SvxMSDffManager::SvxMSDffManager( SvStre
 	 pStData2( 0 ),
 	 nSvxMSDffSettings( 0 ),
 	 nSvxMSDffOLEConvFlags( 0 ),
+	 pSecPropSet( NULL ),
      pEscherBlipCache( NULL ),
 	 mnDefaultColor( COL_DEFAULT ),
 	 mpTracer( pTracer ),
@@ -5508,6 +5619,7 @@ SvxMSDffManager::~SvxMSDffManager()
             delete (EscherBlipCacheEntry*)pPtr;
         delete pEscherBlipCache;
     }
+	delete pSecPropSet;
 	delete pBLIPInfos;
 	delete pShapeInfos;
 	delete pShapeOrders;



Mime
View raw message