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 <svx/xfillit0.hxx>
34 #include <svx/xlineit0.hxx>
35 #include <svx/sdtaitm.hxx>
36 #include <svx/sdtfsitm.hxx>
37 #include <svx/sdtagitm.hxx>
38 #include <svx/sdshitm.hxx>
39 #include <svx/sdshcitm.hxx>
40 #include <svx/sdsxyitm.hxx>
41 #include <editeng/ulspitem.hxx>
42 #include <editeng/numitem.hxx>
43 #include <editeng/cmapitem.hxx>
44 #include <svl/hint.hxx>
45 #include <editeng/charreliefitem.hxx>
46 #include <editeng/emphasismarkitem.hxx>
47 #include <svx/sdr/table/tabledesign.hxx>
48 #include <editeng/autokernitem.hxx>
49 #include <comphelper/diagnose_ex.hxx>
50 #include <tools/UnitConversion.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>
64 #include <svl/itemset.hxx>
66 #include <strings.hxx>
68 #include <com/sun/star/drawing/LineStyle.hpp>
69 #include <com/sun/star/drawing/TextFitToSizeType.hpp>
71 using namespace ::com::sun::star
;
72 using namespace ::com::sun::star::uno
;
73 using namespace ::com::sun::star::lang
;
74 using namespace ::com::sun::star::style
;
75 using namespace ::com::sun::star::container
;
80 OUString
lcl_findRenamedStyleName(std::vector
< std::pair
< OUString
, OUString
> > &rRenamedList
, OUString
const & aOriginalName
)
82 auto aIter
= std::find_if(rRenamedList
.begin(), rRenamedList
.end(),
83 [&aOriginalName
](const std::pair
<OUString
, OUString
>& rItem
) { return rItem
.first
== aOriginalName
; });
84 if (aIter
!= rRenamedList
.end())
85 return (*aIter
).second
;
89 SfxStyleSheet
*lcl_findStyle(StyleSheetCopyResultVector
& rStyles
, std::u16string_view aStyleName
)
91 if( aStyleName
.empty() )
93 for (const auto& a
: rStyles
)
95 if (a
.m_xStyleSheet
->GetName() == aStyleName
)
96 return a
.m_xStyleSheet
.get();
103 SdStyleSheetPool::SdStyleSheetPool(SfxItemPool
const& _rPool
, SdDrawDocument
* pDocument
)
104 : SdStyleSheetPoolBase( _rPool
)
105 , mpActualStyleSheet(nullptr)
111 rtl::Reference
< SfxStyleSheetPool
> xPool( this );
113 // create graphics family
114 mxGraphicFamily
= new SdStyleFamily( xPool
, SfxStyleFamily::Para
);
115 mxCellFamily
= new SdStyleFamily( xPool
, SfxStyleFamily::Frame
);
117 mxTableFamily
= sdr::table::CreateTableDesignFamily();
118 Reference
< XNamed
> xNamed( mxTableFamily
, UNO_QUERY
);
120 msTableFamilyName
= xNamed
->getName();
122 // create presentation families, one for each master page
123 const sal_uInt16 nCount
= mpDoc
->GetMasterSdPageCount(PageKind::Standard
);
124 for( sal_uInt16 nPage
= 0; nPage
< nCount
; ++nPage
)
125 AddStyleFamily( mpDoc
->GetMasterSdPage(nPage
,PageKind::Standard
) );
128 SdStyleSheetPool::~SdStyleSheetPool()
130 DBG_ASSERT( mpDoc
== nullptr, "sd::SdStyleSheetPool::~SdStyleSheetPool(), dispose me first!" );
133 rtl::Reference
<SfxStyleSheetBase
> SdStyleSheetPool::Create(const OUString
& rName
, SfxStyleFamily eFamily
, SfxStyleSearchBits _nMask
)
135 return new SdStyleSheet(rName
, *this, eFamily
, _nMask
);
138 SfxStyleSheetBase
* SdStyleSheetPool::GetTitleSheet(std::u16string_view rLayoutName
)
140 OUString aName
= OUString::Concat(rLayoutName
) + SD_LT_SEPARATOR
+ STR_LAYOUT_TITLE
;
141 SfxStyleSheetBase
* pResult
= Find(aName
, SfxStyleFamily::Page
);
145 /*************************************************************************
147 |* Create a list of outline text templates for a presentation layout.
148 |* The caller has to delete the list.
150 \************************************************************************/
152 void SdStyleSheetPool::CreateOutlineSheetList (std::u16string_view rLayoutName
, std::vector
<SfxStyleSheetBase
*> &rOutlineStyles
)
154 OUString aName
= OUString::Concat(rLayoutName
) + SD_LT_SEPARATOR
+ STR_LAYOUT_OUTLINE
;
156 for (sal_Int32 nSheet
= 1; nSheet
< 10; nSheet
++)
158 OUString
aFullName(aName
+ " " + OUString::number( nSheet
) );
159 SfxStyleSheetBase
* pSheet
= Find(aFullName
, SfxStyleFamily::Page
);
162 rOutlineStyles
.push_back(pSheet
);
166 /*************************************************************************
168 |* Create style sheets with default values for the named presentation layout
170 \************************************************************************/
172 void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName
, bool bCheck
/*= sal_False*/ )
174 const SfxStyleSearchBits nUsedMask
= SfxStyleSearchBits::All
& ~SfxStyleSearchBits::UserDefined
;
176 bool bCreated
= false;
178 SfxStyleSheetBase
* pSheet
= nullptr;
180 OUString
aPrefix(OUString::Concat(rLayoutName
) + SD_LT_SEPARATOR
);
182 vcl::Font aLatinFont
, aCJKFont
, aCTLFont
;
184 mpDoc
->getDefaultFonts( aLatinFont
, aCJKFont
, aCTLFont
);
186 // Font for title and outline
187 SvxFontItem
aSvxFontItem( aLatinFont
.GetFamilyType(), aLatinFont
.GetFamilyName(), aLatinFont
.GetStyleName(), aLatinFont
.GetPitch(),
188 aLatinFont
.GetCharSet(), EE_CHAR_FONTINFO
);
190 SvxFontItem
aSvxFontItemCJK( aCJKFont
.GetFamilyType(), aCJKFont
.GetFamilyName(), aCJKFont
.GetStyleName(), aCJKFont
.GetPitch(),
191 aCJKFont
.GetCharSet(), EE_CHAR_FONTINFO_CJK
);
193 SvxFontItem
aSvxFontItemCTL( aCTLFont
.GetFamilyType(), aCTLFont
.GetFamilyName(), aCTLFont
.GetStyleName(), aCTLFont
.GetPitch(),
194 aCTLFont
.GetCharSet(), EE_CHAR_FONTINFO_CTL
);
196 vcl::Font
aBulletFont( GetBulletFont() );
198 /**************************************************************************
200 **************************************************************************/
201 OUString
aName(STR_LAYOUT_OUTLINE
);
202 const OUString aHelpFile
;
204 SvxLRSpaceItem
aSvxLRSpaceItem( EE_PARA_LRSPACE
);
205 SvxULSpaceItem
aSvxULSpaceItem( EE_PARA_ULSPACE
);
207 for( sal_Int32 nLevel
= 1; nLevel
< 10; nLevel
++)
209 OUString
aLevelName( aPrefix
+ aName
+ " " + OUString::number( nLevel
) ) ;
211 if (!Find(aLevelName
, SfxStyleFamily::Page
))
214 pSheet
= &Make(aLevelName
, SfxStyleFamily::Page
,nUsedMask
);
215 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_OUTLINE
+ nLevel
);
217 pSheet
->SetParent( OUString() );
219 // attributing for level 1, the others levels inherit
222 SfxItemSet
& rSet
= pSheet
->GetItemSet();
224 rSet
.Put(aSvxFontItem
);
225 rSet
.Put(aSvxFontItemCJK
);
226 rSet
.Put(aSvxFontItemCTL
);
227 rSet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC
) );
228 rSet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CJK
) );
229 rSet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CTL
) );
230 rSet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT
) );
231 rSet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CJK
) );
232 rSet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CTL
) );
233 rSet
.Put( SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
) );
234 rSet
.Put( SvxOverlineItem(LINESTYLE_NONE
, EE_CHAR_OVERLINE
) );
235 rSet
.Put( SvxCrossedOutItem(STRIKEOUT_NONE
, EE_CHAR_STRIKEOUT
) );
236 rSet
.Put( SvxCaseMapItem(SvxCaseMap::NotMapped
, EE_CHAR_CASEMAP
) );
237 rSet
.Put( SvxShadowedItem(false, EE_CHAR_SHADOW
) );
238 rSet
.Put( SvxContourItem(false, EE_CHAR_OUTLINE
) );
239 rSet
.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE
, EE_CHAR_EMPHASISMARK
) );
240 rSet
.Put( SvxCharReliefItem(FontRelief::NONE
, EE_CHAR_RELIEF
) );
241 rSet
.Put( SvxColorItem( COL_AUTO
, EE_CHAR_COLOR
) );
242 rSet
.Put( SvxColorItem( COL_AUTO
, EE_CHAR_BKGCOLOR
) );
243 rSet
.Put( XLineStyleItem(css::drawing::LineStyle_NONE
) );
244 rSet
.Put( XFillStyleItem(drawing::FillStyle_NONE
) );
245 rSet
.Put( SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_AUTOFIT
) );
246 rSet
.Put( makeSdrTextAutoGrowHeightItem(false) );
247 // #i16874# enable kerning by default but only for new documents
248 rSet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
250 vcl::Font
f( GetBulletFont() );
251 PutNumBulletItem( pSheet
, f
);
254 sal_uLong nFontSize
= 20;
255 sal_uInt16 nUpper
= 100;
288 nFontSize
= static_cast<sal_uInt16
>(convertPointToMm100(nFontSize
));
289 SfxItemSet
& rOutlineSet
= pSheet
->GetItemSet();
290 rOutlineSet
.Put( SvxFontHeightItem( nFontSize
, 100, EE_CHAR_FONTHEIGHT
) );
291 rOutlineSet
.Put( SvxFontHeightItem( nFontSize
, 100, EE_CHAR_FONTHEIGHT_CJK
) );
292 rOutlineSet
.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( nFontSize
), 100, EE_CHAR_FONTHEIGHT_CTL
) );
294 // Line distance (upwards). Stuff around here cleaned up in i35937
295 aSvxULSpaceItem
.SetUpper(nUpper
);
296 pSheet
->GetItemSet().Put(aSvxULSpaceItem
);
300 // if we created outline styles, we need to chain them
303 SfxStyleSheetBase
* pParent
= nullptr;
304 for (sal_Int32 nLevel
= 1; nLevel
< 10; nLevel
++)
306 OUString
aLevelName( aPrefix
+ aName
+ " " + OUString::number( nLevel
) );
308 pSheet
= Find(aLevelName
, SfxStyleFamily::Page
);
310 DBG_ASSERT( pSheet
, "missing layout style!");
315 pSheet
->SetParent(pParent
->GetName());
321 /**************************************************************************
323 **************************************************************************/
324 aName
= aPrefix
+ STR_LAYOUT_TITLE
;
326 if (!Find(aName
, SfxStyleFamily::Page
))
330 pSheet
= &Make(aName
, SfxStyleFamily::Page
,nUsedMask
);
331 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_TITLE
);
332 pSheet
->SetParent( OUString() );
333 SfxItemSet
& rTitleSet
= pSheet
->GetItemSet();
334 rTitleSet
.Put(XLineStyleItem(drawing::LineStyle_NONE
));
335 rTitleSet
.Put(XFillStyleItem(drawing::FillStyle_NONE
));
336 rTitleSet
.Put(aSvxFontItem
);
337 rTitleSet
.Put(aSvxFontItemCJK
);
338 rTitleSet
.Put(aSvxFontItemCTL
);
339 rTitleSet
.Put(SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC
) );
340 rTitleSet
.Put(SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CJK
) );
341 rTitleSet
.Put(SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CTL
) );
342 rTitleSet
.Put(SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT
) );
343 rTitleSet
.Put(SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CJK
) );
344 rTitleSet
.Put(SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CTL
) );
345 rTitleSet
.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT
) ); // 44 pt
346 rTitleSet
.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT_CJK
) ); // 44 pt
347 rTitleSet
.Put(SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 1552 ), 100, EE_CHAR_FONTHEIGHT_CTL
) ); // 44 pt
348 rTitleSet
.Put(SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
));
349 rTitleSet
.Put(SvxOverlineItem(LINESTYLE_NONE
, EE_CHAR_OVERLINE
));
350 rTitleSet
.Put(SvxCrossedOutItem(STRIKEOUT_NONE
, EE_CHAR_STRIKEOUT
));
351 rTitleSet
.Put(SvxCaseMapItem(SvxCaseMap::NotMapped
, EE_CHAR_CASEMAP
));
352 rTitleSet
.Put(SvxShadowedItem(false, EE_CHAR_SHADOW
));
353 rTitleSet
.Put(SvxContourItem(false, EE_CHAR_OUTLINE
));
354 rTitleSet
.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE
, EE_CHAR_EMPHASISMARK
) );
355 rTitleSet
.Put( SvxCharReliefItem(FontRelief::NONE
, EE_CHAR_RELIEF
) );
356 rTitleSet
.Put(SvxColorItem( COL_AUTO
, EE_CHAR_COLOR
));
357 rTitleSet
.Put(SvxColorItem( COL_AUTO
, EE_CHAR_BKGCOLOR
));
358 rTitleSet
.Put(SvxAdjustItem(SvxAdjust::Center
, EE_PARA_JUST
));
359 rTitleSet
.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER
) );
360 // #i16874# enable kerning by default but only for new documents
361 rTitleSet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
363 aBulletFont
.SetFontSize(Size(0,1552)); // 44 pt
364 PutNumBulletItem( pSheet
, aBulletFont
);
367 /**************************************************************************
369 **************************************************************************/
370 aName
= aPrefix
+ STR_LAYOUT_SUBTITLE
;
372 if (!Find(aName
, SfxStyleFamily::Page
))
376 pSheet
= &Make(aName
, SfxStyleFamily::Page
,nUsedMask
);
377 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_SUBTITLE
);
378 pSheet
->SetParent( OUString() );
379 SfxItemSet
& rSubtitleSet
= pSheet
->GetItemSet();
380 rSubtitleSet
.Put(XLineStyleItem(drawing::LineStyle_NONE
));
381 rSubtitleSet
.Put(XFillStyleItem(drawing::FillStyle_NONE
));
382 rSubtitleSet
.Put(aSvxFontItem
);
383 rSubtitleSet
.Put(aSvxFontItemCJK
);
384 rSubtitleSet
.Put(aSvxFontItemCTL
);
385 rSubtitleSet
.Put(SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC
) );
386 rSubtitleSet
.Put(SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CJK
) );
387 rSubtitleSet
.Put(SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CTL
) );
388 rSubtitleSet
.Put(SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT
) );
389 rSubtitleSet
.Put(SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CJK
) );
390 rSubtitleSet
.Put(SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CTL
) );
391 rSubtitleSet
.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT
) ); // 32 pt
392 rSubtitleSet
.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT_CJK
) ); // 32 pt
393 rSubtitleSet
.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 1129 ), 100, EE_CHAR_FONTHEIGHT_CTL
) ); // 32 pt
394 rSubtitleSet
.Put(SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
));
395 rSubtitleSet
.Put(SvxOverlineItem(LINESTYLE_NONE
, EE_CHAR_OVERLINE
));
396 rSubtitleSet
.Put(SvxCrossedOutItem(STRIKEOUT_NONE
, EE_CHAR_STRIKEOUT
));
397 rSubtitleSet
.Put(SvxCaseMapItem(SvxCaseMap::NotMapped
, EE_CHAR_CASEMAP
));
398 rSubtitleSet
.Put(SvxShadowedItem(false, EE_CHAR_SHADOW
));
399 rSubtitleSet
.Put(SvxContourItem(false, EE_CHAR_OUTLINE
));
400 rSubtitleSet
.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE
, EE_CHAR_EMPHASISMARK
) );
401 rSubtitleSet
.Put( SvxCharReliefItem(FontRelief::NONE
, EE_CHAR_RELIEF
) );
402 rSubtitleSet
.Put(SvxColorItem( COL_AUTO
, EE_CHAR_COLOR
));
403 rSubtitleSet
.Put(SvxColorItem( COL_AUTO
, EE_CHAR_BKGCOLOR
));
404 rSubtitleSet
.Put(SvxAdjustItem(SvxAdjust::Center
, EE_PARA_JUST
));
405 rSubtitleSet
.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER
) );
406 // #i16874# enable kerning by default but only for new documents
407 rSubtitleSet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
408 aSvxLRSpaceItem
.SetTextLeft(0);
409 rSubtitleSet
.Put(aSvxLRSpaceItem
);
411 vcl::Font
aTmpFont( GetBulletFont() );
412 aTmpFont
.SetFontSize(Size(0, 1129)); // 32 pt
413 PutNumBulletItem( pSheet
, aTmpFont
);
416 /**************************************************************************
418 **************************************************************************/
419 aName
= aPrefix
+ STR_LAYOUT_NOTES
;
421 if (!Find(aName
, SfxStyleFamily::Page
))
425 pSheet
= &Make(aName
, SfxStyleFamily::Page
,nUsedMask
);
426 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_NOTES
);
427 pSheet
->SetParent( OUString() );
428 SfxItemSet
& rNotesSet
= pSheet
->GetItemSet();
429 rNotesSet
.Put(XLineStyleItem(drawing::LineStyle_NONE
));
430 rNotesSet
.Put(XFillStyleItem(drawing::FillStyle_NONE
));
431 rNotesSet
.Put(aSvxFontItem
);
432 rNotesSet
.Put(aSvxFontItemCJK
);
433 rNotesSet
.Put(aSvxFontItemCTL
);
434 rNotesSet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC
) );
435 rNotesSet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CJK
) );
436 rNotesSet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CTL
) );
437 rNotesSet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT
) );
438 rNotesSet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CJK
) );
439 rNotesSet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CTL
) );
440 rNotesSet
.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT
) ); // 20 pt
441 rNotesSet
.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT_CJK
) ); // 20 pt
442 rNotesSet
.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 705 ), 100, EE_CHAR_FONTHEIGHT_CTL
) ); // 20 pt
443 rNotesSet
.Put( SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
) );
444 rNotesSet
.Put( SvxOverlineItem(LINESTYLE_NONE
, EE_CHAR_OVERLINE
) );
445 rNotesSet
.Put( SvxCrossedOutItem(STRIKEOUT_NONE
, EE_CHAR_STRIKEOUT
) );
446 rNotesSet
.Put( SvxCaseMapItem(SvxCaseMap::NotMapped
, EE_CHAR_CASEMAP
) );
447 rNotesSet
.Put( SvxShadowedItem(false, EE_CHAR_SHADOW
) );
448 rNotesSet
.Put( SvxContourItem(false, EE_CHAR_OUTLINE
) );
449 rNotesSet
.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE
, EE_CHAR_EMPHASISMARK
) );
450 rNotesSet
.Put( SvxCharReliefItem(FontRelief::NONE
, EE_CHAR_RELIEF
) );
451 rNotesSet
.Put( SvxColorItem( COL_AUTO
, EE_CHAR_COLOR
) );
452 rNotesSet
.Put( SvxColorItem( COL_AUTO
, EE_CHAR_BKGCOLOR
) );
453 rNotesSet
.Put( SvxLRSpaceItem( 0, 0, -600, EE_PARA_LRSPACE
) );
454 // #i16874# enable kerning by default but only for new documents
455 rNotesSet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
461 /**************************************************************************
463 **************************************************************************/
464 aName
= aPrefix
+ STR_LAYOUT_BACKGROUNDOBJECTS
;
466 if (!Find(aName
, SfxStyleFamily::Page
))
470 pSheet
= &Make(aName
, SfxStyleFamily::Page
,nUsedMask
);
471 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_BACKGROUNDOBJECTS
);
472 pSheet
->SetParent( OUString() );
473 SfxItemSet
& rBackgroundObjectsSet
= pSheet
->GetItemSet();
474 rBackgroundObjectsSet
.Put(makeSdrShadowItem(false));
475 rBackgroundObjectsSet
.Put(makeSdrShadowColorItem(COL_GRAY
));
476 rBackgroundObjectsSet
.Put(makeSdrShadowXDistItem(200)); // 3 mm shadow distance
477 rBackgroundObjectsSet
.Put(makeSdrShadowYDistItem(200));
478 // #i16874# enable kerning by default but only for new documents
479 rBackgroundObjectsSet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
480 rBackgroundObjectsSet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK
));
483 /**************************************************************************
485 **************************************************************************/
486 aName
= aPrefix
+ STR_LAYOUT_BACKGROUND
;
488 if (!Find(aName
, SfxStyleFamily::Page
))
492 pSheet
= &Make(aName
, SfxStyleFamily::Page
,nUsedMask
);
493 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_BACKGROUND
);
494 pSheet
->SetParent( OUString() );
495 SfxItemSet
& rBackgroundSet
= pSheet
->GetItemSet();
496 rBackgroundSet
.Put(XLineStyleItem(drawing::LineStyle_NONE
));
497 rBackgroundSet
.Put(XFillStyleItem(drawing::FillStyle_NONE
));
498 // #i16874# enable kerning by default but only for new documents
499 rBackgroundSet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
502 DBG_ASSERT( !bCheck
|| !bCreated
, "missing layout style sheets detected!" );
505 /*************************************************************************
507 |* Copy graphic style sheets from source pool into this pool
509 |* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
511 \************************************************************************/
513 void SdStyleSheetPool::CopyGraphicSheets(SdStyleSheetPool
& rSourcePool
)
515 CopySheets( rSourcePool
, SfxStyleFamily::Para
);
518 void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool
& rSourcePool
)
520 CopySheets( rSourcePool
, SfxStyleFamily::Frame
);
523 void SdStyleSheetPool::CopyTableStyles(SdStyleSheetPool
const & rSourcePool
)
525 XStyleVector aTmpSheets
;
526 CopyTableStyles(rSourcePool
, aTmpSheets
);
529 void SdStyleSheetPool::CopyTableStyles(SdStyleSheetPool
const & rSourcePool
, XStyleVector
& rCreatedSheets
)
531 Reference
< XIndexAccess
> xSource( rSourcePool
.mxTableFamily
, UNO_QUERY
);
532 Reference
< XNameContainer
> xTarget( mxTableFamily
, UNO_QUERY
);
533 Reference
< XSingleServiceFactory
> xFactory( mxTableFamily
, UNO_QUERY
);
535 if( !xSource
|| !xFactory
)
538 for( sal_Int32 nIndex
= 0; nIndex
< xSource
->getCount(); nIndex
++ ) try
540 Reference
< XNameAccess
> xSourceTableStyle( xSource
->getByIndex( nIndex
), UNO_QUERY_THROW
);
541 Reference
< XNameReplace
> xNewTableStyle( xFactory
->createInstance(), UNO_QUERY_THROW
);
543 const Sequence
< OUString
> aStyleNames( xSourceTableStyle
->getElementNames() );
544 for( const OUString
& aName
: aStyleNames
)
546 Reference
< XStyle
> xSourceStyle( xSourceTableStyle
->getByName( aName
), UNO_QUERY
);
547 Reference
< XStyle
> xTargetStyle
;
548 if( xSourceStyle
.is() ) try
550 mxCellFamily
->getByName( xSourceStyle
->getName() ) >>= xTargetStyle
;
554 TOOLS_WARN_EXCEPTION( "sd", "sd::SdStyleSheetPool::CopyTableStyles()" );
557 xNewTableStyle
->replaceByName( aName
, Any( xTargetStyle
) );
560 const OUString
sName(Reference
<XStyle
>(xSourceTableStyle
, UNO_QUERY_THROW
)->getName());
561 if( xTarget
->hasByName( sName
) )
562 Reference
<XComponent
>(xNewTableStyle
, UNO_QUERY_THROW
)->dispose();
565 rCreatedSheets
.emplace_back(xNewTableStyle
, UNO_QUERY_THROW
);
566 xTarget
->insertByName( sName
, Any( xNewTableStyle
) );
571 TOOLS_WARN_EXCEPTION( "sd", "sd::SdStyleSheetPool::CopyTableStyles()");
575 void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool
& rSourcePool
, StyleSheetCopyResultVector
& rCreatedSheets
)
577 CopySheets( rSourcePool
, SfxStyleFamily::Frame
, rCreatedSheets
);
580 void SdStyleSheetPool::RenameAndCopyGraphicSheets(SdStyleSheetPool
& rSourcePool
, StyleSheetCopyResultVector
& rCreatedSheets
, std::u16string_view rRenameSuffix
)
582 CopySheets( rSourcePool
, SfxStyleFamily::Para
, rCreatedSheets
, rRenameSuffix
);
585 void SdStyleSheetPool::CopySheets(SdStyleSheetPool
& rSourcePool
, SfxStyleFamily eFamily
)
587 StyleSheetCopyResultVector aTmpSheets
;
588 CopySheets(rSourcePool
, eFamily
, aTmpSheets
);
591 void SdStyleSheetPool::CopySheets(SdStyleSheetPool
& rSourcePool
, SfxStyleFamily eFamily
, StyleSheetCopyResultVector
& rCreatedSheets
)
593 CopySheets(rSourcePool
, eFamily
, rCreatedSheets
, u
"");
599 struct HasFamilyPredicate
: svl::StyleSheetPredicate
601 explicit HasFamilyPredicate(SfxStyleFamily eFamily
)
602 : meFamily(eFamily
) {}
604 bool Check(const SfxStyleSheetBase
& sheet
) override
606 return sheet
.GetFamily() == meFamily
;
608 SfxStyleFamily meFamily
;
613 void SdStyleSheetPool::CopySheets(SdStyleSheetPool
& rSourcePool
, SfxStyleFamily eFamily
, StyleSheetCopyResultVector
& rCreatedSheets
, std::u16string_view rRenameSuffix
)
615 std::vector
< std::pair
< rtl::Reference
< SfxStyleSheetBase
>, OUString
> > aNewStyles
;
616 std::vector
< std::pair
< OUString
, OUString
> > aRenamedList
;
618 // find all style sheets of the source pool which have the same family
619 HasFamilyPredicate
aHasFamilyPredicate(eFamily
);
620 std::vector
<sal_Int32
> aSheetsWithFamily
= rSourcePool
.GetIndexedStyleSheets().FindPositionsByPredicate(aHasFamilyPredicate
);
622 for (const auto& rPos
: aSheetsWithFamily
)
624 SfxStyleSheetBase
* pSheet
= rSourcePool
.GetStyleSheetByPositionInIndex( rPos
);
627 OUString
aName( pSheet
->GetName() );
629 // now check whether we already have a sheet with the same name
630 std::vector
<sal_Int32
> aSheetsWithName
= GetIndexedStyleSheets().FindPositionsByName(aName
);
631 bool bAddToList
= false;
632 SfxStyleSheetBase
* pExistingSheet
= nullptr;
633 if (!aSheetsWithName
.empty())
635 // if we have a rename suffix, try to find a new name
637 GetStyleSheetByPositionInIndex(aSheetsWithName
.front());
638 if (!rRenameSuffix
.empty() &&
639 !pExistingSheet
->GetItemSet().Equals(pSheet
->GetItemSet(), false))
641 // we have found a sheet with the same name, but different contents. Try to find a new name.
642 // If we already have a sheet with the new name, and it is equal to the one in the source pool,
644 OUString aTmpName
= aName
+ rRenameSuffix
;
645 sal_Int32 nSuffix
= 1;
648 aTmpName
= aName
+ rRenameSuffix
+ OUString::number(nSuffix
);
649 pExistingSheet
= Find(aTmpName
, eFamily
);
651 } while (pExistingSheet
&&
652 !pExistingSheet
->GetItemSet().Equals(pSheet
->GetItemSet(), false));
657 // we do not already have a sheet with the same name and contents. Create a new one.
660 assert(!Find(aName
, eFamily
));
661 rtl::Reference
< SfxStyleSheetBase
> xNewSheet( &Make( aName
, eFamily
) );
663 xNewSheet
->SetMask( pSheet
->GetMask() );
665 // Also set parent relation for copied style sheets
666 OUString
aParent( pSheet
->GetParent() );
667 if( !aParent
.isEmpty() )
668 aNewStyles
.emplace_back( xNewSheet
, aParent
);
673 xNewSheet
->SetHelpId( aHelpFile
, pSheet
->GetHelpId( aHelpFile
) );
675 xNewSheet
->GetItemSet().Put( pSheet
->GetItemSet() );
677 rCreatedSheets
.emplace_back(static_cast<SdStyleSheet
*>(xNewSheet
.get()), true);
678 aRenamedList
.emplace_back( pSheet
->GetName(), aName
);
682 // Add to list - used for renaming
683 rCreatedSheets
.emplace_back(static_cast<SdStyleSheet
*>(pExistingSheet
), false);
684 aRenamedList
.emplace_back( pSheet
->GetName(), aName
);
688 // set parents on newly added stylesheets
689 for( auto& rStyle
: aNewStyles
)
691 if( !rRenameSuffix
.empty() )
693 SfxStyleSheet
*pParent
= lcl_findStyle(rCreatedSheets
, lcl_findRenamedStyleName(aRenamedList
, rStyle
.second
));
696 rStyle
.first
->SetParent( pParent
->GetName() );
700 DBG_ASSERT( rSourcePool
.Find( rStyle
.second
, eFamily
), "StyleSheet has invalid parent: Family mismatch" );
701 rStyle
.first
->SetParent( rStyle
.second
);
703 // we have changed names of style sheets. Trigger reindexing.
707 /*************************************************************************
709 |* Copy style sheets of the named presentation layout from the source pool into
710 |* this pool. Copies only the style sheets which aren't yet in this pool.
711 |* If not NULL, pCreatedSheets is filled with pointers to the created style
714 |* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
716 \************************************************************************/
718 void SdStyleSheetPool::CopyLayoutSheets(std::u16string_view rLayoutName
, SdStyleSheetPool
& rSourcePool
, StyleSheetCopyResultVector
& rCreatedSheets
)
720 SfxStyleSheetBase
* pSheet
= nullptr;
722 std::vector
<OUString
> aNameList
;
723 CreateLayoutSheetNames(rLayoutName
,aNameList
);
725 for (const auto& rName
: aNameList
)
727 pSheet
= Find(rName
, SfxStyleFamily::Page
);
730 SfxStyleSheetBase
* pSourceSheet
= rSourcePool
.Find(rName
, SfxStyleFamily::Page
);
731 DBG_ASSERT(pSourceSheet
, "CopyLayoutSheets: Style sheet missing");
734 // In the case one comes with Methusalem-Docs.
735 SfxStyleSheetBase
& rNewSheet
= Make(rName
, SfxStyleFamily::Page
);
737 rNewSheet
.SetHelpId( file
, pSourceSheet
->GetHelpId( file
) );
738 rNewSheet
.GetItemSet().Put(pSourceSheet
->GetItemSet());
739 rCreatedSheets
.emplace_back(static_cast<SdStyleSheet
*>(&rNewSheet
), true);
744 // Special treatment for outline templates: create parent relation
745 std::vector
<SfxStyleSheetBase
*> aOutlineSheets
;
746 CreateOutlineSheetList(rLayoutName
,aOutlineSheets
);
748 if( aOutlineSheets
.empty() )
751 std::vector
<SfxStyleSheetBase
*>::iterator it
= aOutlineSheets
.begin();
752 SfxStyleSheetBase
* pParent
= *it
;
755 while (it
!= aOutlineSheets
.end())
762 if (pSheet
->GetParent().isEmpty())
763 pSheet
->SetParent(pParent
->GetName());
771 /*************************************************************************
773 |* Create list with names of the presentation templates of a layout.
774 |* The list and the containing strings are owned by the caller!
776 \************************************************************************/
778 void SdStyleSheetPool::CreateLayoutSheetNames(std::u16string_view rLayoutName
, std::vector
<OUString
> &aNameList
)
780 OUString
aPrefix(OUString::Concat(rLayoutName
) + SD_LT_SEPARATOR
);
782 for (sal_Int32 nLevel
= 1; nLevel
< 10; nLevel
++)
783 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_OUTLINE
+ " " + OUString::number( nLevel
) );
785 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_TITLE
);
786 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_SUBTITLE
);
787 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_NOTES
);
788 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_BACKGROUNDOBJECTS
);
789 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_BACKGROUND
);
792 /*************************************************************************
794 |* Create a list with pointer to presentation templates of a layout.
795 |* The list is owned by the caller!
797 \************************************************************************/
799 void SdStyleSheetPool::CreateLayoutSheetList(std::u16string_view rLayoutName
, SdStyleSheetVector
& rLayoutSheets
)
801 OUString
aLayoutNameWithSep(OUString::Concat(rLayoutName
) + SD_LT_SEPARATOR
);
803 SfxStyleSheetIterator
aIter(this, SfxStyleFamily::Page
);
804 SfxStyleSheetBase
* pSheet
= aIter
.First();
808 if (pSheet
->GetName().startsWith(aLayoutNameWithSep
))
809 rLayoutSheets
.emplace_back( static_cast< SdStyleSheet
* >( pSheet
) );
810 pSheet
= aIter
.Next();
814 /*************************************************************************
816 |* Create pseudo style sheets if necessary
818 \************************************************************************/
820 void SdStyleSheetPool::CreatePseudosIfNecessary()
823 const OUString aHelpFile
;
824 SfxStyleSheetBase
* pSheet
= nullptr;
825 SfxStyleSheetBase
* pParent
= nullptr;
827 SfxStyleSearchBits nUsedMask
= SfxStyleSearchBits::Used
;
829 aName
= SdResId(STR_PSEUDOSHEET_TITLE
);
830 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
832 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
833 pSheet
->SetParent( OUString() );
834 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
836 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_TITLE
);
838 aName
= SdResId(STR_PSEUDOSHEET_SUBTITLE
);
839 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
841 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
842 pSheet
->SetParent( OUString() );
843 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
845 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_SUBTITLE
);
847 aName
= SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS
);
848 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
850 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
851 pSheet
->SetParent( OUString() );
852 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
854 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_BACKGROUNDOBJECTS
);
856 aName
= SdResId(STR_PSEUDOSHEET_BACKGROUND
);
857 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
859 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
860 pSheet
->SetParent( OUString() );
861 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
863 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_BACKGROUND
);
865 aName
= SdResId(STR_PSEUDOSHEET_NOTES
);
866 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
868 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
869 pSheet
->SetParent( OUString() );
870 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
872 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_NOTES
);
875 aName
= SdResId(STR_PSEUDOSHEET_OUTLINE
);
876 for (sal_Int32 nLevel
= 1; nLevel
< 10; nLevel
++)
878 OUString
aLevelName( aName
+ " " + OUString::number( nLevel
) );
880 if( (pSheet
= Find(aLevelName
, SfxStyleFamily::Pseudo
)) == nullptr )
882 pSheet
= &Make(aLevelName
, SfxStyleFamily::Pseudo
, nUsedMask
);
885 pSheet
->SetParent(pParent
->GetName());
887 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
889 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_OUTLINE
+ nLevel
);
893 /*************************************************************************
895 |* Set the correct name in the program language to the standard styles
897 \************************************************************************/
901 struct StyleSheetIsUserDefinedPredicate
: svl::StyleSheetPredicate
903 StyleSheetIsUserDefinedPredicate()
906 bool Check(const SfxStyleSheetBase
& sheet
) override
908 return sheet
.IsUserDefined();
913 void SdStyleSheetPool::UpdateStdNames()
916 StyleSheetIsUserDefinedPredicate aPredicate
;
917 std::vector
<SfxStyleSheetBase
*> aEraseList
;
918 std::vector
<sal_Int32
> aUserDefinedStyles
= GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate
);
919 for (const auto& rStyle
: aUserDefinedStyles
)
921 SfxStyleSheetBase
* pStyle
= GetStyleSheetByPositionInIndex(rStyle
);
923 if( !pStyle
->IsUserDefined() )
925 OUString aOldName
= pStyle
->GetName();
926 sal_uLong nHelpId
= pStyle
->GetHelpId( aHelpFile
);
927 SfxStyleFamily eFam
= pStyle
->GetFamily();
929 bool bHelpKnown
= true;
933 case HID_STANDARD_STYLESHEET_NAME
: pNameId
= STR_STANDARD_STYLESHEET_NAME
; break;
934 case HID_POOLSHEET_OBJWITHOUTFILL
: pNameId
= STR_POOLSHEET_OBJWITHOUTFILL
; break;
935 case HID_POOLSHEET_OBJNOLINENOFILL
: pNameId
= STR_POOLSHEET_OBJNOLINENOFILL
;break;
936 case HID_POOLSHEET_TEXT
: pNameId
= STR_POOLSHEET_TEXT
; break;
937 case HID_POOLSHEET_A4
: pNameId
= STR_POOLSHEET_A4
; break;
938 case HID_POOLSHEET_A4_TITLE
: pNameId
= STR_POOLSHEET_A4_TITLE
; break;
939 case HID_POOLSHEET_A4_HEADLINE
: pNameId
= STR_POOLSHEET_A4_HEADLINE
; break;
940 case HID_POOLSHEET_A4_TEXT
: pNameId
= STR_POOLSHEET_A4_TEXT
; break;
941 case HID_POOLSHEET_A0
: pNameId
= STR_POOLSHEET_A0
; break;
942 case HID_POOLSHEET_A0_TITLE
: pNameId
= STR_POOLSHEET_A0_TITLE
; break;
943 case HID_POOLSHEET_A0_HEADLINE
: pNameId
= STR_POOLSHEET_A0_HEADLINE
; break;
944 case HID_POOLSHEET_A0_TEXT
: pNameId
= STR_POOLSHEET_A0_TEXT
; break;
945 case HID_POOLSHEET_GRAPHIC
: pNameId
= STR_POOLSHEET_GRAPHIC
; break;
946 case HID_POOLSHEET_SHAPES
: pNameId
= STR_POOLSHEET_SHAPES
; break;
947 case HID_POOLSHEET_FILLED
: pNameId
= STR_POOLSHEET_FILLED
; break;
948 case HID_POOLSHEET_FILLED_BLUE
: pNameId
= STR_POOLSHEET_FILLED_BLUE
; break;
949 case HID_POOLSHEET_FILLED_GREEN
: pNameId
= STR_POOLSHEET_FILLED_GREEN
; break;
950 case HID_POOLSHEET_FILLED_RED
: pNameId
= STR_POOLSHEET_FILLED_RED
; break;
951 case HID_POOLSHEET_FILLED_YELLOW
: pNameId
= STR_POOLSHEET_FILLED_YELLOW
; break;
952 case HID_POOLSHEET_OUTLINE
: pNameId
= STR_POOLSHEET_OUTLINE
; break;
953 case HID_POOLSHEET_OUTLINE_BLUE
: pNameId
= STR_POOLSHEET_OUTLINE_BLUE
; break;
954 case HID_POOLSHEET_OUTLINE_GREEN
: pNameId
= STR_POOLSHEET_OUTLINE_GREEN
; break;
955 case HID_POOLSHEET_OUTLINE_RED
: pNameId
= STR_POOLSHEET_OUTLINE_RED
; break;
956 case HID_POOLSHEET_OUTLINE_YELLOW
: pNameId
= STR_POOLSHEET_OUTLINE_YELLOW
; break;
957 case HID_POOLSHEET_LINES
: pNameId
= STR_POOLSHEET_LINES
; break;
958 case HID_POOLSHEET_MEASURE
: pNameId
= STR_POOLSHEET_MEASURE
; break;
959 case HID_POOLSHEET_LINES_DASHED
: pNameId
= STR_POOLSHEET_LINES_DASHED
; break;
961 case HID_PSEUDOSHEET_OUTLINE1
:
962 case HID_PSEUDOSHEET_OUTLINE2
:
963 case HID_PSEUDOSHEET_OUTLINE3
:
964 case HID_PSEUDOSHEET_OUTLINE4
:
965 case HID_PSEUDOSHEET_OUTLINE5
:
966 case HID_PSEUDOSHEET_OUTLINE6
:
967 case HID_PSEUDOSHEET_OUTLINE7
:
968 case HID_PSEUDOSHEET_OUTLINE8
:
969 case HID_PSEUDOSHEET_OUTLINE9
: pNameId
= STR_PSEUDOSHEET_OUTLINE
; break;
970 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS
: pNameId
= STR_PSEUDOSHEET_BACKGROUNDOBJECTS
; break;
971 case HID_PSEUDOSHEET_BACKGROUND
: pNameId
= STR_PSEUDOSHEET_BACKGROUND
; break;
972 case HID_PSEUDOSHEET_NOTES
: pNameId
= STR_PSEUDOSHEET_NOTES
; break;
975 // 0 or wrong (old) HelpId
983 if (pNameId
== STR_PSEUDOSHEET_OUTLINE
)
985 aNewName
+= " " + OUString::number( sal_Int32( nHelpId
- HID_PSEUDOSHEET_OUTLINE
) );
989 if( !aNewName
.isEmpty() && aNewName
!= aOldName
)
991 SfxStyleSheetBase
* pSheetFound
= Find( aNewName
, eFam
);
995 // Sheet does not yet exist: rename old sheet
996 pStyle
->SetName( aNewName
); // transform also parents
1000 // Sheet does exist: old sheet has to be removed
1001 aEraseList
.push_back( pStyle
);
1008 if (!aEraseList
.empty())
1010 // styles that could not be renamed, must be removed
1011 for (SfxStyleSheetBase
* p
: aEraseList
)
1017 void SdStyleSheetPool::setDefaultOutlineNumberFormatBulletAndIndent(sal_uInt16 i
, SvxNumberFormat
&rNumberFormat
)
1019 rNumberFormat
.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1020 rNumberFormat
.SetBulletRelSize(45);
1021 const auto nLSpace
= (i
+ 1) * 1200;
1022 rNumberFormat
.SetAbsLSpace(nLSpace
);
1023 sal_Int32 nFirstLineOffset
= -600;
1029 nFirstLineOffset
= -900;
1035 rNumberFormat
.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
1036 rNumberFormat
.SetBulletRelSize(75);
1037 nFirstLineOffset
= -900;
1043 nFirstLineOffset
= -800;
1049 rNumberFormat
.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
1050 rNumberFormat
.SetBulletRelSize(75);
1055 rNumberFormat
.SetFirstLineOffset(nFirstLineOffset
);
1058 // Set new SvxNumBulletItem for the respective style sheet
1059 void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase
* pSheet
,
1060 vcl::Font
& rBulletFont
)
1063 sal_uLong nHelpId
= pSheet
->GetHelpId( aHelpFile
);
1064 SfxItemSet
& rSet
= pSheet
->GetItemSet();
1068 case HID_STANDARD_STYLESHEET_NAME
:
1070 // Standard template
1071 SvxNumberFormat
aNumberFormat(SVX_NUM_CHAR_SPECIAL
);
1072 aNumberFormat
.SetBulletFont(&rBulletFont
);
1073 aNumberFormat
.SetBulletChar( 0x25CF ); // U+25CF: BLACK CIRCLE
1074 aNumberFormat
.SetBulletRelSize(45);
1075 aNumberFormat
.SetBulletColor(COL_AUTO
);
1076 aNumberFormat
.SetStart(1);
1077 aNumberFormat
.SetNumAdjust(SvxAdjust::Left
);
1079 SvxNumRule
aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE
| SvxNumRuleFlags::BULLET_COLOR
, SVX_MAX_NUM
, false);
1081 for( sal_uInt16 i
= 0; i
< aNumRule
.GetLevelCount(); i
++ )
1083 const auto nLSpace
= (i
+ 1) * 600;
1084 aNumberFormat
.SetAbsLSpace(nLSpace
);
1085 aNumberFormat
.SetFirstLineOffset(-600);
1086 aNumRule
.SetLevel( i
, aNumberFormat
);
1089 rSet
.Put( SvxNumBulletItem( std::move(aNumRule
), EE_PARA_NUMBULLET
) );
1090 static_cast<SfxStyleSheet
*>(pSheet
)->Broadcast(SfxHint( SfxHintId::DataChanged
) );
1094 case HID_PSEUDOSHEET_TITLE
:
1095 /* title gets same bullet as subtitle and not that page symbol anymore */
1096 case HID_PSEUDOSHEET_SUBTITLE
:
1098 // Subtitle template
1099 SvxNumBulletItem
const*const pItem(
1100 rSet
.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET
));
1101 const SvxNumRule
*const pDefaultRule
= pItem
? &pItem
->GetNumRule() : nullptr;
1102 DBG_ASSERT( pDefaultRule
, "Where is my default template? [CL]" );
1106 SvxNumRule
aNumRule(pDefaultRule
->GetFeatureFlags(), 10, false);
1107 for(sal_uInt16 i
=0; i
< aNumRule
.GetLevelCount(); i
++)
1109 SvxNumberFormat
aFrmt( pDefaultRule
->GetLevel(i
) );
1110 aFrmt
.SetNumberingType(SVX_NUM_CHAR_SPECIAL
);
1111 // #i93908# clear suffix for bullet lists
1112 aFrmt
.SetListFormat("", "", i
);
1114 aFrmt
.SetBulletRelSize(45);
1115 aFrmt
.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1116 aFrmt
.SetBulletFont(&rBulletFont
);
1117 aNumRule
.SetLevel(i
, aFrmt
);
1120 rSet
.Put( SvxNumBulletItem( std::move(aNumRule
), EE_PARA_NUMBULLET
) );
1121 static_cast<SfxStyleSheet
*>(pSheet
)->Broadcast(SfxHint( SfxHintId::DataChanged
) );
1126 case HID_PSEUDOSHEET_OUTLINE
+ 1 :
1129 SvxNumberFormat
aNumberFormat(SVX_NUM_CHAR_SPECIAL
);
1130 aNumberFormat
.SetBulletColor(COL_AUTO
);
1131 aNumberFormat
.SetStart(1);
1132 aNumberFormat
.SetNumAdjust(SvxAdjust::Left
);
1134 SvxNumRule
aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE
| SvxNumRuleFlags::BULLET_COLOR
,
1135 SVX_MAX_NUM
, false );
1136 for( sal_uInt16 i
= 0; i
< aNumRule
.GetLevelCount(); i
++ )
1138 setDefaultOutlineNumberFormatBulletAndIndent(i
, aNumberFormat
);
1139 rBulletFont
.SetFontSize(Size(0,846)); // 24 pt
1140 aNumberFormat
.SetBulletFont(&rBulletFont
);
1141 aNumRule
.SetLevel( i
, aNumberFormat
);
1144 rSet
.Put( SvxNumBulletItem( std::move(aNumRule
), EE_PARA_NUMBULLET
) );
1145 static_cast<SfxStyleSheet
*>(pSheet
)->Broadcast(SfxHint( SfxHintId::DataChanged
) );
1151 /*************************************************************************
1153 |* Create standard bullet font (without size)
1155 \************************************************************************/
1157 vcl::Font
SdStyleSheetPool::GetBulletFont()
1159 vcl::Font
aBulletFont( "OpenSymbol", Size(0, 1000) );
1160 aBulletFont
.SetCharSet(RTL_TEXTENCODING_UNICODE
);
1161 aBulletFont
.SetWeight(WEIGHT_NORMAL
);
1162 aBulletFont
.SetUnderline(LINESTYLE_NONE
);
1163 aBulletFont
.SetOverline(LINESTYLE_NONE
);
1164 aBulletFont
.SetStrikeout(STRIKEOUT_NONE
);
1165 aBulletFont
.SetItalic(ITALIC_NONE
);
1166 aBulletFont
.SetOutline(false);
1167 aBulletFont
.SetShadow(false);
1168 aBulletFont
.SetColor(COL_AUTO
);
1169 aBulletFont
.SetTransparent(true);
1174 void SdStyleSheetPool::AddStyleFamily( const SdPage
* pPage
)
1176 rtl::Reference
< SfxStyleSheetPool
> xPool( this );
1177 maStyleFamilyMap
[pPage
] = new SdStyleFamily( xPool
, pPage
);
1180 void SdStyleSheetPool::RemoveStyleFamily( const SdPage
* pPage
)
1182 SdStyleFamilyMap::iterator
iter( maStyleFamilyMap
.find( pPage
) );
1183 if( iter
== maStyleFamilyMap
.end() )
1186 SdStyleFamilyRef
xStyle( (*iter
).second
);
1187 maStyleFamilyMap
.erase( iter
);
1189 if( xStyle
.is() ) try
1198 void SdStyleSheetPool::throwIfDisposed()
1200 if( mpDoc
== nullptr )
1201 throw DisposedException();
1205 OUString SAL_CALL
SdStyleSheetPool::getImplementationName()
1207 return "SdStyleSheetPool";
1210 sal_Bool SAL_CALL
SdStyleSheetPool::supportsService( const OUString
& ServiceName
)
1212 return cppu::supportsService(this, ServiceName
);
1215 Sequence
< OUString
> SAL_CALL
SdStyleSheetPool::getSupportedServiceNames()
1217 return { "com.sun.star.style.StyleFamilies" };
1221 Any SAL_CALL
SdStyleSheetPool::getByName( const OUString
& aName
)
1225 if( mxGraphicFamily
->getName() == aName
)
1226 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( mxGraphicFamily
.get() ) ) );
1228 if( mxCellFamily
->getName() == aName
)
1229 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( mxCellFamily
.get() ) ) );
1231 if( msTableFamilyName
== aName
)
1232 return Any( mxTableFamily
);
1234 auto iter
= std::find_if(maStyleFamilyMap
.begin(), maStyleFamilyMap
.end(),
1235 [&aName
](const SdStyleFamilyMap::value_type
& rEntry
) { return rEntry
.second
->getName() == aName
; });
1236 if (iter
!= maStyleFamilyMap
.end())
1237 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( (*iter
).second
.get() ) ) );
1239 throw NoSuchElementException();
1242 Sequence
< OUString
> SAL_CALL
SdStyleSheetPool::getElementNames()
1246 Sequence
< OUString
> aNames( maStyleFamilyMap
.size() + 3 );
1247 OUString
* pNames
= aNames
.getArray();
1249 *pNames
++ = mxGraphicFamily
->getName();
1250 *pNames
++ = mxCellFamily
->getName();
1251 *pNames
++ = msTableFamilyName
;
1253 for( const auto& rEntry
: maStyleFamilyMap
)
1255 *pNames
++ = rEntry
.second
->getName();
1261 sal_Bool SAL_CALL
SdStyleSheetPool::hasByName( const OUString
& aName
)
1265 if( mxGraphicFamily
->getName() == aName
)
1268 if( mxCellFamily
->getName() == aName
)
1271 if( msTableFamilyName
== aName
)
1274 return std::any_of(maStyleFamilyMap
.begin(), maStyleFamilyMap
.end(),
1275 [&aName
](const SdStyleFamilyMap::value_type
& rEntry
) { return rEntry
.second
->getName() == aName
; });
1280 Type SAL_CALL
SdStyleSheetPool::getElementType()
1284 return cppu::UnoType
<XNameAccess
>::get();
1287 sal_Bool SAL_CALL
SdStyleSheetPool::hasElements()
1294 sal_Int32 SAL_CALL
SdStyleSheetPool::getCount()
1298 return maStyleFamilyMap
.size() + 3;
1301 Any SAL_CALL
SdStyleSheetPool::getByIndex( sal_Int32 Index
)
1306 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( mxGraphicFamily
.get() ) ) );
1309 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( mxCellFamily
.get() ) ) );
1312 return Any( mxTableFamily
);
1317 if( (Index
< 0) || (Index
>= sal::static_int_cast
<sal_Int32
>(maStyleFamilyMap
.size())) )
1318 throw IndexOutOfBoundsException();
1319 SdStyleFamilyMap::iterator
iter( maStyleFamilyMap
.begin() );
1320 std::advance(iter
, Index
);
1322 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( (*iter
).second
.get() ) ) );
1329 void SAL_CALL
SdStyleSheetPool::dispose()
1334 mxGraphicFamily
->dispose();
1335 mxGraphicFamily
.clear();
1336 mxCellFamily
->dispose();
1337 mxCellFamily
.clear();
1339 Reference
< XComponent
> xComp( mxTableFamily
, UNO_QUERY
);
1342 mxTableFamily
= nullptr;
1344 SdStyleFamilyMap aTempMap
;
1345 aTempMap
.swap( maStyleFamilyMap
);
1347 for( auto& rEntry
: aTempMap
) try
1349 rEntry
.second
->dispose();
1360 void SAL_CALL
SdStyleSheetPool::addEventListener( const Reference
< XEventListener
>& /*xListener*/ )
1364 void SAL_CALL
SdStyleSheetPool::removeEventListener( const Reference
< XEventListener
>& /*aListener*/ )
1368 SdStyleSheetVector
SdStyleSheetPool::CreateChildList( SdStyleSheet
const * pSheet
)
1370 SdStyleSheetVector aResult
;
1372 const size_t nListenerCount
= pSheet
->GetSizeOfVector();
1373 for (size_t n
= 0; n
< nListenerCount
; ++n
)
1375 SdStyleSheet
* pChild
= dynamic_cast< SdStyleSheet
* >( pSheet
->GetListener(n
) );
1376 if(pChild
&& pChild
->GetParent() == pSheet
->GetName())
1378 aResult
.emplace_back( pChild
);
1385 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */