update credits
[LibreOffice.git] / sd / source / core / stlpool.cxx
blob488e6f540d3a4827b42961f6ac1d37e0f790fe29
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <com/sun/star/lang/DisposedException.hpp>
22 #include <editeng/eeitem.hxx>
23 #include <editeng/fhgtitem.hxx>
24 #include <editeng/colritem.hxx>
25 #include <editeng/contouritem.hxx>
26 #include <editeng/shdditem.hxx>
27 #include <editeng/crossedoutitem.hxx>
28 #include <editeng/udlnitem.hxx>
29 #include <editeng/wghtitem.hxx>
30 #include <editeng/postitem.hxx>
31 #include <editeng/fontitem.hxx>
32 #include <svl/poolitem.hxx>
33 #include <svx/xfillit0.hxx>
34 #include <svx/xlineit0.hxx>
35 #include <editeng/ulspitem.hxx>
36 #include <editeng/numitem.hxx>
37 #include <editeng/brushitem.hxx>
38 #include <editeng/editeng.hxx>
39 #include <svl/smplhint.hxx>
40 #include <editeng/langitem.hxx>
41 #include <editeng/charreliefitem.hxx>
42 #include <editeng/emphasismarkitem.hxx>
43 #include <svx/sdr/table/tabledesign.hxx>
44 #include <editeng/autokernitem.hxx>
46 #include <svx/svdattr.hxx>
47 #include <editeng/outliner.hxx>
48 #include <svx/xtable.hxx> // for RGB_Color
49 #include <editeng/bulletitem.hxx>
50 #include <editeng/lrspitem.hxx>
51 #include <editeng/adjustitem.hxx>
52 #include <editeng/numdef.hxx>
53 #include <svl/itempool.hxx>
55 #include "stlpool.hxx"
56 #include "sdresid.hxx"
57 #include "stlsheet.hxx"
58 #include "glob.hrc"
59 #include "glob.hxx"
60 #include "drawdoc.hxx"
61 #include "sdmod.hxx"
62 #include "sdpage.hxx"
63 #include "helpids.h"
64 #include <svl/itemset.hxx>
65 #include "app.hrc"
67 using namespace ::com::sun::star::uno;
68 using namespace ::com::sun::star::lang;
69 using namespace ::com::sun::star::style;
70 using namespace ::com::sun::star::container;
72 // ----------------------------------------------------------
74 SdStyleSheetPool::SdStyleSheetPool(SfxItemPool const& _rPool, SdDrawDocument* pDocument)
75 : SdStyleSheetPoolBase( _rPool )
76 , mpActualStyleSheet(NULL)
77 , mpDoc(pDocument)
79 if( mpDoc )
81 rtl::Reference< SfxStyleSheetPool > xPool( this );
83 // create graphics family
84 mxGraphicFamily = new SdStyleFamily( xPool, SD_STYLE_FAMILY_GRAPHICS );
85 mxCellFamily = new SdStyleFamily( xPool, SD_STYLE_FAMILY_CELL );
87 mxTableFamily = sdr::table::CreateTableDesignFamily();
88 Reference< XNamed > xNamed( mxTableFamily, UNO_QUERY );
89 if( xNamed.is() )
90 msTableFamilyName = xNamed->getName();
92 // create presentation families, one for each master page
93 const sal_uInt16 nCount = mpDoc->GetMasterSdPageCount(PK_STANDARD);
94 for( sal_uInt16 nPage = 0; nPage < nCount; ++nPage )
95 AddStyleFamily( mpDoc->GetMasterSdPage(nPage,PK_STANDARD) );
100 // ----------------------------------------------------------
102 SdStyleSheetPool::~SdStyleSheetPool()
104 DBG_ASSERT( mpDoc == NULL, "sd::SdStyleSheetPool::~SdStyleSheetPool(), dispose me first!" );
107 // ----------------------------------------------------------
109 SfxStyleSheetBase* SdStyleSheetPool::Create(const String& rName, SfxStyleFamily eFamily, sal_uInt16 _nMask )
111 return new SdStyleSheet(rName, *this, eFamily, _nMask);
114 // ----------------------------------------------------------
116 SfxStyleSheetBase* SdStyleSheetPool::Create(const SdStyleSheet& rStyle)
118 return new SdStyleSheet( rStyle );
121 // ----------------------------------------------------------
123 SfxStyleSheetBase* SdStyleSheetPool::GetTitleSheet(const String& rLayoutName)
125 String aName(rLayoutName);
126 aName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
127 aName += String(SdResId(STR_LAYOUT_TITLE));
128 SfxStyleSheetBase* pResult = Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
129 return pResult;
132 /*************************************************************************
134 |* Create a list of outline text templates for a presentation layout.
135 |* The caller has to delete the list.
137 \************************************************************************/
139 void SdStyleSheetPool::CreateOutlineSheetList (const String& rLayoutName, std::vector<SfxStyleSheetBase*> &rOutlineStyles)
141 String aName(rLayoutName);
142 aName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
143 aName += String(SdResId(STR_LAYOUT_OUTLINE));
145 for (sal_uInt16 nSheet = 1; nSheet < 10; nSheet++)
147 String aFullName(aName);
148 aFullName.Append( sal_Unicode( ' ' ));
149 aFullName.Append( OUString::number( (sal_Int32)nSheet ));
150 SfxStyleSheetBase* pSheet = Find(aFullName, SD_STYLE_FAMILY_MASTERPAGE);
152 if (pSheet)
153 rOutlineStyles.push_back(pSheet);
157 /*************************************************************************
159 |* Create style sheets with default values for the named presentation layout
161 \************************************************************************/
163 void SdStyleSheetPool::CreateLayoutStyleSheets(const String& rLayoutName, sal_Bool bCheck /*= sal_False*/ )
165 const sal_uInt16 nUsedMask = SFXSTYLEBIT_ALL & ~SFXSTYLEBIT_USERDEF;
167 (void)bCheck;
168 sal_Bool bCreated = sal_False;
170 SfxStyleSheetBase* pSheet = NULL;
172 String aPrefix(rLayoutName);
173 String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
174 aPrefix.Insert(aSep);
176 Font aLatinFont, aCJKFont, aCTLFont;
178 mpDoc->getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
180 // Font for title and outline
181 SvxFontItem aSvxFontItem( aLatinFont.GetFamily(), aLatinFont.GetName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
182 aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
184 SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamily(), aCJKFont.GetName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
185 aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
187 SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamily(), aCTLFont.GetName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
188 aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
190 Font aBulletFont( GetBulletFont() );
192 /**************************************************************************
193 * outline levels
194 **************************************************************************/
195 String aName(SdResId(STR_LAYOUT_OUTLINE));
196 OUString aHelpFile;
198 SfxStyleSheetBase* pParent = NULL;
199 SvxLRSpaceItem aSvxLRSpaceItem( EE_PARA_LRSPACE );
200 SvxULSpaceItem aSvxULSpaceItem( EE_PARA_ULSPACE );
201 sal_uInt16 nLevel;
203 for( nLevel = 1; nLevel < 10; nLevel++)
205 String aLevelName(aName);
206 aLevelName.Append( sal_Unicode( ' ' ));
207 aLevelName.Append( OUString::number( sal_Int32( nLevel )));
209 aLevelName.Insert(aPrefix, 0);
211 if (!Find(aLevelName, SD_STYLE_FAMILY_MASTERPAGE))
213 bCreated = sal_True;
214 pSheet = &Make(aLevelName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
215 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_OUTLINE + nLevel );
217 pSheet->SetParent( String() );
219 // attributing for level 1, the others levels inherit
220 if (nLevel == 1)
222 SfxItemSet& rSet = pSheet->GetItemSet();
224 rSet.Put(aSvxFontItem);
225 rSet.Put(aSvxFontItemCJK);
226 rSet.Put(aSvxFontItemCTL);
227 rSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
228 rSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
229 rSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
230 rSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
231 rSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
232 rSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
233 rSet.Put( SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE ) );
234 rSet.Put( SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE ) );
235 rSet.Put( SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) );
236 rSet.Put( SvxShadowedItem(sal_False, EE_CHAR_SHADOW ) );
237 rSet.Put( SvxContourItem(sal_False, EE_CHAR_OUTLINE ) );
238 rSet.Put( SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ) );
239 rSet.Put( SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF) );
240 rSet.Put( SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR) );
241 rSet.Put( XLineStyleItem(XLINE_NONE) );
242 rSet.Put( XFillStyleItem(XFILL_NONE) );
243 rSet.Put( SdrTextFitToSizeTypeItem(SDRTEXTFIT_AUTOFIT) );
244 rSet.Put( SdrTextAutoGrowHeightItem(sal_False) );
245 // #i16874# enable kerning by default but only for new documents
246 rSet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
248 if( nLevel == 1 )
250 Font f( GetBulletFont() );
251 PutNumBulletItem( pSheet, f );
255 sal_uLong nFontSize = 20;
256 sal_uInt16 nLower = 100;
258 switch (nLevel)
260 case 1:
262 nFontSize = 32;
263 nLower = 500;
265 break;
267 case 2:
269 nFontSize = 28;
270 nLower = 400;
272 break;
274 case 3:
276 nFontSize = 24;
277 nLower = 300;
279 break;
281 case 4:
283 nLower = 200;
285 break;
288 // FontSize
289 nFontSize = (sal_uInt16)((nFontSize * 2540L) / 72); // Pt --> 1/100 mm
290 SfxItemSet& rOutlineSet = pSheet->GetItemSet();
291 rOutlineSet.Put( SvxFontHeightItem( nFontSize, 100, EE_CHAR_FONTHEIGHT ) );
292 rOutlineSet.Put( SvxFontHeightItem( nFontSize, 100, EE_CHAR_FONTHEIGHT_CJK ) );
293 rOutlineSet.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( nFontSize ), 100, EE_CHAR_FONTHEIGHT_CTL ) );
295 // Line distance (downwards). Stuff around here cleaned up in i35937
296 aSvxULSpaceItem.SetLower(nLower);
297 pSheet->GetItemSet().Put(aSvxULSpaceItem);
301 // if we created outline styles, we need to chain them
302 if( bCreated )
304 pParent = NULL;
305 for (nLevel = 1; nLevel < 10; nLevel++)
307 String aLevelName(aName);
308 aLevelName.Append( sal_Unicode( ' ' ));
309 aLevelName.Append( OUString::number( sal_Int32( nLevel )));
311 aLevelName.Insert(aPrefix, 0);
313 pSheet = Find(aLevelName, SD_STYLE_FAMILY_MASTERPAGE);
315 DBG_ASSERT( pSheet, "missing layout style!");
317 if( pSheet )
319 if (pParent)
320 pSheet->SetParent(pParent->GetName());
321 pParent = pSheet;
326 /**************************************************************************
327 * Title
328 **************************************************************************/
329 aName = String(SdResId(STR_LAYOUT_TITLE));
330 aName.Insert(aPrefix, 0);
332 if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
334 bCreated = sal_True;
336 pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
337 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_TITLE );
338 pSheet->SetParent(String());
339 SfxItemSet& rTitleSet = pSheet->GetItemSet();
340 rTitleSet.Put(XLineStyleItem(XLINE_NONE));
341 rTitleSet.Put(XFillStyleItem(XFILL_NONE));
342 rTitleSet.Put(aSvxFontItem);
343 rTitleSet.Put(aSvxFontItemCJK);
344 rTitleSet.Put(aSvxFontItemCTL);
345 rTitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
346 rTitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
347 rTitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
348 rTitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
349 rTitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
350 rTitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
351 rTitleSet.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT ) ); // 44 pt
352 rTitleSet.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 44 pt
353 rTitleSet.Put(SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 1552 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 44 pt
354 rTitleSet.Put(SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE ));
355 rTitleSet.Put(SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE ));
356 rTitleSet.Put(SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ));
357 rTitleSet.Put(SvxShadowedItem(sal_False, EE_CHAR_SHADOW ));
358 rTitleSet.Put(SvxContourItem(sal_False, EE_CHAR_OUTLINE ));
359 rTitleSet.Put( SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ) );
360 rTitleSet.Put( SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF ) );
361 rTitleSet.Put(SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR ));
362 rTitleSet.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST ));
363 rTitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
364 // #i16874# enable kerning by default but only for new documents
365 rTitleSet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
367 aBulletFont.SetSize(Size(0,1552)); // 44 pt
368 PutNumBulletItem( pSheet, aBulletFont );
371 /**************************************************************************
372 * Subtitle
373 **************************************************************************/
374 aName = String(SdResId(STR_LAYOUT_SUBTITLE));
375 aName.Insert(aPrefix, 0);
377 if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
379 bCreated = sal_True;
381 pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
382 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_SUBTITLE );
383 pSheet->SetParent(String());
384 SfxItemSet& rSubtitleSet = pSheet->GetItemSet();
385 rSubtitleSet.Put(XLineStyleItem(XLINE_NONE));
386 rSubtitleSet.Put(XFillStyleItem(XFILL_NONE));
387 rSubtitleSet.Put(aSvxFontItem);
388 rSubtitleSet.Put(aSvxFontItemCJK);
389 rSubtitleSet.Put(aSvxFontItemCTL);
390 rSubtitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
391 rSubtitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
392 rSubtitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
393 rSubtitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
394 rSubtitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
395 rSubtitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
396 rSubtitleSet.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT ) ); // 32 pt
397 rSubtitleSet.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 32 pt
398 rSubtitleSet.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 1129 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 32 pt
399 rSubtitleSet.Put(SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE ));
400 rSubtitleSet.Put(SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE ));
401 rSubtitleSet.Put(SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ));
402 rSubtitleSet.Put(SvxShadowedItem(sal_False, EE_CHAR_SHADOW ));
403 rSubtitleSet.Put(SvxContourItem(sal_False, EE_CHAR_OUTLINE ));
404 rSubtitleSet.Put( SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ) );
405 rSubtitleSet.Put( SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF ) );
406 rSubtitleSet.Put(SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR ));
407 rSubtitleSet.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST ));
408 rSubtitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
409 // #i16874# enable kerning by default but only for new documents
410 rSubtitleSet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
411 aSvxLRSpaceItem.SetTxtLeft(0);
412 rSubtitleSet.Put(aSvxLRSpaceItem);
414 Font aTmpFont( GetBulletFont() );
415 aTmpFont.SetSize(Size(0, 1129)); // 32 pt
416 PutNumBulletItem( pSheet, aTmpFont );
419 /**************************************************************************
420 * Notes
421 **************************************************************************/
422 aName = String(SdResId(STR_LAYOUT_NOTES));
423 aName.Insert(aPrefix, 0);
425 if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
427 bCreated = sal_True;
429 pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
430 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_NOTES );
431 pSheet->SetParent(String());
432 SfxItemSet& rNotesSet = pSheet->GetItemSet();
433 rNotesSet.Put(XLineStyleItem(XLINE_NONE));
434 rNotesSet.Put(XFillStyleItem(XFILL_NONE));
435 rNotesSet.Put(aSvxFontItem);
436 rNotesSet.Put(aSvxFontItemCJK);
437 rNotesSet.Put(aSvxFontItemCTL);
438 rNotesSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
439 rNotesSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
440 rNotesSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
441 rNotesSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
442 rNotesSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
443 rNotesSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
444 rNotesSet.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT ) ); // 20 pt
445 rNotesSet.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 20 pt
446 rNotesSet.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 705 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 20 pt
447 rNotesSet.Put( SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE ) );
448 rNotesSet.Put( SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE ) );
449 rNotesSet.Put( SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) );
450 rNotesSet.Put( SvxShadowedItem(sal_False, EE_CHAR_SHADOW ) );
451 rNotesSet.Put( SvxContourItem(sal_False, EE_CHAR_OUTLINE ) );
452 rNotesSet.Put( SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ) );
453 rNotesSet.Put( SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF) );
454 rNotesSet.Put( SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR ) );
455 rNotesSet.Put( SvxLRSpaceItem( 0, 0, 600, -600, EE_PARA_LRSPACE ) );
456 // #i16874# enable kerning by default but only for new documents
457 rNotesSet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
459 /* #i35937# */
463 /**************************************************************************
464 * Background objects
465 **************************************************************************/
466 aName = String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS));
467 aName.Insert(aPrefix, 0);
469 if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
471 bCreated = sal_True;
473 pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
474 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUNDOBJECTS );
475 pSheet->SetParent(String());
476 SfxItemSet& rBackgroundObjectsSet = pSheet->GetItemSet();
477 rBackgroundObjectsSet.Put(SdrShadowItem(sal_False));
478 rBackgroundObjectsSet.Put(SdrShadowColorItem(Color(COL_GRAY)));
479 rBackgroundObjectsSet.Put(SdrShadowXDistItem(200)); // 3 mm shadow distance
480 rBackgroundObjectsSet.Put(SdrShadowYDistItem(200));
481 // #i16874# enable kerning by default but only for new documents
482 rBackgroundObjectsSet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
483 rBackgroundObjectsSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK));
486 /**************************************************************************
487 * Background
488 **************************************************************************/
489 aName = String(SdResId(STR_LAYOUT_BACKGROUND));
490 aName.Insert(aPrefix, 0);
492 if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
494 bCreated = sal_True;
496 pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
497 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUND );
498 pSheet->SetParent(String());
499 SfxItemSet& rBackgroundSet = pSheet->GetItemSet();
500 rBackgroundSet.Put(XLineStyleItem(XLINE_NONE));
501 rBackgroundSet.Put(XFillStyleItem(XFILL_NONE));
502 // #i16874# enable kerning by default but only for new documents
503 rBackgroundSet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
506 DBG_ASSERT( !bCheck || !bCreated, "missing layout style sheets detected!" );
509 /*************************************************************************
511 |* Copy graphic style sheets from source pool into this pool
513 |* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
515 \************************************************************************/
517 void SdStyleSheetPool::CopyGraphicSheets(SdStyleSheetPool& rSourcePool)
519 CopySheets( rSourcePool, SD_STYLE_FAMILY_GRAPHICS );
522 void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool& rSourcePool)
524 CopySheets( rSourcePool, SD_STYLE_FAMILY_CELL );
527 void SdStyleSheetPool::CopyTableStyles(SdStyleSheetPool& rSourcePool)
529 Reference< XIndexAccess > xSource( rSourcePool.mxTableFamily, UNO_QUERY );
530 Reference< XNameContainer > xTarget( mxTableFamily, UNO_QUERY );
531 Reference< XSingleServiceFactory > xFactory( mxTableFamily, UNO_QUERY );
533 if( xSource.is() && xFactory.is() && mxTableFamily.is() )
535 for( sal_Int32 nIndex = 0; nIndex < xSource->getCount(); nIndex++ ) try
537 Reference< XStyle > xSourceTableStyle( xSource->getByIndex( nIndex ), UNO_QUERY );
538 if( xSourceTableStyle.is() )
540 Reference< XStyle > xNewTableStyle( xFactory->createInstance(), UNO_QUERY );
541 if( xNewTableStyle.is() )
543 Reference< XNameAccess> xSourceNames( xSourceTableStyle, UNO_QUERY_THROW );
545 Sequence< OUString > aStyleNames( xSourceNames->getElementNames() );
546 OUString* pStyleNames( aStyleNames.getArray() );
548 Reference< XNameReplace > xTargetNames( xNewTableStyle, UNO_QUERY );
550 sal_Int32 nNames = aStyleNames.getLength();
551 while( nNames-- )
553 const OUString aName( *pStyleNames++ );
554 Reference< XStyle > xSourceStyle( xSourceNames->getByName( aName ), UNO_QUERY );
555 Reference< XStyle > xTargetStyle;
556 if( xSourceStyle.is() ) try
558 mxCellFamily->getByName( xSourceStyle->getName() ) >>= xTargetStyle;
560 catch( Exception& )
562 OSL_FAIL( "sd::SdStyleSheetPool::CopyTableStyles(), exception caught!" );
565 if( xTargetStyle.is() )
566 xTargetNames->replaceByName( aName, Any( xTargetStyle ) );
570 OUString sName( Reference< XNamed >( xSourceTableStyle, UNO_QUERY_THROW )->getName() );
571 if( xTarget->hasByName( sName ) )
572 xTarget->replaceByName( sName, Any( xNewTableStyle ) );
573 else
574 xTarget->insertByName( sName, Any( xNewTableStyle ) );
577 catch( Exception& )
579 OSL_FAIL("sd::SdStyleSheetPool::CopyTableStyles(), exception caught!");
584 void SdStyleSheetPool::CopyGraphicSheets(SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets)
586 CopySheets( rSourcePool, SD_STYLE_FAMILY_GRAPHICS, rCreatedSheets );
589 void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets)
591 CopySheets( rSourcePool, SD_STYLE_FAMILY_CELL, rCreatedSheets );
594 void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily )
596 SdStyleSheetVector aTmpSheets;
597 CopySheets(rSourcePool, eFamily, aTmpSheets);
600 void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, SdStyleSheetVector& rCreatedSheets)
602 OUString aHelpFile;
604 sal_uInt32 nCount = rSourcePool.aStyles.size();
606 std::vector< std::pair< rtl::Reference< SfxStyleSheetBase >, String > > aNewStyles;
608 for (sal_uInt32 n = 0; n < nCount; n++)
610 rtl::Reference< SfxStyleSheetBase > xSheet( rSourcePool.aStyles[sal::static_int_cast<sal_uInt16>(n)] );
612 if( xSheet->GetFamily() == eFamily )
614 String aName( xSheet->GetName() );
615 if ( !Find( aName, eFamily ) )
617 rtl::Reference< SfxStyleSheetBase > xNewSheet( &Make( aName, eFamily ) );
619 xNewSheet->SetMask( xSheet->GetMask() );
621 // Also set parent relation for copied style sheets
622 String aParent( xSheet->GetParent() );
623 if( aParent.Len() )
624 aNewStyles.push_back( std::pair< rtl::Reference< SfxStyleSheetBase >, String >( xNewSheet, aParent ) );
626 xNewSheet->SetHelpId( aHelpFile, xSheet->GetHelpId( aHelpFile ) );
627 xNewSheet->GetItemSet().Put( xSheet->GetItemSet() );
629 rCreatedSheets.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( xNewSheet.get() ) ) );
634 // set parents on newly added stylesheets
635 std::vector< std::pair< rtl::Reference< SfxStyleSheetBase >, String > >::iterator aIter;
636 for( aIter = aNewStyles.begin(); aIter != aNewStyles.end(); ++aIter )
638 DBG_ASSERT( rSourcePool.Find( (*aIter).second, eFamily ), "StyleSheet has invalid parent: Family mismatch" );
639 (*aIter).first->SetParent( (*aIter).second );
644 /*************************************************************************
646 |* Copy style sheets of the named presentation layout from the source pool into
647 |* this pool. Copies only the style sheets which aren't yet in this pool.
648 |* If not NULL, pCreatedSheets is filled with pointers to the created style
649 |* sheets.
651 |* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
653 \************************************************************************/
655 void SdStyleSheetPool::CopyLayoutSheets(const String& rLayoutName, SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets)
657 SfxStyleSheetBase* pSheet = NULL;
659 std::vector<String> aNameList;
660 CreateLayoutSheetNames(rLayoutName,aNameList);
662 OUString sEmpty;
663 for (std::vector<String>::const_iterator it = aNameList.begin(); it != aNameList.end(); ++it)
665 pSheet = Find(*it, SD_STYLE_FAMILY_MASTERPAGE);
666 if (!pSheet)
668 SfxStyleSheetBase* pSourceSheet = rSourcePool.Find(*it, SD_STYLE_FAMILY_MASTERPAGE);
669 DBG_ASSERT(pSourceSheet, "CopyLayoutSheets: Style sheet missing");
670 if (pSourceSheet)
672 // In the case one comes with Methusalem-Docs.
673 SfxStyleSheetBase& rNewSheet = Make(*it, SD_STYLE_FAMILY_MASTERPAGE);
674 rNewSheet.SetHelpId( sEmpty, pSourceSheet->GetHelpId( sEmpty ) );
675 rNewSheet.GetItemSet().Put(pSourceSheet->GetItemSet());
676 rCreatedSheets.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( &rNewSheet ) ) );
681 // Special treatment for outline templates: create parent relation
682 std::vector<SfxStyleSheetBase*> aOutlineSheets;
683 CreateOutlineSheetList(rLayoutName,aOutlineSheets);
685 if( !aOutlineSheets.empty() )
687 std::vector<SfxStyleSheetBase*>::iterator it = aOutlineSheets.begin();
688 SfxStyleSheetBase* pParent = *it;
689 ++it;
691 while (it != aOutlineSheets.end())
693 pSheet = *it;
695 if (!pSheet)
696 break;
698 if (pSheet->GetParent().Len() == 0)
699 pSheet->SetParent(pParent->GetName());
701 pParent = pSheet;
703 ++it;
708 /*************************************************************************
710 |* Create list with names of the presentation templates of a layout.
711 |* The list and the containing strings are owned by the caller!
713 \************************************************************************/
715 void SdStyleSheetPool::CreateLayoutSheetNames(const String& rLayoutName, std::vector<String> &aNameList) const
717 String aPrefix(rLayoutName);
718 String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
719 aPrefix.Insert(aSep);
721 String aName(SdResId(STR_LAYOUT_OUTLINE));
722 String aStr;
724 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
726 aStr = String( aPrefix );
727 aStr.Append(aName);
728 aStr.Append( sal_Unicode( ' ' ));
729 aStr.Append( OUString::number( sal_Int32( nLevel )));
730 aNameList.push_back(aStr);
733 aStr = String(SdResId(STR_LAYOUT_TITLE));
734 aStr.Insert(aPrefix, 0);
735 aNameList.push_back(aStr);
737 aStr = String(SdResId(STR_LAYOUT_SUBTITLE));
738 aStr.Insert(aPrefix, 0);
739 aNameList.push_back(aStr);
741 aStr = String(SdResId(STR_LAYOUT_NOTES));
742 aStr.Insert(aPrefix, 0);
743 aNameList.push_back(aStr);
745 aStr = String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS));
746 aStr.Insert(aPrefix, 0);
747 aNameList.push_back(aStr);
749 aStr = String(SdResId(STR_LAYOUT_BACKGROUND));
750 aStr.Insert(aPrefix, 0);
751 aNameList.push_back(aStr);
754 /*************************************************************************
756 |* Create a list with pointer to presentation templates of a layout.
757 |* The list is owned by the caller!
759 \************************************************************************/
761 void SdStyleSheetPool::CreateLayoutSheetList(const String& rLayoutName, SdStyleSheetVector& rLayoutSheets )
763 String aLayoutNameWithSep(rLayoutName);
764 aLayoutNameWithSep.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
765 sal_uInt16 nLen = aLayoutNameWithSep.Len();
767 SfxStyleSheetIterator aIter(this, SD_STYLE_FAMILY_MASTERPAGE);
768 SfxStyleSheetBase* pSheet = aIter.First();
770 while (pSheet)
772 if (pSheet->GetName().Match(aLayoutNameWithSep) == nLen)
773 rLayoutSheets.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( pSheet ) ) );
774 pSheet = aIter.Next();
778 /*************************************************************************
780 |* Create pseudo style sheets if necessary
782 \************************************************************************/
784 void SdStyleSheetPool::CreatePseudosIfNecessary()
786 String aName;
787 OUString aHelpFile;
788 SfxStyleSheetBase* pSheet = NULL;
789 SfxStyleSheetBase* pParent = NULL;
791 sal_uInt16 nUsedMask = SFXSTYLEBIT_USED;
793 aName = String(SdResId(STR_PSEUDOSHEET_TITLE));
794 if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
796 pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
797 pSheet->SetParent( String() );
798 ((SfxStyleSheet*)pSheet)->StartListening(*this);
800 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_TITLE );
802 aName = String(SdResId(STR_PSEUDOSHEET_SUBTITLE));
803 if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
805 pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
806 pSheet->SetParent(String());
807 ((SfxStyleSheet*)pSheet)->StartListening(*this);
809 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_SUBTITLE );
811 aName = String(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS));
812 if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
814 pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
815 pSheet->SetParent( String() );
816 ((SfxStyleSheet*)pSheet)->StartListening(*this);
818 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUNDOBJECTS );
820 aName = String(SdResId(STR_PSEUDOSHEET_BACKGROUND));
821 if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
823 pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
824 pSheet->SetParent( String() );
825 ((SfxStyleSheet*)pSheet)->StartListening(*this);
827 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUND );
829 aName = String(SdResId(STR_PSEUDOSHEET_NOTES));
830 if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
832 pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
833 pSheet->SetParent( String() );
834 ((SfxStyleSheet*)pSheet)->StartListening(*this);
836 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_NOTES );
838 pParent = NULL;
839 SetSearchMask(SD_STYLE_FAMILY_PSEUDO);
840 aName = String(SdResId(STR_PSEUDOSHEET_OUTLINE));
841 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
843 String aLevelName(aName);
844 aLevelName.Append( sal_Unicode( ' ' ));
845 aLevelName.Append( OUString::number( sal_Int32( nLevel )));
847 if( (pSheet = Find(aLevelName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
849 pSheet = &Make(aLevelName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
851 if (pSheet)
853 if (pParent)
854 pSheet->SetParent(pParent->GetName());
855 pParent = pSheet;
856 ((SfxStyleSheet*)pSheet)->StartListening(*this);
859 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_OUTLINE + nLevel );
864 /*************************************************************************
866 |* Set the correct name in the program language to the standard styles
868 \************************************************************************/
870 void SdStyleSheetPool::UpdateStdNames()
872 OUString aHelpFile;
873 sal_uInt32 nCount = aStyles.size();
874 std::vector<SfxStyleSheetBase*> aEraseList;
876 for( sal_uInt32 n=0; n < nCount; n++ )
878 SfxStyleSheetBase* pStyle = aStyles[ n ].get();
880 if( !pStyle->IsUserDefined() )
882 String aOldName = pStyle->GetName();
883 sal_uLong nHelpId = pStyle->GetHelpId( aHelpFile );
884 SfxStyleFamily eFam = pStyle->GetFamily();
886 sal_Bool bHelpKnown = sal_True;
887 String aNewName;
888 sal_uInt16 nNameId = 0;
889 switch( nHelpId )
891 case HID_STANDARD_STYLESHEET_NAME: nNameId = STR_STANDARD_STYLESHEET_NAME; break;
892 case HID_POOLSHEET_OBJWITHARROW: nNameId = STR_POOLSHEET_OBJWITHARROW; break;
893 case HID_POOLSHEET_OBJWITHSHADOW: nNameId = STR_POOLSHEET_OBJWITHSHADOW; break;
894 case HID_POOLSHEET_OBJWITHOUTFILL: nNameId = STR_POOLSHEET_OBJWITHOUTFILL; break;
895 case HID_POOLSHEET_OBJNOLINENOFILL: nNameId = STR_POOLSHEET_OBJNOLINENOFILL;break;
896 case HID_POOLSHEET_TEXT: nNameId = STR_POOLSHEET_TEXT; break;
897 case HID_POOLSHEET_TEXTBODY: nNameId = STR_POOLSHEET_TEXTBODY; break;
898 case HID_POOLSHEET_TEXTBODY_JUSTIFY:nNameId = STR_POOLSHEET_TEXTBODY_JUSTIFY;break;
899 case HID_POOLSHEET_TEXTBODY_INDENT: nNameId = STR_POOLSHEET_TEXTBODY_INDENT;break;
900 case HID_POOLSHEET_TITLE: nNameId = STR_POOLSHEET_TITLE; break;
901 case HID_POOLSHEET_TITLE1: nNameId = STR_POOLSHEET_TITLE1; break;
902 case HID_POOLSHEET_TITLE2: nNameId = STR_POOLSHEET_TITLE2; break;
903 case HID_POOLSHEET_HEADLINE: nNameId = STR_POOLSHEET_HEADLINE; break;
904 case HID_POOLSHEET_HEADLINE1: nNameId = STR_POOLSHEET_HEADLINE1; break;
905 case HID_POOLSHEET_HEADLINE2: nNameId = STR_POOLSHEET_HEADLINE2; break;
906 case HID_POOLSHEET_MEASURE: nNameId = STR_POOLSHEET_MEASURE; break;
908 case HID_PSEUDOSHEET_TITLE: nNameId = STR_PSEUDOSHEET_TITLE; break;
909 case HID_PSEUDOSHEET_SUBTITLE: nNameId = STR_PSEUDOSHEET_SUBTITLE; break;
910 case HID_PSEUDOSHEET_OUTLINE1:
911 case HID_PSEUDOSHEET_OUTLINE2:
912 case HID_PSEUDOSHEET_OUTLINE3:
913 case HID_PSEUDOSHEET_OUTLINE4:
914 case HID_PSEUDOSHEET_OUTLINE5:
915 case HID_PSEUDOSHEET_OUTLINE6:
916 case HID_PSEUDOSHEET_OUTLINE7:
917 case HID_PSEUDOSHEET_OUTLINE8:
918 case HID_PSEUDOSHEET_OUTLINE9: nNameId = STR_PSEUDOSHEET_OUTLINE; break;
919 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS: nNameId = STR_PSEUDOSHEET_BACKGROUNDOBJECTS; break;
920 case HID_PSEUDOSHEET_BACKGROUND: nNameId = STR_PSEUDOSHEET_BACKGROUND; break;
921 case HID_PSEUDOSHEET_NOTES: nNameId = STR_PSEUDOSHEET_NOTES; break;
923 case HID_SD_CELL_STYLE_DEFAULT: nNameId = STR_STANDARD_STYLESHEET_NAME; break;
924 case HID_SD_CELL_STYLE_BANDED: nNameId = STR_POOLSHEET_BANDED_CELL; break;
925 case HID_SD_CELL_STYLE_HEADER: nNameId = STR_POOLSHEET_HEADER; break;
926 case HID_SD_CELL_STYLE_TOTAL: nNameId = STR_POOLSHEET_TOTAL; break;
927 case HID_SD_CELL_STYLE_FIRST_COLUMN: nNameId = STR_POOLSHEET_FIRST_COLUMN; break;
928 case HID_SD_CELL_STYLE_LAST_COLUMN: nNameId = STR_POOLSHEET_LAST_COLUMN; break;
930 default:
931 // 0 or wrong (old) HelpId
932 bHelpKnown = sal_False;
934 if( bHelpKnown )
936 if( nNameId )
938 aNewName = String( SdResId( nNameId ) );
939 if( nNameId == STR_PSEUDOSHEET_OUTLINE )
941 aNewName.Append( sal_Unicode( ' ' ));
942 aNewName.Append( OUString::number( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE )));
946 if( aNewName.Len() && aNewName != aOldName )
948 SfxStyleSheetBase* pSheetFound = Find( aNewName, eFam );
950 if ( !pSheetFound )
952 // Sheet does not yet exist: rename old sheet
953 pStyle->SetName( aNewName ); // transform also parents
955 else
957 // Sheet does exist: old sheet has to be removed
958 aEraseList.push_back( pStyle );
965 // styles that could not be renamed, must be removed
966 for ( size_t i = 0, n = aEraseList.size(); i < n; ++i )
967 Remove( aEraseList[ i ] );
969 // --------------------------------------------------------------------
970 // Set new SvxNumBulletItem for the respective style sheet
971 // --------------------------------------------------------------------
973 void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet,
974 Font& rBulletFont )
976 OUString aHelpFile;
977 sal_uLong nHelpId = pSheet->GetHelpId( aHelpFile );
978 SfxItemSet& rSet = pSheet->GetItemSet();
980 switch ( nHelpId )
982 case HID_STANDARD_STYLESHEET_NAME :
984 // Standard template
985 SvxNumberFormat aNumberFormat(SVX_NUM_CHAR_SPECIAL);
986 aNumberFormat.SetBulletFont(&rBulletFont);
987 aNumberFormat.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
988 aNumberFormat.SetBulletRelSize(45);
989 aNumberFormat.SetBulletColor(Color(COL_AUTO));
990 aNumberFormat.SetStart(1);
991 aNumberFormat.SetNumAdjust(SVX_ADJUST_LEFT);
993 SvxNumRule aNumRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE, SVX_MAX_NUM , sal_False);
995 for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
997 const short nLSpace = (i + 1) * 600;
998 aNumberFormat.SetLSpace(nLSpace);
999 aNumberFormat.SetAbsLSpace(nLSpace);
1000 aNumberFormat.SetFirstLineOffset(-600);
1001 aNumRule.SetLevel( i, aNumberFormat );
1004 rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) );
1005 ((SfxStyleSheet*)pSheet)->Broadcast(SfxSimpleHint( SFX_HINT_DATACHANGED ) );
1007 break;
1009 case HID_PSEUDOSHEET_TITLE:
1010 /* title gets same bullet as subtitle and not that page symbol anymore */
1011 case HID_PSEUDOSHEET_SUBTITLE :
1013 // Subtitle template
1014 SvxNumRule* pDefaultRule = ((SvxNumBulletItem*) rSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET))->GetNumRule();
1015 DBG_ASSERT( pDefaultRule, "Where is my default template? [CL]" );
1017 if(pDefaultRule)
1019 SvxNumRule aNumRule(pDefaultRule->GetFeatureFlags(), 10, sal_False);
1020 for(sal_uInt16 i=0; i < aNumRule.GetLevelCount(); i++)
1022 SvxNumberFormat aFrmt( pDefaultRule->GetLevel(i) );
1023 aFrmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
1024 // #i93908# clear suffix for bullet lists
1025 aFrmt.SetPrefix(OUString());
1026 aFrmt.SetSuffix(OUString());
1027 aFrmt.SetStart(1);
1028 aFrmt.SetBulletRelSize(45);
1029 aFrmt.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1030 aFrmt.SetBulletFont(&rBulletFont);
1031 aNumRule.SetLevel(i, aFrmt);
1034 rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) );
1035 ((SfxStyleSheet*)pSheet)->Broadcast(SfxSimpleHint( SFX_HINT_DATACHANGED ) );
1038 break;
1040 case HID_PSEUDOSHEET_OUTLINE + 1 :
1042 // Outline template
1043 SvxNumberFormat aNumberFormat(SVX_NUM_CHAR_SPECIAL);
1044 aNumberFormat.SetBulletColor(Color(COL_AUTO));
1045 aNumberFormat.SetStart(1);
1046 aNumberFormat.SetNumAdjust(SVX_ADJUST_LEFT);
1048 SvxNumRule aNumRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE|NUM_SYMBOL_ALIGNMENT,
1049 SVX_MAX_NUM, sal_False );
1050 for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
1052 aNumberFormat.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1053 aNumberFormat.SetBulletRelSize(45);
1054 const short nLSpace = (i + 1) * 1200;
1055 aNumberFormat.SetLSpace(nLSpace);
1056 aNumberFormat.SetAbsLSpace(nLSpace);
1057 short nFirstLineOffset = -600;
1059 sal_uLong nFontSize = 20;
1060 switch(i)
1062 case 0:
1064 nFontSize = 32;
1065 nFirstLineOffset = -900;
1067 break;
1069 case 1:
1071 aNumberFormat.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
1072 aNumberFormat.SetBulletRelSize(75);
1073 nFontSize = 32;
1074 nFirstLineOffset = -900;
1076 break;
1078 case 2:
1080 nFontSize = 28;
1081 nFirstLineOffset = -800;
1083 break;
1085 case 3:
1087 aNumberFormat.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
1088 aNumberFormat.SetBulletRelSize(75);
1089 nFontSize = 24;
1091 break;
1094 aNumberFormat.SetFirstLineOffset(nFirstLineOffset);
1095 nFontSize = (sal_uInt16)((nFontSize * 2540L) / 72); // Pt --> 1/100 mm
1096 rBulletFont.SetSize(Size(0,846)); // 24 pt
1097 aNumberFormat.SetBulletFont(&rBulletFont);
1098 aNumRule.SetLevel( i, aNumberFormat );
1101 rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) );
1102 ((SfxStyleSheet*)pSheet)->Broadcast(SfxSimpleHint( SFX_HINT_DATACHANGED ) );
1104 break;
1108 /*************************************************************************
1110 |* Create standard bullet font (without size)
1112 \************************************************************************/
1114 Font SdStyleSheetPool::GetBulletFont() const
1116 Font aBulletFont( OUString( "StarSymbol" ), Size(0, 1000) );
1117 aBulletFont.SetCharSet(RTL_TEXTENCODING_UNICODE);
1118 aBulletFont.SetWeight(WEIGHT_NORMAL);
1119 aBulletFont.SetUnderline(UNDERLINE_NONE);
1120 aBulletFont.SetOverline(UNDERLINE_NONE);
1121 aBulletFont.SetStrikeout(STRIKEOUT_NONE);
1122 aBulletFont.SetItalic(ITALIC_NONE);
1123 aBulletFont.SetOutline(sal_False);
1124 aBulletFont.SetShadow(sal_False);
1125 aBulletFont.SetColor(Color(COL_AUTO));
1126 aBulletFont.SetTransparent(sal_True);
1128 return aBulletFont;
1131 // --------------------------------------------------------------------
1133 void SdStyleSheetPool::AddStyleFamily( const SdPage* pPage )
1135 rtl::Reference< SfxStyleSheetPool > xPool( this );
1136 maStyleFamilyMap[pPage] = new SdStyleFamily( xPool, pPage );
1139 // --------------------------------------------------------------------
1141 void SdStyleSheetPool::RemoveStyleFamily( const SdPage* pPage )
1143 SdStyleFamilyMap::iterator iter( maStyleFamilyMap.find( pPage ) );
1144 if( iter != maStyleFamilyMap.end() )
1146 SdStyleFamilyRef xStyle( (*iter).second );
1147 maStyleFamilyMap.erase( iter );
1149 if( xStyle.is() ) try
1151 xStyle->dispose();
1153 catch( Exception& )
1159 // --------------------------------------------------------------------
1161 void SdStyleSheetPool::throwIfDisposed() throw(::com::sun::star::uno::RuntimeException)
1163 if( mpDoc == NULL )
1164 throw DisposedException();
1167 // --------------------------------------------------------------------
1168 // XServiceInfo
1169 // --------------------------------------------------------------------
1171 OUString SAL_CALL SdStyleSheetPool::getImplementationName() throw(RuntimeException)
1173 return OUString( "SdStyleSheetPool" );
1176 // --------------------------------------------------------------------
1178 static const sal_Char* gpServiceName = "com.sun.star.style.StyleFamilies";
1180 sal_Bool SAL_CALL SdStyleSheetPool::supportsService( const OUString& ServiceName ) throw(RuntimeException)
1182 return ServiceName.equalsAscii( gpServiceName );
1185 // --------------------------------------------------------------------
1187 Sequence< OUString > SAL_CALL SdStyleSheetPool::getSupportedServiceNames() throw(RuntimeException)
1189 OUString aStr( OUString::createFromAscii( gpServiceName ) );
1190 return Sequence< OUString >( &aStr, 1 );
1193 // --------------------------------------------------------------------
1194 // XNameAccess
1195 // --------------------------------------------------------------------
1197 Any SAL_CALL SdStyleSheetPool::getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
1199 throwIfDisposed();
1201 if( mxGraphicFamily->getName() == aName )
1202 return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxGraphicFamily.get() ) ) );
1204 if( mxCellFamily->getName() == aName )
1205 return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxCellFamily.get() ) ) );
1207 if( msTableFamilyName == aName )
1208 return Any( mxTableFamily );
1210 for( SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() ); iter != maStyleFamilyMap.end(); ++iter )
1212 if( (*iter).second->getName() == aName )
1213 return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( (*iter).second.get() ) ) );
1216 throw NoSuchElementException();
1219 // --------------------------------------------------------------------
1221 Sequence< OUString > SAL_CALL SdStyleSheetPool::getElementNames() throw(RuntimeException)
1223 throwIfDisposed();
1225 Sequence< OUString > aNames( maStyleFamilyMap.size() + 3 );
1226 OUString* pNames = aNames.getArray();
1228 *pNames++ = mxGraphicFamily->getName();
1229 *pNames++ = mxCellFamily->getName();
1230 *pNames++ = msTableFamilyName;
1232 for( SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() ); iter != maStyleFamilyMap.end(); ++iter )
1234 *pNames++ = (*iter).second->getName();
1237 return aNames;
1240 // --------------------------------------------------------------------
1242 sal_Bool SAL_CALL SdStyleSheetPool::hasByName( const OUString& aName ) throw(RuntimeException)
1244 throwIfDisposed();
1246 if( mxGraphicFamily->getName() == aName )
1247 return sal_True;
1249 if( mxCellFamily->getName() == aName )
1250 return sal_True;
1252 if( msTableFamilyName == aName )
1253 return sal_True;
1255 for( SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() ); iter != maStyleFamilyMap.end(); ++iter )
1257 if( (*iter).second->getName() == aName )
1258 return sal_True;
1261 return sal_False;
1264 // --------------------------------------------------------------------
1265 // XElementAccess
1266 // --------------------------------------------------------------------
1268 Type SAL_CALL SdStyleSheetPool::getElementType() throw(RuntimeException)
1270 throwIfDisposed();
1272 return XNameAccess::static_type();
1275 // --------------------------------------------------------------------
1277 sal_Bool SAL_CALL SdStyleSheetPool::hasElements() throw(RuntimeException)
1279 return sal_True;
1282 // --------------------------------------------------------------------
1283 // XIndexAccess
1284 // --------------------------------------------------------------------
1286 sal_Int32 SAL_CALL SdStyleSheetPool::getCount() throw(RuntimeException)
1288 throwIfDisposed();
1290 return maStyleFamilyMap.size() + 3;
1293 // --------------------------------------------------------------------
1295 Any SAL_CALL SdStyleSheetPool::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
1297 switch( Index )
1299 case 0:
1300 return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxGraphicFamily.get() ) ) );
1302 case 1:
1303 return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxCellFamily.get() ) ) );
1305 case 2:
1306 return Any( mxTableFamily );
1308 default:
1310 Index -= 3;
1311 if( (Index < 0) || (Index >= sal::static_int_cast<sal_Int32>(maStyleFamilyMap.size())) )
1312 throw IndexOutOfBoundsException();
1313 SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() );
1314 while( Index-- )
1315 ++iter;
1317 return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( (*iter).second.get() ) ) );
1322 // --------------------------------------------------------------------
1323 // XComponent
1324 // --------------------------------------------------------------------
1326 void SAL_CALL SdStyleSheetPool::dispose() throw (RuntimeException)
1328 if( mpDoc )
1330 mxGraphicFamily->dispose();
1331 mxGraphicFamily.clear();
1332 mxCellFamily->dispose();
1333 mxCellFamily.clear();
1335 Reference< XComponent > xComp( mxTableFamily, UNO_QUERY );
1336 if( xComp.is() )
1337 xComp->dispose();
1338 mxTableFamily = 0;
1340 SdStyleFamilyMap aTempMap;
1341 aTempMap.swap( maStyleFamilyMap );
1343 for( SdStyleFamilyMap::iterator iter( aTempMap.begin() ); iter != aTempMap.end(); ++iter ) try
1345 (*iter).second->dispose();
1347 catch( Exception& )
1351 mpDoc = 0;
1353 Clear();
1357 // --------------------------------------------------------------------
1359 void SAL_CALL SdStyleSheetPool::addEventListener( const Reference< XEventListener >& /*xListener*/ ) throw (RuntimeException)
1363 // --------------------------------------------------------------------
1365 void SAL_CALL SdStyleSheetPool::removeEventListener( const Reference< XEventListener >& /*aListener*/ ) throw (RuntimeException)
1369 // --------------------------------------------------------------------
1371 SdStyleSheetVector SdStyleSheetPool::CreateChildList( SdStyleSheet* pSheet )
1373 SdStyleSheetVector aResult;
1375 sal_uInt16 nListenerCount = pSheet->GetListenerCount();
1376 if (nListenerCount > 0)
1378 for (sal_uInt16 n = 0; n < nListenerCount; n++)
1380 SdStyleSheet* pChild = dynamic_cast< SdStyleSheet* >( pSheet->GetListener(n) );
1381 if(pChild && pChild->GetParent() == pSheet->GetName())
1383 aResult.push_back( SdStyleSheetRef( pChild ) );
1388 return aResult;
1391 // --------------------------------------------------------------------
1393 void SAL_CALL SdStyleSheetPool::acquire (void) throw ()
1395 SdStyleSheetPoolBase::acquire();
1398 void SAL_CALL SdStyleSheetPool::release (void) throw ()
1400 SdStyleSheetPoolBase::release();
1403 // --------------------------------------------------------------------
1405 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */