xref: /AOO41X/main/sc/source/core/data/patattr.cxx (revision d3e0dd8eb215533c15e891ee35bd141abe9397ee)
1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "scitems.hxx"
31cdf0e10cSrcweir #include <editeng/adjitem.hxx>
32cdf0e10cSrcweir #include <svx/algitem.hxx>
33cdf0e10cSrcweir #include <editeng/boxitem.hxx>
34cdf0e10cSrcweir #include <editeng/bolnitem.hxx>
35cdf0e10cSrcweir #include <editeng/brshitem.hxx>
36cdf0e10cSrcweir #include <editeng/charreliefitem.hxx>
37cdf0e10cSrcweir #include <editeng/cntritem.hxx>
38cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
39cdf0e10cSrcweir #include <editeng/colritem.hxx>
40cdf0e10cSrcweir #include <editeng/crsditem.hxx>
41cdf0e10cSrcweir #include <editeng/emphitem.hxx>
42cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
43cdf0e10cSrcweir #include <editeng/fontitem.hxx>
44cdf0e10cSrcweir #include <editeng/forbiddenruleitem.hxx>
45cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
46cdf0e10cSrcweir #include <editeng/langitem.hxx>
47cdf0e10cSrcweir #include <editeng/postitem.hxx>
48cdf0e10cSrcweir #include <svx/rotmodit.hxx>
49cdf0e10cSrcweir #include <editeng/scriptspaceitem.hxx>
50cdf0e10cSrcweir #include <editeng/scripttypeitem.hxx>
51cdf0e10cSrcweir #include <editeng/shaditem.hxx>
52cdf0e10cSrcweir #include <editeng/shdditem.hxx>
53cdf0e10cSrcweir #include <editeng/udlnitem.hxx>
54cdf0e10cSrcweir #include <editeng/wghtitem.hxx>
55cdf0e10cSrcweir #include <editeng/wrlmitem.hxx>
56cdf0e10cSrcweir #include <svl/intitem.hxx>
57cdf0e10cSrcweir #include <svl/zforlist.hxx>
58cdf0e10cSrcweir #include <vcl/outdev.hxx>
59cdf0e10cSrcweir #include <vcl/svapp.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #include "patattr.hxx"
62cdf0e10cSrcweir #include "docpool.hxx"
63cdf0e10cSrcweir #include "stlsheet.hxx"
64cdf0e10cSrcweir #include "stlpool.hxx"
65cdf0e10cSrcweir #include "document.hxx"
66cdf0e10cSrcweir #include "global.hxx"
67cdf0e10cSrcweir #include "globstr.hrc"
68cdf0e10cSrcweir #include "conditio.hxx"
69cdf0e10cSrcweir #include "validat.hxx"
70cdf0e10cSrcweir #include "scmod.hxx"
71cdf0e10cSrcweir #include "fillinfo.hxx"
72cdf0e10cSrcweir 
73cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
74cdf0e10cSrcweir 
75cdf0e10cSrcweir ScDocument* ScPatternAttr::pDoc = NULL;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir // -----------------------------------------------------------------------
78cdf0e10cSrcweir 
79cdf0e10cSrcweir //!	move to some header file
TwipsToHMM(long nTwips)80cdf0e10cSrcweir inline long TwipsToHMM(long nTwips)	{ return (nTwips * 127 + 36) / 72; }
HMMToTwips(long nHMM)81cdf0e10cSrcweir inline long HMMToTwips(long nHMM)	{ return (nHMM * 72 + 63) / 127; }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir // -----------------------------------------------------------------------
84cdf0e10cSrcweir 
ScPatternAttr(SfxItemSet * pItemSet,const String & rStyleName)85cdf0e10cSrcweir ScPatternAttr::ScPatternAttr( SfxItemSet* pItemSet, const String& rStyleName )
86cdf0e10cSrcweir 	:	SfxSetItem	( ATTR_PATTERN, pItemSet ),
87cdf0e10cSrcweir 		pName		( new String( rStyleName ) ),
88cdf0e10cSrcweir 		pStyle		( NULL )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
ScPatternAttr(SfxItemSet * pItemSet,ScStyleSheet * pStyleSheet)92cdf0e10cSrcweir ScPatternAttr::ScPatternAttr( SfxItemSet* pItemSet, ScStyleSheet* pStyleSheet )
93cdf0e10cSrcweir 	:	SfxSetItem	( ATTR_PATTERN, pItemSet ),
94cdf0e10cSrcweir 		pName		( NULL ),
95cdf0e10cSrcweir 		pStyle		( pStyleSheet )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	if ( pStyleSheet )
98cdf0e10cSrcweir 		GetItemSet().SetParent( &pStyleSheet->GetItemSet() );
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
ScPatternAttr(SfxItemPool * pItemPool)101cdf0e10cSrcweir ScPatternAttr::ScPatternAttr( SfxItemPool* pItemPool )
102cdf0e10cSrcweir 	:	SfxSetItem	( ATTR_PATTERN, new SfxItemSet( *pItemPool, ATTR_PATTERN_START, ATTR_PATTERN_END ) ),
103cdf0e10cSrcweir 		pName		( NULL ),
104cdf0e10cSrcweir 		pStyle		( NULL )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
ScPatternAttr(const ScPatternAttr & rPatternAttr)108cdf0e10cSrcweir ScPatternAttr::ScPatternAttr( const ScPatternAttr& rPatternAttr )
109cdf0e10cSrcweir 	:	SfxSetItem	( rPatternAttr ),
110cdf0e10cSrcweir 		pStyle		( rPatternAttr.pStyle )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	if (rPatternAttr.pName)
113cdf0e10cSrcweir 		pName = new String(*rPatternAttr.pName);
114cdf0e10cSrcweir 	else
115cdf0e10cSrcweir 		pName = NULL;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
~ScPatternAttr()118cdf0e10cSrcweir __EXPORT ScPatternAttr::~ScPatternAttr()
119cdf0e10cSrcweir {
120cdf0e10cSrcweir 	delete pName;
1213a02adb1SWang Lei 	Broadcast(SfxHint());
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
Clone(SfxItemPool * pPool) const124cdf0e10cSrcweir SfxPoolItem* __EXPORT ScPatternAttr::Clone( SfxItemPool *pPool ) const
125cdf0e10cSrcweir {
126cdf0e10cSrcweir 	ScPatternAttr* pPattern = new ScPatternAttr( GetItemSet().Clone(sal_True, pPool) );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	pPattern->pStyle = pStyle;
129cdf0e10cSrcweir 	pPattern->pName  = pName ? new String(*pName) : NULL;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	return pPattern;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
StrCmp(const String * pStr1,const String * pStr2)134cdf0e10cSrcweir inline int StrCmp( const String* pStr1, const String* pStr2 )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir 	return ( pStr1 ? ( pStr2 ? ( *pStr1 == *pStr2 ) : sal_False ) : ( pStr2 ? sal_False : sal_True ) );
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 
operator ==(const SfxPoolItem & rCmp) const141cdf0e10cSrcweir int __EXPORT ScPatternAttr::operator==( const SfxPoolItem& rCmp ) const
142cdf0e10cSrcweir {
143cdf0e10cSrcweir     // #i62090# Use quick comparison between ScPatternAttr's ItemSets
144cdf0e10cSrcweir 
14505f023e4SWang Lei    //optimize a comparing operation from 'memcmp' to 'hash compare' to improve xls loading performance, i120575
14605f023e4SWang Lei    //More quickly comparing method using hashkey.
14705f023e4SWang Lei    //the const_cast here will then only change the HashKey of that SfxItemSet, so it's safe.
14805f023e4SWang Lei 	return ((const_cast<ScPatternAttr&>(*this)).GetItemSet().QuickCompare( (const_cast<ScPatternAttr&>(static_cast<const ScPatternAttr&>(rCmp))).GetItemSet())&&
149cdf0e10cSrcweir 		StrCmp( GetStyleName(), static_cast<const ScPatternAttr&>(rCmp).GetStyleName() ) );
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
Create(SvStream & rStream,sal_uInt16) const152cdf0e10cSrcweir SfxPoolItem* __EXPORT ScPatternAttr::Create( SvStream& rStream, sal_uInt16 /* nVersion */ ) const
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	String* pStr;
155cdf0e10cSrcweir 	sal_Bool	bHasStyle;
156cdf0e10cSrcweir 	short	eFamDummy;
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	rStream >> bHasStyle;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	if ( bHasStyle )
161cdf0e10cSrcweir 	{
162cdf0e10cSrcweir 		pStr = new String;
163cdf0e10cSrcweir 		rStream.ReadByteString( *pStr, rStream.GetStreamCharSet() );
164cdf0e10cSrcweir 		rStream >> eFamDummy; // wg. altem Dateiformat
165cdf0e10cSrcweir 	}
166cdf0e10cSrcweir 	else
167cdf0e10cSrcweir 		pStr = new String( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	SfxItemSet *pNewSet = new SfxItemSet( *GetItemSet().GetPool(),
170cdf0e10cSrcweir 									   ATTR_PATTERN_START, ATTR_PATTERN_END );
171cdf0e10cSrcweir 	pNewSet->Load( rStream );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	ScPatternAttr* pPattern = new ScPatternAttr( pNewSet );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	pPattern->pName = pStr;
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	return pPattern;
178cdf0e10cSrcweir }
179cdf0e10cSrcweir 
Store(SvStream & rStream,sal_uInt16) const180cdf0e10cSrcweir SvStream& __EXPORT ScPatternAttr::Store(SvStream& rStream, sal_uInt16 /* nItemVersion */) const
181cdf0e10cSrcweir {
182cdf0e10cSrcweir 	rStream << (sal_Bool)sal_True;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 	if ( pStyle )
185cdf0e10cSrcweir 		rStream.WriteByteString( pStyle->GetName(), rStream.GetStreamCharSet() );
186cdf0e10cSrcweir 	else if ( pName )					// wenn Style geloescht ist/war
187cdf0e10cSrcweir 		rStream.WriteByteString( *pName, rStream.GetStreamCharSet() );
188cdf0e10cSrcweir 	else
189cdf0e10cSrcweir 		rStream.WriteByteString( ScGlobal::GetRscString(STR_STYLENAME_STANDARD),
190cdf0e10cSrcweir 									rStream.GetStreamCharSet() );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 	rStream << (short)SFX_STYLE_FAMILY_PARA;  // wg. altem Dateiformat
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 	GetItemSet().Store( rStream );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 	return rStream;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
GetCellOrientation(const SfxItemSet & rItemSet,const SfxItemSet * pCondSet)199cdf0e10cSrcweir SvxCellOrientation ScPatternAttr::GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir     SvxCellOrientation eOrient = SVX_ORIENTATION_STANDARD;
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     if( ((const SfxBoolItem&)GetItem( ATTR_STACKED, rItemSet, pCondSet )).GetValue() )
204cdf0e10cSrcweir     {
205cdf0e10cSrcweir         eOrient = SVX_ORIENTATION_STACKED;
206cdf0e10cSrcweir     }
207cdf0e10cSrcweir     else
208cdf0e10cSrcweir     {
209cdf0e10cSrcweir         sal_Int32 nAngle = ((const SfxInt32Item&)GetItem( ATTR_ROTATE_VALUE, rItemSet, pCondSet )).GetValue();
210cdf0e10cSrcweir         if( nAngle == 9000 )
211cdf0e10cSrcweir             eOrient = SVX_ORIENTATION_BOTTOMTOP;
212cdf0e10cSrcweir         else if( nAngle == 27000 )
213cdf0e10cSrcweir             eOrient = SVX_ORIENTATION_TOPBOTTOM;
214cdf0e10cSrcweir     }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir     return eOrient;
217cdf0e10cSrcweir }
218cdf0e10cSrcweir 
GetCellOrientation(const SfxItemSet * pCondSet) const219cdf0e10cSrcweir SvxCellOrientation ScPatternAttr::GetCellOrientation( const SfxItemSet* pCondSet ) const
220cdf0e10cSrcweir {
221cdf0e10cSrcweir     return GetCellOrientation( GetItemSet(), pCondSet );
222cdf0e10cSrcweir }
223cdf0e10cSrcweir 
GetFont(Font & rFont,const SfxItemSet & rItemSet,ScAutoFontColorMode eAutoMode,OutputDevice * pOutDev,const Fraction * pScale,const SfxItemSet * pCondSet,sal_uInt8 nScript,const Color * pBackConfigColor,const Color * pTextConfigColor)224cdf0e10cSrcweir void ScPatternAttr::GetFont(
225cdf0e10cSrcweir         Font& rFont, const SfxItemSet& rItemSet, ScAutoFontColorMode eAutoMode,
226cdf0e10cSrcweir         OutputDevice* pOutDev, const Fraction* pScale,
227cdf0e10cSrcweir         const SfxItemSet* pCondSet, sal_uInt8 nScript,
228cdf0e10cSrcweir         const Color* pBackConfigColor, const Color* pTextConfigColor )
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	//	Items auslesen
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 	const SvxFontItem* pFontAttr;
233cdf0e10cSrcweir 	sal_uInt32 nFontHeight;
234cdf0e10cSrcweir 	FontWeight eWeight;
235cdf0e10cSrcweir 	FontItalic eItalic;
236cdf0e10cSrcweir 	FontUnderline eUnder;
237cdf0e10cSrcweir 	FontUnderline eOver;
238cdf0e10cSrcweir 	sal_Bool bWordLine;
239cdf0e10cSrcweir 	FontStrikeout eStrike;
240cdf0e10cSrcweir 	sal_Bool bOutline;
241cdf0e10cSrcweir 	sal_Bool bShadow;
242cdf0e10cSrcweir 	FontEmphasisMark eEmphasis;
243cdf0e10cSrcweir 	FontRelief eRelief;
244cdf0e10cSrcweir 	Color aColor;
245cdf0e10cSrcweir 	LanguageType eLang;
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 	sal_uInt16 nFontId, nHeightId, nWeightId, nPostureId, nLangId;
248cdf0e10cSrcweir 	if ( nScript == SCRIPTTYPE_ASIAN )
249cdf0e10cSrcweir 	{
250cdf0e10cSrcweir 		nFontId    = ATTR_CJK_FONT;
251cdf0e10cSrcweir 		nHeightId  = ATTR_CJK_FONT_HEIGHT;
252cdf0e10cSrcweir 		nWeightId  = ATTR_CJK_FONT_WEIGHT;
253cdf0e10cSrcweir 		nPostureId = ATTR_CJK_FONT_POSTURE;
254cdf0e10cSrcweir 		nLangId    = ATTR_CJK_FONT_LANGUAGE;
255cdf0e10cSrcweir 	}
256cdf0e10cSrcweir 	else if ( nScript == SCRIPTTYPE_COMPLEX )
257cdf0e10cSrcweir 	{
258cdf0e10cSrcweir 		nFontId    = ATTR_CTL_FONT;
259cdf0e10cSrcweir 		nHeightId  = ATTR_CTL_FONT_HEIGHT;
260cdf0e10cSrcweir 		nWeightId  = ATTR_CTL_FONT_WEIGHT;
261cdf0e10cSrcweir 		nPostureId = ATTR_CTL_FONT_POSTURE;
262cdf0e10cSrcweir 		nLangId    = ATTR_CTL_FONT_LANGUAGE;
263cdf0e10cSrcweir 	}
264cdf0e10cSrcweir 	else
265cdf0e10cSrcweir 	{
266cdf0e10cSrcweir 		nFontId    = ATTR_FONT;
267cdf0e10cSrcweir 		nHeightId  = ATTR_FONT_HEIGHT;
268cdf0e10cSrcweir 		nWeightId  = ATTR_FONT_WEIGHT;
269cdf0e10cSrcweir 		nPostureId = ATTR_FONT_POSTURE;
270cdf0e10cSrcweir 		nLangId    = ATTR_FONT_LANGUAGE;
271cdf0e10cSrcweir 	}
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 	if ( pCondSet )
274cdf0e10cSrcweir 	{
275cdf0e10cSrcweir 		const SfxPoolItem* pItem;
276cdf0e10cSrcweir 
277cdf0e10cSrcweir 		if ( pCondSet->GetItemState( nFontId, sal_True, &pItem ) != SFX_ITEM_SET )
278cdf0e10cSrcweir             pItem = &rItemSet.Get( nFontId );
279cdf0e10cSrcweir 		pFontAttr = (const SvxFontItem*) pItem;
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 		if ( pCondSet->GetItemState( nHeightId, sal_True, &pItem ) != SFX_ITEM_SET )
282cdf0e10cSrcweir             pItem = &rItemSet.Get( nHeightId );
283cdf0e10cSrcweir 		nFontHeight = ((const SvxFontHeightItem*)pItem)->GetHeight();
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 		if ( pCondSet->GetItemState( nWeightId, sal_True, &pItem ) != SFX_ITEM_SET )
286cdf0e10cSrcweir             pItem = &rItemSet.Get( nWeightId );
287cdf0e10cSrcweir 		eWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue();
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 		if ( pCondSet->GetItemState( nPostureId, sal_True, &pItem ) != SFX_ITEM_SET )
290cdf0e10cSrcweir             pItem = &rItemSet.Get( nPostureId );
291cdf0e10cSrcweir 		eItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue();
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_UNDERLINE, sal_True, &pItem ) != SFX_ITEM_SET )
294cdf0e10cSrcweir             pItem = &rItemSet.Get( ATTR_FONT_UNDERLINE );
295cdf0e10cSrcweir 		eUnder = (FontUnderline)((const SvxUnderlineItem*)pItem)->GetValue();
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_OVERLINE, sal_True, &pItem ) != SFX_ITEM_SET )
298cdf0e10cSrcweir             pItem = &rItemSet.Get( ATTR_FONT_OVERLINE );
299cdf0e10cSrcweir 		eOver = (FontUnderline)((const SvxOverlineItem*)pItem)->GetValue();
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_WORDLINE, sal_True, &pItem ) != SFX_ITEM_SET )
302cdf0e10cSrcweir             pItem = &rItemSet.Get( ATTR_FONT_WORDLINE );
303cdf0e10cSrcweir 		bWordLine = ((const SvxWordLineModeItem*)pItem)->GetValue();
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_CROSSEDOUT, sal_True, &pItem ) != SFX_ITEM_SET )
306cdf0e10cSrcweir             pItem = &rItemSet.Get( ATTR_FONT_CROSSEDOUT );
307cdf0e10cSrcweir 		eStrike = (FontStrikeout)((const SvxCrossedOutItem*)pItem)->GetValue();
308cdf0e10cSrcweir 
309cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_CONTOUR, sal_True, &pItem ) != SFX_ITEM_SET )
310cdf0e10cSrcweir             pItem = &rItemSet.Get( ATTR_FONT_CONTOUR );
311cdf0e10cSrcweir 		bOutline = ((const SvxContourItem*)pItem)->GetValue();
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_SHADOWED, sal_True, &pItem ) != SFX_ITEM_SET )
314cdf0e10cSrcweir             pItem = &rItemSet.Get( ATTR_FONT_SHADOWED );
315cdf0e10cSrcweir 		bShadow = ((const SvxShadowedItem*)pItem)->GetValue();
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_EMPHASISMARK, sal_True, &pItem ) != SFX_ITEM_SET )
318cdf0e10cSrcweir             pItem = &rItemSet.Get( ATTR_FONT_EMPHASISMARK );
319cdf0e10cSrcweir 		eEmphasis = ((const SvxEmphasisMarkItem*)pItem)->GetEmphasisMark();
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_RELIEF, sal_True, &pItem ) != SFX_ITEM_SET )
322cdf0e10cSrcweir             pItem = &rItemSet.Get( ATTR_FONT_RELIEF );
323cdf0e10cSrcweir 		eRelief = (FontRelief)((const SvxCharReliefItem*)pItem)->GetValue();
324cdf0e10cSrcweir 
325cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_COLOR, sal_True, &pItem ) != SFX_ITEM_SET )
326cdf0e10cSrcweir             pItem = &rItemSet.Get( ATTR_FONT_COLOR );
327cdf0e10cSrcweir 		aColor = ((const SvxColorItem*)pItem)->GetValue();
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 		if ( pCondSet->GetItemState( nLangId, sal_True, &pItem ) != SFX_ITEM_SET )
330cdf0e10cSrcweir 			pItem = &rItemSet.Get( nLangId );
331cdf0e10cSrcweir 		eLang = ((const SvxLanguageItem*)pItem)->GetLanguage();
332cdf0e10cSrcweir 	}
333cdf0e10cSrcweir     else    // alles aus rItemSet
334cdf0e10cSrcweir 	{
335cdf0e10cSrcweir         pFontAttr = &(const SvxFontItem&)rItemSet.Get( nFontId );
336cdf0e10cSrcweir 		nFontHeight = ((const SvxFontHeightItem&)
337cdf0e10cSrcweir                         rItemSet.Get( nHeightId )).GetHeight();
338cdf0e10cSrcweir 		eWeight = (FontWeight)((const SvxWeightItem&)
339cdf0e10cSrcweir                         rItemSet.Get( nWeightId )).GetValue();
340cdf0e10cSrcweir 		eItalic = (FontItalic)((const SvxPostureItem&)
341cdf0e10cSrcweir                         rItemSet.Get( nPostureId )).GetValue();
342cdf0e10cSrcweir 		eUnder = (FontUnderline)((const SvxUnderlineItem&)
343cdf0e10cSrcweir                         rItemSet.Get( ATTR_FONT_UNDERLINE )).GetValue();
344cdf0e10cSrcweir 		eOver = (FontUnderline)((const SvxOverlineItem&)
345cdf0e10cSrcweir                         rItemSet.Get( ATTR_FONT_OVERLINE )).GetValue();
346cdf0e10cSrcweir 		bWordLine = ((const SvxWordLineModeItem&)
347cdf0e10cSrcweir                         rItemSet.Get( ATTR_FONT_WORDLINE )).GetValue();
348cdf0e10cSrcweir 		eStrike = (FontStrikeout)((const SvxCrossedOutItem&)
349cdf0e10cSrcweir                         rItemSet.Get( ATTR_FONT_CROSSEDOUT )).GetValue();
350cdf0e10cSrcweir 		bOutline = ((const SvxContourItem&)
351cdf0e10cSrcweir                         rItemSet.Get( ATTR_FONT_CONTOUR )).GetValue();
352cdf0e10cSrcweir 		bShadow = ((const SvxShadowedItem&)
353cdf0e10cSrcweir                         rItemSet.Get( ATTR_FONT_SHADOWED )).GetValue();
354cdf0e10cSrcweir 		eEmphasis = ((const SvxEmphasisMarkItem&)
355cdf0e10cSrcweir                         rItemSet.Get( ATTR_FONT_EMPHASISMARK )).GetEmphasisMark();
356cdf0e10cSrcweir 		eRelief = (FontRelief)((const SvxCharReliefItem&)
357cdf0e10cSrcweir                         rItemSet.Get( ATTR_FONT_RELIEF )).GetValue();
358cdf0e10cSrcweir 		aColor = ((const SvxColorItem&)
359cdf0e10cSrcweir                         rItemSet.Get( ATTR_FONT_COLOR )).GetValue();
360cdf0e10cSrcweir 		// for graphite language features
361cdf0e10cSrcweir 		eLang =
362cdf0e10cSrcweir 		((const SvxLanguageItem&)rItemSet.Get( nLangId )).GetLanguage();
363cdf0e10cSrcweir 	}
364cdf0e10cSrcweir 	DBG_ASSERT(pFontAttr,"nanu?");
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 	//	auswerten
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	//	FontItem:
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 	if (rFont.GetName() != pFontAttr->GetFamilyName())
371cdf0e10cSrcweir 		rFont.SetName( pFontAttr->GetFamilyName() );
372cdf0e10cSrcweir 	if (rFont.GetStyleName() != pFontAttr->GetStyleName())
373cdf0e10cSrcweir 		rFont.SetStyleName( pFontAttr->GetStyleName() );
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 	rFont.SetFamily( pFontAttr->GetFamily() );
376cdf0e10cSrcweir 	rFont.SetCharSet( pFontAttr->GetCharSet() );
377cdf0e10cSrcweir 	rFont.SetPitch( pFontAttr->GetPitch() );
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 	rFont.SetLanguage(eLang);
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	//	Groesse
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 	if ( pOutDev != NULL )
384cdf0e10cSrcweir 	{
385cdf0e10cSrcweir 		Size aEffSize;
386cdf0e10cSrcweir 		Fraction aFraction( 1,1 );
387cdf0e10cSrcweir 		if (pScale)
388cdf0e10cSrcweir 			aFraction = *pScale;
389cdf0e10cSrcweir 		Size aSize( 0, (long) nFontHeight );
390cdf0e10cSrcweir 		MapMode aDestMode = pOutDev->GetMapMode();
391cdf0e10cSrcweir 		MapMode aSrcMode( MAP_TWIP, Point(), aFraction, aFraction );
392cdf0e10cSrcweir 		if (aDestMode.GetMapUnit() == MAP_PIXEL)
393cdf0e10cSrcweir 			aEffSize = pOutDev->LogicToPixel( aSize, aSrcMode );
394cdf0e10cSrcweir 		else
395cdf0e10cSrcweir 		{
396cdf0e10cSrcweir 			Fraction aFractOne(1,1);
397cdf0e10cSrcweir 			aDestMode.SetScaleX( aFractOne );
398cdf0e10cSrcweir 			aDestMode.SetScaleY( aFractOne );
399cdf0e10cSrcweir 			aEffSize = OutputDevice::LogicToLogic( aSize, aSrcMode, aDestMode );
400cdf0e10cSrcweir 		}
401cdf0e10cSrcweir 		rFont.SetSize( aEffSize );
402cdf0e10cSrcweir 	}
403cdf0e10cSrcweir 	else /* if pOutDev != NULL */
404cdf0e10cSrcweir 	{
405cdf0e10cSrcweir 		rFont.SetSize( Size( 0, (long) nFontHeight ) );
406cdf0e10cSrcweir 	}
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 	//	determine effective font color
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 	if ( ( aColor.GetColor() == COL_AUTO && eAutoMode != SC_AUTOCOL_RAW ) ||
411cdf0e10cSrcweir 			eAutoMode == SC_AUTOCOL_IGNOREFONT || eAutoMode == SC_AUTOCOL_IGNOREALL )
412cdf0e10cSrcweir 	{
413cdf0e10cSrcweir 		if ( eAutoMode == SC_AUTOCOL_BLACK )
414cdf0e10cSrcweir 			aColor.SetColor( COL_BLACK );
415cdf0e10cSrcweir 		else
416cdf0e10cSrcweir 		{
417cdf0e10cSrcweir 			//	get background color from conditional or own set
418cdf0e10cSrcweir 			Color aBackColor;
419cdf0e10cSrcweir 			if ( pCondSet )
420cdf0e10cSrcweir 			{
421cdf0e10cSrcweir 				const SfxPoolItem* pItem;
422cdf0e10cSrcweir 				if ( pCondSet->GetItemState( ATTR_BACKGROUND, sal_True, &pItem ) != SFX_ITEM_SET )
423cdf0e10cSrcweir                     pItem = &rItemSet.Get( ATTR_BACKGROUND );
424cdf0e10cSrcweir 				aBackColor = ((const SvxBrushItem*)pItem)->GetColor();
425cdf0e10cSrcweir 			}
426cdf0e10cSrcweir 			else
427cdf0e10cSrcweir                 aBackColor = ((const SvxBrushItem&)rItemSet.Get( ATTR_BACKGROUND )).GetColor();
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 			//	if background color attribute is transparent, use window color for brightness comparisons
430cdf0e10cSrcweir 			if ( aBackColor == COL_TRANSPARENT ||
431cdf0e10cSrcweir 					eAutoMode == SC_AUTOCOL_IGNOREBACK || eAutoMode == SC_AUTOCOL_IGNOREALL )
432cdf0e10cSrcweir 			{
433cdf0e10cSrcweir 				if ( eAutoMode == SC_AUTOCOL_PRINT )
434cdf0e10cSrcweir 					aBackColor.SetColor( COL_WHITE );
435cdf0e10cSrcweir 				else if ( pBackConfigColor )
436cdf0e10cSrcweir 				{
437cdf0e10cSrcweir 					// pBackConfigColor can be used to avoid repeated lookup of the configured color
438cdf0e10cSrcweir 					aBackColor = *pBackConfigColor;
439cdf0e10cSrcweir 				}
440cdf0e10cSrcweir 				else
441cdf0e10cSrcweir                     aBackColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
442cdf0e10cSrcweir 			}
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 			//	get system text color for comparison
445cdf0e10cSrcweir 			Color aSysTextColor;
446cdf0e10cSrcweir 			if ( eAutoMode == SC_AUTOCOL_PRINT )
447cdf0e10cSrcweir 				aSysTextColor.SetColor( COL_BLACK );
448cdf0e10cSrcweir 			else if ( pTextConfigColor )
449cdf0e10cSrcweir 			{
450cdf0e10cSrcweir 				// pTextConfigColor can be used to avoid repeated lookup of the configured color
451cdf0e10cSrcweir 				aSysTextColor = *pTextConfigColor;
452cdf0e10cSrcweir 			}
453cdf0e10cSrcweir 			else
454cdf0e10cSrcweir                 aSysTextColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 			//	select the resulting color
457cdf0e10cSrcweir 			if ( aBackColor.IsDark() && aSysTextColor.IsDark() )
458cdf0e10cSrcweir 			{
459cdf0e10cSrcweir 				//	use white instead of dark on dark
460cdf0e10cSrcweir 				aColor.SetColor( COL_WHITE );
461cdf0e10cSrcweir 			}
462cdf0e10cSrcweir 			else if ( aBackColor.IsBright() && aSysTextColor.IsBright() )
463cdf0e10cSrcweir 			{
464cdf0e10cSrcweir 				//	use black instead of bright on bright
465cdf0e10cSrcweir 				aColor.SetColor( COL_BLACK );
466cdf0e10cSrcweir 			}
467cdf0e10cSrcweir 			else
468cdf0e10cSrcweir 			{
469cdf0e10cSrcweir 				//	use aSysTextColor (black for SC_AUTOCOL_PRINT, from style settings otherwise)
470cdf0e10cSrcweir 				aColor = aSysTextColor;
471cdf0e10cSrcweir 			}
472cdf0e10cSrcweir 		}
473cdf0e10cSrcweir 	}
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 	//	set font effects
476cdf0e10cSrcweir 	rFont.SetWeight( eWeight );
477cdf0e10cSrcweir 	rFont.SetItalic( eItalic );
478cdf0e10cSrcweir 	rFont.SetUnderline( eUnder );
479cdf0e10cSrcweir 	rFont.SetOverline( eOver );
480cdf0e10cSrcweir 	rFont.SetWordLineMode( bWordLine );
481cdf0e10cSrcweir 	rFont.SetStrikeout( eStrike );
482cdf0e10cSrcweir 	rFont.SetOutline( bOutline );
483cdf0e10cSrcweir 	rFont.SetShadow( bShadow );
484cdf0e10cSrcweir 	rFont.SetEmphasisMark( eEmphasis );
485cdf0e10cSrcweir 	rFont.SetRelief( eRelief );
486cdf0e10cSrcweir 	rFont.SetColor( aColor );
487cdf0e10cSrcweir 	rFont.SetTransparent( sal_True );
488cdf0e10cSrcweir }
489cdf0e10cSrcweir 
GetFont(Font & rFont,ScAutoFontColorMode eAutoMode,OutputDevice * pOutDev,const Fraction * pScale,const SfxItemSet * pCondSet,sal_uInt8 nScript,const Color * pBackConfigColor,const Color * pTextConfigColor) const490cdf0e10cSrcweir void ScPatternAttr::GetFont(
491cdf0e10cSrcweir         Font& rFont, ScAutoFontColorMode eAutoMode,
492cdf0e10cSrcweir         OutputDevice* pOutDev, const Fraction* pScale,
493cdf0e10cSrcweir         const SfxItemSet* pCondSet, sal_uInt8 nScript,
494cdf0e10cSrcweir         const Color* pBackConfigColor, const Color* pTextConfigColor ) const
495cdf0e10cSrcweir {
496cdf0e10cSrcweir     GetFont( rFont, GetItemSet(), eAutoMode, pOutDev, pScale, pCondSet, nScript, pBackConfigColor, pTextConfigColor );
497cdf0e10cSrcweir }
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 
FillToEditItemSet(SfxItemSet & rEditSet,const SfxItemSet & rSrcSet,const SfxItemSet * pCondSet)500cdf0e10cSrcweir void ScPatternAttr::FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet )
501cdf0e10cSrcweir {
502cdf0e10cSrcweir 	//	Items auslesen
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 	SvxColorItem	aColorItem(EE_CHAR_COLOR);				// use item as-is
505cdf0e10cSrcweir 	SvxFontItem		aFontItem(EE_CHAR_FONTINFO);			// use item as-is
506cdf0e10cSrcweir 	SvxFontItem		aCjkFontItem(EE_CHAR_FONTINFO_CJK);
507cdf0e10cSrcweir 	SvxFontItem		aCtlFontItem(EE_CHAR_FONTINFO_CTL);
508cdf0e10cSrcweir 	long			nTHeight, nCjkTHeight, nCtlTHeight;		// Twips
509cdf0e10cSrcweir 	FontWeight		eWeight, eCjkWeight, eCtlWeight;
510cdf0e10cSrcweir 	SvxUnderlineItem aUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE);
511cdf0e10cSrcweir 	SvxOverlineItem aOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE);
512cdf0e10cSrcweir 	sal_Bool			bWordLine;
513cdf0e10cSrcweir 	FontStrikeout	eStrike;
514cdf0e10cSrcweir 	FontItalic		eItalic, eCjkItalic, eCtlItalic;
515cdf0e10cSrcweir 	sal_Bool			bOutline;
516cdf0e10cSrcweir 	sal_Bool			bShadow;
517cdf0e10cSrcweir 	sal_Bool			bForbidden;
518cdf0e10cSrcweir 	FontEmphasisMark eEmphasis;
519cdf0e10cSrcweir 	FontRelief		eRelief;
520cdf0e10cSrcweir 	LanguageType	eLang, eCjkLang, eCtlLang;
521cdf0e10cSrcweir 	sal_Bool			bHyphenate;
522cdf0e10cSrcweir 	SvxFrameDirection eDirection;
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 	//!	additional parameter to control if language is needed?
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 	if ( pCondSet )
527cdf0e10cSrcweir 	{
528cdf0e10cSrcweir 		const SfxPoolItem* pItem;
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_COLOR, sal_True, &pItem ) != SFX_ITEM_SET )
531cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_COLOR );
532cdf0e10cSrcweir 		aColorItem = *(const SvxColorItem*)pItem;
533cdf0e10cSrcweir 
534cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT, sal_True, &pItem ) != SFX_ITEM_SET )
535cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT );
536cdf0e10cSrcweir 		aFontItem = *(const SvxFontItem*)pItem;
537cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_CJK_FONT, sal_True, &pItem ) != SFX_ITEM_SET )
538cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_CJK_FONT );
539cdf0e10cSrcweir 		aCjkFontItem = *(const SvxFontItem*)pItem;
540cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_CTL_FONT, sal_True, &pItem ) != SFX_ITEM_SET )
541cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_CTL_FONT );
542cdf0e10cSrcweir 		aCtlFontItem = *(const SvxFontItem*)pItem;
543cdf0e10cSrcweir 
544cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_HEIGHT, sal_True, &pItem ) != SFX_ITEM_SET )
545cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_HEIGHT );
546cdf0e10cSrcweir 		nTHeight = ((const SvxFontHeightItem*)pItem)->GetHeight();
547cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_CJK_FONT_HEIGHT, sal_True, &pItem ) != SFX_ITEM_SET )
548cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_CJK_FONT_HEIGHT );
549cdf0e10cSrcweir 		nCjkTHeight = ((const SvxFontHeightItem*)pItem)->GetHeight();
550cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_CTL_FONT_HEIGHT, sal_True, &pItem ) != SFX_ITEM_SET )
551cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_CTL_FONT_HEIGHT );
552cdf0e10cSrcweir 		nCtlTHeight = ((const SvxFontHeightItem*)pItem)->GetHeight();
553cdf0e10cSrcweir 
554cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_WEIGHT, sal_True, &pItem ) != SFX_ITEM_SET )
555cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_WEIGHT );
556cdf0e10cSrcweir 		eWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue();
557cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_CJK_FONT_WEIGHT, sal_True, &pItem ) != SFX_ITEM_SET )
558cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_CJK_FONT_WEIGHT );
559cdf0e10cSrcweir 		eCjkWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue();
560cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_CTL_FONT_WEIGHT, sal_True, &pItem ) != SFX_ITEM_SET )
561cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_CTL_FONT_WEIGHT );
562cdf0e10cSrcweir 		eCtlWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue();
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_POSTURE, sal_True, &pItem ) != SFX_ITEM_SET )
565cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_POSTURE );
566cdf0e10cSrcweir 		eItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue();
567cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_CJK_FONT_POSTURE, sal_True, &pItem ) != SFX_ITEM_SET )
568cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_CJK_FONT_POSTURE );
569cdf0e10cSrcweir 		eCjkItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue();
570cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_CTL_FONT_POSTURE, sal_True, &pItem ) != SFX_ITEM_SET )
571cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_CTL_FONT_POSTURE );
572cdf0e10cSrcweir 		eCtlItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue();
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_UNDERLINE, sal_True, &pItem ) != SFX_ITEM_SET )
575cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_UNDERLINE );
576cdf0e10cSrcweir 		aUnderlineItem = *(const SvxUnderlineItem*)pItem;
577cdf0e10cSrcweir 
578cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_OVERLINE, sal_True, &pItem ) != SFX_ITEM_SET )
579cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_OVERLINE );
580cdf0e10cSrcweir 		aOverlineItem = *(const SvxOverlineItem*)pItem;
581cdf0e10cSrcweir 
582cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_WORDLINE, sal_True, &pItem ) != SFX_ITEM_SET )
583cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_WORDLINE );
584cdf0e10cSrcweir 		bWordLine = ((const SvxWordLineModeItem*)pItem)->GetValue();
585cdf0e10cSrcweir 
586cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_CROSSEDOUT, sal_True, &pItem ) != SFX_ITEM_SET )
587cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_CROSSEDOUT );
588cdf0e10cSrcweir 		eStrike = (FontStrikeout)((const SvxCrossedOutItem*)pItem)->GetValue();
589cdf0e10cSrcweir 
590cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_CONTOUR, sal_True, &pItem ) != SFX_ITEM_SET )
591cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_CONTOUR );
592cdf0e10cSrcweir 		bOutline = ((const SvxContourItem*)pItem)->GetValue();
593cdf0e10cSrcweir 
594cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_SHADOWED, sal_True, &pItem ) != SFX_ITEM_SET )
595cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_SHADOWED );
596cdf0e10cSrcweir 		bShadow = ((const SvxShadowedItem*)pItem)->GetValue();
597cdf0e10cSrcweir 
598cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FORBIDDEN_RULES, sal_True, &pItem ) != SFX_ITEM_SET )
599cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FORBIDDEN_RULES );
600cdf0e10cSrcweir 		bForbidden = ((const SvxForbiddenRuleItem*)pItem)->GetValue();
601cdf0e10cSrcweir 
602cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_EMPHASISMARK, sal_True, &pItem ) != SFX_ITEM_SET )
603cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_EMPHASISMARK );
604cdf0e10cSrcweir 		eEmphasis = ((const SvxEmphasisMarkItem*)pItem)->GetEmphasisMark();
605cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_RELIEF, sal_True, &pItem ) != SFX_ITEM_SET )
606cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_RELIEF );
607cdf0e10cSrcweir 		eRelief = (FontRelief)((const SvxCharReliefItem*)pItem)->GetValue();
608cdf0e10cSrcweir 
609cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_FONT_LANGUAGE, sal_True, &pItem ) != SFX_ITEM_SET )
610cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_FONT_LANGUAGE );
611cdf0e10cSrcweir 		eLang = ((const SvxLanguageItem*)pItem)->GetLanguage();
612cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_CJK_FONT_LANGUAGE, sal_True, &pItem ) != SFX_ITEM_SET )
613cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_CJK_FONT_LANGUAGE );
614cdf0e10cSrcweir 		eCjkLang = ((const SvxLanguageItem*)pItem)->GetLanguage();
615cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_CTL_FONT_LANGUAGE, sal_True, &pItem ) != SFX_ITEM_SET )
616cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_CTL_FONT_LANGUAGE );
617cdf0e10cSrcweir 		eCtlLang = ((const SvxLanguageItem*)pItem)->GetLanguage();
618cdf0e10cSrcweir 
619cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_HYPHENATE, sal_True, &pItem ) != SFX_ITEM_SET )
620cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_HYPHENATE );
621cdf0e10cSrcweir 		bHyphenate = ((const SfxBoolItem*)pItem)->GetValue();
622cdf0e10cSrcweir 
623cdf0e10cSrcweir 		if ( pCondSet->GetItemState( ATTR_WRITINGDIR, sal_True, &pItem ) != SFX_ITEM_SET )
624cdf0e10cSrcweir             pItem = &rSrcSet.Get( ATTR_WRITINGDIR );
625cdf0e10cSrcweir 		eDirection = (SvxFrameDirection)((const SvxFrameDirectionItem*)pItem)->GetValue();
626cdf0e10cSrcweir 	}
627cdf0e10cSrcweir 	else		// alles direkt aus Pattern
628cdf0e10cSrcweir 	{
629cdf0e10cSrcweir         aColorItem = (const SvxColorItem&) rSrcSet.Get( ATTR_FONT_COLOR );
630cdf0e10cSrcweir         aFontItem = (const SvxFontItem&) rSrcSet.Get( ATTR_FONT );
631cdf0e10cSrcweir         aCjkFontItem = (const SvxFontItem&) rSrcSet.Get( ATTR_CJK_FONT );
632cdf0e10cSrcweir         aCtlFontItem = (const SvxFontItem&) rSrcSet.Get( ATTR_CTL_FONT );
633cdf0e10cSrcweir 		nTHeight = ((const SvxFontHeightItem&)
634cdf0e10cSrcweir                         rSrcSet.Get( ATTR_FONT_HEIGHT )).GetHeight();
635cdf0e10cSrcweir 		nCjkTHeight = ((const SvxFontHeightItem&)
636cdf0e10cSrcweir                         rSrcSet.Get( ATTR_CJK_FONT_HEIGHT )).GetHeight();
637cdf0e10cSrcweir 		nCtlTHeight = ((const SvxFontHeightItem&)
638cdf0e10cSrcweir                         rSrcSet.Get( ATTR_CTL_FONT_HEIGHT )).GetHeight();
639cdf0e10cSrcweir 		eWeight = (FontWeight)((const SvxWeightItem&)
640cdf0e10cSrcweir                         rSrcSet.Get( ATTR_FONT_WEIGHT )).GetValue();
641cdf0e10cSrcweir 		eCjkWeight = (FontWeight)((const SvxWeightItem&)
642cdf0e10cSrcweir                         rSrcSet.Get( ATTR_CJK_FONT_WEIGHT )).GetValue();
643cdf0e10cSrcweir 		eCtlWeight = (FontWeight)((const SvxWeightItem&)
644cdf0e10cSrcweir                         rSrcSet.Get( ATTR_CTL_FONT_WEIGHT )).GetValue();
645cdf0e10cSrcweir 		eItalic = (FontItalic)((const SvxPostureItem&)
646cdf0e10cSrcweir                         rSrcSet.Get( ATTR_FONT_POSTURE )).GetValue();
647cdf0e10cSrcweir 		eCjkItalic = (FontItalic)((const SvxPostureItem&)
648cdf0e10cSrcweir                         rSrcSet.Get( ATTR_CJK_FONT_POSTURE )).GetValue();
649cdf0e10cSrcweir 		eCtlItalic = (FontItalic)((const SvxPostureItem&)
650cdf0e10cSrcweir                         rSrcSet.Get( ATTR_CTL_FONT_POSTURE )).GetValue();
651cdf0e10cSrcweir         aUnderlineItem = (const SvxUnderlineItem&) rSrcSet.Get( ATTR_FONT_UNDERLINE );
652cdf0e10cSrcweir         aOverlineItem  = (const SvxOverlineItem&) rSrcSet.Get( ATTR_FONT_OVERLINE );
653cdf0e10cSrcweir 		bWordLine = ((const SvxWordLineModeItem&)
654cdf0e10cSrcweir                         rSrcSet.Get( ATTR_FONT_WORDLINE )).GetValue();
655cdf0e10cSrcweir 		eStrike = (FontStrikeout)((const SvxCrossedOutItem&)
656cdf0e10cSrcweir                         rSrcSet.Get( ATTR_FONT_CROSSEDOUT )).GetValue();
657cdf0e10cSrcweir 		bOutline = ((const SvxContourItem&)
658cdf0e10cSrcweir                         rSrcSet.Get( ATTR_FONT_CONTOUR )).GetValue();
659cdf0e10cSrcweir 		bShadow = ((const SvxShadowedItem&)
660cdf0e10cSrcweir                         rSrcSet.Get( ATTR_FONT_SHADOWED )).GetValue();
661cdf0e10cSrcweir 		bForbidden = ((const SvxForbiddenRuleItem&)
662cdf0e10cSrcweir                         rSrcSet.Get( ATTR_FORBIDDEN_RULES )).GetValue();
663cdf0e10cSrcweir 		eEmphasis = ((const SvxEmphasisMarkItem&)
664cdf0e10cSrcweir                         rSrcSet.Get( ATTR_FONT_EMPHASISMARK )).GetEmphasisMark();
665cdf0e10cSrcweir 		eRelief = (FontRelief)((const SvxCharReliefItem&)
666cdf0e10cSrcweir                         rSrcSet.Get( ATTR_FONT_RELIEF )).GetValue();
667cdf0e10cSrcweir 		eLang = ((const SvxLanguageItem&)
668cdf0e10cSrcweir                         rSrcSet.Get( ATTR_FONT_LANGUAGE )).GetLanguage();
669cdf0e10cSrcweir 		eCjkLang = ((const SvxLanguageItem&)
670cdf0e10cSrcweir                         rSrcSet.Get( ATTR_CJK_FONT_LANGUAGE )).GetLanguage();
671cdf0e10cSrcweir 		eCtlLang = ((const SvxLanguageItem&)
672cdf0e10cSrcweir                         rSrcSet.Get( ATTR_CTL_FONT_LANGUAGE )).GetLanguage();
673cdf0e10cSrcweir 		bHyphenate = ((const SfxBoolItem&)
674cdf0e10cSrcweir                         rSrcSet.Get( ATTR_HYPHENATE )).GetValue();
675cdf0e10cSrcweir 		eDirection = (SvxFrameDirection)((const SvxFrameDirectionItem&)
676cdf0e10cSrcweir                         rSrcSet.Get( ATTR_WRITINGDIR )).GetValue();
677cdf0e10cSrcweir 	}
678cdf0e10cSrcweir 
679cdf0e10cSrcweir 	// kompatibel zu LogicToLogic rechnen, also 2540/1440 = 127/72, und runden
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 	long nHeight = TwipsToHMM(nTHeight);
682cdf0e10cSrcweir 	long nCjkHeight = TwipsToHMM(nCjkTHeight);
683cdf0e10cSrcweir 	long nCtlHeight = TwipsToHMM(nCtlTHeight);
684cdf0e10cSrcweir 
685cdf0e10cSrcweir 	//	put items into EditEngine ItemSet
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 	if ( aColorItem.GetValue().GetColor() == COL_AUTO )
688cdf0e10cSrcweir 	{
689cdf0e10cSrcweir 		//	#108979# When cell attributes are converted to EditEngine paragraph attributes,
690cdf0e10cSrcweir 		//	don't create a hard item for automatic color, because that would be converted
691cdf0e10cSrcweir 		//	to black when the item's Store method is used in CreateTransferable/WriteBin.
692cdf0e10cSrcweir 		//	COL_AUTO is the EditEngine's pool default, so ClearItem will result in automatic
693cdf0e10cSrcweir 		//	color, too, without having to store the item.
694cdf0e10cSrcweir 		rEditSet.ClearItem( EE_CHAR_COLOR );
695cdf0e10cSrcweir 	}
696cdf0e10cSrcweir 	else
697cdf0e10cSrcweir 	    rEditSet.Put( aColorItem );
698cdf0e10cSrcweir     rEditSet.Put( aFontItem );
699cdf0e10cSrcweir     rEditSet.Put( aCjkFontItem );
700cdf0e10cSrcweir     rEditSet.Put( aCtlFontItem );
701cdf0e10cSrcweir     rEditSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
702cdf0e10cSrcweir     rEditSet.Put( SvxFontHeightItem( nCjkHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
703cdf0e10cSrcweir     rEditSet.Put( SvxFontHeightItem( nCtlHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
704cdf0e10cSrcweir     rEditSet.Put( SvxWeightItem ( eWeight,      EE_CHAR_WEIGHT ) );
705cdf0e10cSrcweir     rEditSet.Put( SvxWeightItem ( eCjkWeight,   EE_CHAR_WEIGHT_CJK ) );
706cdf0e10cSrcweir     rEditSet.Put( SvxWeightItem ( eCtlWeight,   EE_CHAR_WEIGHT_CTL ) );
707cdf0e10cSrcweir     rEditSet.Put( aUnderlineItem );
708cdf0e10cSrcweir     rEditSet.Put( aOverlineItem );
709cdf0e10cSrcweir     rEditSet.Put( SvxWordLineModeItem( bWordLine,   EE_CHAR_WLM ) );
710cdf0e10cSrcweir     rEditSet.Put( SvxCrossedOutItem( eStrike,       EE_CHAR_STRIKEOUT ) );
711cdf0e10cSrcweir     rEditSet.Put( SvxPostureItem    ( eItalic,      EE_CHAR_ITALIC ) );
712cdf0e10cSrcweir     rEditSet.Put( SvxPostureItem    ( eCjkItalic,   EE_CHAR_ITALIC_CJK ) );
713cdf0e10cSrcweir     rEditSet.Put( SvxPostureItem    ( eCtlItalic,   EE_CHAR_ITALIC_CTL ) );
714cdf0e10cSrcweir     rEditSet.Put( SvxContourItem    ( bOutline,     EE_CHAR_OUTLINE ) );
715cdf0e10cSrcweir     rEditSet.Put( SvxShadowedItem   ( bShadow,      EE_CHAR_SHADOW ) );
716cdf0e10cSrcweir     rEditSet.Put( SfxBoolItem       ( EE_PARA_FORBIDDENRULES, bForbidden ) );
717cdf0e10cSrcweir     rEditSet.Put( SvxEmphasisMarkItem( eEmphasis,   EE_CHAR_EMPHASISMARK ) );
718cdf0e10cSrcweir     rEditSet.Put( SvxCharReliefItem( eRelief,       EE_CHAR_RELIEF ) );
719cdf0e10cSrcweir     rEditSet.Put( SvxLanguageItem   ( eLang,        EE_CHAR_LANGUAGE ) );
720cdf0e10cSrcweir     rEditSet.Put( SvxLanguageItem   ( eCjkLang,     EE_CHAR_LANGUAGE_CJK ) );
721cdf0e10cSrcweir     rEditSet.Put( SvxLanguageItem   ( eCtlLang,     EE_CHAR_LANGUAGE_CTL ) );
722cdf0e10cSrcweir     rEditSet.Put( SfxBoolItem       ( EE_PARA_HYPHENATE, bHyphenate ) );
723cdf0e10cSrcweir     rEditSet.Put( SvxFrameDirectionItem( eDirection, EE_PARA_WRITINGDIR ) );
724cdf0e10cSrcweir 
725cdf0e10cSrcweir     // #111216# Script spacing is always off.
726cdf0e10cSrcweir     // The cell attribute isn't used here as long as there is no UI to set it
727cdf0e10cSrcweir     // (don't evaluate attributes that can't be changed).
728cdf0e10cSrcweir     // If a locale-dependent default is needed, it has to go into the cell
729cdf0e10cSrcweir     // style, like the fonts.
730cdf0e10cSrcweir     rEditSet.Put( SvxScriptSpaceItem( sal_False, EE_PARA_ASIANCJKSPACING ) );
731cdf0e10cSrcweir }
732cdf0e10cSrcweir 
FillEditItemSet(SfxItemSet * pEditSet,const SfxItemSet * pCondSet) const733cdf0e10cSrcweir void ScPatternAttr::FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet ) const
734cdf0e10cSrcweir {
735cdf0e10cSrcweir     if( pEditSet )
736cdf0e10cSrcweir         FillToEditItemSet( *pEditSet, GetItemSet(), pCondSet );
737cdf0e10cSrcweir }
738cdf0e10cSrcweir 
739cdf0e10cSrcweir 
GetFromEditItemSet(SfxItemSet & rDestSet,const SfxItemSet & rEditSet)740cdf0e10cSrcweir void ScPatternAttr::GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet& rEditSet )
741cdf0e10cSrcweir {
742cdf0e10cSrcweir 	const SfxPoolItem* pItem;
743cdf0e10cSrcweir 
744cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_COLOR,sal_True,&pItem) == SFX_ITEM_SET)
745cdf0e10cSrcweir         rDestSet.Put( SvxColorItem(ATTR_FONT_COLOR) = *(const SvxColorItem*)pItem );
746cdf0e10cSrcweir 
747cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_FONTINFO,sal_True,&pItem) == SFX_ITEM_SET)
748cdf0e10cSrcweir         rDestSet.Put( SvxFontItem(ATTR_FONT) = *(const SvxFontItem*)pItem );
749cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_FONTINFO_CJK,sal_True,&pItem) == SFX_ITEM_SET)
750cdf0e10cSrcweir         rDestSet.Put( SvxFontItem(ATTR_CJK_FONT) = *(const SvxFontItem*)pItem );
751cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_FONTINFO_CTL,sal_True,&pItem) == SFX_ITEM_SET)
752cdf0e10cSrcweir         rDestSet.Put( SvxFontItem(ATTR_CTL_FONT) = *(const SvxFontItem*)pItem );
753cdf0e10cSrcweir 
754cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT,sal_True,&pItem) == SFX_ITEM_SET)
755cdf0e10cSrcweir         rDestSet.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem*)pItem)->GetHeight() ),
756cdf0e10cSrcweir 						100, ATTR_FONT_HEIGHT ) );
757cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT_CJK,sal_True,&pItem) == SFX_ITEM_SET)
758cdf0e10cSrcweir         rDestSet.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem*)pItem)->GetHeight() ),
759cdf0e10cSrcweir 						100, ATTR_CJK_FONT_HEIGHT ) );
760cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT_CTL,sal_True,&pItem) == SFX_ITEM_SET)
761cdf0e10cSrcweir         rDestSet.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem*)pItem)->GetHeight() ),
762cdf0e10cSrcweir 						100, ATTR_CTL_FONT_HEIGHT ) );
763cdf0e10cSrcweir 
764cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_WEIGHT,sal_True,&pItem) == SFX_ITEM_SET)
765cdf0e10cSrcweir         rDestSet.Put( SvxWeightItem( (FontWeight)((const SvxWeightItem*)pItem)->GetValue(),
766cdf0e10cSrcweir 						ATTR_FONT_WEIGHT) );
767cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_WEIGHT_CJK,sal_True,&pItem) == SFX_ITEM_SET)
768cdf0e10cSrcweir         rDestSet.Put( SvxWeightItem( (FontWeight)((const SvxWeightItem*)pItem)->GetValue(),
769cdf0e10cSrcweir 						ATTR_CJK_FONT_WEIGHT) );
770cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_WEIGHT_CTL,sal_True,&pItem) == SFX_ITEM_SET)
771cdf0e10cSrcweir         rDestSet.Put( SvxWeightItem( (FontWeight)((const SvxWeightItem*)pItem)->GetValue(),
772cdf0e10cSrcweir 						ATTR_CTL_FONT_WEIGHT) );
773cdf0e10cSrcweir 
774cdf0e10cSrcweir 	// SvxTextLineItem contains enum and color
775cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_UNDERLINE,sal_True,&pItem) == SFX_ITEM_SET)
776cdf0e10cSrcweir         rDestSet.Put( SvxUnderlineItem(UNDERLINE_NONE,ATTR_FONT_UNDERLINE) = *(const SvxUnderlineItem*)pItem );
777cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_OVERLINE,sal_True,&pItem) == SFX_ITEM_SET)
778cdf0e10cSrcweir         rDestSet.Put( SvxOverlineItem(UNDERLINE_NONE,ATTR_FONT_OVERLINE) = *(const SvxOverlineItem*)pItem );
779cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_WLM,sal_True,&pItem) == SFX_ITEM_SET)
780cdf0e10cSrcweir         rDestSet.Put( SvxWordLineModeItem( ((const SvxWordLineModeItem*)pItem)->GetValue(),
781cdf0e10cSrcweir 						ATTR_FONT_WORDLINE) );
782cdf0e10cSrcweir 
783cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_STRIKEOUT,sal_True,&pItem) == SFX_ITEM_SET)
784cdf0e10cSrcweir         rDestSet.Put( SvxCrossedOutItem( (FontStrikeout)((const SvxCrossedOutItem*)pItem)->GetValue(),
785cdf0e10cSrcweir 						ATTR_FONT_CROSSEDOUT) );
786cdf0e10cSrcweir 
787cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_ITALIC,sal_True,&pItem) == SFX_ITEM_SET)
788cdf0e10cSrcweir         rDestSet.Put( SvxPostureItem( (FontItalic)((const SvxPostureItem*)pItem)->GetValue(),
789cdf0e10cSrcweir 						ATTR_FONT_POSTURE) );
790cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_ITALIC_CJK,sal_True,&pItem) == SFX_ITEM_SET)
791cdf0e10cSrcweir         rDestSet.Put( SvxPostureItem( (FontItalic)((const SvxPostureItem*)pItem)->GetValue(),
792cdf0e10cSrcweir 						ATTR_CJK_FONT_POSTURE) );
793cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_ITALIC_CTL,sal_True,&pItem) == SFX_ITEM_SET)
794cdf0e10cSrcweir         rDestSet.Put( SvxPostureItem( (FontItalic)((const SvxPostureItem*)pItem)->GetValue(),
795cdf0e10cSrcweir 						ATTR_CTL_FONT_POSTURE) );
796cdf0e10cSrcweir 
797cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_OUTLINE,sal_True,&pItem) == SFX_ITEM_SET)
798cdf0e10cSrcweir         rDestSet.Put( SvxContourItem( ((const SvxContourItem*)pItem)->GetValue(),
799cdf0e10cSrcweir 						ATTR_FONT_CONTOUR) );
800cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_SHADOW,sal_True,&pItem) == SFX_ITEM_SET)
801cdf0e10cSrcweir         rDestSet.Put( SvxShadowedItem( ((const SvxShadowedItem*)pItem)->GetValue(),
802cdf0e10cSrcweir 						ATTR_FONT_SHADOWED) );
803cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_EMPHASISMARK,sal_True,&pItem) == SFX_ITEM_SET)
804cdf0e10cSrcweir         rDestSet.Put( SvxEmphasisMarkItem( ((const SvxEmphasisMarkItem*)pItem)->GetEmphasisMark(),
805cdf0e10cSrcweir 						ATTR_FONT_EMPHASISMARK) );
806cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_RELIEF,sal_True,&pItem) == SFX_ITEM_SET)
807cdf0e10cSrcweir         rDestSet.Put( SvxCharReliefItem( (FontRelief)((const SvxCharReliefItem*)pItem)->GetValue(),
808cdf0e10cSrcweir 						ATTR_FONT_RELIEF) );
809cdf0e10cSrcweir 
810cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_LANGUAGE,sal_True,&pItem) == SFX_ITEM_SET)
811cdf0e10cSrcweir         rDestSet.Put( SvxLanguageItem(static_cast<const SvxLanguageItem*>(pItem)->GetValue(), ATTR_FONT_LANGUAGE) );
812cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_LANGUAGE_CJK,sal_True,&pItem) == SFX_ITEM_SET)
813cdf0e10cSrcweir         rDestSet.Put( SvxLanguageItem(static_cast<const SvxLanguageItem*>(pItem)->GetValue(), ATTR_CJK_FONT_LANGUAGE) );
814cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_CHAR_LANGUAGE_CTL,sal_True,&pItem) == SFX_ITEM_SET)
815cdf0e10cSrcweir         rDestSet.Put( SvxLanguageItem(static_cast<const SvxLanguageItem*>(pItem)->GetValue(), ATTR_CTL_FONT_LANGUAGE) );
816cdf0e10cSrcweir 
817cdf0e10cSrcweir     if (rEditSet.GetItemState(EE_PARA_JUST,sal_True,&pItem) == SFX_ITEM_SET)
818cdf0e10cSrcweir 	{
819cdf0e10cSrcweir 		SvxCellHorJustify eVal;
820cdf0e10cSrcweir 		switch ( ((const SvxAdjustItem*)pItem)->GetAdjust() )
821cdf0e10cSrcweir 		{
822cdf0e10cSrcweir 			case SVX_ADJUST_LEFT:
823cdf0e10cSrcweir 				// #30154# EditEngine Default ist bei dem GetAttribs() ItemSet
824cdf0e10cSrcweir 				// immer gesetzt!
825cdf0e10cSrcweir 				// ob links oder rechts entscheiden wir selbst bei Text/Zahl
826cdf0e10cSrcweir 				eVal = SVX_HOR_JUSTIFY_STANDARD;
827cdf0e10cSrcweir 				break;
828cdf0e10cSrcweir 			case SVX_ADJUST_RIGHT:
829cdf0e10cSrcweir 				eVal = SVX_HOR_JUSTIFY_RIGHT;
830cdf0e10cSrcweir 				break;
831cdf0e10cSrcweir 			case SVX_ADJUST_BLOCK:
832cdf0e10cSrcweir 				eVal = SVX_HOR_JUSTIFY_BLOCK;
833cdf0e10cSrcweir 				break;
834cdf0e10cSrcweir 			case SVX_ADJUST_CENTER:
835cdf0e10cSrcweir 				eVal = SVX_HOR_JUSTIFY_CENTER;
836cdf0e10cSrcweir 				break;
837cdf0e10cSrcweir 			case SVX_ADJUST_BLOCKLINE:
838cdf0e10cSrcweir 				eVal = SVX_HOR_JUSTIFY_BLOCK;
839cdf0e10cSrcweir 				break;
840cdf0e10cSrcweir 			case SVX_ADJUST_END:
841cdf0e10cSrcweir 				eVal = SVX_HOR_JUSTIFY_RIGHT;
842cdf0e10cSrcweir 				break;
843cdf0e10cSrcweir 			default:
844cdf0e10cSrcweir 				eVal = SVX_HOR_JUSTIFY_STANDARD;
845cdf0e10cSrcweir 		}
846cdf0e10cSrcweir 		if ( eVal != SVX_HOR_JUSTIFY_STANDARD )
847cdf0e10cSrcweir             rDestSet.Put( SvxHorJustifyItem( eVal, ATTR_HOR_JUSTIFY) );
848cdf0e10cSrcweir 	}
849cdf0e10cSrcweir }
850cdf0e10cSrcweir 
GetFromEditItemSet(const SfxItemSet * pEditSet)851cdf0e10cSrcweir void ScPatternAttr::GetFromEditItemSet( const SfxItemSet* pEditSet )
852cdf0e10cSrcweir {
853cdf0e10cSrcweir     if( pEditSet )
854cdf0e10cSrcweir         GetFromEditItemSet( GetItemSet(), *pEditSet );
855cdf0e10cSrcweir }
856cdf0e10cSrcweir 
FillEditParaItems(SfxItemSet * pEditSet) const857cdf0e10cSrcweir void ScPatternAttr::FillEditParaItems( SfxItemSet* pEditSet ) const
858cdf0e10cSrcweir {
859cdf0e10cSrcweir 	//	in GetFromEditItemSet schon dabei, in FillEditItemSet aber nicht
860cdf0e10cSrcweir 	//	Hor. Ausrichtung Standard wird immer als "links" umgesetzt
861cdf0e10cSrcweir 
862cdf0e10cSrcweir 	const SfxItemSet& rMySet = GetItemSet();
863cdf0e10cSrcweir 
864cdf0e10cSrcweir 	SvxCellHorJustify eHorJust = (SvxCellHorJustify)
865cdf0e10cSrcweir 		((const SvxHorJustifyItem&)rMySet.Get(ATTR_HOR_JUSTIFY)).GetValue();
866cdf0e10cSrcweir 
867cdf0e10cSrcweir 	SvxAdjust eSvxAdjust;
868cdf0e10cSrcweir 	switch (eHorJust)
869cdf0e10cSrcweir 	{
870cdf0e10cSrcweir 		case SVX_HOR_JUSTIFY_RIGHT:	 eSvxAdjust = SVX_ADJUST_RIGHT;	 break;
871cdf0e10cSrcweir 		case SVX_HOR_JUSTIFY_CENTER: eSvxAdjust = SVX_ADJUST_CENTER; break;
872cdf0e10cSrcweir 		case SVX_HOR_JUSTIFY_BLOCK:	 eSvxAdjust = SVX_ADJUST_BLOCK;	 break;
873cdf0e10cSrcweir 		default:					 eSvxAdjust = SVX_ADJUST_LEFT;	 break;
874cdf0e10cSrcweir 	}
875cdf0e10cSrcweir 	pEditSet->Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) );
876cdf0e10cSrcweir }
877cdf0e10cSrcweir 
DeleteUnchanged(const ScPatternAttr * pOldAttrs)878cdf0e10cSrcweir void ScPatternAttr::DeleteUnchanged( const ScPatternAttr* pOldAttrs )
879cdf0e10cSrcweir {
880cdf0e10cSrcweir 	SfxItemSet& rThisSet = GetItemSet();
881cdf0e10cSrcweir 	const SfxItemSet& rOldSet = pOldAttrs->GetItemSet();
882cdf0e10cSrcweir 
883cdf0e10cSrcweir 	const SfxPoolItem* pThisItem;
884cdf0e10cSrcweir 	const SfxPoolItem* pOldItem;
885cdf0e10cSrcweir 
886cdf0e10cSrcweir     for ( sal_uInt16 nSubWhich=ATTR_PATTERN_START; nSubWhich<=ATTR_PATTERN_END; nSubWhich++ )
887cdf0e10cSrcweir 	{
888cdf0e10cSrcweir 		//	only items that are set are interesting
889cdf0e10cSrcweir         if ( rThisSet.GetItemState( nSubWhich, sal_False, &pThisItem ) == SFX_ITEM_SET )
890cdf0e10cSrcweir         {
891cdf0e10cSrcweir             SfxItemState eOldState = rOldSet.GetItemState( nSubWhich, sal_True, &pOldItem );
892cdf0e10cSrcweir             if ( eOldState == SFX_ITEM_SET )
893cdf0e10cSrcweir 			{
894cdf0e10cSrcweir 				//	item is set in OldAttrs (or its parent) -> compare pointers
895cdf0e10cSrcweir 				if ( pThisItem == pOldItem )
896cdf0e10cSrcweir                     rThisSet.ClearItem( nSubWhich );
897cdf0e10cSrcweir 			}
898cdf0e10cSrcweir             else if ( eOldState != SFX_ITEM_DONTCARE )
899cdf0e10cSrcweir 			{
900cdf0e10cSrcweir 				//	not set in OldAttrs -> compare item value to default item
901cdf0e10cSrcweir                 if ( *pThisItem == rThisSet.GetPool()->GetDefaultItem( nSubWhich ) )
902cdf0e10cSrcweir                     rThisSet.ClearItem( nSubWhich );
903cdf0e10cSrcweir 			}
904cdf0e10cSrcweir 		}
905cdf0e10cSrcweir 	}
906cdf0e10cSrcweir }
907cdf0e10cSrcweir 
HasItemsSet(const sal_uInt16 * pWhich) const908cdf0e10cSrcweir sal_Bool ScPatternAttr::HasItemsSet( const sal_uInt16* pWhich ) const
909cdf0e10cSrcweir {
910cdf0e10cSrcweir 	const SfxItemSet& rSet = GetItemSet();
911cdf0e10cSrcweir 	for (sal_uInt16 i=0; pWhich[i]; i++)
912cdf0e10cSrcweir 		if ( rSet.GetItemState( pWhich[i], sal_False ) == SFX_ITEM_SET )
913cdf0e10cSrcweir 			return sal_True;
914cdf0e10cSrcweir 	return sal_False;
915cdf0e10cSrcweir }
916cdf0e10cSrcweir 
ClearItems(const sal_uInt16 * pWhich)917cdf0e10cSrcweir void ScPatternAttr::ClearItems( const sal_uInt16* pWhich )
918cdf0e10cSrcweir {
919cdf0e10cSrcweir 	SfxItemSet& rSet = GetItemSet();
920cdf0e10cSrcweir 	for (sal_uInt16 i=0; pWhich[i]; i++)
921cdf0e10cSrcweir 		rSet.ClearItem(pWhich[i]);
922cdf0e10cSrcweir }
923cdf0e10cSrcweir 
lcl_CopyStyleToPool(SfxStyleSheetBase * pSrcStyle,SfxStyleSheetBasePool * pSrcPool,SfxStyleSheetBasePool * pDestPool,const SvNumberFormatterIndexTable * pFormatExchangeList)924cdf0e10cSrcweir SfxStyleSheetBase* lcl_CopyStyleToPool
925cdf0e10cSrcweir 	(
926cdf0e10cSrcweir 		SfxStyleSheetBase*		pSrcStyle,
927cdf0e10cSrcweir 		SfxStyleSheetBasePool*	pSrcPool,
928cdf0e10cSrcweir         SfxStyleSheetBasePool*	pDestPool,
929cdf0e10cSrcweir         const SvNumberFormatterIndexTable*     pFormatExchangeList
930cdf0e10cSrcweir 	)
931cdf0e10cSrcweir {
932cdf0e10cSrcweir 	if ( !pSrcStyle || !pDestPool || !pSrcPool )
933cdf0e10cSrcweir 	{
934cdf0e10cSrcweir 		DBG_ERROR( "CopyStyleToPool: Invalid Arguments :-/" );
935cdf0e10cSrcweir 		return NULL;
936cdf0e10cSrcweir 	}
937cdf0e10cSrcweir 
938cdf0e10cSrcweir 	//--------------------------------------------------------
939cdf0e10cSrcweir 
940cdf0e10cSrcweir 	const String		 aStrSrcStyle = pSrcStyle->GetName();
941cdf0e10cSrcweir 	const SfxStyleFamily eFamily	  = pSrcStyle->GetFamily();
942cdf0e10cSrcweir 	SfxStyleSheetBase*	 pDestStyle   = pDestPool->Find( aStrSrcStyle, eFamily );
943cdf0e10cSrcweir 
944cdf0e10cSrcweir 	if ( !pDestStyle )
945cdf0e10cSrcweir 	{
946cdf0e10cSrcweir 		const String  aStrParent = pSrcStyle->GetParent();
947cdf0e10cSrcweir         const SfxItemSet& rSrcSet = pSrcStyle->GetItemSet();
948cdf0e10cSrcweir 
949cdf0e10cSrcweir 		pDestStyle = &pDestPool->Make( aStrSrcStyle, eFamily, SFXSTYLEBIT_USERDEF );
950cdf0e10cSrcweir         SfxItemSet& rDestSet = pDestStyle->GetItemSet();
951cdf0e10cSrcweir         rDestSet.Put( rSrcSet );
952cdf0e10cSrcweir 
953cdf0e10cSrcweir         // #b5017505# number format exchange list has to be handled here, too
954cdf0e10cSrcweir         // (only called for cell styles)
955cdf0e10cSrcweir 
956cdf0e10cSrcweir         const SfxPoolItem* pSrcItem;
957cdf0e10cSrcweir         if ( pFormatExchangeList &&
958cdf0e10cSrcweir              rSrcSet.GetItemState( ATTR_VALUE_FORMAT, sal_False, &pSrcItem ) == SFX_ITEM_SET )
959cdf0e10cSrcweir         {
960cdf0e10cSrcweir             sal_uLong nOldFormat = static_cast<const SfxUInt32Item*>(pSrcItem)->GetValue();
961cdf0e10cSrcweir             sal_uInt32* pNewFormat = static_cast<sal_uInt32*>(pFormatExchangeList->Get( nOldFormat ));
962cdf0e10cSrcweir             if (pNewFormat)
963cdf0e10cSrcweir                 rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, *pNewFormat ) );
964cdf0e10cSrcweir         }
965cdf0e10cSrcweir 
966cdf0e10cSrcweir 		// ggF. abgeleitete Styles erzeugen, wenn nicht vorhanden:
967cdf0e10cSrcweir 
968cdf0e10cSrcweir 		if ( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) != aStrParent &&
969cdf0e10cSrcweir 			 aStrSrcStyle != aStrParent &&
970cdf0e10cSrcweir 			 !pDestPool->Find( aStrParent, eFamily ) )
971cdf0e10cSrcweir 		{
972cdf0e10cSrcweir 			lcl_CopyStyleToPool( pSrcPool->Find( aStrParent, eFamily ),
973cdf0e10cSrcweir 								 pSrcPool, pDestPool, pFormatExchangeList );
974cdf0e10cSrcweir 		}
975cdf0e10cSrcweir 
976cdf0e10cSrcweir 		pDestStyle->SetParent( aStrParent );
977cdf0e10cSrcweir 	}
978cdf0e10cSrcweir 
979cdf0e10cSrcweir 	return pDestStyle;
980cdf0e10cSrcweir }
981cdf0e10cSrcweir 
PutInPool(ScDocument * pDestDoc,ScDocument * pSrcDoc) const982cdf0e10cSrcweir ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const
983cdf0e10cSrcweir {
984cdf0e10cSrcweir 	const SfxItemSet* pSrcSet = &GetItemSet();
985cdf0e10cSrcweir 
986cdf0e10cSrcweir 	ScPatternAttr* pDestPattern = new ScPatternAttr(pDestDoc->GetPool());
987cdf0e10cSrcweir 	SfxItemSet* pDestSet = &pDestPattern->GetItemSet();
988cdf0e10cSrcweir 
989cdf0e10cSrcweir 	// Zellformatvorlage in anderes Dokument kopieren:
990cdf0e10cSrcweir 
991cdf0e10cSrcweir 	if ( pDestDoc != pSrcDoc )
992cdf0e10cSrcweir 	{
993cdf0e10cSrcweir 		DBG_ASSERT( pStyle, "Missing Pattern-Style! :-/" );
994cdf0e10cSrcweir 
995cdf0e10cSrcweir 		// wenn Vorlage im DestDoc vorhanden, dieses benutzen, sonst Style
996cdf0e10cSrcweir 		// mit Parent-Vorlagen kopieren/ggF. erzeugen und dem DestDoc hinzufuegen
997cdf0e10cSrcweir 
998cdf0e10cSrcweir 		SfxStyleSheetBase* pStyleCpy = lcl_CopyStyleToPool( pStyle,
999cdf0e10cSrcweir 															pSrcDoc->GetStyleSheetPool(),
1000cdf0e10cSrcweir 															pDestDoc->GetStyleSheetPool(),
1001cdf0e10cSrcweir 															pDestDoc->GetFormatExchangeList() );
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir 		pDestPattern->SetStyleSheet( (ScStyleSheet*)pStyleCpy );
1004cdf0e10cSrcweir 	}
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir 	for ( sal_uInt16 nAttrId = ATTR_PATTERN_START; nAttrId <= ATTR_PATTERN_END; nAttrId++ )
1007cdf0e10cSrcweir 	{
1008cdf0e10cSrcweir 		const SfxPoolItem* pSrcItem;
1009cdf0e10cSrcweir 		SfxItemState eItemState = pSrcSet->GetItemState( nAttrId, sal_False, &pSrcItem );
1010cdf0e10cSrcweir 		if (eItemState==SFX_ITEM_ON)
1011cdf0e10cSrcweir 		{
1012cdf0e10cSrcweir 			SfxPoolItem* pNewItem = NULL;
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir 			if ( nAttrId == ATTR_CONDITIONAL )
1015cdf0e10cSrcweir 			{
1016cdf0e10cSrcweir 				//	Bedingte Formate ins neue Dokument kopieren
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir 				sal_uLong nNewIndex = 0;
1019cdf0e10cSrcweir 				ScConditionalFormatList* pSrcList = pSrcDoc->GetCondFormList();
1020cdf0e10cSrcweir 				if ( pSrcList )
1021cdf0e10cSrcweir 				{
1022cdf0e10cSrcweir 					sal_uLong nOldIndex = ((const SfxUInt32Item*)pSrcItem)->GetValue();
1023cdf0e10cSrcweir 					const ScConditionalFormat* pOldData = pSrcList->GetFormat( nOldIndex );
1024cdf0e10cSrcweir 					if ( pOldData )
1025cdf0e10cSrcweir 					{
1026cdf0e10cSrcweir 						nNewIndex = pDestDoc->AddCondFormat( *pOldData );
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir 						//	zugehoerige Styles auch mitkopieren
1029cdf0e10cSrcweir 						//!	nur wenn Format bei Add neu angelegt
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir 						ScStyleSheetPool* pSrcSPool = pSrcDoc->GetStyleSheetPool();
1032cdf0e10cSrcweir 						ScStyleSheetPool* pDestSPool = pDestDoc->GetStyleSheetPool();
1033cdf0e10cSrcweir                         const SvNumberFormatterIndexTable* pFormatExchangeList = pDestDoc->GetFormatExchangeList();
1034cdf0e10cSrcweir 						sal_uInt16 nStlCnt = pOldData->Count();
1035cdf0e10cSrcweir 						for (sal_uInt16 i=0; i<nStlCnt; i++)
1036cdf0e10cSrcweir 						{
1037cdf0e10cSrcweir 							String aName = pOldData->GetEntry(i)->GetStyle();
1038cdf0e10cSrcweir 							SfxStyleSheetBase* pSrcStl =
1039cdf0e10cSrcweir 								pSrcDoc->GetStyleSheetPool()->Find(aName, SFX_STYLE_FAMILY_PARA);
1040cdf0e10cSrcweir 							lcl_CopyStyleToPool( pSrcStl, pSrcSPool, pDestSPool, pFormatExchangeList );
1041cdf0e10cSrcweir 						}
1042cdf0e10cSrcweir 					}
1043cdf0e10cSrcweir 				}
1044cdf0e10cSrcweir 				pNewItem = new SfxUInt32Item( ATTR_CONDITIONAL, nNewIndex );
1045cdf0e10cSrcweir 			}
1046cdf0e10cSrcweir 			else if ( nAttrId == ATTR_VALIDDATA )
1047cdf0e10cSrcweir 			{
1048cdf0e10cSrcweir 				//	Gueltigkeit ins neue Dokument kopieren
1049cdf0e10cSrcweir 
1050cdf0e10cSrcweir 				sal_uLong nNewIndex = 0;
1051cdf0e10cSrcweir 				ScValidationDataList* pSrcList = pSrcDoc->GetValidationList();
1052cdf0e10cSrcweir 				if ( pSrcList )
1053cdf0e10cSrcweir 				{
1054cdf0e10cSrcweir 					sal_uLong nOldIndex = ((const SfxUInt32Item*)pSrcItem)->GetValue();
1055cdf0e10cSrcweir 					const ScValidationData* pOldData = pSrcList->GetData( nOldIndex );
1056cdf0e10cSrcweir 					if ( pOldData )
1057cdf0e10cSrcweir 						nNewIndex = pDestDoc->AddValidationEntry( *pOldData );
1058cdf0e10cSrcweir 				}
1059cdf0e10cSrcweir 				pNewItem = new SfxUInt32Item( ATTR_VALIDDATA, nNewIndex );
1060cdf0e10cSrcweir 			}
1061cdf0e10cSrcweir 			else if ( nAttrId == ATTR_VALUE_FORMAT && pDestDoc->GetFormatExchangeList() )
1062cdf0e10cSrcweir 			{
1063cdf0e10cSrcweir 				//	Zahlformate nach Exchange-Liste
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir 				sal_uLong nOldFormat = ((const SfxUInt32Item*)pSrcItem)->GetValue();
1066cdf0e10cSrcweir 				sal_uInt32* pNewFormat = static_cast<sal_uInt32*>(pDestDoc->GetFormatExchangeList()->Get(nOldFormat));
1067cdf0e10cSrcweir 				if (pNewFormat)
1068cdf0e10cSrcweir 					pNewItem = new SfxUInt32Item( ATTR_VALUE_FORMAT, (sal_uInt32) (*pNewFormat) );
1069cdf0e10cSrcweir 			}
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir 			if ( pNewItem )
1072cdf0e10cSrcweir 			{
1073cdf0e10cSrcweir 				pDestSet->Put(*pNewItem);
1074cdf0e10cSrcweir 				delete pNewItem;
1075cdf0e10cSrcweir 			}
1076cdf0e10cSrcweir 			else
1077cdf0e10cSrcweir 				pDestSet->Put(*pSrcItem);
1078cdf0e10cSrcweir 		}
1079cdf0e10cSrcweir 	}
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir 	ScPatternAttr* pPatternAttr =
1082cdf0e10cSrcweir 		(ScPatternAttr*) &pDestDoc->GetPool()->Put(*pDestPattern);
1083cdf0e10cSrcweir 	delete pDestPattern;
1084cdf0e10cSrcweir 	return pPatternAttr;
1085cdf0e10cSrcweir }
1086cdf0e10cSrcweir 
IsVisible() const1087cdf0e10cSrcweir sal_Bool ScPatternAttr::IsVisible() const
1088cdf0e10cSrcweir {
1089cdf0e10cSrcweir 	const SfxItemSet& rSet = GetItemSet();
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir 	const SfxPoolItem* pItem;
1092cdf0e10cSrcweir 	SfxItemState eState;
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir 	eState = rSet.GetItemState( ATTR_BACKGROUND, sal_True, &pItem );
1095cdf0e10cSrcweir 	if ( eState == SFX_ITEM_SET )
1096cdf0e10cSrcweir         if ( ((const SvxBrushItem*)pItem)->GetColor().GetColor() != COL_TRANSPARENT )
1097cdf0e10cSrcweir 			return sal_True;
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir 	eState = rSet.GetItemState( ATTR_BORDER, sal_True, &pItem );
1100cdf0e10cSrcweir 	if ( eState == SFX_ITEM_SET )
1101cdf0e10cSrcweir 	{
1102cdf0e10cSrcweir         const SvxBoxItem* pBoxItem = (SvxBoxItem*) pItem;
1103cdf0e10cSrcweir 		if ( pBoxItem->GetTop() || pBoxItem->GetBottom() ||
1104cdf0e10cSrcweir 			 pBoxItem->GetLeft() || pBoxItem->GetRight() )
1105cdf0e10cSrcweir 			return sal_True;
1106cdf0e10cSrcweir 	}
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir     eState = rSet.GetItemState( ATTR_BORDER_TLBR, sal_True, &pItem );
1109cdf0e10cSrcweir     if ( eState == SFX_ITEM_SET )
1110cdf0e10cSrcweir         if( static_cast< const SvxLineItem* >( pItem )->GetLine() )
1111cdf0e10cSrcweir             return sal_True;
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir     eState = rSet.GetItemState( ATTR_BORDER_BLTR, sal_True, &pItem );
1114cdf0e10cSrcweir     if ( eState == SFX_ITEM_SET )
1115cdf0e10cSrcweir         if( static_cast< const SvxLineItem* >( pItem )->GetLine() )
1116cdf0e10cSrcweir             return sal_True;
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir 	eState = rSet.GetItemState( ATTR_SHADOW, sal_True, &pItem );
1119cdf0e10cSrcweir 	if ( eState == SFX_ITEM_SET )
1120cdf0e10cSrcweir         if ( ((const SvxShadowItem*)pItem)->GetLocation() != SVX_SHADOW_NONE )
1121cdf0e10cSrcweir 			return sal_True;
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir 	return sal_False;
1124cdf0e10cSrcweir }
1125cdf0e10cSrcweir 
OneEqual(const SfxItemSet & rSet1,const SfxItemSet & rSet2,sal_uInt16 nId)1126cdf0e10cSrcweir inline sal_Bool OneEqual( const SfxItemSet& rSet1, const SfxItemSet& rSet2, sal_uInt16 nId )
1127cdf0e10cSrcweir {
1128cdf0e10cSrcweir 	const SfxPoolItem* pItem1 = &rSet1.Get(nId);
1129cdf0e10cSrcweir 	const SfxPoolItem* pItem2 = &rSet2.Get(nId);
1130cdf0e10cSrcweir 	return ( pItem1 == pItem2 || *pItem1 == *pItem2 );
1131cdf0e10cSrcweir }
1132cdf0e10cSrcweir 
IsVisibleEqual(const ScPatternAttr & rOther) const1133cdf0e10cSrcweir sal_Bool ScPatternAttr::IsVisibleEqual( const ScPatternAttr& rOther ) const
1134cdf0e10cSrcweir {
1135cdf0e10cSrcweir 	const SfxItemSet& rThisSet = GetItemSet();
1136cdf0e10cSrcweir 	const SfxItemSet& rOtherSet = rOther.GetItemSet();
1137cdf0e10cSrcweir 
1138cdf0e10cSrcweir 	return OneEqual( rThisSet, rOtherSet, ATTR_BACKGROUND ) &&
1139cdf0e10cSrcweir 			OneEqual( rThisSet, rOtherSet, ATTR_BORDER ) &&
1140cdf0e10cSrcweir             OneEqual( rThisSet, rOtherSet, ATTR_BORDER_TLBR ) &&
1141cdf0e10cSrcweir             OneEqual( rThisSet, rOtherSet, ATTR_BORDER_BLTR ) &&
1142cdf0e10cSrcweir 			OneEqual( rThisSet, rOtherSet, ATTR_SHADOW );
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir 	//!		auch hier nur wirklich sichtbare Werte testen !!!
1145cdf0e10cSrcweir }
1146cdf0e10cSrcweir 
IsEqual(const ScPatternAttr & rOther) const1147*6a261b58SHerbert Dürr sal_Bool ScPatternAttr::IsEqual( const ScPatternAttr& rOther ) const
1148*6a261b58SHerbert Dürr {
1149*6a261b58SHerbert Dürr 	const SfxItemSet& rThisSet = GetItemSet();
1150*6a261b58SHerbert Dürr 	const SfxItemSet& rOtherSet = rOther.GetItemSet();
1151*6a261b58SHerbert Dürr 
1152*6a261b58SHerbert Dürr 	return OneEqual( rThisSet, rOtherSet, ATTR_BACKGROUND ) &&
1153*6a261b58SHerbert Dürr 			OneEqual( rThisSet, rOtherSet, ATTR_BORDER ) &&
1154*6a261b58SHerbert Dürr 			OneEqual( rThisSet, rOtherSet, ATTR_BORDER_TLBR ) &&
1155*6a261b58SHerbert Dürr 			OneEqual( rThisSet, rOtherSet, ATTR_BORDER_BLTR ) &&
1156*6a261b58SHerbert Dürr 			OneEqual( rThisSet, rOtherSet, ATTR_VALUE_FORMAT ) &&
1157*6a261b58SHerbert Dürr 			OneEqual( rThisSet, rOtherSet, ATTR_SHADOW );
1158*6a261b58SHerbert Dürr }
1159*6a261b58SHerbert Dürr 
GetStyleName() const1160cdf0e10cSrcweir const String* ScPatternAttr::GetStyleName() const
1161cdf0e10cSrcweir {
1162cdf0e10cSrcweir 	return pName ? pName : ( pStyle ? &pStyle->GetName() : NULL );
1163cdf0e10cSrcweir }
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir 
SetStyleSheet(ScStyleSheet * pNewStyle)1166cdf0e10cSrcweir void ScPatternAttr::SetStyleSheet( ScStyleSheet* pNewStyle )
1167cdf0e10cSrcweir {
1168cdf0e10cSrcweir 	if (pNewStyle)
1169cdf0e10cSrcweir 	{
1170cdf0e10cSrcweir 		SfxItemSet&		  rPatternSet = GetItemSet();
1171cdf0e10cSrcweir 		const SfxItemSet& rStyleSet = pNewStyle->GetItemSet();
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir 		for (sal_uInt16 i=ATTR_PATTERN_START; i<=ATTR_PATTERN_END; i++)
1174cdf0e10cSrcweir 		{
1175cdf0e10cSrcweir 			if (rStyleSet.GetItemState(i, sal_True) == SFX_ITEM_SET)
1176cdf0e10cSrcweir 				rPatternSet.ClearItem(i);
1177cdf0e10cSrcweir 		}
1178cdf0e10cSrcweir 		rPatternSet.SetParent(&pNewStyle->GetItemSet());
1179cdf0e10cSrcweir 		pStyle = pNewStyle;
1180cdf0e10cSrcweir 		DELETEZ( pName );
1181cdf0e10cSrcweir 	}
1182cdf0e10cSrcweir 	else
1183cdf0e10cSrcweir 	{
1184cdf0e10cSrcweir 		DBG_ERROR( "ScPatternAttr::SetStyleSheet( NULL ) :-|" );
1185cdf0e10cSrcweir 		GetItemSet().SetParent(NULL);
1186cdf0e10cSrcweir 		pStyle = NULL;
1187cdf0e10cSrcweir 	}
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir 
UpdateStyleSheet()1190cdf0e10cSrcweir void ScPatternAttr::UpdateStyleSheet()
1191cdf0e10cSrcweir {
1192cdf0e10cSrcweir 	if (pName)
1193cdf0e10cSrcweir 	{
119449bd4d4bSArmin Le Grand 		pStyle = (ScStyleSheet*)pDoc->GetStyleSheetPool()->Find(*pName, SFX_STYLE_FAMILY_PARA);
1195cdf0e10cSrcweir 
1196cdf0e10cSrcweir 		//	wenn Style nicht gefunden, Standard nehmen,
1197cdf0e10cSrcweir 		//	damit keine leere Anzeige im Toolbox-Controller
1198cdf0e10cSrcweir 		//!	es wird vorausgesetzt, dass "Standard" immer der erste Eintrag ist!
1199cdf0e10cSrcweir 		if (!pStyle)
1200cdf0e10cSrcweir 		{
120149bd4d4bSArmin Le Grand 			SfxStyleSheetIteratorPtr pIter = pDoc->GetStyleSheetPool()->CreateIterator( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
120249bd4d4bSArmin Le Grand 			pStyle = dynamic_cast< ScStyleSheet* >(pIter->First());
1203cdf0e10cSrcweir 		}
1204cdf0e10cSrcweir 
1205cdf0e10cSrcweir 		if (pStyle)
1206cdf0e10cSrcweir 		{
1207cdf0e10cSrcweir 			GetItemSet().SetParent(&pStyle->GetItemSet());
1208cdf0e10cSrcweir 			DELETEZ( pName );
1209cdf0e10cSrcweir 		}
1210cdf0e10cSrcweir 	}
1211cdf0e10cSrcweir 	else
1212cdf0e10cSrcweir 		pStyle = NULL;
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir 
StyleToName()1215cdf0e10cSrcweir void ScPatternAttr::StyleToName()
1216cdf0e10cSrcweir {
1217cdf0e10cSrcweir 	// Style wurde geloescht, Namen merken:
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir 	if ( pStyle )
1220cdf0e10cSrcweir 	{
1221cdf0e10cSrcweir 		if ( pName )
1222cdf0e10cSrcweir 			*pName = pStyle->GetName();
1223cdf0e10cSrcweir 		else
1224cdf0e10cSrcweir 			pName = new String( pStyle->GetName() );
1225cdf0e10cSrcweir 
1226cdf0e10cSrcweir 		pStyle = NULL;
1227cdf0e10cSrcweir 		GetItemSet().SetParent( NULL );
1228cdf0e10cSrcweir 	}
1229cdf0e10cSrcweir }
1230cdf0e10cSrcweir 
IsSymbolFont() const1231cdf0e10cSrcweir sal_Bool ScPatternAttr::IsSymbolFont() const
1232cdf0e10cSrcweir {
1233cdf0e10cSrcweir 	const SfxPoolItem* pItem;
1234cdf0e10cSrcweir 	if( GetItemSet().GetItemState( ATTR_FONT, sal_True, &pItem ) == SFX_ITEM_SET )
1235cdf0e10cSrcweir 		return sal_Bool( ((const SvxFontItem*) pItem)->GetCharSet()
1236cdf0e10cSrcweir 			== RTL_TEXTENCODING_SYMBOL );
1237cdf0e10cSrcweir 	else
1238cdf0e10cSrcweir 		return sal_False;
1239cdf0e10cSrcweir }
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir //UNUSED2008-05  FontToSubsFontConverter ScPatternAttr::GetSubsFontConverter( sal_uLong nFlags ) const
1242cdf0e10cSrcweir //UNUSED2008-05  {
1243cdf0e10cSrcweir //UNUSED2008-05      const SfxPoolItem* pItem;
1244cdf0e10cSrcweir //UNUSED2008-05      if( GetItemSet().GetItemState( ATTR_FONT, sal_True, &pItem ) == SFX_ITEM_SET )
1245cdf0e10cSrcweir //UNUSED2008-05          return CreateFontToSubsFontConverter(
1246cdf0e10cSrcweir //UNUSED2008-05              ((const SvxFontItem*) pItem)->GetFamilyName(), nFlags );
1247cdf0e10cSrcweir //UNUSED2008-05      else
1248cdf0e10cSrcweir //UNUSED2008-05          return 0;
1249cdf0e10cSrcweir //UNUSED2008-05  }
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir 
GetNumberFormat(SvNumberFormatter * pFormatter) const1252cdf0e10cSrcweir sal_uLong ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter ) const
1253cdf0e10cSrcweir {
1254cdf0e10cSrcweir 	sal_uLong nFormat =
1255cdf0e10cSrcweir 		((SfxUInt32Item*)&GetItemSet().Get( ATTR_VALUE_FORMAT ))->GetValue();
1256cdf0e10cSrcweir 	LanguageType eLang =
1257cdf0e10cSrcweir 		((SvxLanguageItem*)&GetItemSet().Get( ATTR_LANGUAGE_FORMAT ))->GetLanguage();
1258cdf0e10cSrcweir 	if ( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && eLang == LANGUAGE_SYSTEM )
1259cdf0e10cSrcweir 		;		// es bleibt wie es ist
1260cdf0e10cSrcweir 	else if ( pFormatter )
1261cdf0e10cSrcweir 		nFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nFormat, eLang );
1262cdf0e10cSrcweir 	return nFormat;
1263cdf0e10cSrcweir }
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir //	dasselbe, wenn bedingte Formatierung im Spiel ist:
1266cdf0e10cSrcweir 
GetNumberFormat(SvNumberFormatter * pFormatter,const SfxItemSet * pCondSet) const1267cdf0e10cSrcweir sal_uLong ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter,
1268cdf0e10cSrcweir 										const SfxItemSet* pCondSet ) const
1269cdf0e10cSrcweir {
1270cdf0e10cSrcweir 	DBG_ASSERT(pFormatter,"GetNumberFormat ohne Formatter");
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir 	const SfxPoolItem* pFormItem;
1273cdf0e10cSrcweir 	if ( !pCondSet || pCondSet->GetItemState(ATTR_VALUE_FORMAT,sal_True,&pFormItem) != SFX_ITEM_SET )
1274cdf0e10cSrcweir 		pFormItem = &GetItemSet().Get(ATTR_VALUE_FORMAT);
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir 	const SfxPoolItem* pLangItem;
1277cdf0e10cSrcweir 	if ( !pCondSet || pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT,sal_True,&pLangItem) != SFX_ITEM_SET )
1278cdf0e10cSrcweir 		pLangItem = &GetItemSet().Get(ATTR_LANGUAGE_FORMAT);
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir 	return pFormatter->GetFormatForLanguageIfBuiltIn(
1281cdf0e10cSrcweir 					((SfxUInt32Item*)pFormItem)->GetValue(),
1282cdf0e10cSrcweir 					((SvxLanguageItem*)pLangItem)->GetLanguage() );
1283cdf0e10cSrcweir }
1284cdf0e10cSrcweir 
GetItem(sal_uInt16 nWhich,const SfxItemSet & rItemSet,const SfxItemSet * pCondSet)1285cdf0e10cSrcweir const SfxPoolItem& ScPatternAttr::GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet )
1286cdf0e10cSrcweir {
1287cdf0e10cSrcweir     const SfxPoolItem* pCondItem;
1288cdf0e10cSrcweir     if ( pCondSet && pCondSet->GetItemState( nWhich, sal_True, &pCondItem ) == SFX_ITEM_SET )
1289cdf0e10cSrcweir         return *pCondItem;
1290cdf0e10cSrcweir     return rItemSet.Get(nWhich);
1291cdf0e10cSrcweir }
1292cdf0e10cSrcweir 
GetItem(sal_uInt16 nSubWhich,const SfxItemSet * pCondSet) const1293cdf0e10cSrcweir const SfxPoolItem& ScPatternAttr::GetItem( sal_uInt16 nSubWhich, const SfxItemSet* pCondSet ) const
1294cdf0e10cSrcweir {
1295cdf0e10cSrcweir     return GetItem( nSubWhich, GetItemSet(), pCondSet );
1296cdf0e10cSrcweir }
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir //	GetRotateVal testet vorher ATTR_ORIENTATION
1299cdf0e10cSrcweir 
GetRotateVal(const SfxItemSet * pCondSet) const1300cdf0e10cSrcweir long ScPatternAttr::GetRotateVal( const SfxItemSet* pCondSet ) const
1301cdf0e10cSrcweir {
1302cdf0e10cSrcweir 	long nAttrRotate = 0;
1303cdf0e10cSrcweir     if ( GetCellOrientation() == SVX_ORIENTATION_STANDARD )
1304cdf0e10cSrcweir     {
1305cdf0e10cSrcweir         sal_Bool bRepeat = ( static_cast<const SvxHorJustifyItem&>(GetItem(ATTR_HOR_JUSTIFY, pCondSet)).
1306cdf0e10cSrcweir                             GetValue() == SVX_HOR_JUSTIFY_REPEAT );
1307cdf0e10cSrcweir         // ignore orientation/rotation if "repeat" is active
1308cdf0e10cSrcweir         if ( !bRepeat )
1309cdf0e10cSrcweir             nAttrRotate = ((const SfxInt32Item&)GetItem( ATTR_ROTATE_VALUE, pCondSet )).GetValue();
1310cdf0e10cSrcweir     }
1311cdf0e10cSrcweir 	return nAttrRotate;
1312cdf0e10cSrcweir }
1313cdf0e10cSrcweir 
GetRotateDir(const SfxItemSet * pCondSet) const1314cdf0e10cSrcweir sal_uInt8 ScPatternAttr::GetRotateDir( const SfxItemSet* pCondSet ) const
1315cdf0e10cSrcweir {
1316cdf0e10cSrcweir 	sal_uInt8 nRet = SC_ROTDIR_NONE;
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir 	long nAttrRotate = GetRotateVal( pCondSet );
1319cdf0e10cSrcweir 	if ( nAttrRotate )
1320cdf0e10cSrcweir 	{
1321cdf0e10cSrcweir 		SvxRotateMode eRotMode = (SvxRotateMode)((const SvxRotateModeItem&)
1322cdf0e10cSrcweir 									GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue();
1323cdf0e10cSrcweir 
1324cdf0e10cSrcweir 		if ( eRotMode == SVX_ROTATE_MODE_STANDARD || nAttrRotate == 18000 )
1325cdf0e10cSrcweir 			nRet = SC_ROTDIR_STANDARD;
1326cdf0e10cSrcweir 		else if ( eRotMode == SVX_ROTATE_MODE_CENTER )
1327cdf0e10cSrcweir 			nRet = SC_ROTDIR_CENTER;
1328cdf0e10cSrcweir 		else if ( eRotMode == SVX_ROTATE_MODE_TOP || eRotMode == SVX_ROTATE_MODE_BOTTOM )
1329cdf0e10cSrcweir 		{
1330cdf0e10cSrcweir 			long nRot180 = nAttrRotate % 18000;		// 1/100 Grad
1331cdf0e10cSrcweir 			if ( nRot180 == 9000 )
1332cdf0e10cSrcweir 				nRet = SC_ROTDIR_CENTER;
1333cdf0e10cSrcweir 			else if ( ( eRotMode == SVX_ROTATE_MODE_TOP && nRot180 < 9000 ) ||
1334cdf0e10cSrcweir 					  ( eRotMode == SVX_ROTATE_MODE_BOTTOM && nRot180 > 9000 ) )
1335cdf0e10cSrcweir 				nRet = SC_ROTDIR_LEFT;
1336cdf0e10cSrcweir 			else
1337cdf0e10cSrcweir 				nRet = SC_ROTDIR_RIGHT;
1338cdf0e10cSrcweir 		}
1339cdf0e10cSrcweir 	}
1340cdf0e10cSrcweir 
1341cdf0e10cSrcweir 	return nRet;
1342cdf0e10cSrcweir }
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir 
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir 
1347