You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by pf...@apache.org on 2012/02/21 20:25:07 UTC

svn commit: r1291962 - in /incubator/ooo/trunk/main: editeng/source/editeng/ sw/inc/ sw/source/ui/app/ sw/source/ui/dochdl/

Author: pfg
Date: Tue Feb 21 19:25:07 2012
New Revision: 1291962

URL: http://svn.apache.org/viewvc?rev=1291962&view=rev
Log:
i#115580# - Font size changes when copying words to impress.

Copying words from writer/calc to impress, some font sizes
may get bigger. Additionally other fonts atrtributes like
the font size changes.

Special thanks to the author for working so diligently
on this issue.

BZ:	115580
Author: Jing Dong Chen

Modified:
    incubator/ooo/trunk/main/editeng/source/editeng/editdoc.cxx
    incubator/ooo/trunk/main/editeng/source/editeng/editdoc.hxx
    incubator/ooo/trunk/main/editeng/source/editeng/eertfpar.cxx
    incubator/ooo/trunk/main/editeng/source/editeng/impedit.hxx
    incubator/ooo/trunk/main/editeng/source/editeng/impedit2.cxx
    incubator/ooo/trunk/main/editeng/source/editeng/impedit4.cxx
    incubator/ooo/trunk/main/editeng/source/editeng/impedit5.cxx
    incubator/ooo/trunk/main/sw/inc/docsh.hxx
    incubator/ooo/trunk/main/sw/source/ui/app/docshini.cxx
    incubator/ooo/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx

Modified: incubator/ooo/trunk/main/editeng/source/editeng/editdoc.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/source/editeng/editdoc.cxx?rev=1291962&r1=1291961&r2=1291962&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/source/editeng/editdoc.cxx (original)
+++ incubator/ooo/trunk/main/editeng/source/editeng/editdoc.cxx Tue Feb 21 19:25:07 2012
@@ -1066,12 +1066,27 @@ void ContentNode::CreateDefFont()
 {
 	// Erst alle Informationen aus dem Style verwenden...
 	SfxStyleSheet* pS = aContentAttribs.GetStyleSheet();
-	if ( pS )
-		CreateFont( GetCharAttribs().GetDefFont(), pS->GetItemSet() );
-	
+	/* if ( pS ) //#115580#
+	CreateFont( GetCharAttribs().GetDefFont(), pS->GetItemSet() );
+
 	// ... dann die harte Absatzformatierung rueberbuegeln...
 	CreateFont( GetCharAttribs().GetDefFont(),
-		GetContentAttribs().GetItems(), pS == NULL );
+		GetContentAttribs().GetItems(), pS == NULL ); */
+
+	SvxFont& rFont = GetCharAttribs().GetDefFont();
+	SvxFont& rFontCJK = GetCharAttribs().GetDefFontCJK();
+	SvxFont& rFontCTL = GetCharAttribs().GetDefFontCTL();
+
+	if ( pS )
+	{
+		CreateFont( rFont, pS->GetItemSet(), sal_True, i18n::ScriptType::LATIN );
+		CreateFont( rFontCJK, pS->GetItemSet(), sal_True, i18n::ScriptType::ASIAN );
+		CreateFont( rFontCTL, pS->GetItemSet(), sal_True, i18n::ScriptType::COMPLEX );
+	}
+
+	CreateFont( rFont, GetContentAttribs().GetItems(), pS == NULL, i18n::ScriptType::LATIN );
+	CreateFont( rFontCJK, GetContentAttribs().GetItems(), pS == NULL, i18n::ScriptType::ASIAN );
+	CreateFont( rFontCTL, GetContentAttribs().GetItems(), pS == NULL, i18n::ScriptType::COMPLEX );
 }
 
 void ContentNode::SetStyleSheet( SfxStyleSheet* pS, const SvxFont& rFontFromStyle )
@@ -1448,7 +1463,7 @@ sal_uLong EditDoc::GetTextLen() const
 	{
 		ContentNode* pNode = GetObject( nNode );
 		nLen += pNode->Len();
-		// Felder k�nnen laenger sein als der Platzhalter im Node.
+		// Felder k???nnen laenger sein als der Platzhalter im Node.
 		const CharAttribArray& rAttrs = pNode->GetCharAttribs().GetAttribs();
 		for ( sal_uInt16 nAttr = rAttrs.Count(); nAttr; )
 		{
@@ -1560,6 +1575,9 @@ EditPaM EditDoc::InsertParaBreak( EditPa
 
 	// Den Default-Font kopieren
 	pNode->GetCharAttribs().GetDefFont() = aPaM.GetNode()->GetCharAttribs().GetDefFont();
+	//#115580# start
+	pNode->GetCharAttribs().GetDefFontCJK() = aPaM.GetNode()->GetCharAttribs().GetDefFontCJK();
+	pNode->GetCharAttribs().GetDefFontCTL() = aPaM.GetNode()->GetCharAttribs().GetDefFontCTL();
 	SfxStyleSheet* pStyle = aPaM.GetNode()->GetStyleSheet();
 	if ( pStyle )
 	{

Modified: incubator/ooo/trunk/main/editeng/source/editeng/editdoc.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/source/editeng/editdoc.hxx?rev=1291962&r1=1291961&r2=1291962&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/source/editeng/editdoc.hxx (original)
+++ incubator/ooo/trunk/main/editeng/source/editeng/editdoc.hxx Tue Feb 21 19:25:07 2012
@@ -202,7 +202,9 @@ class CharAttribList
 {
 private:
 	CharAttribArray	aAttribs;
-	SvxFont			aDefFont;				// schneller, als jedesmal vom Pool!
+	SvxFont			aDefFont;			// schneller, als jedesmal vom Pool!
+	SvxFont			aDefFontCJK;			//#115580#
+	SvxFont			aDefFontCTL;
 	sal_Bool			bHasEmptyAttribs;
 
 					CharAttribList( const CharAttribList& ) {;}
@@ -228,6 +230,8 @@ public:
 	void			InsertAttrib( EditCharAttrib* pAttrib );
 
 	SvxFont&		GetDefFont() 			{ return aDefFont; }
+	SvxFont&		GetDefFontCJK() 		{ return aDefFontCJK; } //#115580#
+	SvxFont&		GetDefFontCTL() 		{ return aDefFontCTL; }
 
 	sal_Bool			HasEmptyAttribs() const	{ return bHasEmptyAttribs; }
 	sal_Bool&			HasEmptyAttribs() 		{ return bHasEmptyAttribs; }

Modified: incubator/ooo/trunk/main/editeng/source/editeng/eertfpar.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/source/editeng/eertfpar.cxx?rev=1291962&r1=1291961&r2=1291962&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/source/editeng/eertfpar.cxx (original)
+++ incubator/ooo/trunk/main/editeng/source/editeng/eertfpar.cxx Tue Feb 21 19:25:07 2012
@@ -108,7 +108,7 @@ SvParserState __EXPORT EditRTFParser::Ca
 	EditPaM aStart2PaM = aCurSel.Min();
 	// Sinnvoll oder nicht?:
 	aStart2PaM.GetNode()->GetContentAttribs().GetItems().ClearItem();
-    AddRTFDefaultValues( aStart2PaM, aStart2PaM );
+    //AddRTFDefaultValues( aStart2PaM, aStart2PaM ); //#115580#
 	EditPaM aEnd1PaM( pImpEditEngine->ImpInsertParaBreak( aCurSel.Max() ) );
 	// aCurCel zeigt jetzt auf den Zwischenraum
 
@@ -136,6 +136,47 @@ SvParserState __EXPORT EditRTFParser::Ca
 		aSel.Min() = EditPaM( pPrevNode, pPrevNode->Len() );
 		aSel.Max() = EditPaM( pCurNode, 0 );
 		aCurSel.Max() = pImpEditEngine->ImpDeleteSelection( aSel );
+		//#115580# added at 2011/11/28 start
+		sal_uInt16 nStart2 = pImpEditEngine->GetEditDoc().GetPos( aStart2PaM.GetNode() );
+		sal_uInt16 nEnd2 = pImpEditEngine->GetEditDoc().GetPos( aCurSel.Max().GetNode() );
+		for ( sal_uInt16 n = nStart2; n <= nEnd2; n++ )
+		{
+			ContentNode* pTmpNode = pImpEditEngine->GetEditDoc().SaveGetObject( n );
+			if ( pTmpNode )
+			{
+				{//if ContentAttribs of node has no font info, add default font attribs into it.
+					Size aSz( 12, 0 );
+					MapMode aPntMode( MAP_POINT );
+					MapMode _aEditMapMode( pImpEditEngine->GetRefDevice()->GetMapMode().GetMapUnit() );
+					aSz = pImpEditEngine->GetRefDevice()->LogicToLogic( aSz, &aPntMode, &_aEditMapMode );
+
+					SfxItemSet& rSet = pTmpNode->GetContentAttribs().GetItems();
+					SvxFont& rFont = pTmpNode->GetCharAttribs().GetDefFont();
+					SvxFont& rFontCJK = pTmpNode->GetCharAttribs().GetDefFontCJK();
+					SvxFont& rFontCTL = pTmpNode->GetCharAttribs().GetDefFontCTL();
+
+					if ( rSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_ON )
+						rSet.Put( SvxFontItem( rFont.GetFamily(), rFont.GetName(), XubString(), 
+									rFont.GetPitch(), rFont.GetCharSet(), EE_CHAR_FONTINFO ) );
+					if ( rSet.GetItemState( EE_CHAR_FONTINFO_CJK ) != SFX_ITEM_ON )
+						rSet.Put( SvxFontItem( rFontCJK.GetFamily(), rFontCJK.GetName(), XubString(), 
+									rFontCJK.GetPitch(), rFontCJK.GetCharSet(), EE_CHAR_FONTINFO_CJK ) );
+					if ( rSet.GetItemState( EE_CHAR_FONTINFO_CTL ) != SFX_ITEM_ON )
+						rSet.Put( SvxFontItem( rFontCTL.GetFamily(), rFontCTL.GetName(), XubString(), 
+									rFontCTL.GetPitch(), rFontCTL.GetCharSet(), EE_CHAR_FONTINFO_CTL ) );
+
+					if ( rSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_ON )
+						rSet.Put( SvxFontHeightItem( aSz.Width(), 100, EE_CHAR_FONTHEIGHT )  );
+					if ( rSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) != SFX_ITEM_ON )
+						rSet.Put( SvxFontHeightItem( aSz.Width(), 100, EE_CHAR_FONTHEIGHT_CJK )  );
+					if ( rSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) != SFX_ITEM_ON )
+						rSet.Put( SvxFontHeightItem( aSz.Width(), 100, EE_CHAR_FONTHEIGHT_CTL )  );
+				}
+
+				pImpEditEngine->AdjustParaAttribsByStyleSheet( pTmpNode );
+				pImpEditEngine->ParaAttribsToCharAttribs( pTmpNode );
+			}
+		}
 	}
 	EditPaM aEnd2PaM( aCurSel.Max() );
     //AddRTFDefaultValues( aStart2PaM, aEnd2PaM );
@@ -145,14 +186,16 @@ SvParserState __EXPORT EditRTFParser::Ca
 	// => Zeichenattribute machen.
 
 	sal_Bool bSpecialBackward = aStart1PaM.GetNode()->Len() ? sal_False : sal_True;
-	if ( bOnlyOnePara || aStart1PaM.GetNode()->Len() )
-		pImpEditEngine->ParaAttribsToCharAttribs( aStart2PaM.GetNode() );
+	/* if ( bOnlyOnePara || aStart1PaM.GetNode()->Len() ) //#115580# 
+		pImpEditEngine->ParaAttribsToCharAttribs( aStart2PaM.GetNode() ); */
+	// end
 	aCurSel.Min() = pImpEditEngine->ImpConnectParagraphs(
 		aStart1PaM.GetNode(), aStart2PaM.GetNode(), bSpecialBackward );
 	bSpecialBackward = aEnd1PaM.GetNode()->Len() ? sal_True : sal_False;
 	// wenn bOnlyOnePara, dann ist der Node beim Connect verschwunden.
-	if ( !bOnlyOnePara && aEnd1PaM.GetNode()->Len() )
-		pImpEditEngine->ParaAttribsToCharAttribs( aEnd2PaM.GetNode() );
+	/* if ( !bOnlyOnePara && aEnd1PaM.GetNode()->Len() )	//#115580# 
+		pImpEditEngine->ParaAttribsToCharAttribs( aEnd2PaM.GetNode() ); */
+	// end
 	aCurSel.Max() = pImpEditEngine->ImpConnectParagraphs(
 		( bOnlyOnePara ? aStart1PaM.GetNode() : aEnd2PaM.GetNode() ),
 			aEnd1PaM.GetNode(), bSpecialBackward );

Modified: incubator/ooo/trunk/main/editeng/source/editeng/impedit.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/source/editeng/impedit.hxx?rev=1291962&r1=1291961&r2=1291962&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/source/editeng/impedit.hxx (original)
+++ incubator/ooo/trunk/main/editeng/source/editeng/impedit.hxx Tue Feb 21 19:25:07 2012
@@ -479,6 +479,7 @@ private:
 	sal_Bool			bFormatted;
 	sal_Bool			bInSelection;
 	sal_Bool			bIsInUndo;
+	sal_Bool			bIsPasting; //#115580#	
 	sal_Bool			bUpdate;
 	sal_Bool			bUndoEnabled;
 	sal_Bool			bOwnerOfRefDev;
@@ -543,6 +544,7 @@ private:
 	void				SetParaAttrib( sal_uInt8 nFunc, EditSelection aSel, sal_uInt16 nValue );
 	sal_uInt16			GetParaAttrib( sal_uInt8 nFunc, EditSelection aSel );
 	void				SetCharAttrib( EditSelection aSel, const SfxPoolItem& rItem );
+	void 				AdjustParaAttribsByStyleSheet( ContentNode* pNode ); //#115580#
 	void				ParaAttribsToCharAttribs( ContentNode* pNode );
 	void				GetCharAttribs( sal_uInt16 nPara, EECharAttribArray& rLst ) const;
 

Modified: incubator/ooo/trunk/main/editeng/source/editeng/impedit2.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/source/editeng/impedit2.cxx?rev=1291962&r1=1291961&r2=1291962&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/source/editeng/impedit2.cxx (original)
+++ incubator/ooo/trunk/main/editeng/source/editeng/impedit2.cxx Tue Feb 21 19:25:07 2012
@@ -133,6 +133,7 @@ ImpEditEngine::ImpEditEngine( EditEngine
 	bOwnerOfRefDev 		= sal_False;
 	bDowning 			= sal_False;
 	bIsInUndo 			= sal_False;
+	bIsPasting 			= sal_False; //#115580#	
 	bIsFormatting 		= sal_False;
 	bFormatted			= sal_False;
 	bUpdate 			= sal_True;
@@ -3701,6 +3702,7 @@ EditSelection ImpEditEngine::InsertText(
 
 	if ( rxDataObj.is() )
 	{
+		bIsPasting = sal_True; //#115580#		
 		datatransfer::DataFlavor aFlavor;
 		sal_Bool bDone = sal_False;
 
@@ -3791,6 +3793,7 @@ EditSelection ImpEditEngine::InsertText(
 				}
 			}
 		}
+		bIsPasting = sal_False; //#115580#		
 	}
 
 	return aNewSelection;

Modified: incubator/ooo/trunk/main/editeng/source/editeng/impedit4.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/source/editeng/impedit4.cxx?rev=1291962&r1=1291961&r2=1291962&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/source/editeng/impedit4.cxx (original)
+++ incubator/ooo/trunk/main/editeng/source/editeng/impedit4.cxx Tue Feb 21 19:25:07 2012
@@ -1241,6 +1241,13 @@ EditSelection ImpEditEngine::InsertBinTe
 	EditSelection aSel( aPaM, aPaM );
 	DBG_ASSERT( !aSel.DbgIsBuggy( aEditDoc ), "InsertBibTextObject: Selektion kaput!(1)" );
 
+	//#115580#
+	EditPaM aStart1PaM( aSel.Min().GetNode(), aSel.Min().GetIndex() );
+	aSel = ImpInsertParaBreak( aSel );
+	EditPaM aStart2PaM = aSel.Min();
+	EditPaM aEnd1PaM( ImpInsertParaBreak( aSel.Max() ) );
+	aEnd1PaM.GetNode()->SetStyleSheet( aStart1PaM.GetNode()->GetStyleSheet(), sal_False );
+
 	sal_Bool bUsePortionInfo = sal_False;
 //	sal_Bool bFields = sal_False;
 	XParaPortionList* pPortionInfo = rTextObject.GetPortionInfo();
@@ -1270,6 +1277,17 @@ EditSelection ImpEditEngine::InsertBinTe
 	for ( sal_uInt16 n = 0; n < nContents; n++, nPara++ )
 	{
 		ContentInfo* pC = rTextObject.GetContents().GetObject( n );
+
+		if ( bIsPasting ) 	//#115580#
+		{
+			if ( !n )
+				aPaM = aStart2PaM;
+			//init node
+			aPaM.GetNode()->SetStyleSheet( aStart1PaM.GetNode()->GetStyleSheet(), sal_False );
+			aPaM.GetNode()->GetContentAttribs().GetItems().ClearItem();
+			aPaM.GetNode()->GetCharAttribs().Clear();
+		}
+
 		sal_Bool bNewContent = aPaM.GetNode()->Len() ? sal_False: sal_True;
 		sal_uInt16 nStartPos = aPaM.GetIndex();
 
@@ -1340,6 +1358,18 @@ EditSelection ImpEditEngine::InsertBinTe
 			    // nur dann Style und ParaAttribs, wenn neuer Absatz, oder
 			    // komplett inneliegender...
 			    bParaAttribs = pC->GetParaAttribs().Count() ? sal_True : sal_False;
+
+			    if ( bIsPasting )	//#115580#
+			    {
+				    nPara = aEditDoc.GetPos( aPaM.GetNode() );
+				    if ( GetStyleSheetPool() && pC->GetStyle().Len() )
+				    {
+					SfxStyleSheet* pStyle = (SfxStyleSheet*)GetStyleSheetPool()->Find( pC->GetStyle(), pC->GetFamily() );
+					DBG_ASSERT( pStyle, "InsertBinTextObject - Style not found!" );
+					SetStyleSheet( nPara, pStyle );
+				    }
+			    }
+			    else
 			    if ( GetStyleSheetPool() && pC->GetStyle().Len() )
 			    {
 				    SfxStyleSheet* pStyle = (SfxStyleSheet*)GetStyleSheetPool()->Find( pC->GetStyle(), pC->GetFamily() );
@@ -1412,6 +1442,12 @@ EditSelection ImpEditEngine::InsertBinTe
 		}
 #endif // !SVX_LIGHT
 
+		if ( bIsPasting )	//#115580#
+		{
+			AdjustParaAttribsByStyleSheet( aPaM.GetNode() );
+			ParaAttribsToCharAttribs( aPaM.GetNode() );
+		}
+	
 		// Zeilenumbruch, wenn weitere folgen...
 		if ( n < ( nContents-1) )
 		{
@@ -1422,7 +1458,23 @@ EditSelection ImpEditEngine::InsertBinTe
 		}
 	}
 
-	aSel.Max() = aPaM;
+	/* aSel.Max() = aPaM; */	//#115580#
+
+	if ( bIsPasting )
+	{
+		EditPaM aEnd2PaM( aPaM );
+
+		sal_Bool bSpecialBackward = aStart1PaM.GetNode()->Len() ? sal_False : sal_True;
+
+		aSel.Min() = ImpConnectParagraphs( aStart1PaM.GetNode(), aStart2PaM.GetNode(), bSpecialBackward );
+		bSpecialBackward = aEnd1PaM.GetNode()->Len() ? sal_True : sal_False;
+
+		aSel.Max() = ImpConnectParagraphs( ( ( nContents == 1 ) ? aStart1PaM.GetNode() : aEnd2PaM.GetNode() ),
+																		aEnd1PaM.GetNode(), bSpecialBackward );
+	}
+	else
+		aSel.Max() = aPaM;
+	
 	DBG_ASSERT( !aSel.DbgIsBuggy( aEditDoc ), "InsertBibTextObject: Selektion kaput!(1)" );
 	return aSel;
 }

Modified: incubator/ooo/trunk/main/editeng/source/editeng/impedit5.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/source/editeng/impedit5.cxx?rev=1291962&r1=1291961&r2=1291962&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/source/editeng/impedit5.cxx (original)
+++ incubator/ooo/trunk/main/editeng/source/editeng/impedit5.cxx Tue Feb 21 19:25:07 2012
@@ -813,6 +813,23 @@ void ImpEditEngine::GetCharAttribs( sal_
 	}
 }
 
+void ImpEditEngine::AdjustParaAttribsByStyleSheet( ContentNode* pNode ) //#115580#
+{
+	if ( !pNode )
+		return;
+
+	SfxStyleSheet* pStyle = pNode->GetStyleSheet();
+	for ( sal_uInt16 nWhich = EE_PARA_START; nWhich < EE_CHAR_START && pStyle; nWhich++ )
+	{
+		if ( pNode->GetContentAttribs().GetItems().GetItemState( nWhich ) == SFX_ITEM_ON   )
+		{
+			const SfxItemSet& rStyleAttribs = pStyle->GetItemSet();
+			if ( rStyleAttribs.GetItemState( nWhich ) == SFX_ITEM_ON )
+				pNode->GetContentAttribs().GetItems().ClearItem( nWhich );	
+		}
+	}
+}
+
 void ImpEditEngine::ParaAttribsToCharAttribs( ContentNode* pNode )
 {
 	pNode->GetCharAttribs().DeleteEmptyAttribs( GetEditDoc().GetItemPool() );
@@ -841,6 +858,8 @@ void ImpEditEngine::ParaAttribsToCharAtt
 	}
 	bFormatted = sal_False;
 	// Portion braucht hier nicht invalidiert werden, geschieht woanders.
+	if ( bIsPasting )	//#115580#
+		pNode->GetContentAttribs().GetItems().ClearItem();
 }
 
 IdleFormattter::IdleFormattter()

Modified: incubator/ooo/trunk/main/sw/inc/docsh.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/inc/docsh.hxx?rev=1291962&r1=1291961&r2=1291962&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/inc/docsh.hxx (original)
+++ incubator/ooo/trunk/main/sw/inc/docsh.hxx Tue Feb 21 19:25:07 2012
@@ -147,6 +147,8 @@ public:
 
 	static rtl::OUString GetEventName( sal_Int32 nId );
 
+	static void	InitDefaultFontAttr( SwDoc* pDoc ); //#115580# added at 2011/11/28
+
 	//Das Doc wird fuer SO-Datenaustausch benoetigt!
 	SwDocShell( SfxObjectCreateMode eMode = SFX_CREATE_MODE_EMBEDDED );
 	SwDocShell( const sal_uInt64 i_nSfxCreationFlags );

Modified: incubator/ooo/trunk/main/sw/source/ui/app/docshini.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/ui/app/docshini.cxx?rev=1291962&r1=1291961&r2=1291962&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/ui/app/docshini.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/ui/app/docshini.cxx Tue Feb 21 19:25:07 2012
@@ -358,6 +358,145 @@ sal_Bool SwDocShell::InitNew( const uno:
 	return bRet;
 }
 
+//#115580# When creating a new document, if needed, set the default
+// font and languague attributes.
+void SwDocShell::InitDefaultFontAttr( SwDoc* pDoc )
+{
+	sal_uInt16 aFontWhich[] =
+	{   
+		RES_CHRATR_FONT,
+		RES_CHRATR_CJK_FONT,
+		RES_CHRATR_CTL_FONT
+	};
+	sal_uInt16 aFontHeightWhich[] =
+	{
+		RES_CHRATR_FONTSIZE,
+		RES_CHRATR_CJK_FONTSIZE,
+		RES_CHRATR_CTL_FONTSIZE
+	};
+	sal_uInt16 aFontIds[] =
+	{
+		FONT_STANDARD,
+		FONT_STANDARD_CJK,
+		FONT_STANDARD_CTL
+	};
+	sal_uInt16 nFontTypes[] =
+	{
+		DEFAULTFONT_LATIN_TEXT,
+		DEFAULTFONT_CJK_TEXT,
+		DEFAULTFONT_CTL_TEXT
+	};
+
+	sal_uInt16 aLangWhich[] =
+	{
+		RES_CHRATR_LANGUAGE,
+		RES_CHRATR_CJK_LANGUAGE,
+		RES_CHRATR_CTL_LANGUAGE
+	};
+	sal_uInt16 aLangTypes[] =
+	{
+		LANGUAGE_ENGLISH_US,
+		LANGUAGE_ENGLISH_US,
+		LANGUAGE_ARABIC_SAUDI_ARABIA
+	};
+
+	SwStdFontConfig* pStdFont = SW_MOD()->GetStdFontConfig();
+	SfxPrinter* pPrt = pDoc->getPrinter( false );
+	String sEntry;
+
+	for(sal_uInt8 i = 0; i < 3; i++)
+	{
+		sal_uInt16 nFontWhich = aFontWhich[i];
+		sal_uInt16 nFontId = aFontIds[i];
+		SvxFontItem* pFontItem = 0;
+		const SvxLanguageItem& rLang = (const SvxLanguageItem&)pDoc->GetDefault( aLangWhich[i] );
+		LanguageType eLanguage = rLang.GetLanguage();
+		if ( (eLanguage == LANGUAGE_DONTKNOW) || (eLanguage == LANGUAGE_NONE) )
+			eLanguage = aLangTypes[i];
+		{
+			if ( i == 0 )
+			{//At present, just supports for the following languages: english, french and german.
+				LanguageType eUiLanguage = Application::GetSettings().GetUILanguage();
+				switch( eUiLanguage )
+				{
+				case LANGUAGE_ENGLISH_US:
+				case LANGUAGE_FRENCH:
+				case LANGUAGE_FRENCH_BELGIAN:
+				case LANGUAGE_FRENCH_CAMEROON:
+				case LANGUAGE_FRENCH_CANADIAN:
+				case LANGUAGE_FRENCH_COTE_D_IVOIRE:
+				case LANGUAGE_FRENCH_HAITI:
+				case LANGUAGE_FRENCH_LUXEMBOURG:
+				case LANGUAGE_FRENCH_MALI:
+				case LANGUAGE_FRENCH_MONACO:
+				case LANGUAGE_FRENCH_MOROCCO:
+				case LANGUAGE_FRENCH_NORTH_AFRICA:
+				case LANGUAGE_FRENCH_REUNION:
+				case LANGUAGE_FRENCH_SENEGAL:
+				case LANGUAGE_FRENCH_SWISS:
+				case LANGUAGE_FRENCH_WEST_INDIES:
+				case LANGUAGE_FRENCH_ZAIRE:
+				case LANGUAGE_GERMAN:
+				case LANGUAGE_GERMAN_AUSTRIAN:
+				case LANGUAGE_GERMAN_LIECHTENSTEIN:
+				case LANGUAGE_GERMAN_LUXEMBOURG:
+				case LANGUAGE_GERMAN_SWISS:
+					eLanguage = eUiLanguage;
+					break;
+
+				}
+			}
+
+			if ( i == 2 ) //CTL,just supports for HINDI and ARABIC_SAUDI_ARABIA
+			{
+				LanguageType eUiLanguage = Application::GetSettings().GetUILanguage();
+				switch( eUiLanguage )
+				{
+				case LANGUAGE_HINDI:
+					eLanguage = eUiLanguage;
+					break;
+
+				}
+			}
+
+			if ( i == 1 ) //CJK
+			{
+				LanguageType eUiLanguage = Application::GetSettings().GetUILanguage();
+				switch( eUiLanguage )
+				{
+				case LANGUAGE_KOREAN:
+				case LANGUAGE_KOREAN_JOHAB:
+				case LANGUAGE_CHINESE:
+				case LANGUAGE_CHINESE_HONGKONG:
+				case LANGUAGE_CHINESE_MACAU:
+				case LANGUAGE_CHINESE_SIMPLIFIED:
+				case LANGUAGE_CHINESE_SINGAPORE:
+				case LANGUAGE_CHINESE_TRADITIONAL:
+				case LANGUAGE_JAPANESE:
+					eLanguage = eUiLanguage;
+					break;
+				}
+			}
+
+			Font aLangDefFont = OutputDevice::GetDefaultFont(
+				nFontTypes[i],
+				eLanguage,
+				DEFAULTFONT_FLAGS_ONLYONE );
+			pFontItem = new SvxFontItem(aLangDefFont.GetFamily(), aLangDefFont.GetName(),
+				aEmptyStr, aLangDefFont.GetPitch(), aLangDefFont.GetCharSet(), nFontWhich);
+		}
+
+		pDoc->SetDefault(*pFontItem);
+		delete pFontItem; 
+
+		sal_Int32 nFontHeight = pStdFont->GetFontHeight( FONT_STANDARD, i, eLanguage );
+		if(nFontHeight <= 0)
+			nFontHeight = pStdFont->GetDefaultHeightFor( nFontId, eLanguage );
+		pDoc->SetDefault(SvxFontHeightItem( nFontHeight, 100, aFontHeightWhich[i] ));
+		pDoc->SetDefault( SvxLanguageItem( eLanguage, aLangWhich[i] ) );
+	}
+}
+
 /*--------------------------------------------------------------------
 	Beschreibung:	Ctor mit SfxCreateMode ?????
  --------------------------------------------------------------------*/

Modified: incubator/ooo/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx?rev=1291962&r1=1291961&r2=1291962&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx Tue Feb 21 19:25:07 2012
@@ -838,6 +838,8 @@ int SwTransferable::PrepareForCopy( sal_
 
         SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac);
 
+		SwDocShell::InitDefaultFontAttr( pTmpDoc ); //#115580#
+
 		pTmpDoc->LockExpFlds(); 	// nie die Felder updaten - Text so belassen
 		pWrtShell->Copy( pTmpDoc );