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