Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <com/sun/star/lang/DisposedException.hpp>
21 : #include <cppuhelper/supportsservice.hxx>
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 <editeng/cmapitem.hxx>
40 : #include <svl/smplhint.hxx>
41 : #include <editeng/langitem.hxx>
42 : #include <editeng/charreliefitem.hxx>
43 : #include <editeng/emphasismarkitem.hxx>
44 : #include <svx/sdr/table/tabledesign.hxx>
45 : #include <editeng/autokernitem.hxx>
46 :
47 : #include <svx/svdattr.hxx>
48 : #include <editeng/outliner.hxx>
49 : #include <svx/xtable.hxx>
50 : #include <editeng/bulletitem.hxx>
51 : #include <editeng/lrspitem.hxx>
52 : #include <editeng/adjustitem.hxx>
53 : #include <editeng/numdef.hxx>
54 : #include <svl/itempool.hxx>
55 : #include <svl/IndexedStyleSheets.hxx>
56 :
57 : #include "stlpool.hxx"
58 : #include "sdresid.hxx"
59 : #include "stlsheet.hxx"
60 : #include "glob.hrc"
61 : #include "glob.hxx"
62 : #include "drawdoc.hxx"
63 : #include "sdmod.hxx"
64 : #include "sdpage.hxx"
65 : #include "helpids.h"
66 : #include <svl/itemset.hxx>
67 : #include "app.hrc"
68 :
69 : using namespace ::com::sun::star;
70 : using namespace ::com::sun::star::uno;
71 : using namespace ::com::sun::star::lang;
72 : using namespace ::com::sun::star::style;
73 : using namespace ::com::sun::star::container;
74 :
75 : namespace
76 : {
77 :
78 0 : OUString lcl_findRenamedStyleName(std::vector< std::pair< OUString, OUString > > &rRenamedList, OUString& aOriginalName )
79 : {
80 0 : std::vector< std::pair< OUString, OUString > >::iterator aIter;
81 0 : for( aIter = rRenamedList.begin(); aIter != rRenamedList.end(); ++aIter )
82 : {
83 0 : if((*aIter).first == aOriginalName )
84 0 : return (*aIter).second;
85 : }
86 0 : return OUString();
87 : }
88 :
89 0 : SfxStyleSheet *lcl_findStyle(SdStyleSheetVector& rStyles, const OUString& aStyleName)
90 : {
91 0 : if( aStyleName.isEmpty() )
92 0 : return NULL;
93 0 : for(SdStyleSheetVector::const_iterator aIt(rStyles.begin()), aLast(rStyles.end()); aIt != aLast; ++aIt)
94 : {
95 0 : if((*aIt)->GetName() == aStyleName)
96 0 : return (*aIt).get();
97 : }
98 0 : return NULL;
99 : }
100 :
101 : }
102 :
103 442 : SdStyleSheetPool::SdStyleSheetPool(SfxItemPool const& _rPool, SdDrawDocument* pDocument)
104 : : SdStyleSheetPoolBase( _rPool )
105 : , mpActualStyleSheet(NULL)
106 442 : , mpDoc(pDocument)
107 : {
108 442 : if( mpDoc )
109 : {
110 442 : rtl::Reference< SfxStyleSheetPool > xPool( this );
111 :
112 : // create graphics family
113 442 : mxGraphicFamily = new SdStyleFamily( xPool, SD_STYLE_FAMILY_GRAPHICS );
114 442 : mxCellFamily = new SdStyleFamily( xPool, SD_STYLE_FAMILY_CELL );
115 :
116 442 : mxTableFamily = sdr::table::CreateTableDesignFamily();
117 884 : Reference< XNamed > xNamed( mxTableFamily, UNO_QUERY );
118 442 : if( xNamed.is() )
119 442 : msTableFamilyName = xNamed->getName();
120 :
121 : // create presentation families, one for each master page
122 442 : const sal_uInt16 nCount = mpDoc->GetMasterSdPageCount(PK_STANDARD);
123 442 : for( sal_uInt16 nPage = 0; nPage < nCount; ++nPage )
124 442 : AddStyleFamily( mpDoc->GetMasterSdPage(nPage,PK_STANDARD) );
125 :
126 : }
127 442 : }
128 :
129 884 : SdStyleSheetPool::~SdStyleSheetPool()
130 : {
131 : DBG_ASSERT( mpDoc == NULL, "sd::SdStyleSheetPool::~SdStyleSheetPool(), dispose me first!" );
132 884 : }
133 :
134 28756 : SfxStyleSheetBase* SdStyleSheetPool::Create(const OUString& rName, SfxStyleFamily eFamily, sal_uInt16 _nMask )
135 : {
136 28756 : return new SdStyleSheet(rName, *this, eFamily, _nMask);
137 : }
138 :
139 0 : SfxStyleSheetBase* SdStyleSheetPool::Create(const SdStyleSheet& rStyle)
140 : {
141 0 : return new SdStyleSheet( rStyle );
142 : }
143 :
144 0 : SfxStyleSheetBase* SdStyleSheetPool::GetTitleSheet(const OUString& rLayoutName)
145 : {
146 0 : OUString aName(rLayoutName);
147 0 : aName += SD_LT_SEPARATOR;
148 0 : aName += SD_RESSTR(STR_LAYOUT_TITLE);
149 0 : SfxStyleSheetBase* pResult = Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
150 0 : return pResult;
151 : }
152 :
153 : /*************************************************************************
154 : |*
155 : |* Create a list of outline text templates for a presentation layout.
156 : |* The caller has to delete the list.
157 : |*
158 : \************************************************************************/
159 :
160 342 : void SdStyleSheetPool::CreateOutlineSheetList (const OUString& rLayoutName, std::vector<SfxStyleSheetBase*> &rOutlineStyles)
161 : {
162 342 : OUString aName(rLayoutName);
163 342 : aName += SD_LT_SEPARATOR;
164 342 : aName += SD_RESSTR(STR_LAYOUT_OUTLINE);
165 :
166 3420 : for (sal_Int32 nSheet = 1; nSheet < 10; nSheet++)
167 : {
168 3078 : OUString aFullName(aName + " " + OUString::number( nSheet ) );
169 3078 : SfxStyleSheetBase* pSheet = Find(aFullName, SD_STYLE_FAMILY_MASTERPAGE);
170 :
171 3078 : if (pSheet)
172 3078 : rOutlineStyles.push_back(pSheet);
173 3420 : }
174 342 : }
175 :
176 : /*************************************************************************
177 : |*
178 : |* Create style sheets with default values for the named presentation layout
179 : |*
180 : \************************************************************************/
181 :
182 398 : void SdStyleSheetPool::CreateLayoutStyleSheets(const OUString& rLayoutName, bool bCheck /*= sal_False*/ )
183 : {
184 398 : const sal_uInt16 nUsedMask = SFXSTYLEBIT_ALL & ~SFXSTYLEBIT_USERDEF;
185 :
186 : (void)bCheck;
187 398 : bool bCreated = false;
188 :
189 398 : SfxStyleSheetBase* pSheet = NULL;
190 :
191 398 : OUString aPrefix(rLayoutName + SD_LT_SEPARATOR);
192 :
193 796 : vcl::Font aLatinFont, aCJKFont, aCTLFont;
194 :
195 398 : mpDoc->getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
196 :
197 : // Font for title and outline
198 398 : SvxFontItem aSvxFontItem( aLatinFont.GetFamily(), aLatinFont.GetName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
199 1194 : aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
200 :
201 398 : SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamily(), aCJKFont.GetName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
202 1194 : aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
203 :
204 398 : SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamily(), aCTLFont.GetName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
205 1194 : aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
206 :
207 796 : vcl::Font aBulletFont( GetBulletFont() );
208 :
209 : /**************************************************************************
210 : * outline levels
211 : **************************************************************************/
212 796 : OUString aName(SD_RESSTR(STR_LAYOUT_OUTLINE));
213 796 : OUString aHelpFile;
214 :
215 398 : SfxStyleSheetBase* pParent = NULL;
216 796 : SvxLRSpaceItem aSvxLRSpaceItem( EE_PARA_LRSPACE );
217 796 : SvxULSpaceItem aSvxULSpaceItem( EE_PARA_ULSPACE );
218 :
219 3980 : for( sal_Int32 nLevel = 1; nLevel < 10; nLevel++)
220 : {
221 3582 : OUString aLevelName( aPrefix + aName + " " + OUString::number( nLevel ) ) ;
222 :
223 3582 : if (!Find(aLevelName, SD_STYLE_FAMILY_MASTERPAGE))
224 : {
225 3546 : bCreated = true;
226 3546 : pSheet = &Make(aLevelName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
227 3546 : pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_OUTLINE + nLevel );
228 :
229 3546 : pSheet->SetParent( OUString() );
230 :
231 : // attributing for level 1, the others levels inherit
232 3546 : if (nLevel == 1)
233 : {
234 394 : SfxItemSet& rSet = pSheet->GetItemSet();
235 :
236 394 : rSet.Put(aSvxFontItem);
237 394 : rSet.Put(aSvxFontItemCJK);
238 394 : rSet.Put(aSvxFontItemCTL);
239 394 : rSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
240 394 : rSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
241 394 : rSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
242 394 : rSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
243 394 : rSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
244 394 : rSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
245 394 : rSet.Put( SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE ) );
246 394 : rSet.Put( SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE ) );
247 394 : rSet.Put( SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) );
248 394 : rSet.Put( SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED, EE_CHAR_CASEMAP ) );
249 394 : rSet.Put( SvxShadowedItem(false, EE_CHAR_SHADOW ) );
250 394 : rSet.Put( SvxContourItem(false, EE_CHAR_OUTLINE ) );
251 394 : rSet.Put( SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ) );
252 394 : rSet.Put( SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF) );
253 394 : rSet.Put( SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR) );
254 394 : rSet.Put( SvxBackgroundColorItem( Color (COL_AUTO), EE_CHAR_BKGCOLOR ) );
255 394 : rSet.Put( XLineStyleItem(XLINE_NONE) );
256 394 : rSet.Put( XFillStyleItem(drawing::FillStyle_NONE) );
257 394 : rSet.Put( SdrTextFitToSizeTypeItem(SDRTEXTFIT_AUTOFIT) );
258 394 : rSet.Put( makeSdrTextAutoGrowHeightItem(false) );
259 : // #i16874# enable kerning by default but only for new documents
260 394 : rSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
261 :
262 394 : if( nLevel == 1 )
263 : {
264 394 : vcl::Font f( GetBulletFont() );
265 394 : PutNumBulletItem( pSheet, f );
266 : }
267 : }
268 :
269 3546 : sal_uLong nFontSize = 20;
270 3546 : sal_uInt16 nUpper = 100;
271 :
272 3546 : switch (nLevel)
273 : {
274 : case 1:
275 : {
276 394 : nFontSize = 32;
277 394 : nUpper = 500;
278 : }
279 394 : break;
280 :
281 : case 2:
282 : {
283 394 : nFontSize = 28;
284 394 : nUpper = 400;
285 : }
286 394 : break;
287 :
288 : case 3:
289 : {
290 394 : nFontSize = 24;
291 394 : nUpper = 300;
292 : }
293 394 : break;
294 :
295 : case 4:
296 : {
297 394 : nUpper = 200;
298 : }
299 394 : break;
300 : }
301 :
302 : // FontSize
303 3546 : nFontSize = (sal_uInt16)((nFontSize * 2540L) / 72); // Pt --> 1/100 mm
304 3546 : SfxItemSet& rOutlineSet = pSheet->GetItemSet();
305 3546 : rOutlineSet.Put( SvxFontHeightItem( nFontSize, 100, EE_CHAR_FONTHEIGHT ) );
306 3546 : rOutlineSet.Put( SvxFontHeightItem( nFontSize, 100, EE_CHAR_FONTHEIGHT_CJK ) );
307 3546 : rOutlineSet.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( nFontSize ), 100, EE_CHAR_FONTHEIGHT_CTL ) );
308 :
309 : // Line distance (upwards). Stuff around here cleaned up in i35937
310 3546 : aSvxULSpaceItem.SetUpper(nUpper);
311 3546 : pSheet->GetItemSet().Put(aSvxULSpaceItem);
312 : }
313 3582 : }
314 :
315 : // if we created outline styles, we need to chain them
316 398 : if( bCreated )
317 : {
318 394 : pParent = NULL;
319 3940 : for (sal_Int32 nLevel = 1; nLevel < 10; nLevel++)
320 : {
321 3546 : OUString aLevelName( aPrefix + aName + " " + OUString::number( nLevel ) );
322 :
323 3546 : pSheet = Find(aLevelName, SD_STYLE_FAMILY_MASTERPAGE);
324 :
325 : DBG_ASSERT( pSheet, "missing layout style!");
326 :
327 3546 : if( pSheet )
328 : {
329 3546 : if (pParent)
330 3152 : pSheet->SetParent(pParent->GetName());
331 3546 : pParent = pSheet;
332 : }
333 3546 : }
334 : }
335 :
336 : /**************************************************************************
337 : * Title
338 : **************************************************************************/
339 398 : aName = aPrefix + SD_RESSTR(STR_LAYOUT_TITLE);
340 :
341 398 : if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
342 : {
343 394 : bCreated = true;
344 :
345 394 : pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
346 394 : pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_TITLE );
347 394 : pSheet->SetParent( OUString() );
348 394 : SfxItemSet& rTitleSet = pSheet->GetItemSet();
349 394 : rTitleSet.Put(XLineStyleItem(XLINE_NONE));
350 394 : rTitleSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
351 394 : rTitleSet.Put(aSvxFontItem);
352 394 : rTitleSet.Put(aSvxFontItemCJK);
353 394 : rTitleSet.Put(aSvxFontItemCTL);
354 394 : rTitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
355 394 : rTitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
356 394 : rTitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
357 394 : rTitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
358 394 : rTitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
359 394 : rTitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
360 394 : rTitleSet.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT ) ); // 44 pt
361 394 : rTitleSet.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 44 pt
362 394 : rTitleSet.Put(SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 1552 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 44 pt
363 394 : rTitleSet.Put(SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE ));
364 394 : rTitleSet.Put(SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE ));
365 394 : rTitleSet.Put(SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ));
366 394 : rTitleSet.Put(SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED, EE_CHAR_CASEMAP ));
367 394 : rTitleSet.Put(SvxShadowedItem(false, EE_CHAR_SHADOW ));
368 394 : rTitleSet.Put(SvxContourItem(false, EE_CHAR_OUTLINE ));
369 394 : rTitleSet.Put( SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ) );
370 394 : rTitleSet.Put( SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF ) );
371 394 : rTitleSet.Put(SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR ));
372 394 : rTitleSet.Put(SvxBackgroundColorItem( Color(COL_AUTO), EE_CHAR_BKGCOLOR ));
373 394 : rTitleSet.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST ));
374 394 : rTitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
375 : // #i16874# enable kerning by default but only for new documents
376 394 : rTitleSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
377 :
378 394 : aBulletFont.SetSize(Size(0,1552)); // 44 pt
379 394 : PutNumBulletItem( pSheet, aBulletFont );
380 : }
381 :
382 : /**************************************************************************
383 : * Subtitle
384 : **************************************************************************/
385 398 : aName = aPrefix + SD_RESSTR(STR_LAYOUT_SUBTITLE);
386 :
387 398 : if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
388 : {
389 394 : bCreated = true;
390 :
391 394 : pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
392 394 : pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_SUBTITLE );
393 394 : pSheet->SetParent( OUString() );
394 394 : SfxItemSet& rSubtitleSet = pSheet->GetItemSet();
395 394 : rSubtitleSet.Put(XLineStyleItem(XLINE_NONE));
396 394 : rSubtitleSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
397 394 : rSubtitleSet.Put(aSvxFontItem);
398 394 : rSubtitleSet.Put(aSvxFontItemCJK);
399 394 : rSubtitleSet.Put(aSvxFontItemCTL);
400 394 : rSubtitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
401 394 : rSubtitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
402 394 : rSubtitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
403 394 : rSubtitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
404 394 : rSubtitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
405 394 : rSubtitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
406 394 : rSubtitleSet.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT ) ); // 32 pt
407 394 : rSubtitleSet.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 32 pt
408 394 : rSubtitleSet.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 1129 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 32 pt
409 394 : rSubtitleSet.Put(SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE ));
410 394 : rSubtitleSet.Put(SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE ));
411 394 : rSubtitleSet.Put(SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ));
412 394 : rSubtitleSet.Put(SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED, EE_CHAR_CASEMAP ));
413 394 : rSubtitleSet.Put(SvxShadowedItem(false, EE_CHAR_SHADOW ));
414 394 : rSubtitleSet.Put(SvxContourItem(false, EE_CHAR_OUTLINE ));
415 394 : rSubtitleSet.Put( SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ) );
416 394 : rSubtitleSet.Put( SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF ) );
417 394 : rSubtitleSet.Put(SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR ));
418 394 : rSubtitleSet.Put(SvxBackgroundColorItem( Color(COL_AUTO), EE_CHAR_BKGCOLOR ));
419 394 : rSubtitleSet.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST ));
420 394 : rSubtitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
421 : // #i16874# enable kerning by default but only for new documents
422 394 : rSubtitleSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
423 394 : aSvxLRSpaceItem.SetTxtLeft(0);
424 394 : rSubtitleSet.Put(aSvxLRSpaceItem);
425 :
426 394 : vcl::Font aTmpFont( GetBulletFont() );
427 394 : aTmpFont.SetSize(Size(0, 1129)); // 32 pt
428 394 : PutNumBulletItem( pSheet, aTmpFont );
429 : }
430 :
431 : /**************************************************************************
432 : * Notes
433 : **************************************************************************/
434 398 : aName = aPrefix + SD_RESSTR(STR_LAYOUT_NOTES);
435 :
436 398 : if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
437 : {
438 394 : bCreated = true;
439 :
440 394 : pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
441 394 : pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_NOTES );
442 394 : pSheet->SetParent( OUString() );
443 394 : SfxItemSet& rNotesSet = pSheet->GetItemSet();
444 394 : rNotesSet.Put(XLineStyleItem(XLINE_NONE));
445 394 : rNotesSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
446 394 : rNotesSet.Put(aSvxFontItem);
447 394 : rNotesSet.Put(aSvxFontItemCJK);
448 394 : rNotesSet.Put(aSvxFontItemCTL);
449 394 : rNotesSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
450 394 : rNotesSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
451 394 : rNotesSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
452 394 : rNotesSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
453 394 : rNotesSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
454 394 : rNotesSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
455 394 : rNotesSet.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT ) ); // 20 pt
456 394 : rNotesSet.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 20 pt
457 394 : rNotesSet.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 705 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 20 pt
458 394 : rNotesSet.Put( SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE ) );
459 394 : rNotesSet.Put( SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE ) );
460 394 : rNotesSet.Put( SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) );
461 394 : rNotesSet.Put( SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED, EE_CHAR_CASEMAP ) );
462 394 : rNotesSet.Put( SvxShadowedItem(false, EE_CHAR_SHADOW ) );
463 394 : rNotesSet.Put( SvxContourItem(false, EE_CHAR_OUTLINE ) );
464 394 : rNotesSet.Put( SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ) );
465 394 : rNotesSet.Put( SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF) );
466 394 : rNotesSet.Put( SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR ) );
467 394 : rNotesSet.Put( SvxBackgroundColorItem( Color(COL_AUTO), EE_CHAR_BKGCOLOR ) );
468 394 : rNotesSet.Put( SvxLRSpaceItem( 0, 0, 600, -600, EE_PARA_LRSPACE ) );
469 : // #i16874# enable kerning by default but only for new documents
470 394 : rNotesSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
471 :
472 : /* #i35937# */
473 :
474 : }
475 :
476 : /**************************************************************************
477 : * Background objects
478 : **************************************************************************/
479 398 : aName = aPrefix + SD_RESSTR(STR_LAYOUT_BACKGROUNDOBJECTS);
480 :
481 398 : if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
482 : {
483 394 : bCreated = true;
484 :
485 394 : pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
486 394 : pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUNDOBJECTS );
487 394 : pSheet->SetParent( OUString() );
488 394 : SfxItemSet& rBackgroundObjectsSet = pSheet->GetItemSet();
489 394 : rBackgroundObjectsSet.Put(makeSdrShadowItem(false));
490 394 : rBackgroundObjectsSet.Put(makeSdrShadowColorItem(Color(COL_GRAY)));
491 394 : rBackgroundObjectsSet.Put(makeSdrShadowXDistItem(200)); // 3 mm shadow distance
492 394 : rBackgroundObjectsSet.Put(makeSdrShadowYDistItem(200));
493 : // #i16874# enable kerning by default but only for new documents
494 394 : rBackgroundObjectsSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
495 394 : rBackgroundObjectsSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK));
496 : }
497 :
498 : /**************************************************************************
499 : * Background
500 : **************************************************************************/
501 398 : aName = aPrefix + SD_RESSTR(STR_LAYOUT_BACKGROUND);
502 :
503 398 : if (!Find(aName, SD_STYLE_FAMILY_MASTERPAGE))
504 : {
505 394 : bCreated = true;
506 :
507 394 : pSheet = &Make(aName, SD_STYLE_FAMILY_MASTERPAGE,nUsedMask);
508 394 : pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUND );
509 394 : pSheet->SetParent( OUString() );
510 394 : SfxItemSet& rBackgroundSet = pSheet->GetItemSet();
511 394 : rBackgroundSet.Put(XLineStyleItem(XLINE_NONE));
512 394 : rBackgroundSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
513 : // #i16874# enable kerning by default but only for new documents
514 394 : rBackgroundSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
515 : }
516 :
517 398 : DBG_ASSERT( !bCheck || !bCreated, "missing layout style sheets detected!" );
518 398 : }
519 :
520 : /*************************************************************************
521 : |*
522 : |* Copy graphic style sheets from source pool into this pool
523 : |*
524 : |* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
525 : |*
526 : \************************************************************************/
527 :
528 0 : void SdStyleSheetPool::CopyGraphicSheets(SdStyleSheetPool& rSourcePool)
529 : {
530 0 : CopySheets( rSourcePool, SD_STYLE_FAMILY_GRAPHICS );
531 0 : }
532 :
533 0 : void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool& rSourcePool)
534 : {
535 0 : CopySheets( rSourcePool, SD_STYLE_FAMILY_CELL );
536 0 : }
537 :
538 0 : void SdStyleSheetPool::CopyTableStyles(SdStyleSheetPool& rSourcePool)
539 : {
540 0 : Reference< XIndexAccess > xSource( rSourcePool.mxTableFamily, UNO_QUERY );
541 0 : Reference< XNameContainer > xTarget( mxTableFamily, UNO_QUERY );
542 0 : Reference< XSingleServiceFactory > xFactory( mxTableFamily, UNO_QUERY );
543 :
544 0 : if( xSource.is() && xFactory.is() && mxTableFamily.is() )
545 : {
546 0 : for( sal_Int32 nIndex = 0; nIndex < xSource->getCount(); nIndex++ ) try
547 : {
548 0 : Reference< XStyle > xSourceTableStyle( xSource->getByIndex( nIndex ), UNO_QUERY );
549 0 : if( xSourceTableStyle.is() )
550 : {
551 0 : Reference< XStyle > xNewTableStyle( xFactory->createInstance(), UNO_QUERY );
552 0 : if( xNewTableStyle.is() )
553 : {
554 0 : Reference< XNameAccess> xSourceNames( xSourceTableStyle, UNO_QUERY_THROW );
555 :
556 0 : Sequence< OUString > aStyleNames( xSourceNames->getElementNames() );
557 0 : OUString* pStyleNames( aStyleNames.getArray() );
558 :
559 0 : Reference< XNameReplace > xTargetNames( xNewTableStyle, UNO_QUERY );
560 :
561 0 : sal_Int32 nNames = aStyleNames.getLength();
562 0 : while( nNames-- )
563 : {
564 0 : const OUString aName( *pStyleNames++ );
565 0 : Reference< XStyle > xSourceStyle( xSourceNames->getByName( aName ), UNO_QUERY );
566 0 : Reference< XStyle > xTargetStyle;
567 0 : if( xSourceStyle.is() ) try
568 : {
569 0 : mxCellFamily->getByName( xSourceStyle->getName() ) >>= xTargetStyle;
570 : }
571 0 : catch( Exception& )
572 : {
573 : OSL_FAIL( "sd::SdStyleSheetPool::CopyTableStyles(), exception caught!" );
574 : }
575 :
576 0 : if( xTargetStyle.is() )
577 0 : xTargetNames->replaceByName( aName, Any( xTargetStyle ) );
578 0 : }
579 : }
580 :
581 0 : OUString sName( xSourceTableStyle->getName() );
582 0 : if( xTarget->hasByName( sName ) )
583 0 : xTarget->replaceByName( sName, Any( xNewTableStyle ) );
584 : else
585 0 : xTarget->insertByName( sName, Any( xNewTableStyle ) );
586 0 : }
587 : }
588 0 : catch( Exception& )
589 : {
590 : OSL_FAIL("sd::SdStyleSheetPool::CopyTableStyles(), exception caught!");
591 : }
592 0 : }
593 0 : }
594 :
595 0 : void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets)
596 : {
597 0 : CopySheets( rSourcePool, SD_STYLE_FAMILY_CELL, rCreatedSheets );
598 0 : }
599 :
600 0 : void SdStyleSheetPool::RenameAndCopyGraphicSheets(SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets, OUString &rRenameSuffix)
601 : {
602 0 : RenameAndCopySheets( rSourcePool, SD_STYLE_FAMILY_GRAPHICS, rCreatedSheets, rRenameSuffix );
603 0 : }
604 :
605 0 : void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily )
606 : {
607 0 : SdStyleSheetVector aTmpSheets;
608 0 : CopySheets(rSourcePool, eFamily, aTmpSheets);
609 0 : }
610 :
611 0 : void SdStyleSheetPool::RenameAndCopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, SdStyleSheetVector& rCreatedSheets, OUString &rRenameSuffix)
612 : {
613 0 : CopySheets( rSourcePool, eFamily, rCreatedSheets, rRenameSuffix );
614 0 : }
615 :
616 0 : void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, SdStyleSheetVector& rCreatedSheets)
617 : {
618 0 : OUString emptyName;
619 0 : CopySheets(rSourcePool, eFamily, rCreatedSheets, emptyName);
620 0 : }
621 :
622 : namespace
623 : {
624 :
625 0 : struct HasFamilyPredicate : svl::StyleSheetPredicate
626 : {
627 0 : HasFamilyPredicate(SfxStyleFamily eFamily)
628 0 : : meFamily(eFamily) {;}
629 :
630 0 : bool Check(const SfxStyleSheetBase& sheet) SAL_OVERRIDE
631 : {
632 0 : return sheet.GetFamily() == meFamily;
633 : }
634 : SfxStyleFamily meFamily;
635 : };
636 :
637 : }
638 :
639 0 : void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, SdStyleSheetVector& rCreatedSheets, OUString& rRenameSuffix)
640 : {
641 0 : OUString aHelpFile;
642 :
643 0 : std::vector< std::pair< rtl::Reference< SfxStyleSheetBase >, OUString > > aNewStyles;
644 0 : std::vector< std::pair< OUString, OUString > > aRenamedList;
645 :
646 : // find all style sheets of the source pool which have the same family
647 0 : HasFamilyPredicate aHasFamilyPredicate(eFamily);
648 0 : std::vector<unsigned> aSheetsWithFamily = rSourcePool.GetIndexedStyleSheets().FindPositionsByPredicate(aHasFamilyPredicate);
649 :
650 0 : for (std::vector<unsigned>::const_iterator it = aSheetsWithFamily.begin();
651 0 : it != aSheetsWithFamily.end(); ++it )
652 : {
653 : rtl::Reference<SfxStyleSheetBase> const xSheet =
654 0 : rSourcePool.GetStyleSheetByPositionInIndex( *it );
655 0 : if( !xSheet.is() )
656 0 : continue;
657 0 : rtl::OUString aName( xSheet->GetName() );
658 :
659 : // now check whether we already have a sheet with the same name
660 0 : std::vector<unsigned> aSheetsWithName = GetIndexedStyleSheets().FindPositionsByName(aName);
661 0 : bool bAddToList = false;
662 0 : SfxStyleSheetBase * pExistingSheet = 0;
663 0 : if (!aSheetsWithName.empty())
664 : {
665 : // if we have a rename suffix, try to find a new name
666 : pExistingSheet =
667 0 : GetStyleSheetByPositionInIndex(aSheetsWithName.front()).get();
668 0 : sal_Int32 nHash = xSheet->GetItemSet().getHash();
669 0 : if (!rRenameSuffix.isEmpty() &&
670 0 : pExistingSheet->GetItemSet().getHash() != nHash)
671 : {
672 : // we have found a sheet with the same name, but different contents. Try to find a new name.
673 : // If we already have a sheet with the new name, and it is equal to the one in the source pool,
674 : // do nothing.
675 0 : OUString aTmpName = aName + rRenameSuffix;
676 0 : sal_Int32 nSuffix = 1;
677 0 : do
678 : {
679 0 : aTmpName = aName + rRenameSuffix + OUString::number(nSuffix);
680 0 : pExistingSheet = Find(aTmpName, eFamily);
681 0 : nSuffix++;
682 0 : } while( pExistingSheet && pExistingSheet->GetItemSet().getHash() != nHash );
683 0 : aName = aTmpName;
684 0 : bAddToList = true;
685 : }
686 : }
687 : // we do not already have a sheet with the same name and contents. Create a new one.
688 0 : if (!pExistingSheet)
689 : {
690 : assert(!Find(aName, eFamily));
691 0 : rtl::Reference< SfxStyleSheetBase > xNewSheet( &Make( aName, eFamily ) );
692 :
693 0 : xNewSheet->SetMask( xSheet->GetMask() );
694 :
695 : // Also set parent relation for copied style sheets
696 0 : OUString aParent( xSheet->GetParent() );
697 0 : if( !aParent.isEmpty() )
698 0 : aNewStyles.push_back( std::pair< rtl::Reference< SfxStyleSheetBase >, OUString >( xNewSheet, aParent ) );
699 :
700 0 : xNewSheet->SetHelpId( aHelpFile, xSheet->GetHelpId( aHelpFile ) );
701 0 : xNewSheet->GetItemSet().Put( xSheet->GetItemSet() );
702 :
703 0 : rCreatedSheets.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( xNewSheet.get() ) ) );
704 0 : aRenamedList.push_back( std::pair< OUString, OUString >( xSheet->GetName(), aName ) );
705 : }
706 0 : else if (bAddToList)
707 : {
708 : // Add to list - used for renaming
709 0 : rCreatedSheets.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( pExistingSheet ) ) );
710 0 : aRenamedList.push_back( std::pair< OUString, OUString >( xSheet->GetName(), aName ) );
711 : }
712 0 : }
713 :
714 : // set parents on newly added stylesheets
715 0 : std::vector< std::pair< rtl::Reference< SfxStyleSheetBase >, OUString > >::iterator aIter;
716 0 : for( aIter = aNewStyles.begin(); aIter != aNewStyles.end(); ++aIter )
717 : {
718 0 : if( !rRenameSuffix.isEmpty() )
719 : {
720 0 : SfxStyleSheet *pParent = lcl_findStyle(rCreatedSheets, lcl_findRenamedStyleName(aRenamedList, (*aIter).second));
721 0 : if( pParent )
722 : {
723 0 : (*aIter).first->SetParent( pParent->GetName() );
724 0 : continue;
725 : }
726 : }
727 : DBG_ASSERT( rSourcePool.Find( (*aIter).second, eFamily ), "StyleSheet has invalid parent: Family mismatch" );
728 0 : (*aIter).first->SetParent( (*aIter).second );
729 : }
730 : // we have changed names of style sheets. Trigger reindexing.
731 0 : Reindex();
732 0 : }
733 :
734 : /*************************************************************************
735 : |*
736 : |* Copy style sheets of the named presentation layout from the source pool into
737 : |* this pool. Copies only the style sheets which aren't yet in this pool.
738 : |* If not NULL, pCreatedSheets is filled with pointers to the created style
739 : |* sheets.
740 : |*
741 : |* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
742 : |*
743 : \************************************************************************/
744 :
745 0 : void SdStyleSheetPool::CopyLayoutSheets(const OUString& rLayoutName, SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets)
746 : {
747 0 : SfxStyleSheetBase* pSheet = NULL;
748 :
749 0 : std::vector<OUString> aNameList;
750 0 : CreateLayoutSheetNames(rLayoutName,aNameList);
751 :
752 0 : OUString sEmpty;
753 0 : for (std::vector<OUString>::const_iterator it = aNameList.begin(); it != aNameList.end(); ++it)
754 : {
755 0 : pSheet = Find(*it, SD_STYLE_FAMILY_MASTERPAGE);
756 0 : if (!pSheet)
757 : {
758 0 : SfxStyleSheetBase* pSourceSheet = rSourcePool.Find(*it, SD_STYLE_FAMILY_MASTERPAGE);
759 : DBG_ASSERT(pSourceSheet, "CopyLayoutSheets: Style sheet missing");
760 0 : if (pSourceSheet)
761 : {
762 : // In the case one comes with Methusalem-Docs.
763 0 : SfxStyleSheetBase& rNewSheet = Make(*it, SD_STYLE_FAMILY_MASTERPAGE);
764 0 : rNewSheet.SetHelpId( sEmpty, pSourceSheet->GetHelpId( sEmpty ) );
765 0 : rNewSheet.GetItemSet().Put(pSourceSheet->GetItemSet());
766 0 : rCreatedSheets.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( &rNewSheet ) ) );
767 : }
768 : }
769 : }
770 :
771 : // Special treatment for outline templates: create parent relation
772 0 : std::vector<SfxStyleSheetBase*> aOutlineSheets;
773 0 : CreateOutlineSheetList(rLayoutName,aOutlineSheets);
774 :
775 0 : if( !aOutlineSheets.empty() )
776 : {
777 0 : std::vector<SfxStyleSheetBase*>::iterator it = aOutlineSheets.begin();
778 0 : SfxStyleSheetBase* pParent = *it;
779 0 : ++it;
780 :
781 0 : while (it != aOutlineSheets.end())
782 : {
783 0 : pSheet = *it;
784 :
785 0 : if (!pSheet)
786 0 : break;
787 :
788 0 : if (pSheet->GetParent().isEmpty())
789 0 : pSheet->SetParent(pParent->GetName());
790 :
791 0 : pParent = pSheet;
792 :
793 0 : ++it;
794 : }
795 0 : }
796 0 : }
797 :
798 : /*************************************************************************
799 : |*
800 : |* Create list with names of the presentation templates of a layout.
801 : |* The list and the containing strings are owned by the caller!
802 : |*
803 : \************************************************************************/
804 :
805 0 : void SdStyleSheetPool::CreateLayoutSheetNames(const OUString& rLayoutName, std::vector<OUString> &aNameList) const
806 : {
807 0 : OUString aPrefix(rLayoutName + SD_LT_SEPARATOR);
808 0 : OUString aName(SD_RESSTR(STR_LAYOUT_OUTLINE));
809 :
810 0 : for (sal_Int32 nLevel = 1; nLevel < 10; nLevel++)
811 0 : aNameList.push_back( aPrefix + aName + " " + OUString::number( nLevel ) );
812 :
813 0 : aNameList.push_back( aPrefix + SD_RESSTR(STR_LAYOUT_TITLE) );
814 0 : aNameList.push_back( aPrefix + SD_RESSTR(STR_LAYOUT_SUBTITLE) );
815 0 : aNameList.push_back( aPrefix + SD_RESSTR(STR_LAYOUT_NOTES) );
816 0 : aNameList.push_back( aPrefix + SD_RESSTR(STR_LAYOUT_BACKGROUNDOBJECTS) );
817 0 : aNameList.push_back( aPrefix + SD_RESSTR(STR_LAYOUT_BACKGROUND) );
818 0 : }
819 :
820 : /*************************************************************************
821 : |*
822 : |* Create a list with pointer to presentation templates of a layout.
823 : |* The list is owned by the caller!
824 : |*
825 : \************************************************************************/
826 :
827 0 : void SdStyleSheetPool::CreateLayoutSheetList(const OUString& rLayoutName, SdStyleSheetVector& rLayoutSheets )
828 : {
829 0 : OUString aLayoutNameWithSep(rLayoutName + OUString(SD_LT_SEPARATOR ));
830 :
831 0 : SfxStyleSheetIterator aIter(this, SD_STYLE_FAMILY_MASTERPAGE);
832 0 : SfxStyleSheetBase* pSheet = aIter.First();
833 :
834 0 : while (pSheet)
835 : {
836 0 : if (pSheet->GetName().startsWith(aLayoutNameWithSep))
837 0 : rLayoutSheets.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( pSheet ) ) );
838 0 : pSheet = aIter.Next();
839 0 : }
840 0 : }
841 :
842 : /*************************************************************************
843 : |*
844 : |* Create pseudo style sheets if necessary
845 : |*
846 : \************************************************************************/
847 :
848 364 : void SdStyleSheetPool::CreatePseudosIfNecessary()
849 : {
850 364 : OUString aName;
851 728 : OUString aHelpFile;
852 364 : SfxStyleSheetBase* pSheet = NULL;
853 364 : SfxStyleSheetBase* pParent = NULL;
854 :
855 364 : sal_uInt16 nUsedMask = SFXSTYLEBIT_USED;
856 :
857 364 : aName = SD_RESSTR(STR_PSEUDOSHEET_TITLE);
858 364 : if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
859 : {
860 360 : pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
861 360 : pSheet->SetParent( OUString() );
862 360 : ((SfxStyleSheet*)pSheet)->StartListening(*this);
863 : }
864 364 : pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_TITLE );
865 :
866 364 : aName = SD_RESSTR(STR_PSEUDOSHEET_SUBTITLE);
867 364 : if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
868 : {
869 360 : pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
870 360 : pSheet->SetParent( OUString() );
871 360 : ((SfxStyleSheet*)pSheet)->StartListening(*this);
872 : }
873 364 : pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_SUBTITLE );
874 :
875 364 : aName = SD_RESSTR(STR_PSEUDOSHEET_BACKGROUNDOBJECTS);
876 364 : if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
877 : {
878 360 : pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
879 360 : pSheet->SetParent( OUString() );
880 360 : ((SfxStyleSheet*)pSheet)->StartListening(*this);
881 : }
882 364 : pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUNDOBJECTS );
883 :
884 364 : aName = SD_RESSTR(STR_PSEUDOSHEET_BACKGROUND);
885 364 : if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
886 : {
887 360 : pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
888 360 : pSheet->SetParent( OUString() );
889 360 : ((SfxStyleSheet*)pSheet)->StartListening(*this);
890 : }
891 364 : pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUND );
892 :
893 364 : aName = SD_RESSTR(STR_PSEUDOSHEET_NOTES);
894 364 : if( (pSheet = Find(aName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
895 : {
896 360 : pSheet = &Make(aName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
897 360 : pSheet->SetParent( OUString() );
898 360 : ((SfxStyleSheet*)pSheet)->StartListening(*this);
899 : }
900 364 : pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_NOTES );
901 :
902 364 : pParent = NULL;
903 364 : SetSearchMask(SD_STYLE_FAMILY_PSEUDO);
904 364 : aName = SD_RESSTR(STR_PSEUDOSHEET_OUTLINE);
905 3640 : for (sal_Int32 nLevel = 1; nLevel < 10; nLevel++)
906 : {
907 3276 : OUString aLevelName( aName + " " + OUString::number( nLevel ) );
908 :
909 3276 : if( (pSheet = Find(aLevelName, SD_STYLE_FAMILY_PSEUDO)) == 0 )
910 : {
911 3240 : pSheet = &Make(aLevelName, SD_STYLE_FAMILY_PSEUDO, nUsedMask);
912 :
913 3240 : if (pSheet)
914 : {
915 3240 : if (pParent)
916 2880 : pSheet->SetParent(pParent->GetName());
917 3240 : pParent = pSheet;
918 3240 : ((SfxStyleSheet*)pSheet)->StartListening(*this);
919 : }
920 : }
921 3276 : pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_OUTLINE + nLevel );
922 3640 : }
923 364 : }
924 :
925 : /*************************************************************************
926 : |*
927 : |* Set the correct name in the program language to the standard styles
928 : |*
929 : \************************************************************************/
930 :
931 : namespace
932 : {
933 0 : struct StyleSheetIsUserDefinedPredicate : svl::StyleSheetPredicate
934 : {
935 0 : StyleSheetIsUserDefinedPredicate()
936 0 : {;}
937 :
938 0 : bool Check(const SfxStyleSheetBase& sheet) SAL_OVERRIDE
939 : {
940 0 : return sheet.IsUserDefined();
941 : }
942 : };
943 : }
944 :
945 0 : void SdStyleSheetPool::UpdateStdNames()
946 : {
947 0 : OUString aHelpFile;
948 0 : StyleSheetIsUserDefinedPredicate aPredicate;
949 0 : std::vector<SfxStyleSheetBase*> aEraseList;
950 0 : std::vector<unsigned> aUserDefinedStyles = GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate);
951 0 : for (std::vector<unsigned>::const_iterator it = aUserDefinedStyles.begin();
952 0 : it != aUserDefinedStyles.end(); ++it)
953 : {
954 0 : SfxStyleSheetBase* pStyle = GetStyleSheetByPositionInIndex(*it).get();
955 :
956 0 : if( !pStyle->IsUserDefined() )
957 : {
958 0 : OUString aOldName = pStyle->GetName();
959 0 : sal_uLong nHelpId = pStyle->GetHelpId( aHelpFile );
960 0 : SfxStyleFamily eFam = pStyle->GetFamily();
961 :
962 0 : bool bHelpKnown = true;
963 0 : OUString aNewName;
964 0 : sal_uInt16 nNameId = 0;
965 0 : switch( nHelpId )
966 : {
967 0 : case HID_STANDARD_STYLESHEET_NAME: nNameId = STR_STANDARD_STYLESHEET_NAME; break;
968 0 : case HID_POOLSHEET_OBJWITHARROW: nNameId = STR_POOLSHEET_OBJWITHARROW; break;
969 0 : case HID_POOLSHEET_OBJWITHSHADOW: nNameId = STR_POOLSHEET_OBJWITHSHADOW; break;
970 0 : case HID_POOLSHEET_OBJWITHOUTFILL: nNameId = STR_POOLSHEET_OBJWITHOUTFILL; break;
971 0 : case HID_POOLSHEET_OBJNOLINENOFILL: nNameId = STR_POOLSHEET_OBJNOLINENOFILL;break;
972 0 : case HID_POOLSHEET_TEXT: nNameId = STR_POOLSHEET_TEXT; break;
973 0 : case HID_POOLSHEET_TEXTBODY: nNameId = STR_POOLSHEET_TEXTBODY; break;
974 0 : case HID_POOLSHEET_TEXTBODY_JUSTIFY:nNameId = STR_POOLSHEET_TEXTBODY_JUSTIFY;break;
975 0 : case HID_POOLSHEET_TEXTBODY_INDENT: nNameId = STR_POOLSHEET_TEXTBODY_INDENT;break;
976 0 : case HID_POOLSHEET_TITLE: nNameId = STR_POOLSHEET_TITLE; break;
977 0 : case HID_POOLSHEET_TITLE1: nNameId = STR_POOLSHEET_TITLE1; break;
978 0 : case HID_POOLSHEET_TITLE2: nNameId = STR_POOLSHEET_TITLE2; break;
979 0 : case HID_POOLSHEET_HEADLINE: nNameId = STR_POOLSHEET_HEADLINE; break;
980 0 : case HID_POOLSHEET_HEADLINE1: nNameId = STR_POOLSHEET_HEADLINE1; break;
981 0 : case HID_POOLSHEET_HEADLINE2: nNameId = STR_POOLSHEET_HEADLINE2; break;
982 0 : case HID_POOLSHEET_MEASURE: nNameId = STR_POOLSHEET_MEASURE; break;
983 :
984 0 : case HID_PSEUDOSHEET_TITLE: nNameId = STR_PSEUDOSHEET_TITLE; break;
985 0 : case HID_PSEUDOSHEET_SUBTITLE: nNameId = STR_PSEUDOSHEET_SUBTITLE; break;
986 : case HID_PSEUDOSHEET_OUTLINE1:
987 : case HID_PSEUDOSHEET_OUTLINE2:
988 : case HID_PSEUDOSHEET_OUTLINE3:
989 : case HID_PSEUDOSHEET_OUTLINE4:
990 : case HID_PSEUDOSHEET_OUTLINE5:
991 : case HID_PSEUDOSHEET_OUTLINE6:
992 : case HID_PSEUDOSHEET_OUTLINE7:
993 : case HID_PSEUDOSHEET_OUTLINE8:
994 0 : case HID_PSEUDOSHEET_OUTLINE9: nNameId = STR_PSEUDOSHEET_OUTLINE; break;
995 0 : case HID_PSEUDOSHEET_BACKGROUNDOBJECTS: nNameId = STR_PSEUDOSHEET_BACKGROUNDOBJECTS; break;
996 0 : case HID_PSEUDOSHEET_BACKGROUND: nNameId = STR_PSEUDOSHEET_BACKGROUND; break;
997 0 : case HID_PSEUDOSHEET_NOTES: nNameId = STR_PSEUDOSHEET_NOTES; break;
998 :
999 0 : case HID_SD_CELL_STYLE_DEFAULT: nNameId = STR_STANDARD_STYLESHEET_NAME; break;
1000 0 : case HID_SD_CELL_STYLE_BANDED: nNameId = STR_POOLSHEET_BANDED_CELL; break;
1001 0 : case HID_SD_CELL_STYLE_HEADER: nNameId = STR_POOLSHEET_HEADER; break;
1002 0 : case HID_SD_CELL_STYLE_TOTAL: nNameId = STR_POOLSHEET_TOTAL; break;
1003 0 : case HID_SD_CELL_STYLE_FIRST_COLUMN: nNameId = STR_POOLSHEET_FIRST_COLUMN; break;
1004 0 : case HID_SD_CELL_STYLE_LAST_COLUMN: nNameId = STR_POOLSHEET_LAST_COLUMN; break;
1005 :
1006 : default:
1007 : // 0 or wrong (old) HelpId
1008 0 : bHelpKnown = false;
1009 : }
1010 0 : if( bHelpKnown )
1011 : {
1012 0 : if( nNameId )
1013 : {
1014 0 : aNewName = SD_RESSTR( nNameId );
1015 0 : if( nNameId == STR_PSEUDOSHEET_OUTLINE )
1016 : {
1017 0 : aNewName += " " + OUString::number( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE ) );
1018 : }
1019 : }
1020 :
1021 0 : if( !aNewName.isEmpty() && aNewName != aOldName )
1022 : {
1023 0 : SfxStyleSheetBase* pSheetFound = Find( aNewName, eFam );
1024 :
1025 0 : if ( !pSheetFound )
1026 : {
1027 : // Sheet does not yet exist: rename old sheet
1028 0 : pStyle->SetName( aNewName ); // transform also parents
1029 : }
1030 : else
1031 : {
1032 : // Sheet does exist: old sheet has to be removed
1033 0 : aEraseList.push_back( pStyle );
1034 : }
1035 : }
1036 0 : }
1037 : }
1038 : }
1039 :
1040 0 : if (!aEraseList.empty())
1041 : {
1042 : // styles that could not be renamed, must be removed
1043 0 : for ( size_t i = 0, n = aEraseList.size(); i < n; ++i )
1044 0 : Remove( aEraseList[ i ] );
1045 0 : Reindex();
1046 0 : }
1047 0 : }
1048 :
1049 4280 : void SdStyleSheetPool::setDefaultOutlineNumberFormatBulletAndIndent(sal_uInt16 i, SvxNumberFormat &rNumberFormat)
1050 : {
1051 4280 : rNumberFormat.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1052 4280 : rNumberFormat.SetBulletRelSize(45);
1053 4280 : const short nLSpace = (i + 1) * 1200;
1054 4280 : rNumberFormat.SetLSpace(nLSpace);
1055 4280 : rNumberFormat.SetAbsLSpace(nLSpace);
1056 4280 : short nFirstLineOffset = -600;
1057 :
1058 4280 : switch(i)
1059 : {
1060 : case 0:
1061 : {
1062 428 : nFirstLineOffset = -900;
1063 : }
1064 428 : break;
1065 :
1066 : case 1:
1067 : {
1068 428 : rNumberFormat.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
1069 428 : rNumberFormat.SetBulletRelSize(75);
1070 428 : nFirstLineOffset = -900;
1071 : }
1072 428 : break;
1073 :
1074 : case 2:
1075 : {
1076 428 : nFirstLineOffset = -800;
1077 : }
1078 428 : break;
1079 :
1080 : case 3:
1081 : {
1082 428 : rNumberFormat.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
1083 428 : rNumberFormat.SetBulletRelSize(75);
1084 : }
1085 428 : break;
1086 : }
1087 :
1088 4280 : rNumberFormat.SetFirstLineOffset(nFirstLineOffset);
1089 4280 : }
1090 :
1091 : // Set new SvxNumBulletItem for the respective style sheet
1092 1696 : void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet,
1093 : vcl::Font& rBulletFont )
1094 : {
1095 1696 : OUString aHelpFile;
1096 1696 : sal_uLong nHelpId = pSheet->GetHelpId( aHelpFile );
1097 1696 : SfxItemSet& rSet = pSheet->GetItemSet();
1098 :
1099 1696 : switch ( nHelpId )
1100 : {
1101 : case HID_STANDARD_STYLESHEET_NAME :
1102 : {
1103 : // Standard template
1104 400 : SvxNumberFormat aNumberFormat(SVX_NUM_CHAR_SPECIAL);
1105 400 : aNumberFormat.SetBulletFont(&rBulletFont);
1106 400 : aNumberFormat.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1107 400 : aNumberFormat.SetBulletRelSize(45);
1108 400 : aNumberFormat.SetBulletColor(Color(COL_AUTO));
1109 400 : aNumberFormat.SetStart(1);
1110 400 : aNumberFormat.SetNumAdjust(SVX_ADJUST_LEFT);
1111 :
1112 800 : SvxNumRule aNumRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE, SVX_MAX_NUM, false);
1113 :
1114 4400 : for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
1115 : {
1116 4000 : const short nLSpace = (i + 1) * 600;
1117 4000 : aNumberFormat.SetLSpace(nLSpace);
1118 4000 : aNumberFormat.SetAbsLSpace(nLSpace);
1119 4000 : aNumberFormat.SetFirstLineOffset(-600);
1120 4000 : aNumRule.SetLevel( i, aNumberFormat );
1121 : }
1122 :
1123 400 : rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) );
1124 800 : ((SfxStyleSheet*)pSheet)->Broadcast(SfxSimpleHint( SFX_HINT_DATACHANGED ) );
1125 : }
1126 400 : break;
1127 :
1128 : case HID_PSEUDOSHEET_TITLE:
1129 : /* title gets same bullet as subtitle and not that page symbol anymore */
1130 : case HID_PSEUDOSHEET_SUBTITLE :
1131 : {
1132 : // Subtitle template
1133 856 : SvxNumRule* pDefaultRule = ((SvxNumBulletItem*) rSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET))->GetNumRule();
1134 : DBG_ASSERT( pDefaultRule, "Where is my default template? [CL]" );
1135 :
1136 856 : if(pDefaultRule)
1137 : {
1138 856 : SvxNumRule aNumRule(pDefaultRule->GetFeatureFlags(), 10, false);
1139 9416 : for(sal_uInt16 i=0; i < aNumRule.GetLevelCount(); i++)
1140 : {
1141 8560 : SvxNumberFormat aFrmt( pDefaultRule->GetLevel(i) );
1142 8560 : aFrmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
1143 : // #i93908# clear suffix for bullet lists
1144 8560 : aFrmt.SetPrefix(OUString());
1145 8560 : aFrmt.SetSuffix(OUString());
1146 8560 : aFrmt.SetStart(1);
1147 8560 : aFrmt.SetBulletRelSize(45);
1148 8560 : aFrmt.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1149 8560 : aFrmt.SetBulletFont(&rBulletFont);
1150 8560 : aNumRule.SetLevel(i, aFrmt);
1151 8560 : }
1152 :
1153 856 : rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) );
1154 856 : ((SfxStyleSheet*)pSheet)->Broadcast(SfxSimpleHint( SFX_HINT_DATACHANGED ) );
1155 : }
1156 : }
1157 856 : break;
1158 :
1159 : case HID_PSEUDOSHEET_OUTLINE + 1 :
1160 : {
1161 : // Outline template
1162 428 : SvxNumberFormat aNumberFormat(SVX_NUM_CHAR_SPECIAL);
1163 428 : aNumberFormat.SetBulletColor(Color(COL_AUTO));
1164 428 : aNumberFormat.SetStart(1);
1165 428 : aNumberFormat.SetNumAdjust(SVX_ADJUST_LEFT);
1166 :
1167 : SvxNumRule aNumRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE|NUM_SYMBOL_ALIGNMENT,
1168 856 : SVX_MAX_NUM, false );
1169 4708 : for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
1170 : {
1171 4280 : setDefaultOutlineNumberFormatBulletAndIndent(i, aNumberFormat);
1172 :
1173 4280 : sal_uLong nFontSize = 20;
1174 4280 : switch(i)
1175 : {
1176 : case 0:
1177 : {
1178 428 : nFontSize = 32;
1179 : }
1180 428 : break;
1181 :
1182 : case 1:
1183 : {
1184 428 : nFontSize = 32;
1185 : }
1186 428 : break;
1187 :
1188 : case 2:
1189 : {
1190 428 : nFontSize = 28;
1191 : }
1192 428 : break;
1193 :
1194 : case 3:
1195 : {
1196 428 : nFontSize = 24;
1197 : }
1198 428 : break;
1199 : }
1200 :
1201 4280 : nFontSize = (sal_uInt16)((nFontSize * 2540L) / 72); // Pt --> 1/100 mm
1202 4280 : rBulletFont.SetSize(Size(0,846)); // 24 pt
1203 4280 : aNumberFormat.SetBulletFont(&rBulletFont);
1204 4280 : aNumRule.SetLevel( i, aNumberFormat );
1205 : }
1206 :
1207 428 : rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) );
1208 856 : ((SfxStyleSheet*)pSheet)->Broadcast(SfxSimpleHint( SFX_HINT_DATACHANGED ) );
1209 : }
1210 428 : break;
1211 1696 : }
1212 1696 : }
1213 :
1214 : /*************************************************************************
1215 : |*
1216 : |* Create standard bullet font (without size)
1217 : |*
1218 : \************************************************************************/
1219 :
1220 1992 : vcl::Font SdStyleSheetPool::GetBulletFont()
1221 : {
1222 1992 : vcl::Font aBulletFont( OUString( "StarSymbol" ), Size(0, 1000) );
1223 1992 : aBulletFont.SetCharSet(RTL_TEXTENCODING_UNICODE);
1224 1992 : aBulletFont.SetWeight(WEIGHT_NORMAL);
1225 1992 : aBulletFont.SetUnderline(UNDERLINE_NONE);
1226 1992 : aBulletFont.SetOverline(UNDERLINE_NONE);
1227 1992 : aBulletFont.SetStrikeout(STRIKEOUT_NONE);
1228 1992 : aBulletFont.SetItalic(ITALIC_NONE);
1229 1992 : aBulletFont.SetOutline(false);
1230 1992 : aBulletFont.SetShadow(false);
1231 1992 : aBulletFont.SetColor(Color(COL_AUTO));
1232 1992 : aBulletFont.SetTransparent(true);
1233 :
1234 1992 : return aBulletFont;
1235 : }
1236 :
1237 394 : void SdStyleSheetPool::AddStyleFamily( const SdPage* pPage )
1238 : {
1239 394 : rtl::Reference< SfxStyleSheetPool > xPool( this );
1240 394 : maStyleFamilyMap[pPage] = new SdStyleFamily( xPool, pPage );
1241 394 : }
1242 :
1243 394 : void SdStyleSheetPool::RemoveStyleFamily( const SdPage* pPage )
1244 : {
1245 394 : SdStyleFamilyMap::iterator iter( maStyleFamilyMap.find( pPage ) );
1246 394 : if( iter != maStyleFamilyMap.end() )
1247 : {
1248 394 : SdStyleFamilyRef xStyle( (*iter).second );
1249 394 : maStyleFamilyMap.erase( iter );
1250 :
1251 394 : if( xStyle.is() ) try
1252 : {
1253 394 : xStyle->dispose();
1254 : }
1255 0 : catch( Exception& )
1256 : {
1257 394 : }
1258 : }
1259 394 : }
1260 :
1261 5792 : void SdStyleSheetPool::throwIfDisposed() throw(::com::sun::star::uno::RuntimeException)
1262 : {
1263 5792 : if( mpDoc == NULL )
1264 0 : throw DisposedException();
1265 5792 : }
1266 :
1267 : // XServiceInfo
1268 0 : OUString SAL_CALL SdStyleSheetPool::getImplementationName() throw(RuntimeException, std::exception)
1269 : {
1270 0 : return OUString( "SdStyleSheetPool" );
1271 : }
1272 :
1273 0 : sal_Bool SAL_CALL SdStyleSheetPool::supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception)
1274 : {
1275 0 : return cppu::supportsService(this, ServiceName);
1276 : }
1277 :
1278 0 : Sequence< OUString > SAL_CALL SdStyleSheetPool::getSupportedServiceNames() throw(RuntimeException, std::exception)
1279 : {
1280 0 : OUString aStr("com.sun.star.style.StyleFamilies");
1281 0 : return Sequence< OUString >( &aStr, 1 );
1282 : }
1283 :
1284 : // XNameAccess
1285 4320 : Any SAL_CALL SdStyleSheetPool::getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
1286 : {
1287 4320 : throwIfDisposed();
1288 :
1289 4320 : if( mxGraphicFamily->getName() == aName )
1290 2482 : return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxGraphicFamily.get() ) ) );
1291 :
1292 1838 : if( mxCellFamily->getName() == aName )
1293 140 : return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxCellFamily.get() ) ) );
1294 :
1295 1698 : if( msTableFamilyName == aName )
1296 396 : return Any( mxTableFamily );
1297 :
1298 1337 : for( SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() ); iter != maStyleFamilyMap.end(); ++iter )
1299 : {
1300 1337 : if( (*iter).second->getName() == aName )
1301 1302 : return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( (*iter).second.get() ) ) );
1302 : }
1303 :
1304 0 : throw NoSuchElementException();
1305 : }
1306 :
1307 0 : Sequence< OUString > SAL_CALL SdStyleSheetPool::getElementNames() throw(RuntimeException, std::exception)
1308 : {
1309 0 : throwIfDisposed();
1310 :
1311 0 : Sequence< OUString > aNames( maStyleFamilyMap.size() + 3 );
1312 0 : OUString* pNames = aNames.getArray();
1313 :
1314 0 : *pNames++ = mxGraphicFamily->getName();
1315 0 : *pNames++ = mxCellFamily->getName();
1316 0 : *pNames++ = msTableFamilyName;
1317 :
1318 0 : for( SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() ); iter != maStyleFamilyMap.end(); ++iter )
1319 : {
1320 0 : *pNames++ = (*iter).second->getName();
1321 : }
1322 :
1323 0 : return aNames;
1324 : }
1325 :
1326 1472 : sal_Bool SAL_CALL SdStyleSheetPool::hasByName( const OUString& aName ) throw(RuntimeException, std::exception)
1327 : {
1328 1472 : throwIfDisposed();
1329 :
1330 1472 : if( mxGraphicFamily->getName() == aName )
1331 42 : return sal_True;
1332 :
1333 1430 : if( mxCellFamily->getName() == aName )
1334 22 : return sal_True;
1335 :
1336 1408 : if( msTableFamilyName == aName )
1337 0 : return sal_True;
1338 :
1339 2212 : for( SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() ); iter != maStyleFamilyMap.end(); ++iter )
1340 : {
1341 1436 : if( (*iter).second->getName() == aName )
1342 632 : return sal_True;
1343 : }
1344 :
1345 776 : return sal_False;
1346 : }
1347 :
1348 : // XElementAccess
1349 :
1350 0 : Type SAL_CALL SdStyleSheetPool::getElementType() throw(RuntimeException, std::exception)
1351 : {
1352 0 : throwIfDisposed();
1353 :
1354 0 : return cppu::UnoType<XNameAccess>::get();
1355 : }
1356 :
1357 0 : sal_Bool SAL_CALL SdStyleSheetPool::hasElements() throw(RuntimeException, std::exception)
1358 : {
1359 0 : return sal_True;
1360 : }
1361 :
1362 : // XIndexAccess
1363 :
1364 0 : sal_Int32 SAL_CALL SdStyleSheetPool::getCount() throw(RuntimeException, std::exception)
1365 : {
1366 0 : throwIfDisposed();
1367 :
1368 0 : return maStyleFamilyMap.size() + 3;
1369 : }
1370 :
1371 0 : Any SAL_CALL SdStyleSheetPool::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception)
1372 : {
1373 0 : switch( Index )
1374 : {
1375 : case 0:
1376 0 : return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxGraphicFamily.get() ) ) );
1377 :
1378 : case 1:
1379 0 : return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxCellFamily.get() ) ) );
1380 :
1381 : case 2:
1382 0 : return Any( mxTableFamily );
1383 :
1384 : default:
1385 : {
1386 0 : Index -= 3;
1387 0 : if( (Index < 0) || (Index >= sal::static_int_cast<sal_Int32>(maStyleFamilyMap.size())) )
1388 0 : throw IndexOutOfBoundsException();
1389 0 : SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() );
1390 0 : while( Index-- )
1391 0 : ++iter;
1392 :
1393 0 : return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( (*iter).second.get() ) ) );
1394 : }
1395 : }
1396 : }
1397 :
1398 : // XComponent
1399 :
1400 442 : void SAL_CALL SdStyleSheetPool::dispose() throw (RuntimeException, std::exception)
1401 : {
1402 442 : if( mpDoc )
1403 : {
1404 442 : mxGraphicFamily->dispose();
1405 442 : mxGraphicFamily.clear();
1406 442 : mxCellFamily->dispose();
1407 442 : mxCellFamily.clear();
1408 :
1409 442 : Reference< XComponent > xComp( mxTableFamily, UNO_QUERY );
1410 442 : if( xComp.is() )
1411 442 : xComp->dispose();
1412 442 : mxTableFamily = 0;
1413 :
1414 884 : SdStyleFamilyMap aTempMap;
1415 442 : aTempMap.swap( maStyleFamilyMap );
1416 :
1417 442 : for( SdStyleFamilyMap::iterator iter( aTempMap.begin() ); iter != aTempMap.end(); ++iter ) try
1418 : {
1419 0 : (*iter).second->dispose();
1420 : }
1421 0 : catch( Exception& )
1422 : {
1423 : }
1424 :
1425 442 : mpDoc = 0;
1426 :
1427 884 : Clear();
1428 : }
1429 442 : }
1430 :
1431 0 : void SAL_CALL SdStyleSheetPool::addEventListener( const Reference< XEventListener >& /*xListener*/ ) throw (RuntimeException, std::exception)
1432 : {
1433 0 : }
1434 :
1435 0 : void SAL_CALL SdStyleSheetPool::removeEventListener( const Reference< XEventListener >& /*aListener*/ ) throw (RuntimeException, std::exception)
1436 : {
1437 0 : }
1438 :
1439 0 : SdStyleSheetVector SdStyleSheetPool::CreateChildList( SdStyleSheet* pSheet )
1440 : {
1441 0 : SdStyleSheetVector aResult;
1442 :
1443 0 : const size_t nListenerCount = pSheet->GetSizeOfVector();
1444 0 : for (size_t n = 0; n < nListenerCount; ++n)
1445 : {
1446 0 : SdStyleSheet* pChild = dynamic_cast< SdStyleSheet* >( pSheet->GetListener(n) );
1447 0 : if(pChild && pChild->GetParent() == pSheet->GetName())
1448 : {
1449 0 : aResult.push_back( SdStyleSheetRef( pChild ) );
1450 : }
1451 : }
1452 :
1453 0 : return aResult;
1454 : }
1455 :
1456 37352 : void SAL_CALL SdStyleSheetPool::acquire (void) throw ()
1457 : {
1458 37352 : SdStyleSheetPoolBase::acquire();
1459 37352 : }
1460 :
1461 37352 : void SAL_CALL SdStyleSheetPool::release (void) throw ()
1462 : {
1463 37352 : SdStyleSheetPoolBase::release();
1464 37466 : }
1465 :
1466 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|