xref: /trunk/main/sd/source/ui/func/bulmaper.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 #ifdef SD_DLLIMPLEMENTATION
32 #undef SD_DLLIMPLEMENTATION
33 #endif
34 
35 #ifndef _SVX_SVXIDS_HRC
36 #include <svx/svxids.hrc>
37 #endif
38 
39 //-> Fonts & Items
40 #include <vcl/font.hxx>
41 #include <editeng/fontitem.hxx>
42 #include <editeng/fhgtitem.hxx>
43 #include <editeng/wghtitem.hxx>
44 #include <editeng/udlnitem.hxx>
45 #include <editeng/crsditem.hxx>
46 #include <editeng/postitem.hxx>
47 #include <editeng/cntritem.hxx>
48 #include <editeng/shdditem.hxx>
49 
50 //<- Fonts & Items
51 #include <editeng/bulitem.hxx>
52 #include <editeng/brshitem.hxx>
53 #include <vcl/graph.hxx>
54 #include <svl/itemset.hxx>
55 #include <svl/itempool.hxx>
56 #include <editeng/numitem.hxx>
57 #include <editeng/eeitem.hxx>
58 
59 #include "bulmaper.hxx"
60 
61 
62 #define GetWhich(nSlot) rSet.GetPool()->GetWhich( nSlot )
63 
64 /* #i35937#
65 
66 void SdBulletMapper::PreMapNumBulletForDialog( SfxItemSet& rSet )
67 {
68     if( SFX_ITEM_SET == rSet.GetItemState( EE_PARA_NUMBULLET, sal_False ) )
69     {
70         SvxNumRule* pRule = ((SvxNumBulletItem*)rSet.GetItem( EE_PARA_NUMBULLET ))->GetNumRule();
71 
72         if(pRule && pRule->GetNumRuleType() == SVX_RULETYPE_PRESENTATION_NUMBERING)
73         {
74             // 10er Bullet Item auf 9er Item mappen
75             SvxNumRule aNewRule( pRule->GetFeatureFlags(), 9, sal_False, SVX_RULETYPE_PRESENTATION_NUMBERING );
76 
77             for( sal_uInt16 i = 0; i < 9; i++ )
78                 aNewRule.SetLevel(i, pRule->GetLevel(i));
79 
80             rSet.Put( SvxNumBulletItem( aNewRule, EE_PARA_NUMBULLET ) );
81         }
82     }
83 }
84 
85 void SdBulletMapper::PostMapNumBulletForDialog( SfxItemSet& rSet )
86 {
87     if( SFX_ITEM_SET == rSet.GetItemState( EE_PARA_NUMBULLET, sal_False ) )
88     {
89         SvxNumRule* pRule = ((SvxNumBulletItem*)rSet.GetItem( EE_PARA_NUMBULLET ))->GetNumRule();
90 
91         if(pRule)
92         {
93             pRule->UnLinkGraphics();
94             if(pRule->GetNumRuleType() == SVX_RULETYPE_PRESENTATION_NUMBERING)
95             {
96                 // 9er Bullet Item auf 10er Item mappen
97                 SvxNumRule aNewRule( pRule->GetFeatureFlags(), 10, sal_False, SVX_RULETYPE_PRESENTATION_NUMBERING );
98 
99                 for( sal_uInt16 i = 0; i < 9; i++ )
100                     aNewRule.SetLevel(i, pRule->GetLevel(i));
101 
102                 rSet.Put( SvxNumBulletItem( aNewRule, EE_PARA_NUMBULLET ) );
103             }
104         }
105     }
106 }
107 */
108 
109 void SdBulletMapper::MapFontsInNumRule( SvxNumRule& aNumRule, const SfxItemSet& rSet )
110 {
111     const sal_uInt16 nCount = aNumRule.GetLevelCount();
112     for( sal_uInt16 nLevel = 0; nLevel < nCount; nLevel++ )
113     {
114         const SvxNumberFormat& rSrcLevel = aNumRule.GetLevel(nLevel);
115         SvxNumberFormat aNewLevel( rSrcLevel );
116 
117         if(rSrcLevel.GetNumberingType() != com::sun::star::style::NumberingType::CHAR_SPECIAL &&
118            rSrcLevel.GetNumberingType() != com::sun::star::style::NumberingType::NUMBER_NONE )
119         {
120             // wenn Aufzaehlung statt Bullet gewaehlt wurde, wird der Bullet-Font
121             // dem Vorlagen-Font angeglichen
122 
123             // to be implemented if module supports CJK
124             long nFontID = SID_ATTR_CHAR_FONT;
125             long nFontHeightID = SID_ATTR_CHAR_FONTHEIGHT;
126             long nWeightID = SID_ATTR_CHAR_WEIGHT;
127             long nPostureID = SID_ATTR_CHAR_POSTURE;
128 
129             if( 0 )
130             {
131                 nFontID = EE_CHAR_FONTINFO_CJK;
132                 nFontHeightID = EE_CHAR_FONTHEIGHT_CJK;
133                 nWeightID = EE_CHAR_WEIGHT_CJK;
134                 nPostureID = EE_CHAR_ITALIC_CJK;
135             }
136             else if( 0 )
137             {
138                 nFontID = EE_CHAR_FONTINFO_CTL;
139                 nFontHeightID = EE_CHAR_FONTHEIGHT_CTL;
140                 nWeightID = EE_CHAR_WEIGHT_CTL;
141                 nPostureID = EE_CHAR_ITALIC_CTL;
142             }
143 
144             Font aMyFont;
145             const SvxFontItem& rFItem =
146                 (SvxFontItem&)rSet.Get(GetWhich( (sal_uInt16)nFontID ));
147             aMyFont.SetFamily(rFItem.GetFamily());
148             aMyFont.SetName(rFItem.GetFamilyName());
149             aMyFont.SetCharSet(rFItem.GetCharSet());
150             aMyFont.SetPitch(rFItem.GetPitch());
151 
152             const SvxFontHeightItem& rFHItem =
153                 (SvxFontHeightItem&)rSet.Get(GetWhich( (sal_uInt16)nFontHeightID ));
154             aMyFont.SetSize(Size(0, rFHItem.GetHeight()));
155 
156             const SvxWeightItem& rWItem =
157                 (SvxWeightItem&)rSet.Get(GetWhich( (sal_uInt16)nWeightID ));
158             aMyFont.SetWeight(rWItem.GetWeight());
159 
160             const SvxPostureItem& rPItem =
161                 (SvxPostureItem&)rSet.Get(GetWhich( (sal_uInt16)nPostureID ));
162             aMyFont.SetItalic(rPItem.GetPosture());
163 
164             const SvxUnderlineItem& rUItem = (SvxUnderlineItem&)rSet.Get(GetWhich(SID_ATTR_CHAR_UNDERLINE));
165             aMyFont.SetUnderline(rUItem.GetLineStyle());
166 
167             const SvxOverlineItem& rOItem = (SvxOverlineItem&)rSet.Get(GetWhich(SID_ATTR_CHAR_OVERLINE));
168             aMyFont.SetOverline(rOItem.GetLineStyle());
169 
170             const SvxCrossedOutItem& rCOItem = (SvxCrossedOutItem&)rSet.Get(GetWhich(SID_ATTR_CHAR_STRIKEOUT));
171             aMyFont.SetStrikeout(rCOItem.GetStrikeout());
172 
173             const SvxContourItem& rCItem = (SvxContourItem&)rSet.Get(GetWhich(SID_ATTR_CHAR_CONTOUR));
174             aMyFont.SetOutline(rCItem.GetValue());
175 
176             const SvxShadowedItem& rSItem = (SvxShadowedItem&)rSet.Get(GetWhich(SID_ATTR_CHAR_SHADOWED));
177             aMyFont.SetShadow(rSItem.GetValue());
178 
179             aNewLevel.SetBulletFont(&aMyFont);
180 //          aNewLevel.SetBulletRelSize( 75 );
181             aNumRule.SetLevel(nLevel, aNewLevel );
182         }
183         else if( rSrcLevel.GetNumberingType() == com::sun::star::style::NumberingType::CHAR_SPECIAL )
184         {
185             String aEmpty;
186             aNewLevel.SetPrefix( aEmpty );
187             aNewLevel.SetSuffix( aEmpty );
188             aNumRule.SetLevel(nLevel, aNewLevel );
189         }
190     }
191 }
192