xref: /AOO41X/main/sd/source/core/stlpool.cxx (revision 4bf7a51aae81eefaa1c594b1f2d068b2a05bd3a8)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include <com/sun/star/lang/DisposedException.hpp>
28 #include <editeng/eeitem.hxx>
29 #include <editeng/fhgtitem.hxx>
30 #include <editeng/colritem.hxx>
31 #include <editeng/cntritem.hxx>
32 #include <editeng/shdditem.hxx>
33 #include <editeng/crsditem.hxx>
34 #include <editeng/udlnitem.hxx>
35 #include <editeng/wghtitem.hxx>
36 #include <editeng/postitem.hxx>
37 #include <editeng/fontitem.hxx>
38 #include <svl/poolitem.hxx>
39 #include <svx/xfillit0.hxx>
40 #include <svx/xlineit0.hxx>
41 #include <editeng/ulspitem.hxx>
42 #include <editeng/numitem.hxx>
43 #include <editeng/brshitem.hxx>
44 #include <editeng/editeng.hxx>
45 #include <svl/smplhint.hxx>
46 #include <editeng/langitem.hxx>
47 #include <editeng/charreliefitem.hxx>
48 #ifndef _SVX_EMPHITEM_HXX
49 #include <editeng/emphitem.hxx>
50 #endif
51 #include <svx/sdr/table/tabledesign.hxx>
52 #include <editeng/akrnitem.hxx>
53 
54 #include <svx/svdattr.hxx>
55 #include "eetext.hxx"
56 #include <svx/xtable.hxx>           // fuer RGB_Color
57 #include <editeng/bulitem.hxx>
58 #include <editeng/lrspitem.hxx>
59 #include <editeng/adjitem.hxx>
60 #include <svl/itempool.hxx>
61 
62 #define _SDR_POSITIVE
63 #define _SDR_ITEMS
64 
65 #include "stlpool.hxx"
66 #include "sdresid.hxx"
67 #include "stlsheet.hxx"
68 #include "glob.hrc"
69 #include "glob.hxx"
70 #include "drawdoc.hxx"
71 #include "sdmod.hxx"
72 #include "sdpage.hxx"
73 #include "helpids.h"
74 #include <svl/itemset.hxx>
75 #include "app.hrc"
76 
77 using ::rtl::OUString;
78 using namespace ::com::sun::star::uno;
79 using namespace ::com::sun::star::lang;
80 using namespace ::com::sun::star::style;
81 using namespace ::com::sun::star::container;
82 
83 // ----------------------------------------------------------
84 
SdStyleSheetPool(SfxItemPool const & _rPool,SdDrawDocument * pDocument)85 SdStyleSheetPool::SdStyleSheetPool(SfxItemPool const& _rPool, SdDrawDocument* pDocument)
86 :   SdStyleSheetPoolBase( _rPool )
87 ,   mpActualStyleSheet(NULL)
88 ,   mpDoc(pDocument)
89 {
90     if( mpDoc )
91     {
92         rtl::Reference< SfxStyleSheetPool > xPool( this );
93 
94         // create graphics family
95         mxGraphicFamily = new SdStyleFamily( xPool, SD_STYLE_FAMILY_GRAPHICS );
96         mxCellFamily = new SdStyleFamily( xPool, SD_STYLE_FAMILY_CELL );
97 
98         mxTableFamily = sdr::table::CreateTableDesignFamily();
99         Reference< XNamed > xNamed( mxTableFamily, UNO_QUERY );
100         if( xNamed.is() )
101             msTableFamilyName = xNamed->getName();
102 
103         // create presentation families, one for each master page
104         const sal_uInt16 nCount = mpDoc->GetMasterSdPageCount(PK_STANDARD);
105         for( sal_uInt16 nPage = 0; nPage < nCount; ++nPage )
106             AddStyleFamily( mpDoc->GetMasterSdPage(nPage,PK_STANDARD) );
107 
108 //      StartListening( *mpDoc );
109     }
110 }
111 
112 // ----------------------------------------------------------
113 
~SdStyleSheetPool()114 SdStyleSheetPool::~SdStyleSheetPool()
115 {
116     DBG_ASSERT( mpDoc == NULL, "sd::SdStyleSheetPool::~SdStyleSheetPool(), dispose me first!" );
117 }
118 
119 // ----------------------------------------------------------
120 
Create(const String & rName,SfxStyleFamily eFamily,sal_uInt16 _nMask)121 SfxStyleSheetBase* SdStyleSheetPool::Create(const String& rName, SfxStyleFamily eFamily, sal_uInt16 _nMask )
122 {
123     return new SdStyleSheet(rName, *this, eFamily, _nMask);
124 }
125 
126 // ----------------------------------------------------------
127 
Create(const SdStyleSheet & rStyle)128 SfxStyleSheetBase* SdStyleSheetPool::Create(const SdStyleSheet& rStyle)
129 {
130     return new SdStyleSheet( rStyle );
131 }
132 
133 // ----------------------------------------------------------
134 
GetTitleSheet(const String & rLayoutName)135 SfxStyleSheetBase* SdStyleSheetPool::GetTitleSheet(const String& rLayoutName)
136 {
137     String aName(rLayoutName);
138     aName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
139     aName += String(SdResId(STR_LAYOUT_TITLE));
140     SfxStyleSheetBase* pResult = Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
141     return pResult;
142 }
143 
144 /*************************************************************************
145 |*
146 |* eine Liste der Gliederungstextvorlagen fuer ein Praesentationlayout
147 |* erstellen, der Aufrufer muss die Liste wieder loeschen
148 |*
149 \************************************************************************/
150 
CreateOutlineSheetList(const String & rLayoutName)151 List* SdStyleSheetPool::CreateOutlineSheetList (const String& rLayoutName)
152 {
153     String aName(rLayoutName);
154     aName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
155     aName += String(SdResId(STR_LAYOUT_OUTLINE));
156     List* pList = new List;
157     for (sal_uInt16 nSheet = 1; nSheet < 10; nSheet++)
158     {
159         String aFullName(aName);
160         aFullName.Append( sal_Unicode( ' ' ));
161         aFullName.Append( String::CreateFromInt32( (sal_Int32)nSheet ));
162         SfxStyleSheetBase* pSheet = Find(aFullName, SD_STYLE_FAMILY_MASTERPAGE);
163         pList->Insert(pSheet, LIST_APPEND);
164     }
165     return pList;
166 }
167 
168 /*************************************************************************
169 |*
170 |* StyleSheets mit Defaultweren fuer das genannte Praesentationslayout erzeugen
171 |*
172 \************************************************************************/
173 
CreateLayoutStyleSheets(const String & rLayoutName,sal_Bool bCheck)174 void SdStyleSheetPool::CreateLayoutStyleSheets(const String& rLayoutName, sal_Bool bCheck /*= sal_False*/ )
175 {
176     const sal_uInt16 nUsedMask = SFXSTYLEBIT_ALL & ~SFXSTYLEBIT_USERDEF;
177 
178     (void)bCheck;
179     sal_Bool bCreated = sal_False;
180 
181     SfxStyleSheetBase* pSheet = NULL;
182 
183     String aPrefix(rLayoutName);
184     String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
185     aPrefix.Insert(aSep);
186 
187     Font aLatinFont, aCJKFont, aCTLFont;
188 
189     mpDoc->getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
190 
191     // Font fuer Titel und Gliederung
192     SvxFontItem aSvxFontItem( aLatinFont.GetFamily(), aLatinFont.GetName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
193                               aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
194 
195     SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamily(), aCJKFont.GetName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
196                                  aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
197 
198     SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamily(), aCTLFont.GetName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
199                                  aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
200 
201     Font aBulletFont( GetBulletFont() );
202 
203     /**************************************************************************
204     * Gliederungsebenen
205     **************************************************************************/
206     String aName(SdResId(STR_LAYOUT_OUTLINE));
207     String aHelpFile;
208 
209     SfxStyleSheetBase* pParent = NULL;
210     SvxLRSpaceItem aSvxLRSpaceItem( EE_PARA_LRSPACE );
211     SvxULSpaceItem aSvxULSpaceItem( EE_PARA_ULSPACE );
212     sal_uInt16 nLevel;
213 
214     for( nLevel = 1; nLevel < 10; nLevel++)
215     {
216         String aLevelName(aName);
217         aLevelName.Append( sal_Unicode( ' ' ));
218         aLevelName.Append( String::CreateFromInt32( sal_Int32( nLevel )));
219 
220         aLevelName.Insert(aPrefix, 0);
221 
222         if (!Find(aLevelName, SD_STYLE_FAMILY_MASTERPAGE))
223         {
224             bCreated = sal_True;
225             pSheet = &Make(aLevelName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
226             pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_OUTLINE + nLevel );
227 
228             pSheet->SetParent( String() );
229 
230             // Attributierung fuer Level 1, die anderen Ebenen "erben"
231             if (nLevel == 1)
232             {
233                 SfxItemSet&     rSet = pSheet->GetItemSet();
234 
235                 rSet.Put(aSvxFontItem);
236                 rSet.Put(aSvxFontItemCJK);
237                 rSet.Put(aSvxFontItemCTL);
238                 rSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
239                 rSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
240                 rSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
241                 rSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
242                 rSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
243                 rSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
244                 rSet.Put( SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE ) );
245                 rSet.Put( SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE ) );
246                 rSet.Put( SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) );
247                 rSet.Put( SvxShadowedItem(sal_False, EE_CHAR_SHADOW ) );
248                 rSet.Put( SvxContourItem(sal_False, EE_CHAR_OUTLINE ) );
249                 rSet.Put( SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ) );
250                 rSet.Put( SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF) );
251                 rSet.Put( SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR) );
252                 rSet.Put( XLineStyleItem(XLINE_NONE) );
253                 rSet.Put( XFillStyleItem(XFILL_NONE) );
254                 // #i16874# enable kerning by default but only for new documents
255                 rSet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
256 
257                 if( nLevel == 1 )
258                 {
259                     Font f( GetBulletFont() );
260                     PutNumBulletItem( pSheet, f );
261                 }
262             }
263 
264             sal_uLong nFontSize = 20;
265             short nFirstIndent = -600;
266 //          sal_uInt16 nIndent = nLevel * 1200;
267             sal_uInt16 nLower = 100;
268 
269             switch (nLevel)
270             {
271                 case 1:
272                 {
273                     nFontSize = 32;
274                     nLower = 500;
275                     nFirstIndent = -900;
276                 }
277                 break;
278 
279                 case 2:
280                 {
281                     nFontSize = 28;
282                     nLower = 400;
283                     nFirstIndent = -800;
284                 }
285                 break;
286 
287                 case 3:
288                 {
289                     nFontSize = 24;
290                     nLower = 300;
291                 }
292                 break;
293 
294                 case 4:
295                 {
296                     nLower = 200;
297                 }
298                 break;
299             }
300 
301             // FontSize
302             nFontSize = (sal_uInt16)((nFontSize * 2540L) / 72);  // Pt --> 1/100 mm
303             SfxItemSet& rOutlineSet = pSheet->GetItemSet();
304             rOutlineSet.Put( SvxFontHeightItem( nFontSize, 100, EE_CHAR_FONTHEIGHT ) );
305             rOutlineSet.Put( SvxFontHeightItem( nFontSize, 100, EE_CHAR_FONTHEIGHT_CJK ) );
306             rOutlineSet.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( nFontSize ), 100, EE_CHAR_FONTHEIGHT_CTL ) );
307 
308             // Einzuege
309 /* i35937
310             aSvxLRSpaceItem.SetTxtFirstLineOfst(nFirstIndent);
311             aSvxLRSpaceItem.SetTxtLeft(nIndent);
312             aSvxLRSpaceItem.SetRight(0);
313             aSvxLRSpaceItem.SetBulletFI(sal_True);
314             pSheet->GetItemSet().Put(aSvxLRSpaceItem);
315 */
316             // Zeilendurchschuss (Abstand nach unten)
317             aSvxULSpaceItem.SetLower(nLower);
318             pSheet->GetItemSet().Put(aSvxULSpaceItem);
319 
320 /* i35937
321             if (nLevel == 1)
322             {
323                 SfxUInt16Item aBulletStateItem(EE_PARA_BULLETSTATE, 1); // Bullets sichtbar
324                 pSheet->GetItemSet().Put(aBulletStateItem);
325             }
326 */
327         }
328     }
329 
330     // if we created outline styles, we need to chain them
331     if( bCreated )
332     {
333         pParent = NULL;
334         for (nLevel = 1; nLevel < 10; nLevel++)
335         {
336             String aLevelName(aName);
337             aLevelName.Append( sal_Unicode( ' ' ));
338             aLevelName.Append( String::CreateFromInt32( sal_Int32( nLevel )));
339 
340             aLevelName.Insert(aPrefix, 0);
341 
342             pSheet = Find(aLevelName, SD_STYLE_FAMILY_MASTERPAGE);
343 
344             DBG_ASSERT( pSheet, "missing layout style!");
345 
346             if( pSheet )
347             {
348                 if (pParent)
349                     pSheet->SetParent(pParent->GetName());
350                 pParent = pSheet;
351             }
352         }
353     }
354 
355     /**************************************************************************
356     * Titel
357     **************************************************************************/
358     aName = String(SdResId(STR_LAYOUT_TITLE));
359     aName.Insert(aPrefix, 0);
360 
361     if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
362     {
363         bCreated = sal_True;
364 
365         pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
366         pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_TITLE );
367         pSheet->SetParent(String());
368         SfxItemSet& rTitleSet = pSheet->GetItemSet();
369         rTitleSet.Put(XLineStyleItem(XLINE_NONE));
370         rTitleSet.Put(XFillStyleItem(XFILL_NONE));
371         rTitleSet.Put(aSvxFontItem);
372         rTitleSet.Put(aSvxFontItemCJK);
373         rTitleSet.Put(aSvxFontItemCTL);
374         rTitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
375         rTitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
376         rTitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
377         rTitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
378         rTitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
379         rTitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
380         rTitleSet.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT ) );                 // 44 pt
381         rTitleSet.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT_CJK ) );                 // 44 pt
382         rTitleSet.Put(SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 1552 ), 100, EE_CHAR_FONTHEIGHT_CTL ) );                   // 44 pt
383         rTitleSet.Put(SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE ));
384         rTitleSet.Put(SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE ));
385         rTitleSet.Put(SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ));
386         rTitleSet.Put(SvxShadowedItem(sal_False, EE_CHAR_SHADOW ));
387         rTitleSet.Put(SvxContourItem(sal_False, EE_CHAR_OUTLINE ));
388         rTitleSet.Put( SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ) );
389         rTitleSet.Put( SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF ) );
390         rTitleSet.Put(SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR ));
391         rTitleSet.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST ));
392         rTitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
393 //      rTitleSet.Put( SfxUInt16Item(EE_PARA_BULLETSTATE, 0) );
394         // #i16874# enable kerning by default but only for new documents
395         rTitleSet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
396 
397         aBulletFont.SetSize(Size(0,1552));                  // 44 pt
398         PutNumBulletItem( pSheet, aBulletFont );
399     }
400 
401     /**************************************************************************
402     * Untertitel
403     **************************************************************************/
404     aName = String(SdResId(STR_LAYOUT_SUBTITLE));
405     aName.Insert(aPrefix, 0);
406 
407     if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
408     {
409         bCreated = sal_True;
410 
411         pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
412         pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_SUBTITLE );
413         pSheet->SetParent(String());
414         SfxItemSet& rSubtitleSet = pSheet->GetItemSet();
415         rSubtitleSet.Put(XLineStyleItem(XLINE_NONE));
416         rSubtitleSet.Put(XFillStyleItem(XFILL_NONE));
417         rSubtitleSet.Put(aSvxFontItem);
418         rSubtitleSet.Put(aSvxFontItemCJK);
419         rSubtitleSet.Put(aSvxFontItemCTL);
420         rSubtitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
421         rSubtitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
422         rSubtitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
423         rSubtitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
424         rSubtitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
425         rSubtitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
426         rSubtitleSet.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT ) );     // 32 pt
427         rSubtitleSet.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 32 pt
428         rSubtitleSet.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 1129 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 32 pt
429         rSubtitleSet.Put(SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE ));
430         rSubtitleSet.Put(SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE ));
431         rSubtitleSet.Put(SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ));
432         rSubtitleSet.Put(SvxShadowedItem(sal_False, EE_CHAR_SHADOW ));
433         rSubtitleSet.Put(SvxContourItem(sal_False, EE_CHAR_OUTLINE ));
434         rSubtitleSet.Put( SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ) );
435         rSubtitleSet.Put( SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF ) );
436         rSubtitleSet.Put(SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR ));
437         rSubtitleSet.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST ));
438         rSubtitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
439 //      rSubtitleSet.Put( SfxUInt16Item(EE_PARA_BULLETSTATE, 0) );
440         // #i16874# enable kerning by default but only for new documents
441         rSubtitleSet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
442         aSvxLRSpaceItem.SetTxtLeft(0);
443         rSubtitleSet.Put(aSvxLRSpaceItem);
444 
445         Font aTmpFont( GetBulletFont() );
446         aTmpFont.SetSize(Size(0, 1129));        // 32 pt
447         PutNumBulletItem( pSheet, aTmpFont );
448     }
449 
450     /**************************************************************************
451     * Notizen
452     **************************************************************************/
453     aName = String(SdResId(STR_LAYOUT_NOTES));
454     aName.Insert(aPrefix, 0);
455 
456     if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
457     {
458         bCreated = sal_True;
459 
460         pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
461         pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_NOTES );
462         pSheet->SetParent(String());
463         SfxItemSet& rNotesSet = pSheet->GetItemSet();
464         rNotesSet.Put(XLineStyleItem(XLINE_NONE));
465         rNotesSet.Put(XFillStyleItem(XFILL_NONE));
466         rNotesSet.Put(aSvxFontItem);
467         rNotesSet.Put(aSvxFontItemCJK);
468         rNotesSet.Put(aSvxFontItemCTL);
469         rNotesSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
470         rNotesSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
471         rNotesSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
472         rNotesSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
473         rNotesSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
474         rNotesSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
475         rNotesSet.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT ) );     // 20 pt
476         rNotesSet.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 20 pt
477         rNotesSet.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 705 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 20 pt
478         rNotesSet.Put( SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE ) );
479         rNotesSet.Put( SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE ) );
480         rNotesSet.Put( SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) );
481         rNotesSet.Put( SvxShadowedItem(sal_False, EE_CHAR_SHADOW ) );
482         rNotesSet.Put( SvxContourItem(sal_False, EE_CHAR_OUTLINE ) );
483         rNotesSet.Put( SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ) );
484         rNotesSet.Put( SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF) );
485         rNotesSet.Put( SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR ) );
486 //      rNotesSet.Put( SfxUInt16Item(EE_PARA_BULLETSTATE, 0) );
487         rNotesSet.Put( SvxLRSpaceItem( 0, 0, 600, -600, EE_PARA_LRSPACE  ) );
488         // #i16874# enable kerning by default but only for new documents
489         rNotesSet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
490 
491 /* #i35937#
492         SvxNumBulletItem aNumBullet( (const SvxNumBulletItem&) rNotesSet.Get(EE_PARA_NUMBULLET) );
493 
494         EditEngine::ImportBulletItem( aNumBullet, 0, NULL,
495                                 &(const SvxLRSpaceItem&) rNotesSet.Get( EE_PARA_LRSPACE ) );
496 
497         ( (SfxItemSet&) rNotesSet).Put( aNumBullet );
498 */
499 
500     }
501 
502     /**************************************************************************
503     * Hintergrundobjekte
504     **************************************************************************/
505     aName = String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS));
506     aName.Insert(aPrefix, 0);
507 
508     if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
509     {
510         bCreated = sal_True;
511 
512         pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
513         pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUNDOBJECTS );
514         pSheet->SetParent(String());
515         SfxItemSet& rBackgroundObjectsSet = pSheet->GetItemSet();
516         rBackgroundObjectsSet.Put(SdrShadowItem(sal_False));
517         rBackgroundObjectsSet.Put(SdrShadowColorItem(String(), Color(COL_GRAY)));
518         rBackgroundObjectsSet.Put(SdrShadowXDistItem(200)); // 3 mm Schattendistanz
519         rBackgroundObjectsSet.Put(SdrShadowYDistItem(200));
520         // #i16874# enable kerning by default but only for new documents
521         rBackgroundObjectsSet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
522         rBackgroundObjectsSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK));
523     }
524 
525     /**************************************************************************
526     * Hintergrund
527     **************************************************************************/
528     aName = String(SdResId(STR_LAYOUT_BACKGROUND));
529     aName.Insert(aPrefix, 0);
530 
531     if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
532     {
533         bCreated = sal_True;
534 
535         pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
536         pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUND );
537         pSheet->SetParent(String());
538         SfxItemSet& rBackgroundSet = pSheet->GetItemSet();
539         rBackgroundSet.Put(XLineStyleItem(XLINE_NONE));
540         rBackgroundSet.Put(XFillStyleItem(XFILL_NONE));
541         // #i16874# enable kerning by default but only for new documents
542         rBackgroundSet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
543     }
544 
545     DBG_ASSERT( !bCheck || !bCreated, "missing layout style sheets detected!" );
546 }
547 
548 /*************************************************************************
549 |*
550 |* Graphik-StyleSheets  aus dem Quellpool in diesen Pool kopieren
551 |*
552 |* (rSourcePool kann nicht const sein, weil SfxStyleSheetPoolBase::Find
553 |*  nicht const ist)
554 |*
555 \************************************************************************/
556 
CopyGraphicSheets(SdStyleSheetPool & rSourcePool)557 void SdStyleSheetPool::CopyGraphicSheets(SdStyleSheetPool& rSourcePool)
558 {
559     CopySheets( rSourcePool, SD_STYLE_FAMILY_GRAPHICS );
560 }
561 
CopyCellSheets(SdStyleSheetPool & rSourcePool)562 void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool& rSourcePool)
563 {
564     CopySheets( rSourcePool, SD_STYLE_FAMILY_CELL );
565 }
566 
CopyTableStyles(SdStyleSheetPool & rSourcePool)567 void SdStyleSheetPool::CopyTableStyles(SdStyleSheetPool& rSourcePool)
568 {
569     Reference< XIndexAccess > xSource( rSourcePool.mxTableFamily, UNO_QUERY );
570     Reference< XNameContainer > xTarget( mxTableFamily, UNO_QUERY );
571     Reference< XSingleServiceFactory > xFactory( mxTableFamily, UNO_QUERY );
572 
573     if( xSource.is() && xFactory.is() && mxTableFamily.is() )
574     {
575         for( sal_Int32 nIndex = 0; nIndex < xSource->getCount(); nIndex++ ) try
576         {
577             Reference< XStyle > xSourceTableStyle( xSource->getByIndex( nIndex ), UNO_QUERY );
578             if( xSourceTableStyle.is() )
579             {
580                 Reference< XStyle > xNewTableStyle( xFactory->createInstance(), UNO_QUERY );
581                 if( xNewTableStyle.is() )
582                 {
583                     Reference< XNameAccess> xSourceNames( xSourceTableStyle, UNO_QUERY_THROW );
584 
585                     Sequence< OUString > aStyleNames( xSourceNames->getElementNames() );
586                     OUString* pStyleNames( aStyleNames.getArray() );
587 
588                     Reference< XNameReplace > xTargetNames( xNewTableStyle, UNO_QUERY );
589 
590                     sal_Int32 nNames = aStyleNames.getLength();
591                     while( nNames-- )
592                     {
593                         const OUString aName( *pStyleNames++ );
594                         Reference< XStyle > xSourceStyle( xSourceNames->getByName( aName ), UNO_QUERY );
595                         Reference< XStyle > xTargetStyle;
596                         if( xSourceStyle.is() ) try
597                         {
598                             mxCellFamily->getByName( xSourceStyle->getName() ) >>= xTargetStyle;
599                         }
600                         catch( Exception& )
601                         {
602                             DBG_ERROR( "sd::SdStyleSheetPool::CopyTableStyles(), exception caught!" );
603                         }
604 
605                         if( xTargetStyle.is() )
606                             xTargetNames->replaceByName( aName, Any( xTargetStyle ) );
607                     }
608                 }
609 
610                 OUString sName( Reference< XNamed >( xSourceTableStyle, UNO_QUERY_THROW )->getName() );
611                 if( xTarget->hasByName( sName ) )
612                     xTarget->replaceByName( sName, Any( xNewTableStyle ) );
613                 else
614                     xTarget->insertByName( sName, Any( xNewTableStyle ) );
615             }
616         }
617         catch( Exception& )
618         {
619             DBG_ERROR("sd::SdStyleSheetPool::CopyTableStyles(), exception caught!");
620         }
621     }
622 }
623 
CopySheets(SdStyleSheetPool & rSourcePool,SfxStyleFamily eFamily)624 void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily )
625 {
626     String aHelpFile;
627 
628     sal_uInt32 nCount = rSourcePool.aStyles.size();
629 
630     std::vector< std::pair< rtl::Reference< SfxStyleSheetBase >, String > > aNewStyles;
631 
632     for (sal_uInt32 n = 0; n < nCount; n++)
633     {
634         rtl::Reference< SfxStyleSheetBase > xSheet( rSourcePool.aStyles[sal::static_int_cast<sal_uInt16>(n)] );
635 
636         if( xSheet->GetFamily() == eFamily )
637         {
638             String aName( xSheet->GetName() );
639             if ( !Find( aName, eFamily ) )
640             {
641                 rtl::Reference< SfxStyleSheetBase > xNewSheet( &Make( aName, eFamily ) );
642 
643                 xNewSheet->SetMask( xSheet->GetMask() );
644 
645                 // #91588# Also set parent relation for copied style sheets
646                 String aParent( xSheet->GetParent() );
647                 if( aParent.Len() )
648                     aNewStyles.push_back( std::pair< rtl::Reference< SfxStyleSheetBase >, String >( xNewSheet, aParent ) );
649 
650                 xNewSheet->SetHelpId( aHelpFile, xSheet->GetHelpId( aHelpFile ) );
651                 xNewSheet->GetItemSet().Put( xSheet->GetItemSet() );
652             }
653         }
654     }
655 
656     // set parents on newly added stylesheets
657     std::vector< std::pair< rtl::Reference< SfxStyleSheetBase >, String > >::iterator aIter;
658     for( aIter = aNewStyles.begin(); aIter != aNewStyles.end(); aIter++ )
659     {
660         DBG_ASSERT( rSourcePool.Find( (*aIter).second, eFamily ), "StyleSheet has invalid parent: Family mismatch" );
661         (*aIter).first->SetParent( (*aIter).second );
662     }
663 }
664 
665 
666 /*************************************************************************
667 |*
668 |* StyleSheets des genannten Praesentationslayouts aus dem Quellpool in diesen
669 |* Pool kopieren. Kopiert werden nur solche StyleSheets, die in diesem Pool
670 |* noch nicht vorhanden sind.
671 |* pCreatedSheets wird - wenn ungleich NULL - mit Zeigern auf die erzeugten
672 |* StyleSheets gefuellt.
673 |*
674 |* (rSourcePool kann nicht const sein, weil SfxStyleSheetPoolBase::Find
675 |*  nicht const ist)
676 |*
677 \************************************************************************/
678 
CopyLayoutSheets(const String & rLayoutName,SdStyleSheetPool & rSourcePool,SdStyleSheetVector & rCreatedSheets)679 void SdStyleSheetPool::CopyLayoutSheets(const String& rLayoutName, SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets)
680 {
681     SfxStyleSheetBase* pSheet = NULL;
682 
683     String aOutlineTag(SdResId(STR_LAYOUT_OUTLINE));
684 
685     List* pNameList = CreateLayoutSheetNames(rLayoutName);
686 
687     String sEmpty;
688     String* pName = (String*)pNameList->First();
689     while (pName)
690     {
691         pSheet = Find(*pName, SD_STYLE_FAMILY_MASTERPAGE);
692         if (!pSheet)
693         {
694             SfxStyleSheetBase* pSourceSheet = rSourcePool.Find(*pName, SD_STYLE_FAMILY_MASTERPAGE);
695             DBG_ASSERT(pSourceSheet, "CopyLayoutSheets: Quellvorlage nicht gefunden");
696             if (pSourceSheet)
697             {
698                 // falls einer mit Methusalem-Doks. ankommt
699                 SfxStyleSheetBase& rNewSheet = Make(*pName, SD_STYLE_FAMILY_MASTERPAGE);
700                 rNewSheet.SetHelpId( sEmpty, pSourceSheet->GetHelpId( sEmpty ) );
701                 rNewSheet.GetItemSet().Put(pSourceSheet->GetItemSet());
702                 rCreatedSheets.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( &rNewSheet ) ) );
703             }
704         }
705         delete pName;
706         pName = (String*)pNameList->Next();
707     }
708     delete pNameList;
709 
710     // Sonderbehandlung fuer Gliederungsvorlagen: Parentbeziehungen aufbauen
711     List* pOutlineSheets = CreateOutlineSheetList(rLayoutName);
712     SfxStyleSheetBase* pParent = (SfxStyleSheetBase*)pOutlineSheets->First();
713     pSheet = (SfxStyleSheetBase*)pOutlineSheets->Next();
714     while (pSheet)
715     {
716         // kein Parent?
717         if (pSheet->GetParent().Len() == 0)
718             pSheet->SetParent(pParent->GetName());
719         pParent = pSheet;
720         pSheet = (SfxStyleSheetBase*)pOutlineSheets->Next();
721     }
722     delete pOutlineSheets;
723 }
724 
725 /*************************************************************************
726 |*
727 |* Liste mit den Namen der Praesentationsvorlagen eines Layouts erzeugen.
728 |* Die Liste und die enthaltenen Strings gehoeren dem Caller!
729 |*
730 \************************************************************************/
731 
CreateLayoutSheetNames(const String & rLayoutName) const732 List* SdStyleSheetPool::CreateLayoutSheetNames(const String& rLayoutName) const
733 {
734     String aPrefix(rLayoutName);
735     String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
736     aPrefix.Insert(aSep);
737 
738     List* pNameList = new List;
739 
740     String aName(SdResId(STR_LAYOUT_OUTLINE));
741     String* pName = NULL;
742 
743     for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
744     {
745         pName = new String(aName);
746         pName->Append( sal_Unicode( ' ' ));
747         pName->Append( String::CreateFromInt32( sal_Int32( nLevel )));
748         pName->Insert(aPrefix, 0);
749         pNameList->Insert(pName, LIST_APPEND);
750     }
751 
752     pName = new String(SdResId(STR_LAYOUT_TITLE));
753     pName->Insert(aPrefix, 0);
754     pNameList->Insert(pName, LIST_APPEND);
755 
756     pName = new String(SdResId(STR_LAYOUT_SUBTITLE));
757     pName->Insert(aPrefix, 0);
758     pNameList->Insert(pName, LIST_APPEND);
759 
760     pName = new String(SdResId(STR_LAYOUT_NOTES));
761     pName->Insert(aPrefix, 0);
762     pNameList->Insert(pName, LIST_APPEND);
763 
764     pName = new String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS));
765     pName->Insert(aPrefix, 0);
766     pNameList->Insert(pName, LIST_APPEND);
767 
768     pName = new String(SdResId(STR_LAYOUT_BACKGROUND));
769     pName->Insert(aPrefix, 0);
770     pNameList->Insert(pName, LIST_APPEND);
771 
772     return pNameList;
773 }
774 
775 /*************************************************************************
776 |*
777 |* Liste mit Zeigern auf Praesentationsvorlagen eines Layouts erzeugen.
778 |* Die Liste gehoert dem Caller!
779 |*
780 \************************************************************************/
781 
CreateLayoutSheetList(const String & rLayoutName,SdStyleSheetVector & rLayoutSheets)782 void SdStyleSheetPool::CreateLayoutSheetList(const String& rLayoutName, SdStyleSheetVector& rLayoutSheets )
783 {
784     String aLayoutNameWithSep(rLayoutName);
785     aLayoutNameWithSep.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
786     sal_uInt16 nLen = aLayoutNameWithSep.Len();
787 
788     SfxStyleSheetIterator aIter(this, SD_STYLE_FAMILY_MASTERPAGE);
789     SfxStyleSheetBase* pSheet = aIter.First();
790 
791     while (pSheet)
792     {
793         if (pSheet->GetName().Match(aLayoutNameWithSep) == nLen)
794             rLayoutSheets.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( pSheet ) ) );
795         pSheet = aIter.Next();
796     }
797 }
798 
799 /*************************************************************************
800 |*
801 |* ggfs. PseudoStyleSheets erzeugen
802 |*
803 \************************************************************************/
804 
CreatePseudosIfNecessary()805 void SdStyleSheetPool::CreatePseudosIfNecessary()
806 {
807     String aName;
808     String aHelpFile;
809     SfxStyleSheetBase* pSheet = NULL;
810     SfxStyleSheetBase* pParent = NULL;
811 
812     //sal_uInt16 nUsedMask = SFXSTYLEBIT_ALL & ~SFXSTYLEBIT_USERDEF;
813     sal_uInt16 nUsedMask = SFXSTYLEBIT_USED;
814 
815     aName = String(SdResId(STR_PSEUDOSHEET_TITLE));
816     if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
817     {
818         pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
819         pSheet->SetParent( String() );
820         ((SfxStyleSheet*)pSheet)->StartListening(*this);
821     }
822     pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_TITLE );
823 
824     aName = String(SdResId(STR_PSEUDOSHEET_SUBTITLE));
825     if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
826     {
827         pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
828         pSheet->SetParent(String());
829         ((SfxStyleSheet*)pSheet)->StartListening(*this);
830     }
831     pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_SUBTITLE );
832 
833     aName = String(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS));
834     if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
835     {
836         pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
837         pSheet->SetParent( String() );
838         ((SfxStyleSheet*)pSheet)->StartListening(*this);
839     }
840     pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUNDOBJECTS );
841 
842     aName = String(SdResId(STR_PSEUDOSHEET_BACKGROUND));
843     if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
844     {
845         pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
846         pSheet->SetParent( String() );
847         ((SfxStyleSheet*)pSheet)->StartListening(*this);
848     }
849     pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUND );
850 
851     aName = String(SdResId(STR_PSEUDOSHEET_NOTES));
852     if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
853     {
854         pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
855         pSheet->SetParent( String() );
856         ((SfxStyleSheet*)pSheet)->StartListening(*this);
857     }
858     pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_NOTES );
859 
860     pParent = NULL;
861     SetSearchMask(SD_STYLE_FAMILY_PSEUDO);
862     aName = String(SdResId(STR_PSEUDOSHEET_OUTLINE));
863     for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
864     {
865         String aLevelName(aName);
866         aLevelName.Append( sal_Unicode( ' ' ));
867         aLevelName.Append( String::CreateFromInt32( sal_Int32( nLevel )));
868 
869         if( (pSheet = Find(aLevelName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
870         {
871             pSheet = &Make(aLevelName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
872 
873             if (pSheet)
874             {
875                 if (pParent)
876                     pSheet->SetParent(pParent->GetName());
877                 pParent = pSheet;
878                 ((SfxStyleSheet*)pSheet)->StartListening(*this);
879             }
880         }
881         pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_OUTLINE + nLevel );
882     }
883 }
884 
885 
886 /*************************************************************************
887 |*
888 |* Standard-Styles den richtigen Namen in der Programm-Sprache geben
889 |*
890 \************************************************************************/
891 
UpdateStdNames()892 void SdStyleSheetPool::UpdateStdNames()
893 {
894     String aHelpFile;
895     sal_uInt32  nCount = aStyles.size();
896     List* pEraseList = NULL;
897 
898     for( sal_uInt32 n=0; n < nCount; n++ )
899     {
900         SfxStyleSheetBase* pStyle = aStyles[ n ].get();
901 
902         if( !pStyle->IsUserDefined() )
903         {
904             String aOldName     = pStyle->GetName();
905             sal_uLong nHelpId       = pStyle->GetHelpId( aHelpFile );
906             SfxStyleFamily eFam = pStyle->GetFamily();
907 
908             sal_Bool bHelpKnown = sal_True;
909             String aNewName;
910             sal_uInt16 nNameId = 0;
911             switch( nHelpId )
912             {
913                 case HID_STANDARD_STYLESHEET_NAME:  nNameId = STR_STANDARD_STYLESHEET_NAME; break;
914                 case HID_POOLSHEET_OBJWITHARROW:    nNameId = STR_POOLSHEET_OBJWITHARROW;   break;
915                 case HID_POOLSHEET_OBJWITHSHADOW:   nNameId = STR_POOLSHEET_OBJWITHSHADOW;  break;
916                 case HID_POOLSHEET_OBJWITHOUTFILL:  nNameId = STR_POOLSHEET_OBJWITHOUTFILL; break;
917                 case HID_POOLSHEET_OBJNOLINENOFILL: nNameId = STR_POOLSHEET_OBJNOLINENOFILL;break;
918                 case HID_POOLSHEET_TEXT:            nNameId = STR_POOLSHEET_TEXT;           break;
919                 case HID_POOLSHEET_TEXTBODY:        nNameId = STR_POOLSHEET_TEXTBODY;       break;
920                 case HID_POOLSHEET_TEXTBODY_JUSTIFY:nNameId = STR_POOLSHEET_TEXTBODY_JUSTIFY;break;
921                 case HID_POOLSHEET_TEXTBODY_INDENT: nNameId = STR_POOLSHEET_TEXTBODY_INDENT;break;
922                 case HID_POOLSHEET_TITLE:           nNameId = STR_POOLSHEET_TITLE;          break;
923                 case HID_POOLSHEET_TITLE1:          nNameId = STR_POOLSHEET_TITLE1;         break;
924                 case HID_POOLSHEET_TITLE2:          nNameId = STR_POOLSHEET_TITLE2;         break;
925                 case HID_POOLSHEET_HEADLINE:        nNameId = STR_POOLSHEET_HEADLINE;       break;
926                 case HID_POOLSHEET_HEADLINE1:       nNameId = STR_POOLSHEET_HEADLINE1;      break;
927                 case HID_POOLSHEET_HEADLINE2:       nNameId = STR_POOLSHEET_HEADLINE2;      break;
928                 case HID_POOLSHEET_MEASURE:         nNameId = STR_POOLSHEET_MEASURE;        break;
929 
930                 case HID_PSEUDOSHEET_TITLE:         nNameId = STR_PSEUDOSHEET_TITLE;        break;
931                 case HID_PSEUDOSHEET_SUBTITLE:      nNameId = STR_PSEUDOSHEET_SUBTITLE;     break;
932                 case HID_PSEUDOSHEET_OUTLINE1:
933                 case HID_PSEUDOSHEET_OUTLINE2:
934                 case HID_PSEUDOSHEET_OUTLINE3:
935                 case HID_PSEUDOSHEET_OUTLINE4:
936                 case HID_PSEUDOSHEET_OUTLINE5:
937                 case HID_PSEUDOSHEET_OUTLINE6:
938                 case HID_PSEUDOSHEET_OUTLINE7:
939                 case HID_PSEUDOSHEET_OUTLINE8:
940                 case HID_PSEUDOSHEET_OUTLINE9:      nNameId = STR_PSEUDOSHEET_OUTLINE;      break;
941                 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS: nNameId = STR_PSEUDOSHEET_BACKGROUNDOBJECTS; break;
942                 case HID_PSEUDOSHEET_BACKGROUND:    nNameId = STR_PSEUDOSHEET_BACKGROUND;   break;
943                 case HID_PSEUDOSHEET_NOTES:         nNameId = STR_PSEUDOSHEET_NOTES;        break;
944 
945                 case HID_SD_CELL_STYLE_DEFAULT:         nNameId = STR_STANDARD_STYLESHEET_NAME; break;
946                 case HID_SD_CELL_STYLE_BANDED:          nNameId = STR_POOLSHEET_BANDED_CELL; break;
947                 case HID_SD_CELL_STYLE_HEADER:          nNameId = STR_POOLSHEET_HEADER; break;
948                 case HID_SD_CELL_STYLE_TOTAL:           nNameId = STR_POOLSHEET_TOTAL; break;
949                 case HID_SD_CELL_STYLE_FIRST_COLUMN:    nNameId = STR_POOLSHEET_FIRST_COLUMN; break;
950                 case HID_SD_CELL_STYLE_LAST_COLUMN:     nNameId = STR_POOLSHEET_LAST_COLUMN; break;
951 
952                 default:
953                     // 0 oder falsche (alte) HelpId
954                     bHelpKnown = sal_False;
955             }
956             if( bHelpKnown )
957             {
958                 if( nNameId )
959                 {
960                     aNewName = String( SdResId( nNameId ) );
961                     if( nNameId == STR_PSEUDOSHEET_OUTLINE )
962                     {
963                         aNewName.Append( sal_Unicode( ' ' ));
964                         aNewName.Append( String::CreateFromInt32( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE )));
965                     }
966                 }
967 
968                 if( aNewName.Len() && aNewName != aOldName )
969                 {
970                     SfxStyleSheetBase* pSheetFound = Find( aNewName, eFam );
971 
972                     if ( !pSheetFound )
973                     {
974                         // Sheet existiert noch nicht: Altes Sheet wird umbenannt
975                         pStyle->SetName( aNewName );    // setzt auch Parents um
976                     }
977                     else
978                     {
979                         // Sheet existiert schon: Altes Sheet muss entfernt werden
980                         if( !pEraseList )
981                         {
982                             pEraseList = new List();
983                         }
984 
985                         pEraseList->Insert( pStyle );
986                     }
987                 }
988             }
989         }
990     }
991 
992     if ( pEraseList )
993     {
994         // Styles, welche nicht umbenannt werden konnten, muessen entfernt werden
995         for ( sal_uLong i = 0; i < pEraseList->Count(); i++ )
996         {
997             SfxStyleSheetBase* pEraseSheet = ( SfxStyleSheetBase* ) pEraseList->GetObject( i );
998             Remove( pEraseSheet );
999         }
1000 
1001         delete pEraseList;
1002         pEraseList = NULL;
1003     }
1004 }
1005 // --------------------------------------------------------------------
1006 // Neues SvxNumBulletItem fuer das jeweilige StyleSheet setzen
1007 // --------------------------------------------------------------------
1008 
PutNumBulletItem(SfxStyleSheetBase * pSheet,Font & rBulletFont)1009 void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet,
1010                                          Font& rBulletFont )
1011 {
1012     String aHelpFile;
1013     sal_uLong nHelpId = pSheet->GetHelpId( aHelpFile );
1014     SfxItemSet& rSet = pSheet->GetItemSet();
1015 
1016     switch ( nHelpId )
1017     {
1018         case HID_STANDARD_STYLESHEET_NAME :
1019         {
1020             // Standard-Vorlage
1021             SvxNumberFormat aNumberFormat(SVX_NUM_CHAR_SPECIAL);
1022             aNumberFormat.SetBulletFont(&rBulletFont);
1023             aNumberFormat.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1024             aNumberFormat.SetBulletRelSize(45);
1025             aNumberFormat.SetBulletColor(Color(COL_AUTO));
1026             aNumberFormat.SetStart(1);
1027             aNumberFormat.SetNumAdjust(SVX_ADJUST_LEFT);
1028 
1029             SvxNumRule aNumRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE, 10 , sal_False);
1030 
1031             for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
1032             {
1033                 const short nLSpace = (i + 1) * 600;
1034                 aNumberFormat.SetLSpace(nLSpace);
1035                 aNumberFormat.SetAbsLSpace(nLSpace);
1036                 aNumberFormat.SetFirstLineOffset(-600);
1037                 aNumRule.SetLevel( i, aNumberFormat );
1038             }
1039 
1040             rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) );
1041             ((SfxStyleSheet*)pSheet)->Broadcast(SfxSimpleHint( SFX_HINT_DATACHANGED ) );
1042         }
1043         break;
1044 
1045         case HID_PSEUDOSHEET_TITLE:
1046             /* #84013# title gets same bullet as subtitle and not that page symbol anymore */
1047         case HID_PSEUDOSHEET_SUBTITLE :
1048         {
1049             // Untertitel-Vorlage
1050             SvxNumRule* pDefaultRule = ((SvxNumBulletItem*) rSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET))->GetNumRule();
1051             DBG_ASSERT( pDefaultRule, "Wo ist mein Default? [CL]" );
1052 
1053             if(pDefaultRule)
1054             {
1055                 SvxNumRule aNumRule(pDefaultRule->GetFeatureFlags(), 10, sal_False);
1056                 for(sal_uInt16 i=0; i < aNumRule.GetLevelCount(); i++)
1057                 {
1058                     SvxNumberFormat aFrmt( pDefaultRule->GetLevel(i) );
1059                     aFrmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
1060                     // #i93908# clear suffix for bullet lists
1061                     aFrmt.SetPrefix(::rtl::OUString());
1062                     aFrmt.SetSuffix(::rtl::OUString());
1063                     aFrmt.SetStart(1);
1064                     aFrmt.SetBulletRelSize(45);
1065                     aFrmt.SetBulletChar( 0x25CF );  // StarBats: 0xF000 + 34
1066                     aFrmt.SetBulletFont(&rBulletFont);
1067                     aNumRule.SetLevel(i, aFrmt);
1068                 }
1069 
1070                 rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) );
1071                 ((SfxStyleSheet*)pSheet)->Broadcast(SfxSimpleHint( SFX_HINT_DATACHANGED ) );
1072             }
1073         }
1074         break;
1075 
1076         case HID_PSEUDOSHEET_OUTLINE + 1 :
1077         {
1078             // Gliederungs-Vorlage
1079             SvxNumberFormat aNumberFormat(SVX_NUM_CHAR_SPECIAL);
1080             aNumberFormat.SetBulletColor(Color(COL_AUTO));
1081             aNumberFormat.SetStart(1);
1082             aNumberFormat.SetNumAdjust(SVX_ADJUST_LEFT);
1083 
1084             SvxNumRule aNumRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE|NUM_SYMBOL_ALIGNMENT,
1085                                  10, sal_False );
1086             for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
1087             {
1088                 aNumberFormat.SetBulletChar( 0x25CF );  // StarBats: 0xF000 + 34
1089                 aNumberFormat.SetBulletRelSize(45);
1090                 const short nLSpace = (i + 1) * 1200;
1091                 aNumberFormat.SetLSpace(nLSpace);
1092                 aNumberFormat.SetAbsLSpace(nLSpace);
1093                 short nFirstLineOffset = -600;
1094 
1095                 sal_uLong nFontSize = 20;
1096                 switch(i)
1097                 {
1098                     case 0:
1099                     {
1100                         nFontSize = 32;
1101                         nFirstLineOffset = -900;
1102                     }
1103                     break;
1104 
1105                     case 1:
1106                     {
1107                         aNumberFormat.SetBulletChar( 0x2013 );  // StarBats: 0xF000 + 150
1108                         aNumberFormat.SetBulletRelSize(75);
1109                         nFontSize = 32;
1110                         nFirstLineOffset = -900;
1111                     }
1112                     break;
1113 
1114                     case 2:
1115                     {
1116                         nFontSize = 28;
1117                         nFirstLineOffset = -800;
1118                     }
1119                     break;
1120 
1121                     case 3:
1122                     {
1123                         aNumberFormat.SetBulletChar( 0x2013 );  // StarBats: 0xF000 + 150
1124                         aNumberFormat.SetBulletRelSize(75);
1125                         nFontSize = 24;
1126                     }
1127                     break;
1128                 }
1129 
1130                 aNumberFormat.SetFirstLineOffset(nFirstLineOffset);
1131                 nFontSize = (sal_uInt16)((nFontSize * 2540L) / 72);  // Pt --> 1/100 mm
1132                 rBulletFont.SetSize(Size(0,846));       // 24 pt
1133                 aNumberFormat.SetBulletFont(&rBulletFont);
1134                 aNumRule.SetLevel( i, aNumberFormat );
1135             }
1136 
1137             rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) );
1138             ((SfxStyleSheet*)pSheet)->Broadcast(SfxSimpleHint( SFX_HINT_DATACHANGED ) );
1139         }
1140         break;
1141     }
1142 }
1143 
1144 /*************************************************************************
1145 |*
1146 |* Standard Bullet-Font erzeugen (ohne Groesse)
1147 |*
1148 \************************************************************************/
1149 
GetBulletFont() const1150 Font SdStyleSheetPool::GetBulletFont() const
1151 {
1152     Font aBulletFont( String( RTL_CONSTASCII_USTRINGPARAM( "StarSymbol" )), Size(0, 1000) );
1153     aBulletFont.SetCharSet(RTL_TEXTENCODING_UNICODE);
1154     aBulletFont.SetWeight(WEIGHT_NORMAL);
1155     aBulletFont.SetUnderline(UNDERLINE_NONE);
1156     aBulletFont.SetOverline(UNDERLINE_NONE);
1157     aBulletFont.SetStrikeout(STRIKEOUT_NONE);
1158     aBulletFont.SetItalic(ITALIC_NONE);
1159     aBulletFont.SetOutline(sal_False);
1160     aBulletFont.SetShadow(sal_False);
1161     aBulletFont.SetColor(Color(COL_AUTO));
1162     aBulletFont.SetTransparent(sal_True);
1163 
1164     return aBulletFont;
1165 }
1166 
1167 // --------------------------------------------------------------------
1168 
AddStyleFamily(const SdPage * pPage)1169 void SdStyleSheetPool::AddStyleFamily( const SdPage* pPage )
1170 {
1171     rtl::Reference< SfxStyleSheetPool > xPool( this );
1172     maStyleFamilyMap[pPage] = new SdStyleFamily( xPool, pPage );
1173 }
1174 
1175 // --------------------------------------------------------------------
1176 
RemoveStyleFamily(const SdPage * pPage)1177 void SdStyleSheetPool::RemoveStyleFamily( const SdPage* pPage )
1178 {
1179     SdStyleFamilyMap::iterator iter( maStyleFamilyMap.find( pPage ) );
1180     if( iter != maStyleFamilyMap.end() )
1181     {
1182         SdStyleFamilyRef xStyle( (*iter).second );
1183         maStyleFamilyMap.erase( iter );
1184 
1185         if( xStyle.is() ) try
1186         {
1187             xStyle->dispose();
1188         }
1189         catch( Exception& )
1190         {
1191         }
1192     }
1193 }
1194 
1195 // --------------------------------------------------------------------
1196 
throwIfDisposed()1197 void SdStyleSheetPool::throwIfDisposed() throw(::com::sun::star::uno::RuntimeException)
1198 {
1199     if( mpDoc == NULL )
1200         throw DisposedException();
1201 }
1202 
1203 // --------------------------------------------------------------------
1204 // XServiceInfo
1205 // --------------------------------------------------------------------
1206 
getImplementationName()1207 OUString SAL_CALL SdStyleSheetPool::getImplementationName() throw(RuntimeException)
1208 {
1209     return OUString( RTL_CONSTASCII_USTRINGPARAM("SdStyleSheetPool") );
1210 }
1211 
1212 // --------------------------------------------------------------------
1213 
1214 static const sal_Char* gpServiceName = "com.sun.star.style.StyleFamilies";
1215 
supportsService(const OUString & ServiceName)1216 sal_Bool SAL_CALL SdStyleSheetPool::supportsService( const OUString& ServiceName ) throw(RuntimeException)
1217 {
1218     return ServiceName.equalsAscii( gpServiceName );
1219 }
1220 
1221 // --------------------------------------------------------------------
1222 
getSupportedServiceNames()1223 Sequence< OUString > SAL_CALL SdStyleSheetPool::getSupportedServiceNames() throw(RuntimeException)
1224 {
1225     OUString aStr( OUString::createFromAscii( gpServiceName ) );
1226     return Sequence< OUString >( &aStr, 1 );
1227 }
1228 
1229 // --------------------------------------------------------------------
1230 // XNameAccess
1231 // --------------------------------------------------------------------
1232 
getByName(const OUString & aName)1233 Any SAL_CALL SdStyleSheetPool::getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
1234 {
1235     throwIfDisposed();
1236 
1237     if( mxGraphicFamily->getName() == aName )
1238         return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxGraphicFamily.get() ) ) );
1239 
1240     if( mxCellFamily->getName() == aName )
1241         return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxCellFamily.get() ) ) );
1242 
1243     if( msTableFamilyName == aName )
1244         return Any( mxTableFamily );
1245 
1246     for( SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() ); iter != maStyleFamilyMap.end(); iter++ )
1247     {
1248         if( (*iter).second->getName() == aName )
1249             return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( (*iter).second.get() ) ) );
1250     }
1251 
1252     throw NoSuchElementException();
1253 }
1254 
1255 // --------------------------------------------------------------------
1256 
getElementNames()1257 Sequence< OUString > SAL_CALL SdStyleSheetPool::getElementNames() throw(RuntimeException)
1258 {
1259     throwIfDisposed();
1260 
1261     Sequence< OUString > aNames( maStyleFamilyMap.size() + 3 );
1262     OUString* pNames = aNames.getArray();
1263 
1264     *pNames++ = mxGraphicFamily->getName();
1265     *pNames++ = mxCellFamily->getName();
1266     *pNames++ = msTableFamilyName;
1267 
1268     for( SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() ); iter != maStyleFamilyMap.end(); iter++ )
1269     {
1270         *pNames++ = (*iter).second->getName();
1271     }
1272 
1273     return aNames;
1274 }
1275 
1276 // --------------------------------------------------------------------
1277 
hasByName(const OUString & aName)1278 sal_Bool SAL_CALL SdStyleSheetPool::hasByName( const OUString& aName ) throw(RuntimeException)
1279 {
1280     throwIfDisposed();
1281 
1282     if( mxGraphicFamily->getName() == aName )
1283         return sal_True;
1284 
1285     if( mxCellFamily->getName() == aName )
1286         return sal_True;
1287 
1288     if( msTableFamilyName == aName )
1289         return sal_True;
1290 
1291     for( SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() ); iter != maStyleFamilyMap.end(); iter++ )
1292     {
1293         if( (*iter).second->getName() == aName )
1294             return sal_True;
1295     }
1296 
1297     return sal_False;
1298 }
1299 
1300 // --------------------------------------------------------------------
1301 // XElementAccess
1302 // --------------------------------------------------------------------
1303 
getElementType()1304 Type SAL_CALL SdStyleSheetPool::getElementType() throw(RuntimeException)
1305 {
1306     throwIfDisposed();
1307 
1308     return XNameAccess::static_type();
1309 }
1310 
1311 // --------------------------------------------------------------------
1312 
hasElements()1313 sal_Bool SAL_CALL SdStyleSheetPool::hasElements() throw(RuntimeException)
1314 {
1315     return sal_True;
1316 }
1317 
1318 // --------------------------------------------------------------------
1319 // XIndexAccess
1320 // --------------------------------------------------------------------
1321 
getCount()1322 sal_Int32 SAL_CALL SdStyleSheetPool::getCount() throw(RuntimeException)
1323 {
1324     throwIfDisposed();
1325 
1326     return maStyleFamilyMap.size() + 3;
1327 }
1328 
1329 // --------------------------------------------------------------------
1330 
getByIndex(sal_Int32 Index)1331 Any SAL_CALL SdStyleSheetPool::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
1332 {
1333     switch( Index )
1334     {
1335     case 0:
1336         return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxGraphicFamily.get() ) ) );
1337 
1338     case 1:
1339         return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxCellFamily.get() ) ) );
1340 
1341     case 2:
1342         return Any( mxTableFamily );
1343 
1344     default:
1345         {
1346             Index -= 3;
1347             if( (Index < 0) || (Index >= sal::static_int_cast<sal_Int32>(maStyleFamilyMap.size())) )
1348                 throw IndexOutOfBoundsException();
1349             SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() );
1350             while( Index-- )
1351                 iter++;
1352 
1353             return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( (*iter).second.get() ) ) );
1354         }
1355     }
1356 }
1357 
1358 // --------------------------------------------------------------------
1359 // XComponent
1360 // --------------------------------------------------------------------
1361 
dispose()1362 void SAL_CALL SdStyleSheetPool::dispose() throw (RuntimeException)
1363 {
1364     if( mpDoc )
1365     {
1366         mxGraphicFamily->dispose();
1367         mxGraphicFamily.clear();
1368         mxCellFamily->dispose();
1369         mxCellFamily.clear();
1370 
1371         Reference< XComponent > xComp( mxTableFamily, UNO_QUERY );
1372         if( xComp.is() )
1373             xComp->dispose();
1374         mxTableFamily = 0;
1375 
1376         SdStyleFamilyMap aTempMap;
1377         aTempMap.swap( maStyleFamilyMap );
1378 
1379         for( SdStyleFamilyMap::iterator iter( aTempMap.begin() ); iter != aTempMap.end(); iter++ ) try
1380         {
1381             (*iter).second->dispose();
1382         }
1383         catch( Exception& )
1384         {
1385         }
1386 
1387 //      EndListening( *mpDoc );
1388         mpDoc = 0;
1389 
1390         Clear();
1391     }
1392 }
1393 
1394 // --------------------------------------------------------------------
1395 
addEventListener(const Reference<XEventListener> &)1396 void SAL_CALL SdStyleSheetPool::addEventListener( const Reference< XEventListener >& /*xListener*/ ) throw (RuntimeException)
1397 {
1398 }
1399 
1400 // --------------------------------------------------------------------
1401 
removeEventListener(const Reference<XEventListener> &)1402 void SAL_CALL SdStyleSheetPool::removeEventListener( const Reference< XEventListener >& /*aListener*/ ) throw (RuntimeException)
1403 {
1404 }
1405 
1406 // --------------------------------------------------------------------
1407 
CreateChildList(SdStyleSheet * pSheet)1408 SdStyleSheetVector SdStyleSheetPool::CreateChildList( SdStyleSheet* pSheet )
1409 {
1410     SdStyleSheetVector aResult;
1411 
1412     sal_uInt16 nListenerCount = pSheet->GetListenerCount();
1413     if (nListenerCount > 0)
1414     {
1415         for (sal_uInt16 n = 0; n < nListenerCount; n++)
1416         {
1417             SdStyleSheet* pChild = dynamic_cast< SdStyleSheet* >( pSheet->GetListener(n) );
1418             if(pChild && pChild->GetParent() == pSheet->GetName())
1419             {
1420                 aResult.push_back( SdStyleSheetRef( pChild ) );
1421             }
1422         }
1423     }
1424 
1425     return aResult;
1426 }
1427 
1428 // --------------------------------------------------------------------
1429 
acquire(void)1430 void SAL_CALL SdStyleSheetPool::acquire (void) throw ()
1431 {
1432     SdStyleSheetPoolBase::acquire();
1433 }
1434 
release(void)1435 void SAL_CALL SdStyleSheetPool::release (void) throw ()
1436 {
1437     SdStyleSheetPoolBase::release();
1438 }
1439 
1440 // --------------------------------------------------------------------
1441