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