1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <com/sun/star/lang/DisposedException.hpp>
21 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
22 #include <cppuhelper/supportsservice.hxx>
23 #include <editeng/eeitem.hxx>
24 #include <editeng/fhgtitem.hxx>
25 #include <editeng/colritem.hxx>
26 #include <editeng/contouritem.hxx>
27 #include <editeng/shdditem.hxx>
28 #include <editeng/crossedoutitem.hxx>
29 #include <editeng/udlnitem.hxx>
30 #include <editeng/wghtitem.hxx>
31 #include <editeng/postitem.hxx>
32 #include <editeng/fontitem.hxx>
33 #include <svl/poolitem.hxx>
34 #include <svx/xfillit0.hxx>
35 #include <svx/xlineit0.hxx>
36 #include <editeng/ulspitem.hxx>
37 #include <editeng/numitem.hxx>
38 #include <editeng/brushitem.hxx>
39 #include <editeng/editeng.hxx>
40 #include <editeng/cmapitem.hxx>
41 #include <svl/hint.hxx>
42 #include <editeng/langitem.hxx>
43 #include <editeng/charreliefitem.hxx>
44 #include <editeng/emphasismarkitem.hxx>
45 #include <svx/sdr/table/tabledesign.hxx>
46 #include <editeng/autokernitem.hxx>
48 #include <svx/svdattr.hxx>
49 #include <editeng/outliner.hxx>
50 #include <svx/xtable.hxx>
51 #include <editeng/bulletitem.hxx>
52 #include <editeng/lrspitem.hxx>
53 #include <editeng/adjustitem.hxx>
54 #include <editeng/numdef.hxx>
55 #include <svl/itempool.hxx>
56 #include <svl/IndexedStyleSheets.hxx>
58 #include <stlpool.hxx>
59 #include <sdresid.hxx>
60 #include <stlsheet.hxx>
61 #include <strings.hrc>
63 #include <drawdoc.hxx>
67 #include <svl/itemset.hxx>
69 #include <strings.hxx>
71 #include <com/sun/star/drawing/LineStyle.hpp>
73 using namespace ::com::sun::star
;
74 using namespace ::com::sun::star::uno
;
75 using namespace ::com::sun::star::lang
;
76 using namespace ::com::sun::star::style
;
77 using namespace ::com::sun::star::container
;
82 OUString
lcl_findRenamedStyleName(std::vector
< std::pair
< OUString
, OUString
> > &rRenamedList
, OUString
const & aOriginalName
)
84 std::vector
< std::pair
< OUString
, OUString
> >::iterator aIter
;
85 for( aIter
= rRenamedList
.begin(); aIter
!= rRenamedList
.end(); ++aIter
)
87 if((*aIter
).first
== aOriginalName
)
88 return (*aIter
).second
;
93 SfxStyleSheet
*lcl_findStyle(SdStyleSheetVector
& rStyles
, const OUString
& aStyleName
)
95 if( aStyleName
.isEmpty() )
97 for(SdStyleSheetVector::const_iterator
aIt(rStyles
.begin()), aLast(rStyles
.end()); aIt
!= aLast
; ++aIt
)
99 if((*aIt
)->GetName() == aStyleName
)
107 SdStyleSheetPool::SdStyleSheetPool(SfxItemPool
const& _rPool
, SdDrawDocument
* pDocument
)
108 : SdStyleSheetPoolBase( _rPool
)
109 , mpActualStyleSheet(nullptr)
114 rtl::Reference
< SfxStyleSheetPool
> xPool( this );
116 // create graphics family
117 mxGraphicFamily
= new SdStyleFamily( xPool
, SfxStyleFamily::Para
);
118 mxCellFamily
= new SdStyleFamily( xPool
, SfxStyleFamily::Frame
);
120 mxTableFamily
= sdr::table::CreateTableDesignFamily();
121 Reference
< XNamed
> xNamed( mxTableFamily
, UNO_QUERY
);
123 msTableFamilyName
= xNamed
->getName();
125 // create presentation families, one for each master page
126 const sal_uInt16 nCount
= mpDoc
->GetMasterSdPageCount(PageKind::Standard
);
127 for( sal_uInt16 nPage
= 0; nPage
< nCount
; ++nPage
)
128 AddStyleFamily( mpDoc
->GetMasterSdPage(nPage
,PageKind::Standard
) );
133 SdStyleSheetPool::~SdStyleSheetPool()
135 DBG_ASSERT( mpDoc
== nullptr, "sd::SdStyleSheetPool::~SdStyleSheetPool(), dispose me first!" );
138 SfxStyleSheetBase
* SdStyleSheetPool::Create(const OUString
& rName
, SfxStyleFamily eFamily
, SfxStyleSearchBits _nMask
)
140 return new SdStyleSheet(rName
, *this, eFamily
, _nMask
);
143 SfxStyleSheetBase
* SdStyleSheetPool::GetTitleSheet(const OUString
& rLayoutName
)
145 OUString
aName(rLayoutName
);
146 aName
+= SD_LT_SEPARATOR
;
147 aName
+= STR_LAYOUT_TITLE
;
148 SfxStyleSheetBase
* pResult
= Find(aName
, SfxStyleFamily::Page
);
152 /*************************************************************************
154 |* Create a list of outline text templates for a presentation layout.
155 |* The caller has to delete the list.
157 \************************************************************************/
159 void SdStyleSheetPool::CreateOutlineSheetList (const OUString
& rLayoutName
, std::vector
<SfxStyleSheetBase
*> &rOutlineStyles
)
161 OUString
aName(rLayoutName
);
162 aName
+= SD_LT_SEPARATOR
;
163 aName
+= STR_LAYOUT_OUTLINE
;
165 for (sal_Int32 nSheet
= 1; nSheet
< 10; nSheet
++)
167 OUString
aFullName(aName
+ " " + OUString::number( nSheet
) );
168 SfxStyleSheetBase
* pSheet
= Find(aFullName
, SfxStyleFamily::Page
);
171 rOutlineStyles
.push_back(pSheet
);
175 /*************************************************************************
177 |* Create style sheets with default values for the named presentation layout
179 \************************************************************************/
181 void SdStyleSheetPool::CreateLayoutStyleSheets(const OUString
& rLayoutName
, bool bCheck
/*= sal_False*/ )
183 const SfxStyleSearchBits nUsedMask
= SfxStyleSearchBits::All
& ~SfxStyleSearchBits::UserDefined
;
185 bool bCreated
= false;
187 SfxStyleSheetBase
* pSheet
= nullptr;
189 OUString
aPrefix(rLayoutName
+ SD_LT_SEPARATOR
);
191 vcl::Font aLatinFont
, aCJKFont
, aCTLFont
;
193 mpDoc
->getDefaultFonts( aLatinFont
, aCJKFont
, aCTLFont
);
195 // Font for title and outline
196 SvxFontItem
aSvxFontItem( aLatinFont
.GetFamilyType(), aLatinFont
.GetFamilyName(), aLatinFont
.GetStyleName(), aLatinFont
.GetPitch(),
197 aLatinFont
.GetCharSet(), EE_CHAR_FONTINFO
);
199 SvxFontItem
aSvxFontItemCJK( aCJKFont
.GetFamilyType(), aCJKFont
.GetFamilyName(), aCJKFont
.GetStyleName(), aCJKFont
.GetPitch(),
200 aCJKFont
.GetCharSet(), EE_CHAR_FONTINFO_CJK
);
202 SvxFontItem
aSvxFontItemCTL( aCTLFont
.GetFamilyType(), aCTLFont
.GetFamilyName(), aCTLFont
.GetStyleName(), aCTLFont
.GetPitch(),
203 aCTLFont
.GetCharSet(), EE_CHAR_FONTINFO_CTL
);
205 vcl::Font
aBulletFont( GetBulletFont() );
207 /**************************************************************************
209 **************************************************************************/
210 OUString
aName(STR_LAYOUT_OUTLINE
);
213 SvxLRSpaceItem
aSvxLRSpaceItem( EE_PARA_LRSPACE
);
214 SvxULSpaceItem
aSvxULSpaceItem( EE_PARA_ULSPACE
);
216 for( sal_Int32 nLevel
= 1; nLevel
< 10; nLevel
++)
218 OUString
aLevelName( aPrefix
+ aName
+ " " + OUString::number( nLevel
) ) ;
220 if (!Find(aLevelName
, SfxStyleFamily::Page
))
223 pSheet
= &Make(aLevelName
, SfxStyleFamily::Page
,nUsedMask
);
224 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_OUTLINE
+ nLevel
);
226 pSheet
->SetParent( OUString() );
228 // attributing for level 1, the others levels inherit
231 SfxItemSet
& rSet
= pSheet
->GetItemSet();
233 rSet
.Put(aSvxFontItem
);
234 rSet
.Put(aSvxFontItemCJK
);
235 rSet
.Put(aSvxFontItemCTL
);
236 rSet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC
) );
237 rSet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CJK
) );
238 rSet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CTL
) );
239 rSet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT
) );
240 rSet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CJK
) );
241 rSet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CTL
) );
242 rSet
.Put( SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
) );
243 rSet
.Put( SvxOverlineItem(LINESTYLE_NONE
, EE_CHAR_OVERLINE
) );
244 rSet
.Put( SvxCrossedOutItem(STRIKEOUT_NONE
, EE_CHAR_STRIKEOUT
) );
245 rSet
.Put( SvxCaseMapItem(SvxCaseMap::NotMapped
, EE_CHAR_CASEMAP
) );
246 rSet
.Put( SvxShadowedItem(false, EE_CHAR_SHADOW
) );
247 rSet
.Put( SvxContourItem(false, EE_CHAR_OUTLINE
) );
248 rSet
.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE
, EE_CHAR_EMPHASISMARK
) );
249 rSet
.Put( SvxCharReliefItem(FontRelief::NONE
, EE_CHAR_RELIEF
) );
250 rSet
.Put( SvxColorItem( COL_AUTO
, EE_CHAR_COLOR
) );
251 rSet
.Put( SvxBackgroundColorItem( COL_AUTO
, EE_CHAR_BKGCOLOR
) );
252 rSet
.Put( XLineStyleItem(css::drawing::LineStyle_NONE
) );
253 rSet
.Put( XFillStyleItem(drawing::FillStyle_NONE
) );
254 rSet
.Put( SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_AUTOFIT
) );
255 rSet
.Put( makeSdrTextAutoGrowHeightItem(false) );
256 // #i16874# enable kerning by default but only for new documents
257 rSet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
259 vcl::Font
f( GetBulletFont() );
260 PutNumBulletItem( pSheet
, f
);
263 sal_uLong nFontSize
= 20;
264 sal_uInt16 nUpper
= 100;
297 nFontSize
= static_cast<sal_uInt16
>((nFontSize
* 2540L) / 72); // Pt --> 1/100 mm
298 SfxItemSet
& rOutlineSet
= pSheet
->GetItemSet();
299 rOutlineSet
.Put( SvxFontHeightItem( nFontSize
, 100, EE_CHAR_FONTHEIGHT
) );
300 rOutlineSet
.Put( SvxFontHeightItem( nFontSize
, 100, EE_CHAR_FONTHEIGHT_CJK
) );
301 rOutlineSet
.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( nFontSize
), 100, EE_CHAR_FONTHEIGHT_CTL
) );
303 // Line distance (upwards). Stuff around here cleaned up in i35937
304 aSvxULSpaceItem
.SetUpper(nUpper
);
305 pSheet
->GetItemSet().Put(aSvxULSpaceItem
);
309 // if we created outline styles, we need to chain them
312 SfxStyleSheetBase
* pParent
= nullptr;
313 for (sal_Int32 nLevel
= 1; nLevel
< 10; nLevel
++)
315 OUString
aLevelName( aPrefix
+ aName
+ " " + OUString::number( nLevel
) );
317 pSheet
= Find(aLevelName
, SfxStyleFamily::Page
);
319 DBG_ASSERT( pSheet
, "missing layout style!");
324 pSheet
->SetParent(pParent
->GetName());
330 /**************************************************************************
332 **************************************************************************/
333 aName
= aPrefix
+ STR_LAYOUT_TITLE
;
335 if (!Find(aName
, SfxStyleFamily::Page
))
339 pSheet
= &Make(aName
, SfxStyleFamily::Page
,nUsedMask
);
340 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_TITLE
);
341 pSheet
->SetParent( OUString() );
342 SfxItemSet
& rTitleSet
= pSheet
->GetItemSet();
343 rTitleSet
.Put(XLineStyleItem(drawing::LineStyle_NONE
));
344 rTitleSet
.Put(XFillStyleItem(drawing::FillStyle_NONE
));
345 rTitleSet
.Put(aSvxFontItem
);
346 rTitleSet
.Put(aSvxFontItemCJK
);
347 rTitleSet
.Put(aSvxFontItemCTL
);
348 rTitleSet
.Put(SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC
) );
349 rTitleSet
.Put(SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CJK
) );
350 rTitleSet
.Put(SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CTL
) );
351 rTitleSet
.Put(SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT
) );
352 rTitleSet
.Put(SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CJK
) );
353 rTitleSet
.Put(SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CTL
) );
354 rTitleSet
.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT
) ); // 44 pt
355 rTitleSet
.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT_CJK
) ); // 44 pt
356 rTitleSet
.Put(SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 1552 ), 100, EE_CHAR_FONTHEIGHT_CTL
) ); // 44 pt
357 rTitleSet
.Put(SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
));
358 rTitleSet
.Put(SvxOverlineItem(LINESTYLE_NONE
, EE_CHAR_OVERLINE
));
359 rTitleSet
.Put(SvxCrossedOutItem(STRIKEOUT_NONE
, EE_CHAR_STRIKEOUT
));
360 rTitleSet
.Put(SvxCaseMapItem(SvxCaseMap::NotMapped
, EE_CHAR_CASEMAP
));
361 rTitleSet
.Put(SvxShadowedItem(false, EE_CHAR_SHADOW
));
362 rTitleSet
.Put(SvxContourItem(false, EE_CHAR_OUTLINE
));
363 rTitleSet
.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE
, EE_CHAR_EMPHASISMARK
) );
364 rTitleSet
.Put( SvxCharReliefItem(FontRelief::NONE
, EE_CHAR_RELIEF
) );
365 rTitleSet
.Put(SvxColorItem( COL_AUTO
, EE_CHAR_COLOR
));
366 rTitleSet
.Put(SvxBackgroundColorItem( COL_AUTO
, EE_CHAR_BKGCOLOR
));
367 rTitleSet
.Put(SvxAdjustItem(SvxAdjust::Center
, EE_PARA_JUST
));
368 rTitleSet
.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER
) );
369 // #i16874# enable kerning by default but only for new documents
370 rTitleSet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
372 aBulletFont
.SetFontSize(Size(0,1552)); // 44 pt
373 PutNumBulletItem( pSheet
, aBulletFont
);
376 /**************************************************************************
378 **************************************************************************/
379 aName
= aPrefix
+ STR_LAYOUT_SUBTITLE
;
381 if (!Find(aName
, SfxStyleFamily::Page
))
385 pSheet
= &Make(aName
, SfxStyleFamily::Page
,nUsedMask
);
386 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_SUBTITLE
);
387 pSheet
->SetParent( OUString() );
388 SfxItemSet
& rSubtitleSet
= pSheet
->GetItemSet();
389 rSubtitleSet
.Put(XLineStyleItem(drawing::LineStyle_NONE
));
390 rSubtitleSet
.Put(XFillStyleItem(drawing::FillStyle_NONE
));
391 rSubtitleSet
.Put(aSvxFontItem
);
392 rSubtitleSet
.Put(aSvxFontItemCJK
);
393 rSubtitleSet
.Put(aSvxFontItemCTL
);
394 rSubtitleSet
.Put(SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC
) );
395 rSubtitleSet
.Put(SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CJK
) );
396 rSubtitleSet
.Put(SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CTL
) );
397 rSubtitleSet
.Put(SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT
) );
398 rSubtitleSet
.Put(SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CJK
) );
399 rSubtitleSet
.Put(SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CTL
) );
400 rSubtitleSet
.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT
) ); // 32 pt
401 rSubtitleSet
.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT_CJK
) ); // 32 pt
402 rSubtitleSet
.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 1129 ), 100, EE_CHAR_FONTHEIGHT_CTL
) ); // 32 pt
403 rSubtitleSet
.Put(SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
));
404 rSubtitleSet
.Put(SvxOverlineItem(LINESTYLE_NONE
, EE_CHAR_OVERLINE
));
405 rSubtitleSet
.Put(SvxCrossedOutItem(STRIKEOUT_NONE
, EE_CHAR_STRIKEOUT
));
406 rSubtitleSet
.Put(SvxCaseMapItem(SvxCaseMap::NotMapped
, EE_CHAR_CASEMAP
));
407 rSubtitleSet
.Put(SvxShadowedItem(false, EE_CHAR_SHADOW
));
408 rSubtitleSet
.Put(SvxContourItem(false, EE_CHAR_OUTLINE
));
409 rSubtitleSet
.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE
, EE_CHAR_EMPHASISMARK
) );
410 rSubtitleSet
.Put( SvxCharReliefItem(FontRelief::NONE
, EE_CHAR_RELIEF
) );
411 rSubtitleSet
.Put(SvxColorItem( COL_AUTO
, EE_CHAR_COLOR
));
412 rSubtitleSet
.Put(SvxBackgroundColorItem( COL_AUTO
, EE_CHAR_BKGCOLOR
));
413 rSubtitleSet
.Put(SvxAdjustItem(SvxAdjust::Center
, EE_PARA_JUST
));
414 rSubtitleSet
.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER
) );
415 // #i16874# enable kerning by default but only for new documents
416 rSubtitleSet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
417 aSvxLRSpaceItem
.SetTextLeft(0);
418 rSubtitleSet
.Put(aSvxLRSpaceItem
);
420 vcl::Font
aTmpFont( GetBulletFont() );
421 aTmpFont
.SetFontSize(Size(0, 1129)); // 32 pt
422 PutNumBulletItem( pSheet
, aTmpFont
);
425 /**************************************************************************
427 **************************************************************************/
428 aName
= aPrefix
+ STR_LAYOUT_NOTES
;
430 if (!Find(aName
, SfxStyleFamily::Page
))
434 pSheet
= &Make(aName
, SfxStyleFamily::Page
,nUsedMask
);
435 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_NOTES
);
436 pSheet
->SetParent( OUString() );
437 SfxItemSet
& rNotesSet
= pSheet
->GetItemSet();
438 rNotesSet
.Put(XLineStyleItem(drawing::LineStyle_NONE
));
439 rNotesSet
.Put(XFillStyleItem(drawing::FillStyle_NONE
));
440 rNotesSet
.Put(aSvxFontItem
);
441 rNotesSet
.Put(aSvxFontItemCJK
);
442 rNotesSet
.Put(aSvxFontItemCTL
);
443 rNotesSet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC
) );
444 rNotesSet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CJK
) );
445 rNotesSet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CTL
) );
446 rNotesSet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT
) );
447 rNotesSet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CJK
) );
448 rNotesSet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CTL
) );
449 rNotesSet
.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT
) ); // 20 pt
450 rNotesSet
.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT_CJK
) ); // 20 pt
451 rNotesSet
.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 705 ), 100, EE_CHAR_FONTHEIGHT_CTL
) ); // 20 pt
452 rNotesSet
.Put( SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
) );
453 rNotesSet
.Put( SvxOverlineItem(LINESTYLE_NONE
, EE_CHAR_OVERLINE
) );
454 rNotesSet
.Put( SvxCrossedOutItem(STRIKEOUT_NONE
, EE_CHAR_STRIKEOUT
) );
455 rNotesSet
.Put( SvxCaseMapItem(SvxCaseMap::NotMapped
, EE_CHAR_CASEMAP
) );
456 rNotesSet
.Put( SvxShadowedItem(false, EE_CHAR_SHADOW
) );
457 rNotesSet
.Put( SvxContourItem(false, EE_CHAR_OUTLINE
) );
458 rNotesSet
.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE
, EE_CHAR_EMPHASISMARK
) );
459 rNotesSet
.Put( SvxCharReliefItem(FontRelief::NONE
, EE_CHAR_RELIEF
) );
460 rNotesSet
.Put( SvxColorItem( COL_AUTO
, EE_CHAR_COLOR
) );
461 rNotesSet
.Put( SvxBackgroundColorItem( COL_AUTO
, EE_CHAR_BKGCOLOR
) );
462 rNotesSet
.Put( SvxLRSpaceItem( 0, 0, 600, -600, EE_PARA_LRSPACE
) );
463 // #i16874# enable kerning by default but only for new documents
464 rNotesSet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
470 /**************************************************************************
472 **************************************************************************/
473 aName
= aPrefix
+ STR_LAYOUT_BACKGROUNDOBJECTS
;
475 if (!Find(aName
, SfxStyleFamily::Page
))
479 pSheet
= &Make(aName
, SfxStyleFamily::Page
,nUsedMask
);
480 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_BACKGROUNDOBJECTS
);
481 pSheet
->SetParent( OUString() );
482 SfxItemSet
& rBackgroundObjectsSet
= pSheet
->GetItemSet();
483 rBackgroundObjectsSet
.Put(makeSdrShadowItem(false));
484 rBackgroundObjectsSet
.Put(makeSdrShadowColorItem(COL_GRAY
));
485 rBackgroundObjectsSet
.Put(makeSdrShadowXDistItem(200)); // 3 mm shadow distance
486 rBackgroundObjectsSet
.Put(makeSdrShadowYDistItem(200));
487 // #i16874# enable kerning by default but only for new documents
488 rBackgroundObjectsSet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
489 rBackgroundObjectsSet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK
));
492 /**************************************************************************
494 **************************************************************************/
495 aName
= aPrefix
+ STR_LAYOUT_BACKGROUND
;
497 if (!Find(aName
, SfxStyleFamily::Page
))
501 pSheet
= &Make(aName
, SfxStyleFamily::Page
,nUsedMask
);
502 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_BACKGROUND
);
503 pSheet
->SetParent( OUString() );
504 SfxItemSet
& rBackgroundSet
= pSheet
->GetItemSet();
505 rBackgroundSet
.Put(XLineStyleItem(drawing::LineStyle_NONE
));
506 rBackgroundSet
.Put(XFillStyleItem(drawing::FillStyle_NONE
));
507 // #i16874# enable kerning by default but only for new documents
508 rBackgroundSet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
511 DBG_ASSERT( !bCheck
|| !bCreated
, "missing layout style sheets detected!" );
514 /*************************************************************************
516 |* Copy graphic style sheets from source pool into this pool
518 |* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
520 \************************************************************************/
522 void SdStyleSheetPool::CopyGraphicSheets(SdStyleSheetPool
& rSourcePool
)
524 CopySheets( rSourcePool
, SfxStyleFamily::Para
);
527 void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool
& rSourcePool
)
529 CopySheets( rSourcePool
, SfxStyleFamily::Frame
);
532 void SdStyleSheetPool::CopyTableStyles(SdStyleSheetPool
const & rSourcePool
)
534 Reference
< XIndexAccess
> xSource( rSourcePool
.mxTableFamily
, UNO_QUERY
);
535 Reference
< XNameContainer
> xTarget( mxTableFamily
, UNO_QUERY
);
536 Reference
< XSingleServiceFactory
> xFactory( mxTableFamily
, UNO_QUERY
);
538 if( xSource
.is() && xFactory
.is() && mxTableFamily
.is() )
540 for( sal_Int32 nIndex
= 0; nIndex
< xSource
->getCount(); nIndex
++ ) try
542 Reference
< XStyle
> xSourceTableStyle( xSource
->getByIndex( nIndex
), UNO_QUERY
);
543 if( xSourceTableStyle
.is() )
545 Reference
< XStyle
> xNewTableStyle( xFactory
->createInstance(), UNO_QUERY
);
546 if( xNewTableStyle
.is() )
548 Reference
< XNameAccess
> xSourceNames( xSourceTableStyle
, UNO_QUERY_THROW
);
550 Sequence
< OUString
> aStyleNames( xSourceNames
->getElementNames() );
551 OUString
* pStyleNames( aStyleNames
.getArray() );
553 Reference
< XNameReplace
> xTargetNames( xNewTableStyle
, UNO_QUERY
);
555 sal_Int32 nNames
= aStyleNames
.getLength();
558 const OUString
aName( *pStyleNames
++ );
559 Reference
< XStyle
> xSourceStyle( xSourceNames
->getByName( aName
), UNO_QUERY
);
560 Reference
< XStyle
> xTargetStyle
;
561 if( xSourceStyle
.is() ) try
563 mxCellFamily
->getByName( xSourceStyle
->getName() ) >>= xTargetStyle
;
567 OSL_FAIL( "sd::SdStyleSheetPool::CopyTableStyles(), exception caught!" );
570 if( xTargetStyle
.is() )
571 xTargetNames
->replaceByName( aName
, Any( xTargetStyle
) );
575 OUString
sName( xSourceTableStyle
->getName() );
576 if( xTarget
->hasByName( sName
) )
577 xTarget
->replaceByName( sName
, Any( xNewTableStyle
) );
579 xTarget
->insertByName( sName
, Any( xNewTableStyle
) );
584 OSL_FAIL("sd::SdStyleSheetPool::CopyTableStyles(), exception caught!");
589 void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool
& rSourcePool
, SdStyleSheetVector
& rCreatedSheets
)
591 CopySheets( rSourcePool
, SfxStyleFamily::Frame
, rCreatedSheets
);
594 void SdStyleSheetPool::RenameAndCopyGraphicSheets(SdStyleSheetPool
& rSourcePool
, SdStyleSheetVector
& rCreatedSheets
, OUString
const &rRenameSuffix
)
596 CopySheets( rSourcePool
, SfxStyleFamily::Para
, rCreatedSheets
, rRenameSuffix
);
599 void SdStyleSheetPool::CopySheets(SdStyleSheetPool
& rSourcePool
, SfxStyleFamily eFamily
)
601 SdStyleSheetVector aTmpSheets
;
602 CopySheets(rSourcePool
, eFamily
, aTmpSheets
);
605 void SdStyleSheetPool::CopySheets(SdStyleSheetPool
& rSourcePool
, SfxStyleFamily eFamily
, SdStyleSheetVector
& rCreatedSheets
)
607 CopySheets(rSourcePool
, eFamily
, rCreatedSheets
, "");
613 struct HasFamilyPredicate
: svl::StyleSheetPredicate
615 explicit HasFamilyPredicate(SfxStyleFamily eFamily
)
616 : meFamily(eFamily
) {}
618 bool Check(const SfxStyleSheetBase
& sheet
) override
620 return sheet
.GetFamily() == meFamily
;
622 SfxStyleFamily meFamily
;
627 void SdStyleSheetPool::CopySheets(SdStyleSheetPool
& rSourcePool
, SfxStyleFamily eFamily
, SdStyleSheetVector
& rCreatedSheets
, const OUString
& rRenameSuffix
)
629 std::vector
< std::pair
< rtl::Reference
< SfxStyleSheetBase
>, OUString
> > aNewStyles
;
630 std::vector
< std::pair
< OUString
, OUString
> > aRenamedList
;
632 // find all style sheets of the source pool which have the same family
633 HasFamilyPredicate
aHasFamilyPredicate(eFamily
);
634 std::vector
<unsigned> aSheetsWithFamily
= rSourcePool
.GetIndexedStyleSheets().FindPositionsByPredicate(aHasFamilyPredicate
);
636 for (std::vector
<unsigned>::const_iterator it
= aSheetsWithFamily
.begin();
637 it
!= aSheetsWithFamily
.end(); ++it
)
639 rtl::Reference
<SfxStyleSheetBase
> const xSheet
=
640 rSourcePool
.GetStyleSheetByPositionInIndex( *it
);
643 rtl::OUString
aName( xSheet
->GetName() );
645 // now check whether we already have a sheet with the same name
646 std::vector
<unsigned> aSheetsWithName
= GetIndexedStyleSheets().FindPositionsByName(aName
);
647 bool bAddToList
= false;
648 SfxStyleSheetBase
* pExistingSheet
= nullptr;
649 if (!aSheetsWithName
.empty())
651 // if we have a rename suffix, try to find a new name
653 GetStyleSheetByPositionInIndex(aSheetsWithName
.front()).get();
654 if (!rRenameSuffix
.isEmpty() &&
655 pExistingSheet
->GetItemSet().Equals(xSheet
->GetItemSet(), false))
657 // we have found a sheet with the same name, but different contents. Try to find a new name.
658 // If we already have a sheet with the new name, and it is equal to the one in the source pool,
660 OUString aTmpName
= aName
+ rRenameSuffix
;
661 sal_Int32 nSuffix
= 1;
664 aTmpName
= aName
+ rRenameSuffix
+ OUString::number(nSuffix
);
665 pExistingSheet
= Find(aTmpName
, eFamily
);
667 } while( pExistingSheet
&& pExistingSheet
->GetItemSet().Equals(xSheet
->GetItemSet(), false) );
672 // we do not already have a sheet with the same name and contents. Create a new one.
675 assert(!Find(aName
, eFamily
));
676 rtl::Reference
< SfxStyleSheetBase
> xNewSheet( &Make( aName
, eFamily
) );
678 xNewSheet
->SetMask( xSheet
->GetMask() );
680 // Also set parent relation for copied style sheets
681 OUString
aParent( xSheet
->GetParent() );
682 if( !aParent
.isEmpty() )
683 aNewStyles
.emplace_back( xNewSheet
, aParent
);
688 xNewSheet
->SetHelpId( aHelpFile
, xSheet
->GetHelpId( aHelpFile
) );
690 xNewSheet
->GetItemSet().Put( xSheet
->GetItemSet() );
692 rCreatedSheets
.emplace_back( static_cast< SdStyleSheet
* >( xNewSheet
.get() ) );
693 aRenamedList
.emplace_back( xSheet
->GetName(), aName
);
697 // Add to list - used for renaming
698 rCreatedSheets
.emplace_back( static_cast< SdStyleSheet
* >( pExistingSheet
) );
699 aRenamedList
.emplace_back( xSheet
->GetName(), aName
);
703 // set parents on newly added stylesheets
704 std::vector
< std::pair
< rtl::Reference
< SfxStyleSheetBase
>, OUString
> >::iterator aIter
;
705 for( aIter
= aNewStyles
.begin(); aIter
!= aNewStyles
.end(); ++aIter
)
707 if( !rRenameSuffix
.isEmpty() )
709 SfxStyleSheet
*pParent
= lcl_findStyle(rCreatedSheets
, lcl_findRenamedStyleName(aRenamedList
, (*aIter
).second
));
712 (*aIter
).first
->SetParent( pParent
->GetName() );
716 DBG_ASSERT( rSourcePool
.Find( (*aIter
).second
, eFamily
), "StyleSheet has invalid parent: Family mismatch" );
717 (*aIter
).first
->SetParent( (*aIter
).second
);
719 // we have changed names of style sheets. Trigger reindexing.
723 /*************************************************************************
725 |* Copy style sheets of the named presentation layout from the source pool into
726 |* this pool. Copies only the style sheets which aren't yet in this pool.
727 |* If not NULL, pCreatedSheets is filled with pointers to the created style
730 |* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
732 \************************************************************************/
734 void SdStyleSheetPool::CopyLayoutSheets(const OUString
& rLayoutName
, SdStyleSheetPool
& rSourcePool
, SdStyleSheetVector
& rCreatedSheets
)
736 SfxStyleSheetBase
* pSheet
= nullptr;
738 std::vector
<OUString
> aNameList
;
739 CreateLayoutSheetNames(rLayoutName
,aNameList
);
741 for (std::vector
<OUString
>::const_iterator it
= aNameList
.begin(); it
!= aNameList
.end(); ++it
)
743 pSheet
= Find(*it
, SfxStyleFamily::Page
);
746 SfxStyleSheetBase
* pSourceSheet
= rSourcePool
.Find(*it
, SfxStyleFamily::Page
);
747 DBG_ASSERT(pSourceSheet
, "CopyLayoutSheets: Style sheet missing");
750 // In the case one comes with Methusalem-Docs.
751 SfxStyleSheetBase
& rNewSheet
= Make(*it
, SfxStyleFamily::Page
);
753 rNewSheet
.SetHelpId( file
, pSourceSheet
->GetHelpId( file
) );
754 rNewSheet
.GetItemSet().Put(pSourceSheet
->GetItemSet());
755 rCreatedSheets
.emplace_back( static_cast< SdStyleSheet
* >( &rNewSheet
) );
760 // Special treatment for outline templates: create parent relation
761 std::vector
<SfxStyleSheetBase
*> aOutlineSheets
;
762 CreateOutlineSheetList(rLayoutName
,aOutlineSheets
);
764 if( !aOutlineSheets
.empty() )
766 std::vector
<SfxStyleSheetBase
*>::iterator it
= aOutlineSheets
.begin();
767 SfxStyleSheetBase
* pParent
= *it
;
770 while (it
!= aOutlineSheets
.end())
777 if (pSheet
->GetParent().isEmpty())
778 pSheet
->SetParent(pParent
->GetName());
787 /*************************************************************************
789 |* Create list with names of the presentation templates of a layout.
790 |* The list and the containing strings are owned by the caller!
792 \************************************************************************/
794 void SdStyleSheetPool::CreateLayoutSheetNames(const OUString
& rLayoutName
, std::vector
<OUString
> &aNameList
)
796 OUString
aPrefix(rLayoutName
+ SD_LT_SEPARATOR
);
798 for (sal_Int32 nLevel
= 1; nLevel
< 10; nLevel
++)
799 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_OUTLINE
" " + OUString::number( nLevel
) );
801 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_TITLE
);
802 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_SUBTITLE
);
803 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_NOTES
);
804 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_BACKGROUNDOBJECTS
);
805 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_BACKGROUND
);
808 /*************************************************************************
810 |* Create a list with pointer to presentation templates of a layout.
811 |* The list is owned by the caller!
813 \************************************************************************/
815 void SdStyleSheetPool::CreateLayoutSheetList(const OUString
& rLayoutName
, SdStyleSheetVector
& rLayoutSheets
)
817 OUString
aLayoutNameWithSep(rLayoutName
+ SD_LT_SEPARATOR
);
819 SfxStyleSheetIterator
aIter(this, SfxStyleFamily::Page
);
820 SfxStyleSheetBase
* pSheet
= aIter
.First();
824 if (pSheet
->GetName().startsWith(aLayoutNameWithSep
))
825 rLayoutSheets
.emplace_back( static_cast< SdStyleSheet
* >( pSheet
) );
826 pSheet
= aIter
.Next();
830 /*************************************************************************
832 |* Create pseudo style sheets if necessary
834 \************************************************************************/
836 void SdStyleSheetPool::CreatePseudosIfNecessary()
840 SfxStyleSheetBase
* pSheet
= nullptr;
841 SfxStyleSheetBase
* pParent
= nullptr;
843 SfxStyleSearchBits nUsedMask
= SfxStyleSearchBits::Used
;
845 aName
= SdResId(STR_PSEUDOSHEET_TITLE
);
846 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
848 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
849 pSheet
->SetParent( OUString() );
850 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
852 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_TITLE
);
854 aName
= SdResId(STR_PSEUDOSHEET_SUBTITLE
);
855 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
857 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
858 pSheet
->SetParent( OUString() );
859 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
861 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_SUBTITLE
);
863 aName
= SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS
);
864 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
866 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
867 pSheet
->SetParent( OUString() );
868 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
870 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_BACKGROUNDOBJECTS
);
872 aName
= SdResId(STR_PSEUDOSHEET_BACKGROUND
);
873 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
875 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
876 pSheet
->SetParent( OUString() );
877 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
879 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_BACKGROUND
);
881 aName
= SdResId(STR_PSEUDOSHEET_NOTES
);
882 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
884 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
885 pSheet
->SetParent( OUString() );
886 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
888 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_NOTES
);
891 SetSearchMask(SfxStyleFamily::Pseudo
);
892 aName
= SdResId(STR_PSEUDOSHEET_OUTLINE
);
893 for (sal_Int32 nLevel
= 1; nLevel
< 10; nLevel
++)
895 OUString
aLevelName( aName
+ " " + OUString::number( nLevel
) );
897 if( (pSheet
= Find(aLevelName
, SfxStyleFamily::Pseudo
)) == nullptr )
899 pSheet
= &Make(aLevelName
, SfxStyleFamily::Pseudo
, nUsedMask
);
904 pSheet
->SetParent(pParent
->GetName());
906 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
909 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_OUTLINE
+ nLevel
);
913 /*************************************************************************
915 |* Set the correct name in the program language to the standard styles
917 \************************************************************************/
921 struct StyleSheetIsUserDefinedPredicate
: svl::StyleSheetPredicate
923 StyleSheetIsUserDefinedPredicate()
926 bool Check(const SfxStyleSheetBase
& sheet
) override
928 return sheet
.IsUserDefined();
933 void SdStyleSheetPool::UpdateStdNames()
936 StyleSheetIsUserDefinedPredicate aPredicate
;
937 std::vector
<SfxStyleSheetBase
*> aEraseList
;
938 std::vector
<unsigned> aUserDefinedStyles
= GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate
);
939 for (std::vector
<unsigned>::const_iterator it
= aUserDefinedStyles
.begin();
940 it
!= aUserDefinedStyles
.end(); ++it
)
942 SfxStyleSheetBase
* pStyle
= GetStyleSheetByPositionInIndex(*it
).get();
944 if( !pStyle
->IsUserDefined() )
946 OUString aOldName
= pStyle
->GetName();
947 sal_uLong nHelpId
= pStyle
->GetHelpId( aHelpFile
);
948 SfxStyleFamily eFam
= pStyle
->GetFamily();
950 bool bHelpKnown
= true;
952 const char* pNameId
= nullptr;
955 case HID_STANDARD_STYLESHEET_NAME
: pNameId
= STR_STANDARD_STYLESHEET_NAME
; break;
956 case HID_POOLSHEET_OBJWITHOUTFILL
: pNameId
= STR_POOLSHEET_OBJWITHOUTFILL
; break;
957 case HID_POOLSHEET_OBJNOLINENOFILL
: pNameId
= STR_POOLSHEET_OBJNOLINENOFILL
;break;
958 case HID_POOLSHEET_TEXT
: pNameId
= STR_POOLSHEET_TEXT
; break;
959 case HID_POOLSHEET_TITLE
: pNameId
= STR_POOLSHEET_TITLE
; break;
960 case HID_POOLSHEET_HEADLINE
: pNameId
= STR_POOLSHEET_HEADLINE
; break;
961 case HID_POOLSHEET_MEASURE
: pNameId
= STR_POOLSHEET_MEASURE
; break;
962 case HID_POOLSHEET_FILLED
: pNameId
= STR_POOLSHEET_FILLED
; break;
963 case HID_POOLSHEET_FILLED_BLUE
: pNameId
= STR_POOLSHEET_FILLED_BLUE
; break;
964 case HID_POOLSHEET_FILLED_GREEN
: pNameId
= STR_POOLSHEET_FILLED_GREEN
; break;
965 case HID_POOLSHEET_FILLED_RED
: pNameId
= STR_POOLSHEET_FILLED_RED
; break;
966 case HID_POOLSHEET_FILLED_YELLOW
: pNameId
= STR_POOLSHEET_FILLED_YELLOW
; break;
967 case HID_POOLSHEET_OUTLINE
: pNameId
= STR_POOLSHEET_OUTLINE
; break;
968 case HID_POOLSHEET_OUTLINE_BLUE
: pNameId
= STR_POOLSHEET_OUTLINE_BLUE
; break;
969 case HID_POOLSHEET_OUTLINE_GREEN
: pNameId
= STR_POOLSHEET_OUTLINE_GREEN
; break;
970 case HID_POOLSHEET_OUTLINE_RED
: pNameId
= STR_POOLSHEET_OUTLINE_RED
; break;
971 case HID_POOLSHEET_OUTLINE_YELLOW
: pNameId
= STR_POOLSHEET_OUTLINE_YELLOW
; break;
973 case HID_PSEUDOSHEET_TITLE
: pNameId
= STR_PSEUDOSHEET_TITLE
; break;
974 case HID_PSEUDOSHEET_SUBTITLE
: pNameId
= STR_PSEUDOSHEET_SUBTITLE
; break;
975 case HID_PSEUDOSHEET_OUTLINE1
:
976 case HID_PSEUDOSHEET_OUTLINE2
:
977 case HID_PSEUDOSHEET_OUTLINE3
:
978 case HID_PSEUDOSHEET_OUTLINE4
:
979 case HID_PSEUDOSHEET_OUTLINE5
:
980 case HID_PSEUDOSHEET_OUTLINE6
:
981 case HID_PSEUDOSHEET_OUTLINE7
:
982 case HID_PSEUDOSHEET_OUTLINE8
:
983 case HID_PSEUDOSHEET_OUTLINE9
: pNameId
= STR_PSEUDOSHEET_OUTLINE
; break;
984 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS
: pNameId
= STR_PSEUDOSHEET_BACKGROUNDOBJECTS
; break;
985 case HID_PSEUDOSHEET_BACKGROUND
: pNameId
= STR_PSEUDOSHEET_BACKGROUND
; break;
986 case HID_PSEUDOSHEET_NOTES
: pNameId
= STR_PSEUDOSHEET_NOTES
; break;
988 case HID_SD_CELL_STYLE_DEFAULT
: pNameId
= STR_STANDARD_STYLESHEET_NAME
; break;
989 case HID_SD_CELL_STYLE_BANDED
: pNameId
= STR_POOLSHEET_BANDED_CELL
; break;
990 case HID_SD_CELL_STYLE_HEADER
: pNameId
= STR_POOLSHEET_HEADER
; break;
991 case HID_SD_CELL_STYLE_TOTAL
: pNameId
= STR_POOLSHEET_TOTAL
; break;
992 case HID_SD_CELL_STYLE_FIRST_COLUMN
: pNameId
= STR_POOLSHEET_FIRST_COLUMN
; break;
993 case HID_SD_CELL_STYLE_LAST_COLUMN
: pNameId
= STR_POOLSHEET_LAST_COLUMN
; break;
996 // 0 or wrong (old) HelpId
1003 aNewName
= SdResId(pNameId
);
1004 if (strcmp(pNameId
, STR_PSEUDOSHEET_OUTLINE
) == 0)
1006 aNewName
+= " " + OUString::number( sal_Int32( nHelpId
- HID_PSEUDOSHEET_OUTLINE
) );
1010 if( !aNewName
.isEmpty() && aNewName
!= aOldName
)
1012 SfxStyleSheetBase
* pSheetFound
= Find( aNewName
, eFam
);
1016 // Sheet does not yet exist: rename old sheet
1017 pStyle
->SetName( aNewName
); // transform also parents
1021 // Sheet does exist: old sheet has to be removed
1022 aEraseList
.push_back( pStyle
);
1029 if (!aEraseList
.empty())
1031 // styles that could not be renamed, must be removed
1032 for (SfxStyleSheetBase
* p
: aEraseList
)
1038 void SdStyleSheetPool::setDefaultOutlineNumberFormatBulletAndIndent(sal_uInt16 i
, SvxNumberFormat
&rNumberFormat
)
1040 rNumberFormat
.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1041 rNumberFormat
.SetBulletRelSize(45);
1042 const short nLSpace
= (i
+ 1) * 1200;
1043 rNumberFormat
.SetAbsLSpace(nLSpace
);
1044 short nFirstLineOffset
= -600;
1050 nFirstLineOffset
= -900;
1056 rNumberFormat
.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
1057 rNumberFormat
.SetBulletRelSize(75);
1058 nFirstLineOffset
= -900;
1064 nFirstLineOffset
= -800;
1070 rNumberFormat
.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
1071 rNumberFormat
.SetBulletRelSize(75);
1076 rNumberFormat
.SetFirstLineOffset(nFirstLineOffset
);
1079 // Set new SvxNumBulletItem for the respective style sheet
1080 void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase
* pSheet
,
1081 vcl::Font
& rBulletFont
)
1084 sal_uLong nHelpId
= pSheet
->GetHelpId( aHelpFile
);
1085 SfxItemSet
& rSet
= pSheet
->GetItemSet();
1089 case HID_STANDARD_STYLESHEET_NAME
:
1091 // Standard template
1092 SvxNumberFormat
aNumberFormat(SVX_NUM_CHAR_SPECIAL
);
1093 aNumberFormat
.SetBulletFont(&rBulletFont
);
1094 aNumberFormat
.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1095 aNumberFormat
.SetBulletRelSize(45);
1096 aNumberFormat
.SetBulletColor(COL_AUTO
);
1097 aNumberFormat
.SetStart(1);
1098 aNumberFormat
.SetNumAdjust(SvxAdjust::Left
);
1100 SvxNumRule
aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE
| SvxNumRuleFlags::BULLET_COLOR
| SvxNumRuleFlags::CHAR_TEXT_DISTANCE
, SVX_MAX_NUM
, false);
1102 for( sal_uInt16 i
= 0; i
< aNumRule
.GetLevelCount(); i
++ )
1104 const short nLSpace
= (i
+ 1) * 600;
1105 aNumberFormat
.SetAbsLSpace(nLSpace
);
1106 aNumberFormat
.SetFirstLineOffset(-600);
1107 aNumRule
.SetLevel( i
, aNumberFormat
);
1110 rSet
.Put( SvxNumBulletItem( aNumRule
, EE_PARA_NUMBULLET
) );
1111 static_cast<SfxStyleSheet
*>(pSheet
)->Broadcast(SfxHint( SfxHintId::DataChanged
) );
1115 case HID_PSEUDOSHEET_TITLE
:
1116 /* title gets same bullet as subtitle and not that page symbol anymore */
1117 case HID_PSEUDOSHEET_SUBTITLE
:
1119 // Subtitle template
1120 SvxNumBulletItem
const*const pItem(
1121 rSet
.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET
));
1122 SvxNumRule
*const pDefaultRule
= pItem
? pItem
->GetNumRule() : nullptr;
1123 DBG_ASSERT( pDefaultRule
, "Where is my default template? [CL]" );
1127 SvxNumRule
aNumRule(pDefaultRule
->GetFeatureFlags(), 10, false);
1128 for(sal_uInt16 i
=0; i
< aNumRule
.GetLevelCount(); i
++)
1130 SvxNumberFormat
aFrmt( pDefaultRule
->GetLevel(i
) );
1131 aFrmt
.SetNumberingType(SVX_NUM_CHAR_SPECIAL
);
1132 // #i93908# clear suffix for bullet lists
1133 aFrmt
.SetPrefix(OUString());
1134 aFrmt
.SetSuffix(OUString());
1136 aFrmt
.SetBulletRelSize(45);
1137 aFrmt
.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1138 aFrmt
.SetBulletFont(&rBulletFont
);
1139 aNumRule
.SetLevel(i
, aFrmt
);
1142 rSet
.Put( SvxNumBulletItem( aNumRule
, EE_PARA_NUMBULLET
) );
1143 static_cast<SfxStyleSheet
*>(pSheet
)->Broadcast(SfxHint( SfxHintId::DataChanged
) );
1148 case HID_PSEUDOSHEET_OUTLINE
+ 1 :
1151 SvxNumberFormat
aNumberFormat(SVX_NUM_CHAR_SPECIAL
);
1152 aNumberFormat
.SetBulletColor(COL_AUTO
);
1153 aNumberFormat
.SetStart(1);
1154 aNumberFormat
.SetNumAdjust(SvxAdjust::Left
);
1156 SvxNumRule
aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE
| SvxNumRuleFlags::BULLET_COLOR
|
1157 SvxNumRuleFlags::CHAR_TEXT_DISTANCE
,
1158 SVX_MAX_NUM
, false );
1159 for( sal_uInt16 i
= 0; i
< aNumRule
.GetLevelCount(); i
++ )
1161 setDefaultOutlineNumberFormatBulletAndIndent(i
, aNumberFormat
);
1162 rBulletFont
.SetFontSize(Size(0,846)); // 24 pt
1163 aNumberFormat
.SetBulletFont(&rBulletFont
);
1164 aNumRule
.SetLevel( i
, aNumberFormat
);
1167 rSet
.Put( SvxNumBulletItem( aNumRule
, EE_PARA_NUMBULLET
) );
1168 static_cast<SfxStyleSheet
*>(pSheet
)->Broadcast(SfxHint( SfxHintId::DataChanged
) );
1174 /*************************************************************************
1176 |* Create standard bullet font (without size)
1178 \************************************************************************/
1180 vcl::Font
SdStyleSheetPool::GetBulletFont()
1182 vcl::Font
aBulletFont( OUString( "StarSymbol" ), Size(0, 1000) );
1183 aBulletFont
.SetCharSet(RTL_TEXTENCODING_UNICODE
);
1184 aBulletFont
.SetWeight(WEIGHT_NORMAL
);
1185 aBulletFont
.SetUnderline(LINESTYLE_NONE
);
1186 aBulletFont
.SetOverline(LINESTYLE_NONE
);
1187 aBulletFont
.SetStrikeout(STRIKEOUT_NONE
);
1188 aBulletFont
.SetItalic(ITALIC_NONE
);
1189 aBulletFont
.SetOutline(false);
1190 aBulletFont
.SetShadow(false);
1191 aBulletFont
.SetColor(COL_AUTO
);
1192 aBulletFont
.SetTransparent(true);
1197 void SdStyleSheetPool::AddStyleFamily( const SdPage
* pPage
)
1199 rtl::Reference
< SfxStyleSheetPool
> xPool( this );
1200 maStyleFamilyMap
[pPage
] = new SdStyleFamily( xPool
, pPage
);
1203 void SdStyleSheetPool::RemoveStyleFamily( const SdPage
* pPage
)
1205 SdStyleFamilyMap::iterator
iter( maStyleFamilyMap
.find( pPage
) );
1206 if( iter
!= maStyleFamilyMap
.end() )
1208 SdStyleFamilyRef
xStyle( (*iter
).second
);
1209 maStyleFamilyMap
.erase( iter
);
1211 if( xStyle
.is() ) try
1221 void SdStyleSheetPool::throwIfDisposed()
1223 if( mpDoc
== nullptr )
1224 throw DisposedException();
1228 OUString SAL_CALL
SdStyleSheetPool::getImplementationName()
1230 return OUString( "SdStyleSheetPool" );
1233 sal_Bool SAL_CALL
SdStyleSheetPool::supportsService( const OUString
& ServiceName
)
1235 return cppu::supportsService(this, ServiceName
);
1238 Sequence
< OUString
> SAL_CALL
SdStyleSheetPool::getSupportedServiceNames()
1240 OUString
aStr("com.sun.star.style.StyleFamilies");
1241 return Sequence
< OUString
>( &aStr
, 1 );
1245 Any SAL_CALL
SdStyleSheetPool::getByName( const OUString
& aName
)
1249 if( mxGraphicFamily
->getName() == aName
)
1250 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( mxGraphicFamily
.get() ) ) );
1252 if( mxCellFamily
->getName() == aName
)
1253 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( mxCellFamily
.get() ) ) );
1255 if( msTableFamilyName
== aName
)
1256 return Any( mxTableFamily
);
1258 for( SdStyleFamilyMap::iterator
iter( maStyleFamilyMap
.begin() ); iter
!= maStyleFamilyMap
.end(); ++iter
)
1260 if( (*iter
).second
->getName() == aName
)
1261 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( (*iter
).second
.get() ) ) );
1264 throw NoSuchElementException();
1267 Sequence
< OUString
> SAL_CALL
SdStyleSheetPool::getElementNames()
1271 Sequence
< OUString
> aNames( maStyleFamilyMap
.size() + 3 );
1272 OUString
* pNames
= aNames
.getArray();
1274 *pNames
++ = mxGraphicFamily
->getName();
1275 *pNames
++ = mxCellFamily
->getName();
1276 *pNames
++ = msTableFamilyName
;
1278 for( SdStyleFamilyMap::iterator
iter( maStyleFamilyMap
.begin() ); iter
!= maStyleFamilyMap
.end(); ++iter
)
1280 *pNames
++ = (*iter
).second
->getName();
1286 sal_Bool SAL_CALL
SdStyleSheetPool::hasByName( const OUString
& aName
)
1290 if( mxGraphicFamily
->getName() == aName
)
1293 if( mxCellFamily
->getName() == aName
)
1296 if( msTableFamilyName
== aName
)
1299 for( SdStyleFamilyMap::iterator
iter( maStyleFamilyMap
.begin() ); iter
!= maStyleFamilyMap
.end(); ++iter
)
1301 if( (*iter
).second
->getName() == aName
)
1310 Type SAL_CALL
SdStyleSheetPool::getElementType()
1314 return cppu::UnoType
<XNameAccess
>::get();
1317 sal_Bool SAL_CALL
SdStyleSheetPool::hasElements()
1324 sal_Int32 SAL_CALL
SdStyleSheetPool::getCount()
1328 return maStyleFamilyMap
.size() + 3;
1331 Any SAL_CALL
SdStyleSheetPool::getByIndex( sal_Int32 Index
)
1336 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( mxGraphicFamily
.get() ) ) );
1339 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( mxCellFamily
.get() ) ) );
1342 return Any( mxTableFamily
);
1347 if( (Index
< 0) || (Index
>= sal::static_int_cast
<sal_Int32
>(maStyleFamilyMap
.size())) )
1348 throw IndexOutOfBoundsException();
1349 SdStyleFamilyMap::iterator
iter( maStyleFamilyMap
.begin() );
1353 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( (*iter
).second
.get() ) ) );
1360 void SAL_CALL
SdStyleSheetPool::dispose()
1364 mxGraphicFamily
->dispose();
1365 mxGraphicFamily
.clear();
1366 mxCellFamily
->dispose();
1367 mxCellFamily
.clear();
1369 Reference
< XComponent
> xComp( mxTableFamily
, UNO_QUERY
);
1372 mxTableFamily
= nullptr;
1374 SdStyleFamilyMap aTempMap
;
1375 aTempMap
.swap( maStyleFamilyMap
);
1377 for( SdStyleFamilyMap::iterator
iter( aTempMap
.begin() ); iter
!= aTempMap
.end(); ++iter
) try
1379 (*iter
).second
->dispose();
1391 void SAL_CALL
SdStyleSheetPool::addEventListener( const Reference
< XEventListener
>& /*xListener*/ )
1395 void SAL_CALL
SdStyleSheetPool::removeEventListener( const Reference
< XEventListener
>& /*aListener*/ )
1399 SdStyleSheetVector
SdStyleSheetPool::CreateChildList( SdStyleSheet
const * pSheet
)
1401 SdStyleSheetVector aResult
;
1403 const size_t nListenerCount
= pSheet
->GetSizeOfVector();
1404 for (size_t n
= 0; n
< nListenerCount
; ++n
)
1406 SdStyleSheet
* pChild
= dynamic_cast< SdStyleSheet
* >( pSheet
->GetListener(n
) );
1407 if(pChild
&& pChild
->GetParent() == pSheet
->GetName())
1409 aResult
.emplace_back( pChild
);
1416 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */