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