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/adjustitem.hxx>
22 : #include <svx/algitem.hxx>
23 : #include <editeng/boxitem.hxx>
24 : #include <editeng/lineitem.hxx>
25 : #include <editeng/brushitem.hxx>
26 : #include <editeng/charreliefitem.hxx>
27 : #include <editeng/contouritem.hxx>
28 : #include <svtools/colorcfg.hxx>
29 : #include <editeng/colritem.hxx>
30 : #include <editeng/crossedoutitem.hxx>
31 : #include <editeng/emphasismarkitem.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 610 : ScPatternAttr::ScPatternAttr( SfxItemSet* pItemSet, const OUString& rStyleName )
76 : : SfxSetItem ( ATTR_PATTERN, pItemSet ),
77 610 : pName ( new OUString( rStyleName ) ),
78 1220 : pStyle ( NULL )
79 : {
80 610 : }
81 :
82 49103 : ScPatternAttr::ScPatternAttr( SfxItemSet* pItemSet, ScStyleSheet* pStyleSheet )
83 : : SfxSetItem ( ATTR_PATTERN, pItemSet ),
84 : pName ( NULL ),
85 49103 : pStyle ( pStyleSheet )
86 : {
87 49103 : if ( pStyleSheet )
88 0 : GetItemSet().SetParent( &pStyleSheet->GetItemSet() );
89 49103 : }
90 :
91 2397 : ScPatternAttr::ScPatternAttr( SfxItemPool* pItemPool )
92 2397 : : SfxSetItem ( ATTR_PATTERN, new SfxItemSet( *pItemPool, ATTR_PATTERN_START, ATTR_PATTERN_END ) ),
93 : pName ( NULL ),
94 4794 : pStyle ( NULL )
95 : {
96 2397 : }
97 :
98 101324 : ScPatternAttr::ScPatternAttr( const ScPatternAttr& rPatternAttr )
99 : : SfxSetItem ( rPatternAttr ),
100 101324 : pStyle ( rPatternAttr.pStyle )
101 : {
102 101324 : if (rPatternAttr.pName)
103 646 : pName = new OUString(*rPatternAttr.pName);
104 : else
105 100678 : pName = NULL;
106 101324 : }
107 :
108 450909 : ScPatternAttr::~ScPatternAttr()
109 : {
110 152884 : delete pName;
111 298025 : }
112 :
113 38697 : SfxPoolItem* ScPatternAttr::Clone( SfxItemPool *pPool ) const
114 : {
115 38697 : ScPatternAttr* pPattern = new ScPatternAttr( GetItemSet().Clone(true, pPool) );
116 :
117 38697 : pPattern->pStyle = pStyle;
118 38697 : pPattern->pName = pName ? new OUString(*pName) : NULL;
119 :
120 38697 : return pPattern;
121 : }
122 :
123 232327 : inline int StrCmp( const OUString* pStr1, const OUString* pStr2 )
124 : {
125 232327 : return ( pStr1 ? ( pStr2 ? ( *pStr1 == *pStr2 ) : false ) : ( pStr2 ? false : true ) );
126 : }
127 :
128 7973725 : 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 7973725 : if ( rSet1.Count() != rSet2.Count() )
135 6580185 : return false;
136 :
137 1393540 : SfxItemArray pItems1 = rSet1.GetItems_Impl(); // inline method of SfxItemSet
138 1393540 : SfxItemArray pItems2 = rSet2.GetItems_Impl();
139 :
140 1393540 : return ( 0 == memcmp( pItems1, pItems2, (ATTR_PATTERN_END - ATTR_PATTERN_START + 1) * sizeof(pItems1[0]) ) );
141 : }
142 :
143 7973725 : int ScPatternAttr::operator==( const SfxPoolItem& rCmp ) const
144 : {
145 : // #i62090# Use quick comparison between ScPatternAttr's ItemSets
146 :
147 8206052 : return ( EqualPatternSets( GetItemSet(), static_cast<const ScPatternAttr&>(rCmp).GetItemSet() ) &&
148 8206052 : StrCmp( GetStyleName(), static_cast<const ScPatternAttr&>(rCmp).GetStyleName() ) );
149 : }
150 :
151 0 : SfxPoolItem* ScPatternAttr::Create( SvStream& rStream, sal_uInt16 /* nVersion */ ) const
152 : {
153 : OUString* pStr;
154 : sal_Bool bHasStyle;
155 :
156 0 : rStream >> bHasStyle;
157 :
158 0 : if ( bHasStyle )
159 : {
160 : short eFamDummy;
161 0 : pStr = new OUString;
162 0 : *pStr = rStream.ReadUniOrByteString( rStream.GetStreamCharSet() );
163 0 : rStream >> eFamDummy; // wg. altem Dateiformat
164 : }
165 : else
166 0 : pStr = new OUString( 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 1254619 : SvxCellOrientation ScPatternAttr::GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet )
199 : {
200 1254619 : SvxCellOrientation eOrient = SVX_ORIENTATION_STANDARD;
201 :
202 1254619 : if( ((const SfxBoolItem&)GetItem( ATTR_STACKED, rItemSet, pCondSet )).GetValue() )
203 : {
204 96205 : eOrient = SVX_ORIENTATION_STACKED;
205 : }
206 : else
207 : {
208 1158414 : sal_Int32 nAngle = ((const SfxInt32Item&)GetItem( ATTR_ROTATE_VALUE, rItemSet, pCondSet )).GetValue();
209 1158414 : if( nAngle == 9000 )
210 2 : eOrient = SVX_ORIENTATION_BOTTOMTOP;
211 1158412 : else if( nAngle == 27000 )
212 972 : eOrient = SVX_ORIENTATION_TOPBOTTOM;
213 : }
214 :
215 1254619 : return eOrient;
216 : }
217 :
218 1254619 : SvxCellOrientation ScPatternAttr::GetCellOrientation( const SfxItemSet* pCondSet ) const
219 : {
220 1254619 : return GetCellOrientation( GetItemSet(), pCondSet );
221 : }
222 :
223 5014 : 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 5014 : Color aColor;
244 : LanguageType eLang;
245 :
246 : sal_uInt16 nFontId, nHeightId, nWeightId, nPostureId, nLangId;
247 5014 : if ( nScript == SCRIPTTYPE_ASIAN )
248 : {
249 2 : nFontId = ATTR_CJK_FONT;
250 2 : nHeightId = ATTR_CJK_FONT_HEIGHT;
251 2 : nWeightId = ATTR_CJK_FONT_WEIGHT;
252 2 : nPostureId = ATTR_CJK_FONT_POSTURE;
253 2 : nLangId = ATTR_CJK_FONT_LANGUAGE;
254 : }
255 5012 : 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 5012 : nFontId = ATTR_FONT;
266 5012 : nHeightId = ATTR_FONT_HEIGHT;
267 5012 : nWeightId = ATTR_FONT_WEIGHT;
268 5012 : nPostureId = ATTR_FONT_POSTURE;
269 5012 : nLangId = ATTR_FONT_LANGUAGE;
270 : }
271 :
272 5014 : if ( pCondSet )
273 : {
274 : const SfxPoolItem* pItem;
275 :
276 2 : if ( pCondSet->GetItemState( nFontId, true, &pItem ) != SFX_ITEM_SET )
277 2 : pItem = &rItemSet.Get( nFontId );
278 2 : pFontAttr = (const SvxFontItem*) pItem;
279 :
280 2 : if ( pCondSet->GetItemState( nHeightId, true, &pItem ) != SFX_ITEM_SET )
281 2 : pItem = &rItemSet.Get( nHeightId );
282 2 : nFontHeight = ((const SvxFontHeightItem*)pItem)->GetHeight();
283 :
284 2 : if ( pCondSet->GetItemState( nWeightId, true, &pItem ) != SFX_ITEM_SET )
285 0 : pItem = &rItemSet.Get( nWeightId );
286 2 : eWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue();
287 :
288 2 : if ( pCondSet->GetItemState( nPostureId, true, &pItem ) != SFX_ITEM_SET )
289 0 : pItem = &rItemSet.Get( nPostureId );
290 2 : eItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue();
291 :
292 2 : if ( pCondSet->GetItemState( ATTR_FONT_UNDERLINE, true, &pItem ) != SFX_ITEM_SET )
293 0 : pItem = &rItemSet.Get( ATTR_FONT_UNDERLINE );
294 2 : eUnder = (FontUnderline)((const SvxUnderlineItem*)pItem)->GetValue();
295 :
296 2 : if ( pCondSet->GetItemState( ATTR_FONT_OVERLINE, true, &pItem ) != SFX_ITEM_SET )
297 2 : pItem = &rItemSet.Get( ATTR_FONT_OVERLINE );
298 2 : eOver = (FontUnderline)((const SvxOverlineItem*)pItem)->GetValue();
299 :
300 2 : if ( pCondSet->GetItemState( ATTR_FONT_WORDLINE, true, &pItem ) != SFX_ITEM_SET )
301 2 : pItem = &rItemSet.Get( ATTR_FONT_WORDLINE );
302 2 : bWordLine = ((const SvxWordLineModeItem*)pItem)->GetValue();
303 :
304 2 : if ( pCondSet->GetItemState( ATTR_FONT_CROSSEDOUT, true, &pItem ) != SFX_ITEM_SET )
305 2 : pItem = &rItemSet.Get( ATTR_FONT_CROSSEDOUT );
306 2 : eStrike = (FontStrikeout)((const SvxCrossedOutItem*)pItem)->GetValue();
307 :
308 2 : if ( pCondSet->GetItemState( ATTR_FONT_CONTOUR, true, &pItem ) != SFX_ITEM_SET )
309 2 : pItem = &rItemSet.Get( ATTR_FONT_CONTOUR );
310 2 : bOutline = ((const SvxContourItem*)pItem)->GetValue();
311 :
312 2 : if ( pCondSet->GetItemState( ATTR_FONT_SHADOWED, true, &pItem ) != SFX_ITEM_SET )
313 2 : pItem = &rItemSet.Get( ATTR_FONT_SHADOWED );
314 2 : bShadow = ((const SvxShadowedItem*)pItem)->GetValue();
315 :
316 2 : if ( pCondSet->GetItemState( ATTR_FONT_EMPHASISMARK, true, &pItem ) != SFX_ITEM_SET )
317 2 : pItem = &rItemSet.Get( ATTR_FONT_EMPHASISMARK );
318 2 : eEmphasis = ((const SvxEmphasisMarkItem*)pItem)->GetEmphasisMark();
319 :
320 2 : if ( pCondSet->GetItemState( ATTR_FONT_RELIEF, true, &pItem ) != SFX_ITEM_SET )
321 2 : pItem = &rItemSet.Get( ATTR_FONT_RELIEF );
322 2 : eRelief = (FontRelief)((const SvxCharReliefItem*)pItem)->GetValue();
323 :
324 2 : if ( pCondSet->GetItemState( ATTR_FONT_COLOR, true, &pItem ) != SFX_ITEM_SET )
325 2 : pItem = &rItemSet.Get( ATTR_FONT_COLOR );
326 2 : aColor = ((const SvxColorItem*)pItem)->GetValue();
327 :
328 2 : if ( pCondSet->GetItemState( nLangId, true, &pItem ) != SFX_ITEM_SET )
329 2 : pItem = &rItemSet.Get( nLangId );
330 2 : eLang = ((const SvxLanguageItem*)pItem)->GetLanguage();
331 : }
332 : else // alles aus rItemSet
333 : {
334 5012 : pFontAttr = &(const SvxFontItem&)rItemSet.Get( nFontId );
335 : nFontHeight = ((const SvxFontHeightItem&)
336 5012 : rItemSet.Get( nHeightId )).GetHeight();
337 : eWeight = (FontWeight)((const SvxWeightItem&)
338 5012 : rItemSet.Get( nWeightId )).GetValue();
339 : eItalic = (FontItalic)((const SvxPostureItem&)
340 5012 : rItemSet.Get( nPostureId )).GetValue();
341 : eUnder = (FontUnderline)((const SvxUnderlineItem&)
342 5012 : rItemSet.Get( ATTR_FONT_UNDERLINE )).GetValue();
343 : eOver = (FontUnderline)((const SvxOverlineItem&)
344 5012 : rItemSet.Get( ATTR_FONT_OVERLINE )).GetValue();
345 : bWordLine = ((const SvxWordLineModeItem&)
346 5012 : rItemSet.Get( ATTR_FONT_WORDLINE )).GetValue();
347 : eStrike = (FontStrikeout)((const SvxCrossedOutItem&)
348 5012 : rItemSet.Get( ATTR_FONT_CROSSEDOUT )).GetValue();
349 : bOutline = ((const SvxContourItem&)
350 5012 : rItemSet.Get( ATTR_FONT_CONTOUR )).GetValue();
351 : bShadow = ((const SvxShadowedItem&)
352 5012 : rItemSet.Get( ATTR_FONT_SHADOWED )).GetValue();
353 : eEmphasis = ((const SvxEmphasisMarkItem&)
354 5012 : rItemSet.Get( ATTR_FONT_EMPHASISMARK )).GetEmphasisMark();
355 : eRelief = (FontRelief)((const SvxCharReliefItem&)
356 5012 : rItemSet.Get( ATTR_FONT_RELIEF )).GetValue();
357 : aColor = ((const SvxColorItem&)
358 5012 : rItemSet.Get( ATTR_FONT_COLOR )).GetValue();
359 : // for graphite language features
360 : eLang =
361 5012 : ((const SvxLanguageItem&)rItemSet.Get( nLangId )).GetLanguage();
362 : }
363 : OSL_ENSURE(pFontAttr,"Oops?");
364 :
365 : // auswerten
366 :
367 : // FontItem:
368 :
369 5014 : if (rFont.GetName() != pFontAttr->GetFamilyName())
370 3163 : rFont.SetName( pFontAttr->GetFamilyName() );
371 5014 : if (rFont.GetStyleName() != pFontAttr->GetStyleName())
372 1366 : rFont.SetStyleName( pFontAttr->GetStyleName() );
373 :
374 5014 : rFont.SetFamily( pFontAttr->GetFamily() );
375 5014 : rFont.SetCharSet( pFontAttr->GetCharSet() );
376 5014 : rFont.SetPitch( pFontAttr->GetPitch() );
377 :
378 5014 : rFont.SetLanguage(eLang);
379 :
380 : // Groesse
381 :
382 5014 : if ( pOutDev != NULL )
383 : {
384 4927 : Size aEffSize;
385 4927 : Fraction aFraction( 1,1 );
386 4927 : if (pScale)
387 3639 : aFraction = *pScale;
388 4927 : Size aSize( 0, (long) nFontHeight );
389 4927 : MapMode aDestMode = pOutDev->GetMapMode();
390 9854 : MapMode aSrcMode( MAP_TWIP, Point(), aFraction, aFraction );
391 4927 : if (aDestMode.GetMapUnit() == MAP_PIXEL)
392 4855 : aEffSize = pOutDev->LogicToPixel( aSize, aSrcMode );
393 : else
394 : {
395 72 : Fraction aFractOne(1,1);
396 72 : aDestMode.SetScaleX( aFractOne );
397 72 : aDestMode.SetScaleY( aFractOne );
398 72 : aEffSize = OutputDevice::LogicToLogic( aSize, aSrcMode, aDestMode );
399 : }
400 9854 : rFont.SetSize( aEffSize );
401 : }
402 : else /* if pOutDev != NULL */
403 : {
404 87 : rFont.SetSize( Size( 0, (long) nFontHeight ) );
405 : }
406 :
407 : // determine effective font color
408 :
409 12988 : if ( ( aColor.GetColor() == COL_AUTO && eAutoMode != SC_AUTOCOL_RAW ) ||
410 7116 : eAutoMode == SC_AUTOCOL_IGNOREFONT || eAutoMode == SC_AUTOCOL_IGNOREALL )
411 : {
412 2912 : if ( eAutoMode == SC_AUTOCOL_BLACK )
413 1453 : aColor.SetColor( COL_BLACK );
414 : else
415 : {
416 : // get background color from conditional or own set
417 1459 : Color aBackColor;
418 1459 : if ( pCondSet )
419 : {
420 : const SfxPoolItem* pItem;
421 2 : if ( pCondSet->GetItemState( ATTR_BACKGROUND, true, &pItem ) != SFX_ITEM_SET )
422 2 : pItem = &rItemSet.Get( ATTR_BACKGROUND );
423 2 : aBackColor = ((const SvxBrushItem*)pItem)->GetColor();
424 : }
425 : else
426 1457 : aBackColor = ((const SvxBrushItem&)rItemSet.Get( ATTR_BACKGROUND )).GetColor();
427 :
428 : // if background color attribute is transparent, use window color for brightness comparisons
429 4377 : if ( aBackColor == COL_TRANSPARENT ||
430 4377 : eAutoMode == SC_AUTOCOL_IGNOREBACK || eAutoMode == SC_AUTOCOL_IGNOREALL )
431 : {
432 1459 : if ( eAutoMode == SC_AUTOCOL_PRINT )
433 1 : aBackColor.SetColor( COL_WHITE );
434 1458 : else if ( pBackConfigColor )
435 : {
436 : // pBackConfigColor can be used to avoid repeated lookup of the configured color
437 1450 : aBackColor = *pBackConfigColor;
438 : }
439 : else
440 8 : aBackColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
441 : }
442 :
443 : // get system text color for comparison
444 1459 : Color aSysTextColor;
445 1459 : if ( eAutoMode == SC_AUTOCOL_PRINT )
446 1 : aSysTextColor.SetColor( COL_BLACK );
447 1458 : else if ( pTextConfigColor )
448 : {
449 : // pTextConfigColor can be used to avoid repeated lookup of the configured color
450 1450 : aSysTextColor = *pTextConfigColor;
451 : }
452 : else
453 8 : aSysTextColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
454 :
455 : // select the resulting color
456 1459 : if ( aBackColor.IsDark() && aSysTextColor.IsDark() )
457 : {
458 : // use white instead of dark on dark
459 0 : aColor.SetColor( COL_WHITE );
460 : }
461 1459 : 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 1459 : aColor = aSysTextColor;
470 : }
471 : }
472 : }
473 :
474 : // set font effects
475 5014 : rFont.SetWeight( eWeight );
476 5014 : rFont.SetItalic( eItalic );
477 5014 : rFont.SetUnderline( eUnder );
478 5014 : rFont.SetOverline( eOver );
479 5014 : rFont.SetWordLineMode( bWordLine );
480 5014 : rFont.SetStrikeout( eStrike );
481 5014 : rFont.SetOutline( bOutline );
482 5014 : rFont.SetShadow( bShadow );
483 5014 : rFont.SetEmphasisMark( eEmphasis );
484 5014 : rFont.SetRelief( eRelief );
485 5014 : rFont.SetColor( aColor );
486 5014 : rFont.SetTransparent( true );
487 5014 : }
488 :
489 4935 : 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 4935 : GetFont( rFont, GetItemSet(), eAutoMode, pOutDev, pScale, pCondSet, nScript, pBackConfigColor, pTextConfigColor );
496 4935 : }
497 :
498 :
499 6467 : void ScPatternAttr::FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet )
500 : {
501 : // Items auslesen
502 :
503 6467 : SvxColorItem aColorItem(EE_CHAR_COLOR); // use item as-is
504 12934 : SvxFontItem aFontItem(EE_CHAR_FONTINFO); // use item as-is
505 12934 : SvxFontItem aCjkFontItem(EE_CHAR_FONTINFO_CJK);
506 12934 : SvxFontItem aCtlFontItem(EE_CHAR_FONTINFO_CTL);
507 : long nTHeight, nCjkTHeight, nCtlTHeight; // Twips
508 : FontWeight eWeight, eCjkWeight, eCtlWeight;
509 12934 : SvxUnderlineItem aUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE);
510 12934 : 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 6467 : 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 6467 : aColorItem = (const SvxColorItem&) rSrcSet.Get( ATTR_FONT_COLOR );
629 6467 : aFontItem = (const SvxFontItem&) rSrcSet.Get( ATTR_FONT );
630 6467 : aCjkFontItem = (const SvxFontItem&) rSrcSet.Get( ATTR_CJK_FONT );
631 6467 : aCtlFontItem = (const SvxFontItem&) rSrcSet.Get( ATTR_CTL_FONT );
632 : nTHeight = ((const SvxFontHeightItem&)
633 6467 : rSrcSet.Get( ATTR_FONT_HEIGHT )).GetHeight();
634 : nCjkTHeight = ((const SvxFontHeightItem&)
635 6467 : rSrcSet.Get( ATTR_CJK_FONT_HEIGHT )).GetHeight();
636 : nCtlTHeight = ((const SvxFontHeightItem&)
637 6467 : rSrcSet.Get( ATTR_CTL_FONT_HEIGHT )).GetHeight();
638 : eWeight = (FontWeight)((const SvxWeightItem&)
639 6467 : rSrcSet.Get( ATTR_FONT_WEIGHT )).GetValue();
640 : eCjkWeight = (FontWeight)((const SvxWeightItem&)
641 6467 : rSrcSet.Get( ATTR_CJK_FONT_WEIGHT )).GetValue();
642 : eCtlWeight = (FontWeight)((const SvxWeightItem&)
643 6467 : rSrcSet.Get( ATTR_CTL_FONT_WEIGHT )).GetValue();
644 : eItalic = (FontItalic)((const SvxPostureItem&)
645 6467 : rSrcSet.Get( ATTR_FONT_POSTURE )).GetValue();
646 : eCjkItalic = (FontItalic)((const SvxPostureItem&)
647 6467 : rSrcSet.Get( ATTR_CJK_FONT_POSTURE )).GetValue();
648 : eCtlItalic = (FontItalic)((const SvxPostureItem&)
649 6467 : rSrcSet.Get( ATTR_CTL_FONT_POSTURE )).GetValue();
650 6467 : aUnderlineItem = (const SvxUnderlineItem&) rSrcSet.Get( ATTR_FONT_UNDERLINE );
651 6467 : aOverlineItem = (const SvxOverlineItem&) rSrcSet.Get( ATTR_FONT_OVERLINE );
652 : bWordLine = ((const SvxWordLineModeItem&)
653 6467 : rSrcSet.Get( ATTR_FONT_WORDLINE )).GetValue();
654 : eStrike = (FontStrikeout)((const SvxCrossedOutItem&)
655 6467 : rSrcSet.Get( ATTR_FONT_CROSSEDOUT )).GetValue();
656 : bOutline = ((const SvxContourItem&)
657 6467 : rSrcSet.Get( ATTR_FONT_CONTOUR )).GetValue();
658 : bShadow = ((const SvxShadowedItem&)
659 6467 : rSrcSet.Get( ATTR_FONT_SHADOWED )).GetValue();
660 : bForbidden = ((const SvxForbiddenRuleItem&)
661 6467 : rSrcSet.Get( ATTR_FORBIDDEN_RULES )).GetValue();
662 : eEmphasis = ((const SvxEmphasisMarkItem&)
663 6467 : rSrcSet.Get( ATTR_FONT_EMPHASISMARK )).GetEmphasisMark();
664 : eRelief = (FontRelief)((const SvxCharReliefItem&)
665 6467 : rSrcSet.Get( ATTR_FONT_RELIEF )).GetValue();
666 : eLang = ((const SvxLanguageItem&)
667 6467 : rSrcSet.Get( ATTR_FONT_LANGUAGE )).GetLanguage();
668 : eCjkLang = ((const SvxLanguageItem&)
669 6467 : rSrcSet.Get( ATTR_CJK_FONT_LANGUAGE )).GetLanguage();
670 : eCtlLang = ((const SvxLanguageItem&)
671 6467 : rSrcSet.Get( ATTR_CTL_FONT_LANGUAGE )).GetLanguage();
672 : bHyphenate = ((const SfxBoolItem&)
673 6467 : rSrcSet.Get( ATTR_HYPHENATE )).GetValue();
674 : eDirection = (SvxFrameDirection)((const SvxFrameDirectionItem&)
675 6467 : rSrcSet.Get( ATTR_WRITINGDIR )).GetValue();
676 : }
677 :
678 : // kompatibel zu LogicToLogic rechnen, also 2540/1440 = 127/72, und runden
679 :
680 6467 : long nHeight = TwipsToHMM(nTHeight);
681 6467 : long nCjkHeight = TwipsToHMM(nCjkTHeight);
682 6467 : long nCtlHeight = TwipsToHMM(nCtlTHeight);
683 :
684 : // put items into EditEngine ItemSet
685 :
686 6467 : 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 4929 : rEditSet.ClearItem( EE_CHAR_COLOR );
694 : }
695 : else
696 1538 : rEditSet.Put( aColorItem );
697 6467 : rEditSet.Put( aFontItem );
698 6467 : rEditSet.Put( aCjkFontItem );
699 6467 : rEditSet.Put( aCtlFontItem );
700 6467 : rEditSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
701 6467 : rEditSet.Put( SvxFontHeightItem( nCjkHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
702 6467 : rEditSet.Put( SvxFontHeightItem( nCtlHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
703 6467 : rEditSet.Put( SvxWeightItem ( eWeight, EE_CHAR_WEIGHT ) );
704 6467 : rEditSet.Put( SvxWeightItem ( eCjkWeight, EE_CHAR_WEIGHT_CJK ) );
705 6467 : rEditSet.Put( SvxWeightItem ( eCtlWeight, EE_CHAR_WEIGHT_CTL ) );
706 6467 : rEditSet.Put( aUnderlineItem );
707 6467 : rEditSet.Put( aOverlineItem );
708 6467 : rEditSet.Put( SvxWordLineModeItem( bWordLine, EE_CHAR_WLM ) );
709 6467 : rEditSet.Put( SvxCrossedOutItem( eStrike, EE_CHAR_STRIKEOUT ) );
710 6467 : rEditSet.Put( SvxPostureItem ( eItalic, EE_CHAR_ITALIC ) );
711 6467 : rEditSet.Put( SvxPostureItem ( eCjkItalic, EE_CHAR_ITALIC_CJK ) );
712 6467 : rEditSet.Put( SvxPostureItem ( eCtlItalic, EE_CHAR_ITALIC_CTL ) );
713 6467 : rEditSet.Put( SvxContourItem ( bOutline, EE_CHAR_OUTLINE ) );
714 6467 : rEditSet.Put( SvxShadowedItem ( bShadow, EE_CHAR_SHADOW ) );
715 6467 : rEditSet.Put( SfxBoolItem ( EE_PARA_FORBIDDENRULES, bForbidden ) );
716 6467 : rEditSet.Put( SvxEmphasisMarkItem( eEmphasis, EE_CHAR_EMPHASISMARK ) );
717 6467 : rEditSet.Put( SvxCharReliefItem( eRelief, EE_CHAR_RELIEF ) );
718 6467 : rEditSet.Put( SvxLanguageItem ( eLang, EE_CHAR_LANGUAGE ) );
719 6467 : rEditSet.Put( SvxLanguageItem ( eCjkLang, EE_CHAR_LANGUAGE_CJK ) );
720 6467 : rEditSet.Put( SvxLanguageItem ( eCtlLang, EE_CHAR_LANGUAGE_CTL ) );
721 6467 : rEditSet.Put( SfxBoolItem ( EE_PARA_HYPHENATE, bHyphenate ) );
722 6467 : 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 12934 : rEditSet.Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) );
730 6467 : }
731 :
732 6412 : void ScPatternAttr::FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet ) const
733 : {
734 6412 : if( pEditSet )
735 6412 : FillToEditItemSet( *pEditSet, GetItemSet(), pCondSet );
736 6412 : }
737 :
738 :
739 192 : void ScPatternAttr::GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet& rEditSet )
740 : {
741 : const SfxPoolItem* pItem;
742 :
743 192 : if (rEditSet.GetItemState(EE_CHAR_COLOR,true,&pItem) == SFX_ITEM_SET)
744 166 : rDestSet.Put( SvxColorItem(ATTR_FONT_COLOR) = *(const SvxColorItem*)pItem );
745 :
746 192 : if (rEditSet.GetItemState(EE_CHAR_FONTINFO,true,&pItem) == SFX_ITEM_SET)
747 171 : rDestSet.Put( SvxFontItem(ATTR_FONT) = *(const SvxFontItem*)pItem );
748 192 : if (rEditSet.GetItemState(EE_CHAR_FONTINFO_CJK,true,&pItem) == SFX_ITEM_SET)
749 155 : rDestSet.Put( SvxFontItem(ATTR_CJK_FONT) = *(const SvxFontItem*)pItem );
750 192 : if (rEditSet.GetItemState(EE_CHAR_FONTINFO_CTL,true,&pItem) == SFX_ITEM_SET)
751 149 : rDestSet.Put( SvxFontItem(ATTR_CTL_FONT) = *(const SvxFontItem*)pItem );
752 :
753 192 : if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT,true,&pItem) == SFX_ITEM_SET)
754 164 : rDestSet.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem*)pItem)->GetHeight() ),
755 164 : 100, ATTR_FONT_HEIGHT ) );
756 192 : if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT_CJK,true,&pItem) == SFX_ITEM_SET)
757 155 : rDestSet.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem*)pItem)->GetHeight() ),
758 155 : 100, ATTR_CJK_FONT_HEIGHT ) );
759 192 : if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT_CTL,true,&pItem) == SFX_ITEM_SET)
760 102 : rDestSet.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem*)pItem)->GetHeight() ),
761 102 : 100, ATTR_CTL_FONT_HEIGHT ) );
762 :
763 192 : if (rEditSet.GetItemState(EE_CHAR_WEIGHT,true,&pItem) == SFX_ITEM_SET)
764 162 : rDestSet.Put( SvxWeightItem( (FontWeight)((const SvxWeightItem*)pItem)->GetValue(),
765 162 : ATTR_FONT_WEIGHT) );
766 192 : if (rEditSet.GetItemState(EE_CHAR_WEIGHT_CJK,true,&pItem) == SFX_ITEM_SET)
767 133 : rDestSet.Put( SvxWeightItem( (FontWeight)((const SvxWeightItem*)pItem)->GetValue(),
768 133 : ATTR_CJK_FONT_WEIGHT) );
769 192 : if (rEditSet.GetItemState(EE_CHAR_WEIGHT_CTL,true,&pItem) == SFX_ITEM_SET)
770 122 : rDestSet.Put( SvxWeightItem( (FontWeight)((const SvxWeightItem*)pItem)->GetValue(),
771 122 : ATTR_CTL_FONT_WEIGHT) );
772 :
773 : // SvxTextLineItem contains enum and color
774 192 : if (rEditSet.GetItemState(EE_CHAR_UNDERLINE,true,&pItem) == SFX_ITEM_SET)
775 163 : rDestSet.Put( SvxUnderlineItem(UNDERLINE_NONE,ATTR_FONT_UNDERLINE) = *(const SvxUnderlineItem*)pItem );
776 192 : if (rEditSet.GetItemState(EE_CHAR_OVERLINE,true,&pItem) == SFX_ITEM_SET)
777 122 : rDestSet.Put( SvxOverlineItem(UNDERLINE_NONE,ATTR_FONT_OVERLINE) = *(const SvxOverlineItem*)pItem );
778 192 : if (rEditSet.GetItemState(EE_CHAR_WLM,true,&pItem) == SFX_ITEM_SET)
779 157 : rDestSet.Put( SvxWordLineModeItem( ((const SvxWordLineModeItem*)pItem)->GetValue(),
780 157 : ATTR_FONT_WORDLINE) );
781 :
782 192 : if (rEditSet.GetItemState(EE_CHAR_STRIKEOUT,true,&pItem) == SFX_ITEM_SET)
783 159 : rDestSet.Put( SvxCrossedOutItem( (FontStrikeout)((const SvxCrossedOutItem*)pItem)->GetValue(),
784 159 : ATTR_FONT_CROSSEDOUT) );
785 :
786 192 : if (rEditSet.GetItemState(EE_CHAR_ITALIC,true,&pItem) == SFX_ITEM_SET)
787 161 : rDestSet.Put( SvxPostureItem( (FontItalic)((const SvxPostureItem*)pItem)->GetValue(),
788 161 : ATTR_FONT_POSTURE) );
789 192 : if (rEditSet.GetItemState(EE_CHAR_ITALIC_CJK,true,&pItem) == SFX_ITEM_SET)
790 138 : rDestSet.Put( SvxPostureItem( (FontItalic)((const SvxPostureItem*)pItem)->GetValue(),
791 138 : ATTR_CJK_FONT_POSTURE) );
792 192 : if (rEditSet.GetItemState(EE_CHAR_ITALIC_CTL,true,&pItem) == SFX_ITEM_SET)
793 129 : rDestSet.Put( SvxPostureItem( (FontItalic)((const SvxPostureItem*)pItem)->GetValue(),
794 129 : ATTR_CTL_FONT_POSTURE) );
795 :
796 192 : if (rEditSet.GetItemState(EE_CHAR_OUTLINE,true,&pItem) == SFX_ITEM_SET)
797 153 : rDestSet.Put( SvxContourItem( ((const SvxContourItem*)pItem)->GetValue(),
798 153 : ATTR_FONT_CONTOUR) );
799 192 : if (rEditSet.GetItemState(EE_CHAR_SHADOW,true,&pItem) == SFX_ITEM_SET)
800 154 : rDestSet.Put( SvxShadowedItem( ((const SvxShadowedItem*)pItem)->GetValue(),
801 154 : ATTR_FONT_SHADOWED) );
802 192 : if (rEditSet.GetItemState(EE_CHAR_EMPHASISMARK,true,&pItem) == SFX_ITEM_SET)
803 152 : rDestSet.Put( SvxEmphasisMarkItem( ((const SvxEmphasisMarkItem*)pItem)->GetEmphasisMark(),
804 152 : ATTR_FONT_EMPHASISMARK) );
805 192 : if (rEditSet.GetItemState(EE_CHAR_RELIEF,true,&pItem) == SFX_ITEM_SET)
806 151 : rDestSet.Put( SvxCharReliefItem( (FontRelief)((const SvxCharReliefItem*)pItem)->GetValue(),
807 151 : ATTR_FONT_RELIEF) );
808 :
809 192 : if (rEditSet.GetItemState(EE_CHAR_LANGUAGE,true,&pItem) == SFX_ITEM_SET)
810 155 : rDestSet.Put( SvxLanguageItem(static_cast<const SvxLanguageItem*>(pItem)->GetValue(), ATTR_FONT_LANGUAGE) );
811 192 : if (rEditSet.GetItemState(EE_CHAR_LANGUAGE_CJK,true,&pItem) == SFX_ITEM_SET)
812 156 : rDestSet.Put( SvxLanguageItem(static_cast<const SvxLanguageItem*>(pItem)->GetValue(), ATTR_CJK_FONT_LANGUAGE) );
813 192 : if (rEditSet.GetItemState(EE_CHAR_LANGUAGE_CTL,true,&pItem) == SFX_ITEM_SET)
814 124 : rDestSet.Put( SvxLanguageItem(static_cast<const SvxLanguageItem*>(pItem)->GetValue(), ATTR_CTL_FONT_LANGUAGE) );
815 :
816 192 : if (rEditSet.GetItemState(EE_PARA_JUST,true,&pItem) == SFX_ITEM_SET)
817 : {
818 : SvxCellHorJustify eVal;
819 21 : 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 21 : eVal = SVX_HOR_JUSTIFY_STANDARD;
826 21 : 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 21 : if ( eVal != SVX_HOR_JUSTIFY_STANDARD )
846 0 : rDestSet.Put( SvxHorJustifyItem( eVal, ATTR_HOR_JUSTIFY) );
847 : }
848 192 : }
849 :
850 171 : void ScPatternAttr::GetFromEditItemSet( const SfxItemSet* pEditSet )
851 : {
852 171 : if( pEditSet )
853 171 : GetFromEditItemSet( GetItemSet(), *pEditSet );
854 171 : }
855 :
856 61 : 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 61 : const SfxItemSet& rMySet = GetItemSet();
862 :
863 : SvxCellHorJustify eHorJust = (SvxCellHorJustify)
864 61 : ((const SvxHorJustifyItem&)rMySet.Get(ATTR_HOR_JUSTIFY)).GetValue();
865 :
866 : SvxAdjust eSvxAdjust;
867 61 : switch (eHorJust)
868 : {
869 2 : 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 59 : default: eSvxAdjust = SVX_ADJUST_LEFT; break;
873 : }
874 61 : pEditSet->Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) );
875 61 : }
876 :
877 165 : void ScPatternAttr::DeleteUnchanged( const ScPatternAttr* pOldAttrs )
878 : {
879 165 : SfxItemSet& rThisSet = GetItemSet();
880 165 : const SfxItemSet& rOldSet = pOldAttrs->GetItemSet();
881 :
882 : const SfxPoolItem* pThisItem;
883 : const SfxPoolItem* pOldItem;
884 :
885 9405 : for ( sal_uInt16 nSubWhich=ATTR_PATTERN_START; nSubWhich<=ATTR_PATTERN_END; nSubWhich++ )
886 : {
887 : // only items that are set are interesting
888 9240 : if ( rThisSet.GetItemState( nSubWhich, false, &pThisItem ) == SFX_ITEM_SET )
889 : {
890 2905 : SfxItemState eOldState = rOldSet.GetItemState( nSubWhich, true, &pOldItem );
891 2905 : if ( eOldState == SFX_ITEM_SET )
892 : {
893 : // item is set in OldAttrs (or its parent) -> compare pointers
894 2748 : if ( pThisItem == pOldItem )
895 2664 : rThisSet.ClearItem( nSubWhich );
896 : }
897 157 : else if ( eOldState != SFX_ITEM_DONTCARE )
898 : {
899 : // not set in OldAttrs -> compare item value to default item
900 157 : if ( *pThisItem == rThisSet.GetPool()->GetDefaultItem( nSubWhich ) )
901 128 : rThisSet.ClearItem( nSubWhich );
902 : }
903 : }
904 : }
905 165 : }
906 :
907 5 : bool ScPatternAttr::HasItemsSet( const sal_uInt16* pWhich ) const
908 : {
909 5 : const SfxItemSet& rSet = GetItemSet();
910 15 : for (sal_uInt16 i=0; pWhich[i]; i++)
911 10 : if ( rSet.GetItemState( pWhich[i], false ) == SFX_ITEM_SET )
912 0 : return true;
913 5 : 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 7 : static SfxStyleSheetBase* lcl_CopyStyleToPool
924 : (
925 : SfxStyleSheetBase* pSrcStyle,
926 : SfxStyleSheetBasePool* pSrcPool,
927 : SfxStyleSheetBasePool* pDestPool,
928 : const SvNumberFormatterIndexTable* pFormatExchangeList
929 : )
930 : {
931 7 : if ( !pSrcStyle || !pDestPool || !pSrcPool )
932 : {
933 : OSL_FAIL( "CopyStyleToPool: Invalid Arguments :-/" );
934 0 : return NULL;
935 : }
936 :
937 : //--------------------------------------------------------
938 :
939 7 : const String aStrSrcStyle = pSrcStyle->GetName();
940 7 : const SfxStyleFamily eFamily = pSrcStyle->GetFamily();
941 7 : SfxStyleSheetBase* pDestStyle = pDestPool->Find( aStrSrcStyle, eFamily );
942 :
943 7 : if ( !pDestStyle )
944 : {
945 1 : const String aStrParent = pSrcStyle->GetParent();
946 1 : const SfxItemSet& rSrcSet = pSrcStyle->GetItemSet();
947 :
948 1 : pDestStyle = &pDestPool->Make( aStrSrcStyle, eFamily, SFXSTYLEBIT_USERDEF );
949 1 : SfxItemSet& rDestSet = pDestStyle->GetItemSet();
950 1 : 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 1 : 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 4 : if ( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) != aStrParent &&
971 2 : aStrSrcStyle != aStrParent &&
972 1 : !pDestPool->Find( aStrParent, eFamily ) )
973 : {
974 0 : lcl_CopyStyleToPool( pSrcPool->Find( aStrParent, eFamily ),
975 0 : pSrcPool, pDestPool, pFormatExchangeList );
976 : }
977 :
978 1 : pDestStyle->SetParent( aStrParent );
979 : }
980 :
981 7 : return pDestStyle;
982 : }
983 :
984 7 : ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const
985 : {
986 7 : const SfxItemSet* pSrcSet = &GetItemSet();
987 :
988 7 : ScPatternAttr* pDestPattern = new ScPatternAttr(pDestDoc->GetPool());
989 7 : SfxItemSet* pDestSet = &pDestPattern->GetItemSet();
990 :
991 : // Zellformatvorlage in anderes Dokument kopieren:
992 :
993 7 : 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 7 : pSrcDoc->GetStyleSheetPool(),
1002 7 : pDestDoc->GetStyleSheetPool(),
1003 14 : pDestDoc->GetFormatExchangeList() );
1004 :
1005 7 : pDestPattern->SetStyleSheet( (ScStyleSheet*)pStyleCpy );
1006 : }
1007 :
1008 399 : for ( sal_uInt16 nAttrId = ATTR_PATTERN_START; nAttrId <= ATTR_PATTERN_END; nAttrId++ )
1009 : {
1010 : const SfxPoolItem* pSrcItem;
1011 392 : SfxItemState eItemState = pSrcSet->GetItemState( nAttrId, false, &pSrcItem );
1012 392 : 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 7 : (ScPatternAttr*) &pDestDoc->GetPool()->Put(*pDestPattern);
1056 7 : delete pDestPattern;
1057 7 : return pPatternAttr;
1058 : }
1059 :
1060 3749 : bool ScPatternAttr::IsVisible() const
1061 : {
1062 3749 : const SfxItemSet& rSet = GetItemSet();
1063 :
1064 : const SfxPoolItem* pItem;
1065 : SfxItemState eState;
1066 :
1067 3749 : eState = rSet.GetItemState( ATTR_BACKGROUND, true, &pItem );
1068 3749 : if ( eState == SFX_ITEM_SET )
1069 3343 : if ( ((const SvxBrushItem*)pItem)->GetColor().GetColor() != COL_TRANSPARENT )
1070 3312 : return true;
1071 :
1072 437 : eState = rSet.GetItemState( ATTR_BORDER, true, &pItem );
1073 437 : if ( eState == SFX_ITEM_SET )
1074 : {
1075 305 : const SvxBoxItem* pBoxItem = (SvxBoxItem*) pItem;
1076 610 : if ( pBoxItem->GetTop() || pBoxItem->GetBottom() ||
1077 305 : pBoxItem->GetLeft() || pBoxItem->GetRight() )
1078 305 : return true;
1079 : }
1080 :
1081 132 : eState = rSet.GetItemState( ATTR_BORDER_TLBR, true, &pItem );
1082 132 : if ( eState == SFX_ITEM_SET )
1083 0 : if( static_cast< const SvxLineItem* >( pItem )->GetLine() )
1084 0 : return true;
1085 :
1086 132 : eState = rSet.GetItemState( ATTR_BORDER_BLTR, true, &pItem );
1087 132 : if ( eState == SFX_ITEM_SET )
1088 0 : if( static_cast< const SvxLineItem* >( pItem )->GetLine() )
1089 0 : return true;
1090 :
1091 132 : eState = rSet.GetItemState( ATTR_SHADOW, true, &pItem );
1092 132 : if ( eState == SFX_ITEM_SET )
1093 0 : if ( ((const SvxShadowItem*)pItem)->GetLocation() != SVX_SHADOW_NONE )
1094 0 : return true;
1095 :
1096 132 : return false;
1097 : }
1098 :
1099 1005304 : inline bool OneEqual( const SfxItemSet& rSet1, const SfxItemSet& rSet2, sal_uInt16 nId )
1100 : {
1101 1005304 : const SfxPoolItem* pItem1 = &rSet1.Get(nId);
1102 1005304 : const SfxPoolItem* pItem2 = &rSet2.Get(nId);
1103 1005304 : return ( pItem1 == pItem2 || *pItem1 == *pItem2 );
1104 : }
1105 :
1106 203513 : bool ScPatternAttr::IsVisibleEqual( const ScPatternAttr& rOther ) const
1107 : {
1108 203513 : const SfxItemSet& rThisSet = GetItemSet();
1109 203513 : const SfxItemSet& rOtherSet = rOther.GetItemSet();
1110 :
1111 406816 : return OneEqual( rThisSet, rOtherSet, ATTR_BACKGROUND ) &&
1112 402799 : OneEqual( rThisSet, rOtherSet, ATTR_BORDER ) &&
1113 398992 : OneEqual( rThisSet, rOtherSet, ATTR_BORDER_TLBR ) &&
1114 602505 : OneEqual( rThisSet, rOtherSet, ATTR_BORDER_BLTR ) &&
1115 403009 : OneEqual( rThisSet, rOtherSet, ATTR_SHADOW );
1116 :
1117 : //! auch hier nur wirklich sichtbare Werte testen !!!
1118 : }
1119 :
1120 569647 : const OUString* ScPatternAttr::GetStyleName() const
1121 : {
1122 569647 : return pName ? pName : ( pStyle ? &pStyle->GetName() : NULL );
1123 : }
1124 :
1125 :
1126 184438 : void ScPatternAttr::SetStyleSheet( ScStyleSheet* pNewStyle, bool bClearDirectFormat )
1127 : {
1128 184438 : if (pNewStyle)
1129 : {
1130 184438 : SfxItemSet& rPatternSet = GetItemSet();
1131 184438 : const SfxItemSet& rStyleSet = pNewStyle->GetItemSet();
1132 :
1133 184438 : if (bClearDirectFormat)
1134 : {
1135 4543755 : for (sal_uInt16 i=ATTR_PATTERN_START; i<=ATTR_PATTERN_END; i++)
1136 : {
1137 4464040 : if (rStyleSet.GetItemState(i, true) == SFX_ITEM_SET)
1138 466640 : rPatternSet.ClearItem(i);
1139 : }
1140 : }
1141 184438 : rPatternSet.SetParent(&pNewStyle->GetItemSet());
1142 184438 : pStyle = pNewStyle;
1143 184438 : DELETEZ( pName );
1144 : }
1145 : else
1146 : {
1147 : OSL_FAIL( "ScPatternAttr::SetStyleSheet( NULL ) :-|" );
1148 0 : GetItemSet().SetParent(NULL);
1149 0 : pStyle = NULL;
1150 : }
1151 184438 : }
1152 :
1153 313 : void ScPatternAttr::UpdateStyleSheet()
1154 : {
1155 313 : if (pName)
1156 : {
1157 313 : 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 313 : if (!pStyle)
1163 : {
1164 0 : SfxStyleSheetIteratorPtr pIter = pDoc->GetStyleSheetPool()->CreateIterator( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
1165 0 : pStyle = dynamic_cast< ScStyleSheet* >(pIter->First());
1166 : }
1167 :
1168 313 : if (pStyle)
1169 : {
1170 313 : GetItemSet().SetParent(&pStyle->GetItemSet());
1171 313 : DELETEZ( pName );
1172 : }
1173 : }
1174 : else
1175 0 : pStyle = NULL;
1176 313 : }
1177 :
1178 0 : void ScPatternAttr::StyleToName()
1179 : {
1180 : // Style wurde geloescht, Namen merken:
1181 :
1182 0 : if ( pStyle )
1183 : {
1184 0 : if ( pName )
1185 0 : *pName = pStyle->GetName();
1186 : else
1187 0 : pName = new OUString( pStyle->GetName() );
1188 :
1189 0 : pStyle = NULL;
1190 0 : GetItemSet().SetParent( NULL );
1191 : }
1192 0 : }
1193 :
1194 0 : bool ScPatternAttr::IsSymbolFont() const
1195 : {
1196 : const SfxPoolItem* pItem;
1197 0 : if( GetItemSet().GetItemState( ATTR_FONT, true, &pItem ) == SFX_ITEM_SET )
1198 0 : return ((const SvxFontItem*) pItem)->GetCharSet() == RTL_TEXTENCODING_SYMBOL;
1199 : else
1200 0 : return false;
1201 : }
1202 :
1203 :
1204 51982 : sal_uLong ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter ) const
1205 : {
1206 : sal_uLong nFormat =
1207 51982 : ((SfxUInt32Item*)&GetItemSet().Get( ATTR_VALUE_FORMAT ))->GetValue();
1208 : LanguageType eLang =
1209 51982 : ((SvxLanguageItem*)&GetItemSet().Get( ATTR_LANGUAGE_FORMAT ))->GetLanguage();
1210 51982 : if ( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && eLang == LANGUAGE_SYSTEM )
1211 : ; // es bleibt wie es ist
1212 517 : else if ( pFormatter )
1213 517 : nFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nFormat, eLang );
1214 51982 : return nFormat;
1215 : }
1216 :
1217 : // dasselbe, wenn bedingte Formatierung im Spiel ist:
1218 :
1219 40074 : sal_uLong ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter,
1220 : const SfxItemSet* pCondSet ) const
1221 : {
1222 : OSL_ENSURE(pFormatter,"GetNumberFormat without Formatter");
1223 :
1224 : const SfxPoolItem* pFormItem;
1225 40074 : if ( !pCondSet || pCondSet->GetItemState(ATTR_VALUE_FORMAT,true,&pFormItem) != SFX_ITEM_SET )
1226 39822 : pFormItem = &GetItemSet().Get(ATTR_VALUE_FORMAT);
1227 :
1228 : const SfxPoolItem* pLangItem;
1229 40074 : if ( !pCondSet || pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT,true,&pLangItem) != SFX_ITEM_SET )
1230 39954 : pLangItem = &GetItemSet().Get(ATTR_LANGUAGE_FORMAT);
1231 :
1232 : return pFormatter->GetFormatForLanguageIfBuiltIn(
1233 : ((SfxUInt32Item*)pFormItem)->GetValue(),
1234 40074 : ((SvxLanguageItem*)pLangItem)->GetLanguage() );
1235 : }
1236 :
1237 3188158 : const SfxPoolItem& ScPatternAttr::GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet )
1238 : {
1239 : const SfxPoolItem* pCondItem;
1240 3188158 : if ( pCondSet && pCondSet->GetItemState( nWhich, true, &pCondItem ) == SFX_ITEM_SET )
1241 2 : return *pCondItem;
1242 3188156 : return rItemSet.Get(nWhich);
1243 : }
1244 :
1245 775125 : const SfxPoolItem& ScPatternAttr::GetItem( sal_uInt16 nSubWhich, const SfxItemSet* pCondSet ) const
1246 : {
1247 775125 : return GetItem( nSubWhich, GetItemSet(), pCondSet );
1248 : }
1249 :
1250 : // GetRotateVal testet vorher ATTR_ORIENTATION
1251 :
1252 361840 : long ScPatternAttr::GetRotateVal( const SfxItemSet* pCondSet ) const
1253 : {
1254 361840 : long nAttrRotate = 0;
1255 361840 : if ( GetCellOrientation() == SVX_ORIENTATION_STANDARD )
1256 : {
1257 361564 : bool bRepeat = ( static_cast<const SvxHorJustifyItem&>(GetItem(ATTR_HOR_JUSTIFY, pCondSet)).
1258 361564 : GetValue() == SVX_HOR_JUSTIFY_REPEAT );
1259 : // ignore orientation/rotation if "repeat" is active
1260 361564 : if ( !bRepeat )
1261 361564 : nAttrRotate = ((const SfxInt32Item&)GetItem( ATTR_ROTATE_VALUE, pCondSet )).GetValue();
1262 : }
1263 361840 : return nAttrRotate;
1264 : }
1265 :
1266 361840 : sal_uInt8 ScPatternAttr::GetRotateDir( const SfxItemSet* pCondSet ) const
1267 : {
1268 361840 : sal_uInt8 nRet = SC_ROTDIR_NONE;
1269 :
1270 361840 : long nAttrRotate = GetRotateVal( pCondSet );
1271 361840 : if ( nAttrRotate )
1272 : {
1273 : SvxRotateMode eRotMode = (SvxRotateMode)((const SvxRotateModeItem&)
1274 2018 : GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue();
1275 :
1276 2018 : if ( eRotMode == SVX_ROTATE_MODE_STANDARD || nAttrRotate == 18000 )
1277 2018 : nRet = SC_ROTDIR_STANDARD;
1278 0 : else if ( eRotMode == SVX_ROTATE_MODE_CENTER )
1279 0 : nRet = SC_ROTDIR_CENTER;
1280 0 : else if ( eRotMode == SVX_ROTATE_MODE_TOP || eRotMode == SVX_ROTATE_MODE_BOTTOM )
1281 : {
1282 0 : long nRot180 = nAttrRotate % 18000; // 1/100 Grad
1283 0 : if ( nRot180 == 9000 )
1284 0 : nRet = SC_ROTDIR_CENTER;
1285 0 : else if ( ( eRotMode == SVX_ROTATE_MODE_TOP && nRot180 < 9000 ) ||
1286 0 : ( eRotMode == SVX_ROTATE_MODE_BOTTOM && nRot180 > 9000 ) )
1287 0 : nRet = SC_ROTDIR_LEFT;
1288 : else
1289 0 : nRet = SC_ROTDIR_RIGHT;
1290 : }
1291 : }
1292 :
1293 361840 : return nRet;
1294 93 : }
1295 :
1296 :
1297 :
1298 :
1299 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|