merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / func / bulmaper.cxx
blobaae1dec75928225cf8e9dbeada2b57fb9d770005
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bulmaper.cxx,v $
10 * $Revision: 1.10.80.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_sd.hxx"
34 #ifdef SD_DLLIMPLEMENTATION
35 #undef SD_DLLIMPLEMENTATION
36 #endif
38 #ifndef _SVX_SVXIDS_HRC
39 #include <svx/svxids.hrc>
40 #endif
42 //-> Fonts & Items
43 #include <vcl/font.hxx>
44 #include <svx/fontitem.hxx>
45 #include <svx/fhgtitem.hxx>
46 #include <svx/wghtitem.hxx>
47 #include <svx/udlnitem.hxx>
48 #include <svx/crsditem.hxx>
49 #include <svx/postitem.hxx>
50 #include <svx/cntritem.hxx>
51 #include <svx/shdditem.hxx>
53 //<- Fonts & Items
54 #include <svx/bulitem.hxx>
55 #include <svx/brshitem.hxx>
56 #include <vcl/graph.hxx>
57 #include <svtools/itemset.hxx>
58 #include <svtools/itempool.hxx>
59 #include <svx/numitem.hxx>
60 #include <svx/eeitem.hxx>
62 #include "bulmaper.hxx"
65 #define GetWhich(nSlot) rSet.GetPool()->GetWhich( nSlot )
67 /* #i35937#
69 void SdBulletMapper::PreMapNumBulletForDialog( SfxItemSet& rSet )
71 if( SFX_ITEM_SET == rSet.GetItemState( EE_PARA_NUMBULLET, FALSE ) )
73 SvxNumRule* pRule = ((SvxNumBulletItem*)rSet.GetItem( EE_PARA_NUMBULLET ))->GetNumRule();
75 if(pRule && pRule->GetNumRuleType() == SVX_RULETYPE_PRESENTATION_NUMBERING)
77 // 10er Bullet Item auf 9er Item mappen
78 SvxNumRule aNewRule( pRule->GetFeatureFlags(), 9, FALSE, SVX_RULETYPE_PRESENTATION_NUMBERING );
80 for( USHORT i = 0; i < 9; i++ )
81 aNewRule.SetLevel(i, pRule->GetLevel(i));
83 rSet.Put( SvxNumBulletItem( aNewRule, EE_PARA_NUMBULLET ) );
88 void SdBulletMapper::PostMapNumBulletForDialog( SfxItemSet& rSet )
90 if( SFX_ITEM_SET == rSet.GetItemState( EE_PARA_NUMBULLET, FALSE ) )
92 SvxNumRule* pRule = ((SvxNumBulletItem*)rSet.GetItem( EE_PARA_NUMBULLET ))->GetNumRule();
94 if(pRule)
96 pRule->UnLinkGraphics();
97 if(pRule->GetNumRuleType() == SVX_RULETYPE_PRESENTATION_NUMBERING)
99 // 9er Bullet Item auf 10er Item mappen
100 SvxNumRule aNewRule( pRule->GetFeatureFlags(), 10, FALSE, SVX_RULETYPE_PRESENTATION_NUMBERING );
102 for( USHORT i = 0; i < 9; i++ )
103 aNewRule.SetLevel(i, pRule->GetLevel(i));
105 rSet.Put( SvxNumBulletItem( aNewRule, EE_PARA_NUMBULLET ) );
112 void SdBulletMapper::MapFontsInNumRule( SvxNumRule& aNumRule, const SfxItemSet& rSet )
114 const USHORT nCount = aNumRule.GetLevelCount();
115 for( USHORT nLevel = 0; nLevel < nCount; nLevel++ )
117 const SvxNumberFormat& rSrcLevel = aNumRule.GetLevel(nLevel);
118 SvxNumberFormat aNewLevel( rSrcLevel );
120 if(rSrcLevel.GetNumberingType() != com::sun::star::style::NumberingType::CHAR_SPECIAL &&
121 rSrcLevel.GetNumberingType() != com::sun::star::style::NumberingType::NUMBER_NONE )
123 // wenn Aufzaehlung statt Bullet gewaehlt wurde, wird der Bullet-Font
124 // dem Vorlagen-Font angeglichen
126 // to be implemented if module supports CJK
127 long nFontID = SID_ATTR_CHAR_FONT;
128 long nFontHeightID = SID_ATTR_CHAR_FONTHEIGHT;
129 long nWeightID = SID_ATTR_CHAR_WEIGHT;
130 long nPostureID = SID_ATTR_CHAR_POSTURE;
132 if( 0 )
134 nFontID = EE_CHAR_FONTINFO_CJK;
135 nFontHeightID = EE_CHAR_FONTHEIGHT_CJK;
136 nWeightID = EE_CHAR_WEIGHT_CJK;
137 nPostureID = EE_CHAR_ITALIC_CJK;
139 else if( 0 )
141 nFontID = EE_CHAR_FONTINFO_CTL;
142 nFontHeightID = EE_CHAR_FONTHEIGHT_CTL;
143 nWeightID = EE_CHAR_WEIGHT_CTL;
144 nPostureID = EE_CHAR_ITALIC_CTL;
147 Font aMyFont;
148 const SvxFontItem& rFItem =
149 (SvxFontItem&)rSet.Get(GetWhich( (USHORT)nFontID ));
150 aMyFont.SetFamily(rFItem.GetFamily());
151 aMyFont.SetName(rFItem.GetFamilyName());
152 aMyFont.SetCharSet(rFItem.GetCharSet());
153 aMyFont.SetPitch(rFItem.GetPitch());
155 const SvxFontHeightItem& rFHItem =
156 (SvxFontHeightItem&)rSet.Get(GetWhich( (USHORT)nFontHeightID ));
157 aMyFont.SetSize(Size(0, rFHItem.GetHeight()));
159 const SvxWeightItem& rWItem =
160 (SvxWeightItem&)rSet.Get(GetWhich( (USHORT)nWeightID ));
161 aMyFont.SetWeight(rWItem.GetWeight());
163 const SvxPostureItem& rPItem =
164 (SvxPostureItem&)rSet.Get(GetWhich( (USHORT)nPostureID ));
165 aMyFont.SetItalic(rPItem.GetPosture());
167 const SvxUnderlineItem& rUItem = (SvxUnderlineItem&)rSet.Get(GetWhich(SID_ATTR_CHAR_UNDERLINE));
168 aMyFont.SetUnderline(rUItem.GetLineStyle());
170 const SvxOverlineItem& rOItem = (SvxOverlineItem&)rSet.Get(GetWhich(SID_ATTR_CHAR_OVERLINE));
171 aMyFont.SetOverline(rOItem.GetLineStyle());
173 const SvxCrossedOutItem& rCOItem = (SvxCrossedOutItem&)rSet.Get(GetWhich(SID_ATTR_CHAR_STRIKEOUT));
174 aMyFont.SetStrikeout(rCOItem.GetStrikeout());
176 const SvxContourItem& rCItem = (SvxContourItem&)rSet.Get(GetWhich(SID_ATTR_CHAR_CONTOUR));
177 aMyFont.SetOutline(rCItem.GetValue());
179 const SvxShadowedItem& rSItem = (SvxShadowedItem&)rSet.Get(GetWhich(SID_ATTR_CHAR_SHADOWED));
180 aMyFont.SetShadow(rSItem.GetValue());
182 aNewLevel.SetBulletFont(&aMyFont);
183 // aNewLevel.SetBulletRelSize( 75 );
184 aNumRule.SetLevel(nLevel, aNewLevel );
186 else if( rSrcLevel.GetNumberingType() == com::sun::star::style::NumberingType::CHAR_SPECIAL )
188 String aEmpty;
189 aNewLevel.SetPrefix( aEmpty );
190 aNewLevel.SetSuffix( aEmpty );
191 aNumRule.SetLevel(nLevel, aNewLevel );