1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: patattr.cxx,v $
10 * $Revision: 1.34.144.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
35 // INCLUDE ---------------------------------------------------------------
37 #include "scitems.hxx"
38 #include <svx/adjitem.hxx>
39 #include <svx/algitem.hxx>
40 #include <svx/boxitem.hxx>
41 #include <svx/bolnitem.hxx>
42 #include <svx/brshitem.hxx>
43 #include <svx/charreliefitem.hxx>
44 #include <svx/cntritem.hxx>
45 #include <svtools/colorcfg.hxx>
46 #include <svx/colritem.hxx>
47 #include <svx/crsditem.hxx>
48 #include <svx/emphitem.hxx>
49 #include <svx/fhgtitem.hxx>
50 #include <svx/fontitem.hxx>
51 #include <svx/forbiddenruleitem.hxx>
52 #include <svx/frmdiritem.hxx>
53 #include <svx/langitem.hxx>
54 #include <svx/postitem.hxx>
55 #include <svx/rotmodit.hxx>
56 #include <svx/scriptspaceitem.hxx>
57 #include <svx/scripttypeitem.hxx>
58 #include <svx/shaditem.hxx>
59 #include <svx/shdditem.hxx>
60 #include <svx/udlnitem.hxx>
61 #include <svx/wghtitem.hxx>
62 #include <svx/wrlmitem.hxx>
63 #include <svtools/intitem.hxx>
64 #include <svtools/zforlist.hxx>
65 #include <vcl/outdev.hxx>
66 #include <vcl/svapp.hxx>
68 #include "patattr.hxx"
69 #include "docpool.hxx"
70 #include "stlsheet.hxx"
71 #include "stlpool.hxx"
72 #include "document.hxx"
74 #include "globstr.hrc"
75 #include "conditio.hxx"
76 #include "validat.hxx"
78 #include "fillinfo.hxx"
80 // STATIC DATA -----------------------------------------------------------
82 ScDocument
* ScPatternAttr::pDoc
= NULL
;
84 // -----------------------------------------------------------------------
86 //! move to some header file
87 inline long TwipsToHMM(long nTwips
) { return (nTwips
* 127 + 36) / 72; }
88 inline long HMMToTwips(long nHMM
) { return (nHMM
* 72 + 63) / 127; }
90 // -----------------------------------------------------------------------
92 ScPatternAttr::ScPatternAttr( SfxItemSet
* pItemSet
, const String
& rStyleName
)
93 : SfxSetItem ( ATTR_PATTERN
, pItemSet
),
94 pName ( new String( rStyleName
) ),
99 ScPatternAttr::ScPatternAttr( SfxItemSet
* pItemSet
, ScStyleSheet
* pStyleSheet
)
100 : SfxSetItem ( ATTR_PATTERN
, pItemSet
),
102 pStyle ( pStyleSheet
)
105 GetItemSet().SetParent( &pStyleSheet
->GetItemSet() );
108 ScPatternAttr::ScPatternAttr( SfxItemPool
* pItemPool
)
109 : SfxSetItem ( ATTR_PATTERN
, new SfxItemSet( *pItemPool
, ATTR_PATTERN_START
, ATTR_PATTERN_END
) ),
115 ScPatternAttr::ScPatternAttr( const ScPatternAttr
& rPatternAttr
)
116 : SfxSetItem ( rPatternAttr
),
117 pStyle ( rPatternAttr
.pStyle
)
119 if (rPatternAttr
.pName
)
120 pName
= new String(*rPatternAttr
.pName
);
125 __EXPORT
ScPatternAttr::~ScPatternAttr()
130 SfxPoolItem
* __EXPORT
ScPatternAttr::Clone( SfxItemPool
*pPool
) const
132 ScPatternAttr
* pPattern
= new ScPatternAttr( GetItemSet().Clone(TRUE
, pPool
) );
134 pPattern
->pStyle
= pStyle
;
135 pPattern
->pName
= pName
? new String(*pName
) : NULL
;
140 inline int StrCmp( const String
* pStr1
, const String
* pStr2
)
142 return ( pStr1
? ( pStr2
? ( *pStr1
== *pStr2
) : FALSE
) : ( pStr2
? FALSE
: TRUE
) );
145 inline bool EqualPatternSets( const SfxItemSet
& rSet1
, const SfxItemSet
& rSet2
)
147 // #i62090# The SfxItemSet in the SfxSetItem base class always has the same ranges
148 // (single range from ATTR_PATTERN_START to ATTR_PATTERN_END), and the items are pooled,
149 // so it's enough to compare just the pointers (Count just because it's even faster).
151 if ( rSet1
.Count() != rSet2
.Count() )
154 SfxItemArray pItems1
= rSet1
.GetItems_Impl(); // inline method of SfxItemSet
155 SfxItemArray pItems2
= rSet2
.GetItems_Impl();
157 return ( 0 == memcmp( pItems1
, pItems2
, (ATTR_PATTERN_END
- ATTR_PATTERN_START
+ 1) * sizeof(pItems1
[0]) ) );
160 int __EXPORT
ScPatternAttr::operator==( const SfxPoolItem
& rCmp
) const
162 // #i62090# Use quick comparison between ScPatternAttr's ItemSets
164 return ( EqualPatternSets( GetItemSet(), static_cast<const ScPatternAttr
&>(rCmp
).GetItemSet() ) &&
165 StrCmp( GetStyleName(), static_cast<const ScPatternAttr
&>(rCmp
).GetStyleName() ) );
168 SfxPoolItem
* __EXPORT
ScPatternAttr::Create( SvStream
& rStream
, USHORT
/* nVersion */ ) const
174 rStream
>> bHasStyle
;
179 rStream
.ReadByteString( *pStr
, rStream
.GetStreamCharSet() );
180 rStream
>> eFamDummy
; // wg. altem Dateiformat
183 pStr
= new String( ScGlobal::GetRscString(STR_STYLENAME_STANDARD
) );
185 SfxItemSet
*pNewSet
= new SfxItemSet( *GetItemSet().GetPool(),
186 ATTR_PATTERN_START
, ATTR_PATTERN_END
);
187 pNewSet
->Load( rStream
);
189 ScPatternAttr
* pPattern
= new ScPatternAttr( pNewSet
);
191 pPattern
->pName
= pStr
;
196 SvStream
& __EXPORT
ScPatternAttr::Store(SvStream
& rStream
, USHORT
/* nItemVersion */) const
198 rStream
<< (BOOL
)TRUE
;
201 rStream
.WriteByteString( pStyle
->GetName(), rStream
.GetStreamCharSet() );
202 else if ( pName
) // wenn Style geloescht ist/war
203 rStream
.WriteByteString( *pName
, rStream
.GetStreamCharSet() );
205 rStream
.WriteByteString( ScGlobal::GetRscString(STR_STYLENAME_STANDARD
),
206 rStream
.GetStreamCharSet() );
208 rStream
<< (short)SFX_STYLE_FAMILY_PARA
; // wg. altem Dateiformat
210 GetItemSet().Store( rStream
);
215 SvxCellOrientation
ScPatternAttr::GetCellOrientation( const SfxItemSet
& rItemSet
, const SfxItemSet
* pCondSet
)
217 SvxCellOrientation eOrient
= SVX_ORIENTATION_STANDARD
;
219 if( ((const SfxBoolItem
&)GetItem( ATTR_STACKED
, rItemSet
, pCondSet
)).GetValue() )
221 eOrient
= SVX_ORIENTATION_STACKED
;
225 INT32 nAngle
= ((const SfxInt32Item
&)GetItem( ATTR_ROTATE_VALUE
, rItemSet
, pCondSet
)).GetValue();
227 eOrient
= SVX_ORIENTATION_BOTTOMTOP
;
228 else if( nAngle
== 27000 )
229 eOrient
= SVX_ORIENTATION_TOPBOTTOM
;
235 SvxCellOrientation
ScPatternAttr::GetCellOrientation( const SfxItemSet
* pCondSet
) const
237 return GetCellOrientation( GetItemSet(), pCondSet
);
240 void ScPatternAttr::GetFont(
241 Font
& rFont
, const SfxItemSet
& rItemSet
, ScAutoFontColorMode eAutoMode
,
242 OutputDevice
* pOutDev
, const Fraction
* pScale
,
243 const SfxItemSet
* pCondSet
, BYTE nScript
,
244 const Color
* pBackConfigColor
, const Color
* pTextConfigColor
)
248 const SvxFontItem
* pFontAttr
;
252 FontUnderline eUnder
;
255 FontStrikeout eStrike
;
258 FontEmphasisMark eEmphasis
;
263 USHORT nFontId
, nHeightId
, nWeightId
, nPostureId
, nLangId
;
264 if ( nScript
== SCRIPTTYPE_ASIAN
)
266 nFontId
= ATTR_CJK_FONT
;
267 nHeightId
= ATTR_CJK_FONT_HEIGHT
;
268 nWeightId
= ATTR_CJK_FONT_WEIGHT
;
269 nPostureId
= ATTR_CJK_FONT_POSTURE
;
270 nLangId
= ATTR_CJK_FONT_LANGUAGE
;
272 else if ( nScript
== SCRIPTTYPE_COMPLEX
)
274 nFontId
= ATTR_CTL_FONT
;
275 nHeightId
= ATTR_CTL_FONT_HEIGHT
;
276 nWeightId
= ATTR_CTL_FONT_WEIGHT
;
277 nPostureId
= ATTR_CTL_FONT_POSTURE
;
278 nLangId
= ATTR_CTL_FONT_LANGUAGE
;
283 nHeightId
= ATTR_FONT_HEIGHT
;
284 nWeightId
= ATTR_FONT_WEIGHT
;
285 nPostureId
= ATTR_FONT_POSTURE
;
286 nLangId
= ATTR_FONT_LANGUAGE
;
291 const SfxPoolItem
* pItem
;
293 if ( pCondSet
->GetItemState( nFontId
, TRUE
, &pItem
) != SFX_ITEM_SET
)
294 pItem
= &rItemSet
.Get( nFontId
);
295 pFontAttr
= (const SvxFontItem
*) pItem
;
297 if ( pCondSet
->GetItemState( nHeightId
, TRUE
, &pItem
) != SFX_ITEM_SET
)
298 pItem
= &rItemSet
.Get( nHeightId
);
299 nFontHeight
= ((const SvxFontHeightItem
*)pItem
)->GetHeight();
301 if ( pCondSet
->GetItemState( nWeightId
, TRUE
, &pItem
) != SFX_ITEM_SET
)
302 pItem
= &rItemSet
.Get( nWeightId
);
303 eWeight
= (FontWeight
)((const SvxWeightItem
*)pItem
)->GetValue();
305 if ( pCondSet
->GetItemState( nPostureId
, TRUE
, &pItem
) != SFX_ITEM_SET
)
306 pItem
= &rItemSet
.Get( nPostureId
);
307 eItalic
= (FontItalic
)((const SvxPostureItem
*)pItem
)->GetValue();
309 if ( pCondSet
->GetItemState( ATTR_FONT_UNDERLINE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
310 pItem
= &rItemSet
.Get( ATTR_FONT_UNDERLINE
);
311 eUnder
= (FontUnderline
)((const SvxUnderlineItem
*)pItem
)->GetValue();
313 if ( pCondSet
->GetItemState( ATTR_FONT_OVERLINE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
314 pItem
= &rItemSet
.Get( ATTR_FONT_OVERLINE
);
315 eOver
= (FontUnderline
)((const SvxOverlineItem
*)pItem
)->GetValue();
317 if ( pCondSet
->GetItemState( ATTR_FONT_WORDLINE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
318 pItem
= &rItemSet
.Get( ATTR_FONT_WORDLINE
);
319 bWordLine
= ((const SvxWordLineModeItem
*)pItem
)->GetValue();
321 if ( pCondSet
->GetItemState( ATTR_FONT_CROSSEDOUT
, TRUE
, &pItem
) != SFX_ITEM_SET
)
322 pItem
= &rItemSet
.Get( ATTR_FONT_CROSSEDOUT
);
323 eStrike
= (FontStrikeout
)((const SvxCrossedOutItem
*)pItem
)->GetValue();
325 if ( pCondSet
->GetItemState( ATTR_FONT_CONTOUR
, TRUE
, &pItem
) != SFX_ITEM_SET
)
326 pItem
= &rItemSet
.Get( ATTR_FONT_CONTOUR
);
327 bOutline
= ((const SvxContourItem
*)pItem
)->GetValue();
329 if ( pCondSet
->GetItemState( ATTR_FONT_SHADOWED
, TRUE
, &pItem
) != SFX_ITEM_SET
)
330 pItem
= &rItemSet
.Get( ATTR_FONT_SHADOWED
);
331 bShadow
= ((const SvxShadowedItem
*)pItem
)->GetValue();
333 if ( pCondSet
->GetItemState( ATTR_FONT_EMPHASISMARK
, TRUE
, &pItem
) != SFX_ITEM_SET
)
334 pItem
= &rItemSet
.Get( ATTR_FONT_EMPHASISMARK
);
335 eEmphasis
= ((const SvxEmphasisMarkItem
*)pItem
)->GetEmphasisMark();
337 if ( pCondSet
->GetItemState( ATTR_FONT_RELIEF
, TRUE
, &pItem
) != SFX_ITEM_SET
)
338 pItem
= &rItemSet
.Get( ATTR_FONT_RELIEF
);
339 eRelief
= (FontRelief
)((const SvxCharReliefItem
*)pItem
)->GetValue();
341 if ( pCondSet
->GetItemState( ATTR_FONT_COLOR
, TRUE
, &pItem
) != SFX_ITEM_SET
)
342 pItem
= &rItemSet
.Get( ATTR_FONT_COLOR
);
343 aColor
= ((const SvxColorItem
*)pItem
)->GetValue();
345 if ( pCondSet
->GetItemState( nLangId
, TRUE
, &pItem
) != SFX_ITEM_SET
)
346 pItem
= &rItemSet
.Get( nLangId
);
347 eLang
= ((const SvxLanguageItem
*)pItem
)->GetLanguage();
349 else // alles aus rItemSet
351 pFontAttr
= &(const SvxFontItem
&)rItemSet
.Get( nFontId
);
352 nFontHeight
= ((const SvxFontHeightItem
&)
353 rItemSet
.Get( nHeightId
)).GetHeight();
354 eWeight
= (FontWeight
)((const SvxWeightItem
&)
355 rItemSet
.Get( nWeightId
)).GetValue();
356 eItalic
= (FontItalic
)((const SvxPostureItem
&)
357 rItemSet
.Get( nPostureId
)).GetValue();
358 eUnder
= (FontUnderline
)((const SvxUnderlineItem
&)
359 rItemSet
.Get( ATTR_FONT_UNDERLINE
)).GetValue();
360 eOver
= (FontUnderline
)((const SvxOverlineItem
&)
361 rItemSet
.Get( ATTR_FONT_OVERLINE
)).GetValue();
362 bWordLine
= ((const SvxWordLineModeItem
&)
363 rItemSet
.Get( ATTR_FONT_WORDLINE
)).GetValue();
364 eStrike
= (FontStrikeout
)((const SvxCrossedOutItem
&)
365 rItemSet
.Get( ATTR_FONT_CROSSEDOUT
)).GetValue();
366 bOutline
= ((const SvxContourItem
&)
367 rItemSet
.Get( ATTR_FONT_CONTOUR
)).GetValue();
368 bShadow
= ((const SvxShadowedItem
&)
369 rItemSet
.Get( ATTR_FONT_SHADOWED
)).GetValue();
370 eEmphasis
= ((const SvxEmphasisMarkItem
&)
371 rItemSet
.Get( ATTR_FONT_EMPHASISMARK
)).GetEmphasisMark();
372 eRelief
= (FontRelief
)((const SvxCharReliefItem
&)
373 rItemSet
.Get( ATTR_FONT_RELIEF
)).GetValue();
374 aColor
= ((const SvxColorItem
&)
375 rItemSet
.Get( ATTR_FONT_COLOR
)).GetValue();
376 // for graphite language features
378 ((const SvxLanguageItem
&)rItemSet
.Get( nLangId
)).GetLanguage();
380 DBG_ASSERT(pFontAttr
,"nanu?");
386 if (rFont
.GetName() != pFontAttr
->GetFamilyName())
387 rFont
.SetName( pFontAttr
->GetFamilyName() );
388 if (rFont
.GetStyleName() != pFontAttr
->GetStyleName())
389 rFont
.SetStyleName( pFontAttr
->GetStyleName() );
391 rFont
.SetFamily( pFontAttr
->GetFamily() );
392 rFont
.SetCharSet( pFontAttr
->GetCharSet() );
393 rFont
.SetPitch( pFontAttr
->GetPitch() );
395 rFont
.SetLanguage(eLang
);
399 if ( pOutDev
!= NULL
)
402 Fraction
aFraction( 1,1 );
405 Size
aSize( 0, (long) nFontHeight
);
406 MapMode aDestMode
= pOutDev
->GetMapMode();
407 MapMode
aSrcMode( MAP_TWIP
, Point(), aFraction
, aFraction
);
408 if (aDestMode
.GetMapUnit() == MAP_PIXEL
)
409 aEffSize
= pOutDev
->LogicToPixel( aSize
, aSrcMode
);
412 Fraction
aFractOne(1,1);
413 aDestMode
.SetScaleX( aFractOne
);
414 aDestMode
.SetScaleY( aFractOne
);
415 aEffSize
= OutputDevice::LogicToLogic( aSize
, aSrcMode
, aDestMode
);
417 rFont
.SetSize( aEffSize
);
419 else /* if pOutDev != NULL */
421 rFont
.SetSize( Size( 0, (long) nFontHeight
) );
424 // determine effective font color
426 if ( ( aColor
.GetColor() == COL_AUTO
&& eAutoMode
!= SC_AUTOCOL_RAW
) ||
427 eAutoMode
== SC_AUTOCOL_IGNOREFONT
|| eAutoMode
== SC_AUTOCOL_IGNOREALL
)
429 if ( eAutoMode
== SC_AUTOCOL_BLACK
)
430 aColor
.SetColor( COL_BLACK
);
433 // get background color from conditional or own set
437 const SfxPoolItem
* pItem
;
438 if ( pCondSet
->GetItemState( ATTR_BACKGROUND
, TRUE
, &pItem
) != SFX_ITEM_SET
)
439 pItem
= &rItemSet
.Get( ATTR_BACKGROUND
);
440 aBackColor
= ((const SvxBrushItem
*)pItem
)->GetColor();
443 aBackColor
= ((const SvxBrushItem
&)rItemSet
.Get( ATTR_BACKGROUND
)).GetColor();
445 // if background color attribute is transparent, use window color for brightness comparisons
446 if ( aBackColor
== COL_TRANSPARENT
||
447 eAutoMode
== SC_AUTOCOL_IGNOREBACK
|| eAutoMode
== SC_AUTOCOL_IGNOREALL
)
449 if ( eAutoMode
== SC_AUTOCOL_PRINT
)
450 aBackColor
.SetColor( COL_WHITE
);
451 else if ( pBackConfigColor
)
453 // pBackConfigColor can be used to avoid repeated lookup of the configured color
454 aBackColor
= *pBackConfigColor
;
457 aBackColor
.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR
).nColor
);
460 // get system text color for comparison
462 if ( eAutoMode
== SC_AUTOCOL_PRINT
)
463 aSysTextColor
.SetColor( COL_BLACK
);
464 else if ( pTextConfigColor
)
466 // pTextConfigColor can be used to avoid repeated lookup of the configured color
467 aSysTextColor
= *pTextConfigColor
;
470 aSysTextColor
.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR
).nColor
);
472 // select the resulting color
473 if ( aBackColor
.IsDark() && aSysTextColor
.IsDark() )
475 // use white instead of dark on dark
476 aColor
.SetColor( COL_WHITE
);
478 else if ( aBackColor
.IsBright() && aSysTextColor
.IsBright() )
480 // use black instead of bright on bright
481 aColor
.SetColor( COL_BLACK
);
485 // use aSysTextColor (black for SC_AUTOCOL_PRINT, from style settings otherwise)
486 aColor
= aSysTextColor
;
492 rFont
.SetWeight( eWeight
);
493 rFont
.SetItalic( eItalic
);
494 rFont
.SetUnderline( eUnder
);
495 rFont
.SetOverline( eOver
);
496 rFont
.SetWordLineMode( bWordLine
);
497 rFont
.SetStrikeout( eStrike
);
498 rFont
.SetOutline( bOutline
);
499 rFont
.SetShadow( bShadow
);
500 rFont
.SetEmphasisMark( eEmphasis
);
501 rFont
.SetRelief( eRelief
);
502 rFont
.SetColor( aColor
);
503 rFont
.SetTransparent( TRUE
);
506 void ScPatternAttr::GetFont(
507 Font
& rFont
, ScAutoFontColorMode eAutoMode
,
508 OutputDevice
* pOutDev
, const Fraction
* pScale
,
509 const SfxItemSet
* pCondSet
, BYTE nScript
,
510 const Color
* pBackConfigColor
, const Color
* pTextConfigColor
) const
512 GetFont( rFont
, GetItemSet(), eAutoMode
, pOutDev
, pScale
, pCondSet
, nScript
, pBackConfigColor
, pTextConfigColor
);
516 void ScPatternAttr::FillToEditItemSet( SfxItemSet
& rEditSet
, const SfxItemSet
& rSrcSet
, const SfxItemSet
* pCondSet
)
520 SvxColorItem
aColorItem(EE_CHAR_COLOR
); // use item as-is
521 SvxFontItem
aFontItem(EE_CHAR_FONTINFO
); // use item as-is
522 SvxFontItem
aCjkFontItem(EE_CHAR_FONTINFO_CJK
);
523 SvxFontItem
aCtlFontItem(EE_CHAR_FONTINFO_CTL
);
524 long nTHeight
, nCjkTHeight
, nCtlTHeight
; // Twips
525 FontWeight eWeight
, eCjkWeight
, eCtlWeight
;
526 SvxUnderlineItem
aUnderlineItem(UNDERLINE_NONE
, EE_CHAR_UNDERLINE
);
527 SvxOverlineItem
aOverlineItem(UNDERLINE_NONE
, EE_CHAR_OVERLINE
);
529 FontStrikeout eStrike
;
530 FontItalic eItalic
, eCjkItalic
, eCtlItalic
;
534 FontEmphasisMark eEmphasis
;
536 LanguageType eLang
, eCjkLang
, eCtlLang
;
538 SvxFrameDirection eDirection
;
540 //! additional parameter to control if language is needed?
544 const SfxPoolItem
* pItem
;
546 if ( pCondSet
->GetItemState( ATTR_FONT_COLOR
, TRUE
, &pItem
) != SFX_ITEM_SET
)
547 pItem
= &rSrcSet
.Get( ATTR_FONT_COLOR
);
548 aColorItem
= *(const SvxColorItem
*)pItem
;
550 if ( pCondSet
->GetItemState( ATTR_FONT
, TRUE
, &pItem
) != SFX_ITEM_SET
)
551 pItem
= &rSrcSet
.Get( ATTR_FONT
);
552 aFontItem
= *(const SvxFontItem
*)pItem
;
553 if ( pCondSet
->GetItemState( ATTR_CJK_FONT
, TRUE
, &pItem
) != SFX_ITEM_SET
)
554 pItem
= &rSrcSet
.Get( ATTR_CJK_FONT
);
555 aCjkFontItem
= *(const SvxFontItem
*)pItem
;
556 if ( pCondSet
->GetItemState( ATTR_CTL_FONT
, TRUE
, &pItem
) != SFX_ITEM_SET
)
557 pItem
= &rSrcSet
.Get( ATTR_CTL_FONT
);
558 aCtlFontItem
= *(const SvxFontItem
*)pItem
;
560 if ( pCondSet
->GetItemState( ATTR_FONT_HEIGHT
, TRUE
, &pItem
) != SFX_ITEM_SET
)
561 pItem
= &rSrcSet
.Get( ATTR_FONT_HEIGHT
);
562 nTHeight
= ((const SvxFontHeightItem
*)pItem
)->GetHeight();
563 if ( pCondSet
->GetItemState( ATTR_CJK_FONT_HEIGHT
, TRUE
, &pItem
) != SFX_ITEM_SET
)
564 pItem
= &rSrcSet
.Get( ATTR_CJK_FONT_HEIGHT
);
565 nCjkTHeight
= ((const SvxFontHeightItem
*)pItem
)->GetHeight();
566 if ( pCondSet
->GetItemState( ATTR_CTL_FONT_HEIGHT
, TRUE
, &pItem
) != SFX_ITEM_SET
)
567 pItem
= &rSrcSet
.Get( ATTR_CTL_FONT_HEIGHT
);
568 nCtlTHeight
= ((const SvxFontHeightItem
*)pItem
)->GetHeight();
570 if ( pCondSet
->GetItemState( ATTR_FONT_WEIGHT
, TRUE
, &pItem
) != SFX_ITEM_SET
)
571 pItem
= &rSrcSet
.Get( ATTR_FONT_WEIGHT
);
572 eWeight
= (FontWeight
)((const SvxWeightItem
*)pItem
)->GetValue();
573 if ( pCondSet
->GetItemState( ATTR_CJK_FONT_WEIGHT
, TRUE
, &pItem
) != SFX_ITEM_SET
)
574 pItem
= &rSrcSet
.Get( ATTR_CJK_FONT_WEIGHT
);
575 eCjkWeight
= (FontWeight
)((const SvxWeightItem
*)pItem
)->GetValue();
576 if ( pCondSet
->GetItemState( ATTR_CTL_FONT_WEIGHT
, TRUE
, &pItem
) != SFX_ITEM_SET
)
577 pItem
= &rSrcSet
.Get( ATTR_CTL_FONT_WEIGHT
);
578 eCtlWeight
= (FontWeight
)((const SvxWeightItem
*)pItem
)->GetValue();
580 if ( pCondSet
->GetItemState( ATTR_FONT_POSTURE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
581 pItem
= &rSrcSet
.Get( ATTR_FONT_POSTURE
);
582 eItalic
= (FontItalic
)((const SvxPostureItem
*)pItem
)->GetValue();
583 if ( pCondSet
->GetItemState( ATTR_CJK_FONT_POSTURE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
584 pItem
= &rSrcSet
.Get( ATTR_CJK_FONT_POSTURE
);
585 eCjkItalic
= (FontItalic
)((const SvxPostureItem
*)pItem
)->GetValue();
586 if ( pCondSet
->GetItemState( ATTR_CTL_FONT_POSTURE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
587 pItem
= &rSrcSet
.Get( ATTR_CTL_FONT_POSTURE
);
588 eCtlItalic
= (FontItalic
)((const SvxPostureItem
*)pItem
)->GetValue();
590 if ( pCondSet
->GetItemState( ATTR_FONT_UNDERLINE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
591 pItem
= &rSrcSet
.Get( ATTR_FONT_UNDERLINE
);
592 aUnderlineItem
= *(const SvxUnderlineItem
*)pItem
;
594 if ( pCondSet
->GetItemState( ATTR_FONT_OVERLINE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
595 pItem
= &rSrcSet
.Get( ATTR_FONT_OVERLINE
);
596 aOverlineItem
= *(const SvxOverlineItem
*)pItem
;
598 if ( pCondSet
->GetItemState( ATTR_FONT_WORDLINE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
599 pItem
= &rSrcSet
.Get( ATTR_FONT_WORDLINE
);
600 bWordLine
= ((const SvxWordLineModeItem
*)pItem
)->GetValue();
602 if ( pCondSet
->GetItemState( ATTR_FONT_CROSSEDOUT
, TRUE
, &pItem
) != SFX_ITEM_SET
)
603 pItem
= &rSrcSet
.Get( ATTR_FONT_CROSSEDOUT
);
604 eStrike
= (FontStrikeout
)((const SvxCrossedOutItem
*)pItem
)->GetValue();
606 if ( pCondSet
->GetItemState( ATTR_FONT_CONTOUR
, TRUE
, &pItem
) != SFX_ITEM_SET
)
607 pItem
= &rSrcSet
.Get( ATTR_FONT_CONTOUR
);
608 bOutline
= ((const SvxContourItem
*)pItem
)->GetValue();
610 if ( pCondSet
->GetItemState( ATTR_FONT_SHADOWED
, TRUE
, &pItem
) != SFX_ITEM_SET
)
611 pItem
= &rSrcSet
.Get( ATTR_FONT_SHADOWED
);
612 bShadow
= ((const SvxShadowedItem
*)pItem
)->GetValue();
614 if ( pCondSet
->GetItemState( ATTR_FORBIDDEN_RULES
, TRUE
, &pItem
) != SFX_ITEM_SET
)
615 pItem
= &rSrcSet
.Get( ATTR_FORBIDDEN_RULES
);
616 bForbidden
= ((const SvxForbiddenRuleItem
*)pItem
)->GetValue();
618 if ( pCondSet
->GetItemState( ATTR_FONT_EMPHASISMARK
, TRUE
, &pItem
) != SFX_ITEM_SET
)
619 pItem
= &rSrcSet
.Get( ATTR_FONT_EMPHASISMARK
);
620 eEmphasis
= ((const SvxEmphasisMarkItem
*)pItem
)->GetEmphasisMark();
621 if ( pCondSet
->GetItemState( ATTR_FONT_RELIEF
, TRUE
, &pItem
) != SFX_ITEM_SET
)
622 pItem
= &rSrcSet
.Get( ATTR_FONT_RELIEF
);
623 eRelief
= (FontRelief
)((const SvxCharReliefItem
*)pItem
)->GetValue();
625 if ( pCondSet
->GetItemState( ATTR_FONT_LANGUAGE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
626 pItem
= &rSrcSet
.Get( ATTR_FONT_LANGUAGE
);
627 eLang
= ((const SvxLanguageItem
*)pItem
)->GetLanguage();
628 if ( pCondSet
->GetItemState( ATTR_CJK_FONT_LANGUAGE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
629 pItem
= &rSrcSet
.Get( ATTR_CJK_FONT_LANGUAGE
);
630 eCjkLang
= ((const SvxLanguageItem
*)pItem
)->GetLanguage();
631 if ( pCondSet
->GetItemState( ATTR_CTL_FONT_LANGUAGE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
632 pItem
= &rSrcSet
.Get( ATTR_CTL_FONT_LANGUAGE
);
633 eCtlLang
= ((const SvxLanguageItem
*)pItem
)->GetLanguage();
635 if ( pCondSet
->GetItemState( ATTR_HYPHENATE
, TRUE
, &pItem
) != SFX_ITEM_SET
)
636 pItem
= &rSrcSet
.Get( ATTR_HYPHENATE
);
637 bHyphenate
= ((const SfxBoolItem
*)pItem
)->GetValue();
639 if ( pCondSet
->GetItemState( ATTR_WRITINGDIR
, TRUE
, &pItem
) != SFX_ITEM_SET
)
640 pItem
= &rSrcSet
.Get( ATTR_WRITINGDIR
);
641 eDirection
= (SvxFrameDirection
)((const SvxFrameDirectionItem
*)pItem
)->GetValue();
643 else // alles direkt aus Pattern
645 aColorItem
= (const SvxColorItem
&) rSrcSet
.Get( ATTR_FONT_COLOR
);
646 aFontItem
= (const SvxFontItem
&) rSrcSet
.Get( ATTR_FONT
);
647 aCjkFontItem
= (const SvxFontItem
&) rSrcSet
.Get( ATTR_CJK_FONT
);
648 aCtlFontItem
= (const SvxFontItem
&) rSrcSet
.Get( ATTR_CTL_FONT
);
649 nTHeight
= ((const SvxFontHeightItem
&)
650 rSrcSet
.Get( ATTR_FONT_HEIGHT
)).GetHeight();
651 nCjkTHeight
= ((const SvxFontHeightItem
&)
652 rSrcSet
.Get( ATTR_CJK_FONT_HEIGHT
)).GetHeight();
653 nCtlTHeight
= ((const SvxFontHeightItem
&)
654 rSrcSet
.Get( ATTR_CTL_FONT_HEIGHT
)).GetHeight();
655 eWeight
= (FontWeight
)((const SvxWeightItem
&)
656 rSrcSet
.Get( ATTR_FONT_WEIGHT
)).GetValue();
657 eCjkWeight
= (FontWeight
)((const SvxWeightItem
&)
658 rSrcSet
.Get( ATTR_CJK_FONT_WEIGHT
)).GetValue();
659 eCtlWeight
= (FontWeight
)((const SvxWeightItem
&)
660 rSrcSet
.Get( ATTR_CTL_FONT_WEIGHT
)).GetValue();
661 eItalic
= (FontItalic
)((const SvxPostureItem
&)
662 rSrcSet
.Get( ATTR_FONT_POSTURE
)).GetValue();
663 eCjkItalic
= (FontItalic
)((const SvxPostureItem
&)
664 rSrcSet
.Get( ATTR_CJK_FONT_POSTURE
)).GetValue();
665 eCtlItalic
= (FontItalic
)((const SvxPostureItem
&)
666 rSrcSet
.Get( ATTR_CTL_FONT_POSTURE
)).GetValue();
667 aUnderlineItem
= (const SvxUnderlineItem
&) rSrcSet
.Get( ATTR_FONT_UNDERLINE
);
668 aOverlineItem
= (const SvxOverlineItem
&) rSrcSet
.Get( ATTR_FONT_OVERLINE
);
669 bWordLine
= ((const SvxWordLineModeItem
&)
670 rSrcSet
.Get( ATTR_FONT_WORDLINE
)).GetValue();
671 eStrike
= (FontStrikeout
)((const SvxCrossedOutItem
&)
672 rSrcSet
.Get( ATTR_FONT_CROSSEDOUT
)).GetValue();
673 bOutline
= ((const SvxContourItem
&)
674 rSrcSet
.Get( ATTR_FONT_CONTOUR
)).GetValue();
675 bShadow
= ((const SvxShadowedItem
&)
676 rSrcSet
.Get( ATTR_FONT_SHADOWED
)).GetValue();
677 bForbidden
= ((const SvxForbiddenRuleItem
&)
678 rSrcSet
.Get( ATTR_FORBIDDEN_RULES
)).GetValue();
679 eEmphasis
= ((const SvxEmphasisMarkItem
&)
680 rSrcSet
.Get( ATTR_FONT_EMPHASISMARK
)).GetEmphasisMark();
681 eRelief
= (FontRelief
)((const SvxCharReliefItem
&)
682 rSrcSet
.Get( ATTR_FONT_RELIEF
)).GetValue();
683 eLang
= ((const SvxLanguageItem
&)
684 rSrcSet
.Get( ATTR_FONT_LANGUAGE
)).GetLanguage();
685 eCjkLang
= ((const SvxLanguageItem
&)
686 rSrcSet
.Get( ATTR_CJK_FONT_LANGUAGE
)).GetLanguage();
687 eCtlLang
= ((const SvxLanguageItem
&)
688 rSrcSet
.Get( ATTR_CTL_FONT_LANGUAGE
)).GetLanguage();
689 bHyphenate
= ((const SfxBoolItem
&)
690 rSrcSet
.Get( ATTR_HYPHENATE
)).GetValue();
691 eDirection
= (SvxFrameDirection
)((const SvxFrameDirectionItem
&)
692 rSrcSet
.Get( ATTR_WRITINGDIR
)).GetValue();
695 // kompatibel zu LogicToLogic rechnen, also 2540/1440 = 127/72, und runden
697 long nHeight
= TwipsToHMM(nTHeight
);
698 long nCjkHeight
= TwipsToHMM(nCjkTHeight
);
699 long nCtlHeight
= TwipsToHMM(nCtlTHeight
);
701 // put items into EditEngine ItemSet
703 if ( aColorItem
.GetValue().GetColor() == COL_AUTO
)
705 // #108979# When cell attributes are converted to EditEngine paragraph attributes,
706 // don't create a hard item for automatic color, because that would be converted
707 // to black when the item's Store method is used in CreateTransferable/WriteBin.
708 // COL_AUTO is the EditEngine's pool default, so ClearItem will result in automatic
709 // color, too, without having to store the item.
710 rEditSet
.ClearItem( EE_CHAR_COLOR
);
713 rEditSet
.Put( aColorItem
);
714 rEditSet
.Put( aFontItem
);
715 rEditSet
.Put( aCjkFontItem
);
716 rEditSet
.Put( aCtlFontItem
);
717 rEditSet
.Put( SvxFontHeightItem( nHeight
, 100, EE_CHAR_FONTHEIGHT
) );
718 rEditSet
.Put( SvxFontHeightItem( nCjkHeight
, 100, EE_CHAR_FONTHEIGHT_CJK
) );
719 rEditSet
.Put( SvxFontHeightItem( nCtlHeight
, 100, EE_CHAR_FONTHEIGHT_CTL
) );
720 rEditSet
.Put( SvxWeightItem ( eWeight
, EE_CHAR_WEIGHT
) );
721 rEditSet
.Put( SvxWeightItem ( eCjkWeight
, EE_CHAR_WEIGHT_CJK
) );
722 rEditSet
.Put( SvxWeightItem ( eCtlWeight
, EE_CHAR_WEIGHT_CTL
) );
723 rEditSet
.Put( aUnderlineItem
);
724 rEditSet
.Put( aOverlineItem
);
725 rEditSet
.Put( SvxWordLineModeItem( bWordLine
, EE_CHAR_WLM
) );
726 rEditSet
.Put( SvxCrossedOutItem( eStrike
, EE_CHAR_STRIKEOUT
) );
727 rEditSet
.Put( SvxPostureItem ( eItalic
, EE_CHAR_ITALIC
) );
728 rEditSet
.Put( SvxPostureItem ( eCjkItalic
, EE_CHAR_ITALIC_CJK
) );
729 rEditSet
.Put( SvxPostureItem ( eCtlItalic
, EE_CHAR_ITALIC_CTL
) );
730 rEditSet
.Put( SvxContourItem ( bOutline
, EE_CHAR_OUTLINE
) );
731 rEditSet
.Put( SvxShadowedItem ( bShadow
, EE_CHAR_SHADOW
) );
732 rEditSet
.Put( SfxBoolItem ( EE_PARA_FORBIDDENRULES
, bForbidden
) );
733 rEditSet
.Put( SvxEmphasisMarkItem( eEmphasis
, EE_CHAR_EMPHASISMARK
) );
734 rEditSet
.Put( SvxCharReliefItem( eRelief
, EE_CHAR_RELIEF
) );
735 rEditSet
.Put( SvxLanguageItem ( eLang
, EE_CHAR_LANGUAGE
) );
736 rEditSet
.Put( SvxLanguageItem ( eCjkLang
, EE_CHAR_LANGUAGE_CJK
) );
737 rEditSet
.Put( SvxLanguageItem ( eCtlLang
, EE_CHAR_LANGUAGE_CTL
) );
738 rEditSet
.Put( SfxBoolItem ( EE_PARA_HYPHENATE
, bHyphenate
) );
739 rEditSet
.Put( SvxFrameDirectionItem( eDirection
, EE_PARA_WRITINGDIR
) );
741 // #111216# Script spacing is always off.
742 // The cell attribute isn't used here as long as there is no UI to set it
743 // (don't evaluate attributes that can't be changed).
744 // If a locale-dependent default is needed, it has to go into the cell
745 // style, like the fonts.
746 rEditSet
.Put( SvxScriptSpaceItem( FALSE
, EE_PARA_ASIANCJKSPACING
) );
749 void ScPatternAttr::FillEditItemSet( SfxItemSet
* pEditSet
, const SfxItemSet
* pCondSet
) const
752 FillToEditItemSet( *pEditSet
, GetItemSet(), pCondSet
);
756 void ScPatternAttr::GetFromEditItemSet( SfxItemSet
& rDestSet
, const SfxItemSet
& rEditSet
)
758 const SfxPoolItem
* pItem
;
760 if (rEditSet
.GetItemState(EE_CHAR_COLOR
,TRUE
,&pItem
) == SFX_ITEM_SET
)
761 rDestSet
.Put( SvxColorItem(ATTR_FONT_COLOR
) = *(const SvxColorItem
*)pItem
);
763 if (rEditSet
.GetItemState(EE_CHAR_FONTINFO
,TRUE
,&pItem
) == SFX_ITEM_SET
)
764 rDestSet
.Put( SvxFontItem(ATTR_FONT
) = *(const SvxFontItem
*)pItem
);
765 if (rEditSet
.GetItemState(EE_CHAR_FONTINFO_CJK
,TRUE
,&pItem
) == SFX_ITEM_SET
)
766 rDestSet
.Put( SvxFontItem(ATTR_CJK_FONT
) = *(const SvxFontItem
*)pItem
);
767 if (rEditSet
.GetItemState(EE_CHAR_FONTINFO_CTL
,TRUE
,&pItem
) == SFX_ITEM_SET
)
768 rDestSet
.Put( SvxFontItem(ATTR_CTL_FONT
) = *(const SvxFontItem
*)pItem
);
770 if (rEditSet
.GetItemState(EE_CHAR_FONTHEIGHT
,TRUE
,&pItem
) == SFX_ITEM_SET
)
771 rDestSet
.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem
*)pItem
)->GetHeight() ),
772 100, ATTR_FONT_HEIGHT
) );
773 if (rEditSet
.GetItemState(EE_CHAR_FONTHEIGHT_CJK
,TRUE
,&pItem
) == SFX_ITEM_SET
)
774 rDestSet
.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem
*)pItem
)->GetHeight() ),
775 100, ATTR_CJK_FONT_HEIGHT
) );
776 if (rEditSet
.GetItemState(EE_CHAR_FONTHEIGHT_CTL
,TRUE
,&pItem
) == SFX_ITEM_SET
)
777 rDestSet
.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem
*)pItem
)->GetHeight() ),
778 100, ATTR_CTL_FONT_HEIGHT
) );
780 if (rEditSet
.GetItemState(EE_CHAR_WEIGHT
,TRUE
,&pItem
) == SFX_ITEM_SET
)
781 rDestSet
.Put( SvxWeightItem( (FontWeight
)((const SvxWeightItem
*)pItem
)->GetValue(),
783 if (rEditSet
.GetItemState(EE_CHAR_WEIGHT_CJK
,TRUE
,&pItem
) == SFX_ITEM_SET
)
784 rDestSet
.Put( SvxWeightItem( (FontWeight
)((const SvxWeightItem
*)pItem
)->GetValue(),
785 ATTR_CJK_FONT_WEIGHT
) );
786 if (rEditSet
.GetItemState(EE_CHAR_WEIGHT_CTL
,TRUE
,&pItem
) == SFX_ITEM_SET
)
787 rDestSet
.Put( SvxWeightItem( (FontWeight
)((const SvxWeightItem
*)pItem
)->GetValue(),
788 ATTR_CTL_FONT_WEIGHT
) );
790 // SvxTextLineItem contains enum and color
791 if (rEditSet
.GetItemState(EE_CHAR_UNDERLINE
,TRUE
,&pItem
) == SFX_ITEM_SET
)
792 rDestSet
.Put( SvxUnderlineItem(UNDERLINE_NONE
,ATTR_FONT_UNDERLINE
) = *(const SvxUnderlineItem
*)pItem
);
793 if (rEditSet
.GetItemState(EE_CHAR_OVERLINE
,TRUE
,&pItem
) == SFX_ITEM_SET
)
794 rDestSet
.Put( SvxOverlineItem(UNDERLINE_NONE
,ATTR_FONT_OVERLINE
) = *(const SvxOverlineItem
*)pItem
);
795 if (rEditSet
.GetItemState(EE_CHAR_WLM
,TRUE
,&pItem
) == SFX_ITEM_SET
)
796 rDestSet
.Put( SvxWordLineModeItem( ((const SvxWordLineModeItem
*)pItem
)->GetValue(),
797 ATTR_FONT_WORDLINE
) );
799 if (rEditSet
.GetItemState(EE_CHAR_STRIKEOUT
,TRUE
,&pItem
) == SFX_ITEM_SET
)
800 rDestSet
.Put( SvxCrossedOutItem( (FontStrikeout
)((const SvxCrossedOutItem
*)pItem
)->GetValue(),
801 ATTR_FONT_CROSSEDOUT
) );
803 if (rEditSet
.GetItemState(EE_CHAR_ITALIC
,TRUE
,&pItem
) == SFX_ITEM_SET
)
804 rDestSet
.Put( SvxPostureItem( (FontItalic
)((const SvxPostureItem
*)pItem
)->GetValue(),
805 ATTR_FONT_POSTURE
) );
806 if (rEditSet
.GetItemState(EE_CHAR_ITALIC_CJK
,TRUE
,&pItem
) == SFX_ITEM_SET
)
807 rDestSet
.Put( SvxPostureItem( (FontItalic
)((const SvxPostureItem
*)pItem
)->GetValue(),
808 ATTR_CJK_FONT_POSTURE
) );
809 if (rEditSet
.GetItemState(EE_CHAR_ITALIC_CTL
,TRUE
,&pItem
) == SFX_ITEM_SET
)
810 rDestSet
.Put( SvxPostureItem( (FontItalic
)((const SvxPostureItem
*)pItem
)->GetValue(),
811 ATTR_CTL_FONT_POSTURE
) );
813 if (rEditSet
.GetItemState(EE_CHAR_OUTLINE
,TRUE
,&pItem
) == SFX_ITEM_SET
)
814 rDestSet
.Put( SvxContourItem( ((const SvxContourItem
*)pItem
)->GetValue(),
815 ATTR_FONT_CONTOUR
) );
816 if (rEditSet
.GetItemState(EE_CHAR_SHADOW
,TRUE
,&pItem
) == SFX_ITEM_SET
)
817 rDestSet
.Put( SvxShadowedItem( ((const SvxShadowedItem
*)pItem
)->GetValue(),
818 ATTR_FONT_SHADOWED
) );
819 if (rEditSet
.GetItemState(EE_CHAR_EMPHASISMARK
,TRUE
,&pItem
) == SFX_ITEM_SET
)
820 rDestSet
.Put( SvxEmphasisMarkItem( ((const SvxEmphasisMarkItem
*)pItem
)->GetEmphasisMark(),
821 ATTR_FONT_EMPHASISMARK
) );
822 if (rEditSet
.GetItemState(EE_CHAR_RELIEF
,TRUE
,&pItem
) == SFX_ITEM_SET
)
823 rDestSet
.Put( SvxCharReliefItem( (FontRelief
)((const SvxCharReliefItem
*)pItem
)->GetValue(),
826 if (rEditSet
.GetItemState(EE_CHAR_LANGUAGE
,TRUE
,&pItem
) == SFX_ITEM_SET
)
827 rDestSet
.Put( SvxLanguageItem(static_cast<const SvxLanguageItem
*>(pItem
)->GetValue(), ATTR_FONT_LANGUAGE
) );
828 if (rEditSet
.GetItemState(EE_CHAR_LANGUAGE_CJK
,TRUE
,&pItem
) == SFX_ITEM_SET
)
829 rDestSet
.Put( SvxLanguageItem(static_cast<const SvxLanguageItem
*>(pItem
)->GetValue(), ATTR_CJK_FONT_LANGUAGE
) );
830 if (rEditSet
.GetItemState(EE_CHAR_LANGUAGE_CTL
,TRUE
,&pItem
) == SFX_ITEM_SET
)
831 rDestSet
.Put( SvxLanguageItem(static_cast<const SvxLanguageItem
*>(pItem
)->GetValue(), ATTR_CTL_FONT_LANGUAGE
) );
833 if (rEditSet
.GetItemState(EE_PARA_JUST
,TRUE
,&pItem
) == SFX_ITEM_SET
)
835 SvxCellHorJustify eVal
;
836 switch ( ((const SvxAdjustItem
*)pItem
)->GetAdjust() )
838 case SVX_ADJUST_LEFT
:
839 // #30154# EditEngine Default ist bei dem GetAttribs() ItemSet
841 // ob links oder rechts entscheiden wir selbst bei Text/Zahl
842 eVal
= SVX_HOR_JUSTIFY_STANDARD
;
844 case SVX_ADJUST_RIGHT
:
845 eVal
= SVX_HOR_JUSTIFY_RIGHT
;
847 case SVX_ADJUST_BLOCK
:
848 eVal
= SVX_HOR_JUSTIFY_BLOCK
;
850 case SVX_ADJUST_CENTER
:
851 eVal
= SVX_HOR_JUSTIFY_CENTER
;
853 case SVX_ADJUST_BLOCKLINE
:
854 eVal
= SVX_HOR_JUSTIFY_BLOCK
;
857 eVal
= SVX_HOR_JUSTIFY_RIGHT
;
860 eVal
= SVX_HOR_JUSTIFY_STANDARD
;
862 if ( eVal
!= SVX_HOR_JUSTIFY_STANDARD
)
863 rDestSet
.Put( SvxHorJustifyItem( eVal
, ATTR_HOR_JUSTIFY
) );
867 void ScPatternAttr::GetFromEditItemSet( const SfxItemSet
* pEditSet
)
870 GetFromEditItemSet( GetItemSet(), *pEditSet
);
873 void ScPatternAttr::FillEditParaItems( SfxItemSet
* pEditSet
) const
875 // in GetFromEditItemSet schon dabei, in FillEditItemSet aber nicht
876 // Hor. Ausrichtung Standard wird immer als "links" umgesetzt
878 const SfxItemSet
& rMySet
= GetItemSet();
880 SvxCellHorJustify eHorJust
= (SvxCellHorJustify
)
881 ((const SvxHorJustifyItem
&)rMySet
.Get(ATTR_HOR_JUSTIFY
)).GetValue();
883 SvxAdjust eSvxAdjust
;
886 case SVX_HOR_JUSTIFY_RIGHT
: eSvxAdjust
= SVX_ADJUST_RIGHT
; break;
887 case SVX_HOR_JUSTIFY_CENTER
: eSvxAdjust
= SVX_ADJUST_CENTER
; break;
888 case SVX_HOR_JUSTIFY_BLOCK
: eSvxAdjust
= SVX_ADJUST_BLOCK
; break;
889 default: eSvxAdjust
= SVX_ADJUST_LEFT
; break;
891 pEditSet
->Put( SvxAdjustItem( eSvxAdjust
, EE_PARA_JUST
) );
894 void ScPatternAttr::DeleteUnchanged( const ScPatternAttr
* pOldAttrs
)
896 SfxItemSet
& rThisSet
= GetItemSet();
897 const SfxItemSet
& rOldSet
= pOldAttrs
->GetItemSet();
899 const SfxPoolItem
* pThisItem
;
900 const SfxPoolItem
* pOldItem
;
902 for ( USHORT nSubWhich
=ATTR_PATTERN_START
; nSubWhich
<=ATTR_PATTERN_END
; nSubWhich
++ )
904 // only items that are set are interesting
905 if ( rThisSet
.GetItemState( nSubWhich
, FALSE
, &pThisItem
) == SFX_ITEM_SET
)
907 SfxItemState eOldState
= rOldSet
.GetItemState( nSubWhich
, TRUE
, &pOldItem
);
908 if ( eOldState
== SFX_ITEM_SET
)
910 // item is set in OldAttrs (or its parent) -> compare pointers
911 if ( pThisItem
== pOldItem
)
912 rThisSet
.ClearItem( nSubWhich
);
914 else if ( eOldState
!= SFX_ITEM_DONTCARE
)
916 // not set in OldAttrs -> compare item value to default item
917 if ( *pThisItem
== rThisSet
.GetPool()->GetDefaultItem( nSubWhich
) )
918 rThisSet
.ClearItem( nSubWhich
);
924 BOOL
ScPatternAttr::HasItemsSet( const USHORT
* pWhich
) const
926 const SfxItemSet
& rSet
= GetItemSet();
927 for (USHORT i
=0; pWhich
[i
]; i
++)
928 if ( rSet
.GetItemState( pWhich
[i
], FALSE
) == SFX_ITEM_SET
)
933 void ScPatternAttr::ClearItems( const USHORT
* pWhich
)
935 SfxItemSet
& rSet
= GetItemSet();
936 for (USHORT i
=0; pWhich
[i
]; i
++)
937 rSet
.ClearItem(pWhich
[i
]);
940 SfxStyleSheetBase
* lcl_CopyStyleToPool
942 SfxStyleSheetBase
* pSrcStyle
,
943 SfxStyleSheetBasePool
* pSrcPool
,
944 SfxStyleSheetBasePool
* pDestPool
,
945 const SvNumberFormatterIndexTable
* pFormatExchangeList
948 if ( !pSrcStyle
|| !pDestPool
|| !pSrcPool
)
950 DBG_ERROR( "CopyStyleToPool: Invalid Arguments :-/" );
954 //--------------------------------------------------------
956 const String aStrSrcStyle
= pSrcStyle
->GetName();
957 const SfxStyleFamily eFamily
= pSrcStyle
->GetFamily();
958 SfxStyleSheetBase
* pDestStyle
= pDestPool
->Find( aStrSrcStyle
, eFamily
);
962 const String aStrParent
= pSrcStyle
->GetParent();
963 const SfxItemSet
& rSrcSet
= pSrcStyle
->GetItemSet();
965 pDestStyle
= &pDestPool
->Make( aStrSrcStyle
, eFamily
, SFXSTYLEBIT_USERDEF
);
966 SfxItemSet
& rDestSet
= pDestStyle
->GetItemSet();
967 rDestSet
.Put( rSrcSet
);
969 // #b5017505# number format exchange list has to be handled here, too
970 // (only called for cell styles)
972 const SfxPoolItem
* pSrcItem
;
973 if ( pFormatExchangeList
&&
974 rSrcSet
.GetItemState( ATTR_VALUE_FORMAT
, FALSE
, &pSrcItem
) == SFX_ITEM_SET
)
976 ULONG nOldFormat
= static_cast<const SfxUInt32Item
*>(pSrcItem
)->GetValue();
977 sal_uInt32
* pNewFormat
= static_cast<sal_uInt32
*>(pFormatExchangeList
->Get( nOldFormat
));
979 rDestSet
.Put( SfxUInt32Item( ATTR_VALUE_FORMAT
, *pNewFormat
) );
982 // ggF. abgeleitete Styles erzeugen, wenn nicht vorhanden:
984 if ( ScGlobal::GetRscString(STR_STYLENAME_STANDARD
) != aStrParent
&&
985 aStrSrcStyle
!= aStrParent
&&
986 !pDestPool
->Find( aStrParent
, eFamily
) )
988 lcl_CopyStyleToPool( pSrcPool
->Find( aStrParent
, eFamily
),
989 pSrcPool
, pDestPool
, pFormatExchangeList
);
992 pDestStyle
->SetParent( aStrParent
);
998 ScPatternAttr
* ScPatternAttr::PutInPool( ScDocument
* pDestDoc
, ScDocument
* pSrcDoc
) const
1000 const SfxItemSet
* pSrcSet
= &GetItemSet();
1002 ScPatternAttr
* pDestPattern
= new ScPatternAttr(pDestDoc
->GetPool());
1003 SfxItemSet
* pDestSet
= &pDestPattern
->GetItemSet();
1005 // Zellformatvorlage in anderes Dokument kopieren:
1007 if ( pDestDoc
!= pSrcDoc
)
1009 DBG_ASSERT( pStyle
, "Missing Pattern-Style! :-/" );
1011 // wenn Vorlage im DestDoc vorhanden, dieses benutzen, sonst Style
1012 // mit Parent-Vorlagen kopieren/ggF. erzeugen und dem DestDoc hinzufuegen
1014 SfxStyleSheetBase
* pStyleCpy
= lcl_CopyStyleToPool( pStyle
,
1015 pSrcDoc
->GetStyleSheetPool(),
1016 pDestDoc
->GetStyleSheetPool(),
1017 pDestDoc
->GetFormatExchangeList() );
1019 pDestPattern
->SetStyleSheet( (ScStyleSheet
*)pStyleCpy
);
1022 for ( USHORT nAttrId
= ATTR_PATTERN_START
; nAttrId
<= ATTR_PATTERN_END
; nAttrId
++ )
1024 const SfxPoolItem
* pSrcItem
;
1025 SfxItemState eItemState
= pSrcSet
->GetItemState( nAttrId
, FALSE
, &pSrcItem
);
1026 if (eItemState
==SFX_ITEM_ON
)
1028 SfxPoolItem
* pNewItem
= NULL
;
1030 if ( nAttrId
== ATTR_CONDITIONAL
)
1032 // Bedingte Formate ins neue Dokument kopieren
1034 ULONG nNewIndex
= 0;
1035 ScConditionalFormatList
* pSrcList
= pSrcDoc
->GetCondFormList();
1038 ULONG nOldIndex
= ((const SfxUInt32Item
*)pSrcItem
)->GetValue();
1039 const ScConditionalFormat
* pOldData
= pSrcList
->GetFormat( nOldIndex
);
1042 nNewIndex
= pDestDoc
->AddCondFormat( *pOldData
);
1044 // zugehoerige Styles auch mitkopieren
1045 //! nur wenn Format bei Add neu angelegt
1047 ScStyleSheetPool
* pSrcSPool
= pSrcDoc
->GetStyleSheetPool();
1048 ScStyleSheetPool
* pDestSPool
= pDestDoc
->GetStyleSheetPool();
1049 const SvNumberFormatterIndexTable
* pFormatExchangeList
= pDestDoc
->GetFormatExchangeList();
1050 USHORT nStlCnt
= pOldData
->Count();
1051 for (USHORT i
=0; i
<nStlCnt
; i
++)
1053 String aName
= pOldData
->GetEntry(i
)->GetStyle();
1054 SfxStyleSheetBase
* pSrcStl
=
1055 pSrcDoc
->GetStyleSheetPool()->Find(aName
, SFX_STYLE_FAMILY_PARA
);
1056 lcl_CopyStyleToPool( pSrcStl
, pSrcSPool
, pDestSPool
, pFormatExchangeList
);
1060 pNewItem
= new SfxUInt32Item( ATTR_CONDITIONAL
, nNewIndex
);
1062 else if ( nAttrId
== ATTR_VALIDDATA
)
1064 // Gueltigkeit ins neue Dokument kopieren
1066 ULONG nNewIndex
= 0;
1067 ScValidationDataList
* pSrcList
= pSrcDoc
->GetValidationList();
1070 ULONG nOldIndex
= ((const SfxUInt32Item
*)pSrcItem
)->GetValue();
1071 const ScValidationData
* pOldData
= pSrcList
->GetData( nOldIndex
);
1073 nNewIndex
= pDestDoc
->AddValidationEntry( *pOldData
);
1075 pNewItem
= new SfxUInt32Item( ATTR_VALIDDATA
, nNewIndex
);
1077 else if ( nAttrId
== ATTR_VALUE_FORMAT
&& pDestDoc
->GetFormatExchangeList() )
1079 // Zahlformate nach Exchange-Liste
1081 ULONG nOldFormat
= ((const SfxUInt32Item
*)pSrcItem
)->GetValue();
1082 sal_uInt32
* pNewFormat
= static_cast<sal_uInt32
*>(pDestDoc
->GetFormatExchangeList()->Get(nOldFormat
));
1084 pNewItem
= new SfxUInt32Item( ATTR_VALUE_FORMAT
, (UINT32
) (*pNewFormat
) );
1089 pDestSet
->Put(*pNewItem
);
1093 pDestSet
->Put(*pSrcItem
);
1097 ScPatternAttr
* pPatternAttr
=
1098 (ScPatternAttr
*) &pDestDoc
->GetPool()->Put(*pDestPattern
);
1099 delete pDestPattern
;
1100 return pPatternAttr
;
1103 BOOL
ScPatternAttr::IsVisible() const
1105 const SfxItemSet
& rSet
= GetItemSet();
1107 const SfxPoolItem
* pItem
;
1108 SfxItemState eState
;
1110 eState
= rSet
.GetItemState( ATTR_BACKGROUND
, TRUE
, &pItem
);
1111 if ( eState
== SFX_ITEM_SET
)
1112 if ( ((const SvxBrushItem
*)pItem
)->GetColor().GetColor() != COL_TRANSPARENT
)
1115 eState
= rSet
.GetItemState( ATTR_BORDER
, TRUE
, &pItem
);
1116 if ( eState
== SFX_ITEM_SET
)
1118 const SvxBoxItem
* pBoxItem
= (SvxBoxItem
*) pItem
;
1119 if ( pBoxItem
->GetTop() || pBoxItem
->GetBottom() ||
1120 pBoxItem
->GetLeft() || pBoxItem
->GetRight() )
1124 eState
= rSet
.GetItemState( ATTR_BORDER_TLBR
, TRUE
, &pItem
);
1125 if ( eState
== SFX_ITEM_SET
)
1126 if( static_cast< const SvxLineItem
* >( pItem
)->GetLine() )
1129 eState
= rSet
.GetItemState( ATTR_BORDER_BLTR
, TRUE
, &pItem
);
1130 if ( eState
== SFX_ITEM_SET
)
1131 if( static_cast< const SvxLineItem
* >( pItem
)->GetLine() )
1134 eState
= rSet
.GetItemState( ATTR_SHADOW
, TRUE
, &pItem
);
1135 if ( eState
== SFX_ITEM_SET
)
1136 if ( ((const SvxShadowItem
*)pItem
)->GetLocation() != SVX_SHADOW_NONE
)
1142 inline BOOL
OneEqual( const SfxItemSet
& rSet1
, const SfxItemSet
& rSet2
, USHORT nId
)
1144 const SfxPoolItem
* pItem1
= &rSet1
.Get(nId
);
1145 const SfxPoolItem
* pItem2
= &rSet2
.Get(nId
);
1146 return ( pItem1
== pItem2
|| *pItem1
== *pItem2
);
1149 BOOL
ScPatternAttr::IsVisibleEqual( const ScPatternAttr
& rOther
) const
1151 const SfxItemSet
& rThisSet
= GetItemSet();
1152 const SfxItemSet
& rOtherSet
= rOther
.GetItemSet();
1154 return OneEqual( rThisSet
, rOtherSet
, ATTR_BACKGROUND
) &&
1155 OneEqual( rThisSet
, rOtherSet
, ATTR_BORDER
) &&
1156 OneEqual( rThisSet
, rOtherSet
, ATTR_BORDER_TLBR
) &&
1157 OneEqual( rThisSet
, rOtherSet
, ATTR_BORDER_BLTR
) &&
1158 OneEqual( rThisSet
, rOtherSet
, ATTR_SHADOW
);
1160 //! auch hier nur wirklich sichtbare Werte testen !!!
1163 const String
* ScPatternAttr::GetStyleName() const
1165 return pName
? pName
: ( pStyle
? &pStyle
->GetName() : NULL
);
1169 void ScPatternAttr::SetStyleSheet( ScStyleSheet
* pNewStyle
)
1173 SfxItemSet
& rPatternSet
= GetItemSet();
1174 const SfxItemSet
& rStyleSet
= pNewStyle
->GetItemSet();
1176 for (USHORT i
=ATTR_PATTERN_START
; i
<=ATTR_PATTERN_END
; i
++)
1178 if (rStyleSet
.GetItemState(i
, TRUE
) == SFX_ITEM_SET
)
1179 rPatternSet
.ClearItem(i
);
1181 rPatternSet
.SetParent(&pNewStyle
->GetItemSet());
1187 DBG_ERROR( "ScPatternAttr::SetStyleSheet( NULL ) :-|" );
1188 GetItemSet().SetParent(NULL
);
1193 void ScPatternAttr::UpdateStyleSheet()
1197 pStyle
= (ScStyleSheet
*)pDoc
->GetStyleSheetPool()->Find(*pName
, SFX_STYLE_FAMILY_PARA
);
1199 // wenn Style nicht gefunden, Standard nehmen,
1200 // damit keine leere Anzeige im Toolbox-Controller
1201 //! es wird vorausgesetzt, dass "Standard" immer der erste Eintrag ist!
1204 SfxStyleSheetIterator
* pIter
= pDoc
->GetStyleSheetPool()->CreateIterator(
1205 SFX_STYLE_FAMILY_PARA
, SFXSTYLEBIT_ALL
);
1206 pStyle
= (ScStyleSheet
*)pIter
->First();
1211 GetItemSet().SetParent(&pStyle
->GetItemSet());
1219 void ScPatternAttr::StyleToName()
1221 // Style wurde geloescht, Namen merken:
1226 *pName
= pStyle
->GetName();
1228 pName
= new String( pStyle
->GetName() );
1231 GetItemSet().SetParent( NULL
);
1235 BOOL
ScPatternAttr::IsSymbolFont() const
1237 const SfxPoolItem
* pItem
;
1238 if( GetItemSet().GetItemState( ATTR_FONT
, TRUE
, &pItem
) == SFX_ITEM_SET
)
1239 return BOOL( ((const SvxFontItem
*) pItem
)->GetCharSet()
1240 == RTL_TEXTENCODING_SYMBOL
);
1245 //UNUSED2008-05 FontToSubsFontConverter ScPatternAttr::GetSubsFontConverter( ULONG nFlags ) const
1247 //UNUSED2008-05 const SfxPoolItem* pItem;
1248 //UNUSED2008-05 if( GetItemSet().GetItemState( ATTR_FONT, TRUE, &pItem ) == SFX_ITEM_SET )
1249 //UNUSED2008-05 return CreateFontToSubsFontConverter(
1250 //UNUSED2008-05 ((const SvxFontItem*) pItem)->GetFamilyName(), nFlags );
1251 //UNUSED2008-05 else
1252 //UNUSED2008-05 return 0;
1256 ULONG
ScPatternAttr::GetNumberFormat( SvNumberFormatter
* pFormatter
) const
1259 ((SfxUInt32Item
*)&GetItemSet().Get( ATTR_VALUE_FORMAT
))->GetValue();
1260 LanguageType eLang
=
1261 ((SvxLanguageItem
*)&GetItemSet().Get( ATTR_LANGUAGE_FORMAT
))->GetLanguage();
1262 if ( nFormat
< SV_COUNTRY_LANGUAGE_OFFSET
&& eLang
== LANGUAGE_SYSTEM
)
1263 ; // es bleibt wie es ist
1264 else if ( pFormatter
)
1265 nFormat
= pFormatter
->GetFormatForLanguageIfBuiltIn( nFormat
, eLang
);
1269 // dasselbe, wenn bedingte Formatierung im Spiel ist:
1271 ULONG
ScPatternAttr::GetNumberFormat( SvNumberFormatter
* pFormatter
,
1272 const SfxItemSet
* pCondSet
) const
1274 DBG_ASSERT(pFormatter
,"GetNumberFormat ohne Formatter");
1276 const SfxPoolItem
* pFormItem
;
1277 if ( !pCondSet
|| pCondSet
->GetItemState(ATTR_VALUE_FORMAT
,TRUE
,&pFormItem
) != SFX_ITEM_SET
)
1278 pFormItem
= &GetItemSet().Get(ATTR_VALUE_FORMAT
);
1280 const SfxPoolItem
* pLangItem
;
1281 if ( !pCondSet
|| pCondSet
->GetItemState(ATTR_LANGUAGE_FORMAT
,TRUE
,&pLangItem
) != SFX_ITEM_SET
)
1282 pLangItem
= &GetItemSet().Get(ATTR_LANGUAGE_FORMAT
);
1284 return pFormatter
->GetFormatForLanguageIfBuiltIn(
1285 ((SfxUInt32Item
*)pFormItem
)->GetValue(),
1286 ((SvxLanguageItem
*)pLangItem
)->GetLanguage() );
1289 const SfxPoolItem
& ScPatternAttr::GetItem( USHORT nWhich
, const SfxItemSet
& rItemSet
, const SfxItemSet
* pCondSet
)
1291 const SfxPoolItem
* pCondItem
;
1292 if ( pCondSet
&& pCondSet
->GetItemState( nWhich
, TRUE
, &pCondItem
) == SFX_ITEM_SET
)
1294 return rItemSet
.Get(nWhich
);
1297 const SfxPoolItem
& ScPatternAttr::GetItem( USHORT nSubWhich
, const SfxItemSet
* pCondSet
) const
1299 return GetItem( nSubWhich
, GetItemSet(), pCondSet
);
1302 // GetRotateVal testet vorher ATTR_ORIENTATION
1304 long ScPatternAttr::GetRotateVal( const SfxItemSet
* pCondSet
) const
1306 long nAttrRotate
= 0;
1307 if ( GetCellOrientation() == SVX_ORIENTATION_STANDARD
)
1309 BOOL bRepeat
= ( static_cast<const SvxHorJustifyItem
&>(GetItem(ATTR_HOR_JUSTIFY
, pCondSet
)).
1310 GetValue() == SVX_HOR_JUSTIFY_REPEAT
);
1311 // ignore orientation/rotation if "repeat" is active
1313 nAttrRotate
= ((const SfxInt32Item
&)GetItem( ATTR_ROTATE_VALUE
, pCondSet
)).GetValue();
1318 BYTE
ScPatternAttr::GetRotateDir( const SfxItemSet
* pCondSet
) const
1320 BYTE nRet
= SC_ROTDIR_NONE
;
1322 long nAttrRotate
= GetRotateVal( pCondSet
);
1325 SvxRotateMode eRotMode
= (SvxRotateMode
)((const SvxRotateModeItem
&)
1326 GetItem(ATTR_ROTATE_MODE
, pCondSet
)).GetValue();
1328 if ( eRotMode
== SVX_ROTATE_MODE_STANDARD
|| nAttrRotate
== 18000 )
1329 nRet
= SC_ROTDIR_STANDARD
;
1330 else if ( eRotMode
== SVX_ROTATE_MODE_CENTER
)
1331 nRet
= SC_ROTDIR_CENTER
;
1332 else if ( eRotMode
== SVX_ROTATE_MODE_TOP
|| eRotMode
== SVX_ROTATE_MODE_BOTTOM
)
1334 long nRot180
= nAttrRotate
% 18000; // 1/100 Grad
1335 if ( nRot180
== 9000 )
1336 nRet
= SC_ROTDIR_CENTER
;
1337 else if ( ( eRotMode
== SVX_ROTATE_MODE_TOP
&& nRot180
< 9000 ) ||
1338 ( eRotMode
== SVX_ROTATE_MODE_BOTTOM
&& nRot180
> 9000 ) )
1339 nRet
= SC_ROTDIR_LEFT
;
1341 nRet
= SC_ROTDIR_RIGHT
;