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 <tools/diagnose_ex.h>
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, -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 Reference
< XIndexAccess
> xSource( rSourcePool
.mxTableFamily
, UNO_QUERY
);
526 Reference
< XNameContainer
> xTarget( mxTableFamily
, UNO_QUERY
);
527 Reference
< XSingleServiceFactory
> xFactory( mxTableFamily
, UNO_QUERY
);
529 if( !(xSource
.is() && xFactory
.is() && mxTableFamily
.is()) )
532 for( sal_Int32 nIndex
= 0; nIndex
< xSource
->getCount(); nIndex
++ ) try
534 Reference
< XStyle
> xSourceTableStyle( xSource
->getByIndex( nIndex
), UNO_QUERY
);
535 if( xSourceTableStyle
.is() )
537 Reference
< XStyle
> xNewTableStyle( xFactory
->createInstance(), UNO_QUERY
);
538 if( xNewTableStyle
.is() )
540 Reference
< XNameAccess
> xSourceNames( xSourceTableStyle
, UNO_QUERY_THROW
);
542 const Sequence
< OUString
> aStyleNames( xSourceNames
->getElementNames() );
544 Reference
< XNameReplace
> xTargetNames( xNewTableStyle
, UNO_QUERY
);
546 for( const OUString
& aName
: aStyleNames
)
548 Reference
< XStyle
> xSourceStyle( xSourceNames
->getByName( aName
), UNO_QUERY
);
549 Reference
< XStyle
> xTargetStyle
;
550 if( xSourceStyle
.is() ) try
552 mxCellFamily
->getByName( xSourceStyle
->getName() ) >>= xTargetStyle
;
556 TOOLS_WARN_EXCEPTION( "sd", "sd::SdStyleSheetPool::CopyTableStyles()" );
559 if( xTargetStyle
.is() )
560 xTargetNames
->replaceByName( aName
, Any( xTargetStyle
) );
564 OUString
sName( xSourceTableStyle
->getName() );
565 if( xTarget
->hasByName( sName
) )
566 xTarget
->replaceByName( sName
, Any( xNewTableStyle
) );
568 xTarget
->insertByName( sName
, Any( xNewTableStyle
) );
573 TOOLS_WARN_EXCEPTION( "sd", "sd::SdStyleSheetPool::CopyTableStyles()");
577 void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool
& rSourcePool
, StyleSheetCopyResultVector
& rCreatedSheets
)
579 CopySheets( rSourcePool
, SfxStyleFamily::Frame
, rCreatedSheets
);
582 void SdStyleSheetPool::RenameAndCopyGraphicSheets(SdStyleSheetPool
& rSourcePool
, StyleSheetCopyResultVector
& rCreatedSheets
, std::u16string_view rRenameSuffix
)
584 CopySheets( rSourcePool
, SfxStyleFamily::Para
, rCreatedSheets
, rRenameSuffix
);
587 void SdStyleSheetPool::CopySheets(SdStyleSheetPool
& rSourcePool
, SfxStyleFamily eFamily
)
589 StyleSheetCopyResultVector aTmpSheets
;
590 CopySheets(rSourcePool
, eFamily
, aTmpSheets
);
593 void SdStyleSheetPool::CopySheets(SdStyleSheetPool
& rSourcePool
, SfxStyleFamily eFamily
, StyleSheetCopyResultVector
& rCreatedSheets
)
595 CopySheets(rSourcePool
, eFamily
, rCreatedSheets
, u
"");
601 struct HasFamilyPredicate
: svl::StyleSheetPredicate
603 explicit HasFamilyPredicate(SfxStyleFamily eFamily
)
604 : meFamily(eFamily
) {}
606 bool Check(const SfxStyleSheetBase
& sheet
) override
608 return sheet
.GetFamily() == meFamily
;
610 SfxStyleFamily meFamily
;
615 void SdStyleSheetPool::CopySheets(SdStyleSheetPool
& rSourcePool
, SfxStyleFamily eFamily
, StyleSheetCopyResultVector
& rCreatedSheets
, std::u16string_view rRenameSuffix
)
617 std::vector
< std::pair
< rtl::Reference
< SfxStyleSheetBase
>, OUString
> > aNewStyles
;
618 std::vector
< std::pair
< OUString
, OUString
> > aRenamedList
;
620 // find all style sheets of the source pool which have the same family
621 HasFamilyPredicate
aHasFamilyPredicate(eFamily
);
622 std::vector
<sal_Int32
> aSheetsWithFamily
= rSourcePool
.GetIndexedStyleSheets().FindPositionsByPredicate(aHasFamilyPredicate
);
624 for (const auto& rPos
: aSheetsWithFamily
)
626 SfxStyleSheetBase
* pSheet
= rSourcePool
.GetStyleSheetByPositionInIndex( rPos
);
629 OUString
aName( pSheet
->GetName() );
631 // now check whether we already have a sheet with the same name
632 std::vector
<sal_Int32
> aSheetsWithName
= GetIndexedStyleSheets().FindPositionsByName(aName
);
633 bool bAddToList
= false;
634 SfxStyleSheetBase
* pExistingSheet
= nullptr;
635 if (!aSheetsWithName
.empty())
637 // if we have a rename suffix, try to find a new name
639 GetStyleSheetByPositionInIndex(aSheetsWithName
.front());
640 if (!rRenameSuffix
.empty() &&
641 !pExistingSheet
->GetItemSet().Equals(pSheet
->GetItemSet(), false))
643 // we have found a sheet with the same name, but different contents. Try to find a new name.
644 // If we already have a sheet with the new name, and it is equal to the one in the source pool,
646 OUString aTmpName
= aName
+ rRenameSuffix
;
647 sal_Int32 nSuffix
= 1;
650 aTmpName
= aName
+ rRenameSuffix
+ OUString::number(nSuffix
);
651 pExistingSheet
= Find(aTmpName
, eFamily
);
653 } while (pExistingSheet
&&
654 !pExistingSheet
->GetItemSet().Equals(pSheet
->GetItemSet(), false));
659 // we do not already have a sheet with the same name and contents. Create a new one.
662 assert(!Find(aName
, eFamily
));
663 rtl::Reference
< SfxStyleSheetBase
> xNewSheet( &Make( aName
, eFamily
) );
665 xNewSheet
->SetMask( pSheet
->GetMask() );
667 // Also set parent relation for copied style sheets
668 OUString
aParent( pSheet
->GetParent() );
669 if( !aParent
.isEmpty() )
670 aNewStyles
.emplace_back( xNewSheet
, aParent
);
675 xNewSheet
->SetHelpId( aHelpFile
, pSheet
->GetHelpId( aHelpFile
) );
677 xNewSheet
->GetItemSet().Put( pSheet
->GetItemSet() );
679 rCreatedSheets
.emplace_back(static_cast<SdStyleSheet
*>(xNewSheet
.get()), true);
680 aRenamedList
.emplace_back( pSheet
->GetName(), aName
);
684 // Add to list - used for renaming
685 rCreatedSheets
.emplace_back(static_cast<SdStyleSheet
*>(pExistingSheet
), false);
686 aRenamedList
.emplace_back( pSheet
->GetName(), aName
);
690 // set parents on newly added stylesheets
691 for( auto& rStyle
: aNewStyles
)
693 if( !rRenameSuffix
.empty() )
695 SfxStyleSheet
*pParent
= lcl_findStyle(rCreatedSheets
, lcl_findRenamedStyleName(aRenamedList
, rStyle
.second
));
698 rStyle
.first
->SetParent( pParent
->GetName() );
702 DBG_ASSERT( rSourcePool
.Find( rStyle
.second
, eFamily
), "StyleSheet has invalid parent: Family mismatch" );
703 rStyle
.first
->SetParent( rStyle
.second
);
705 // we have changed names of style sheets. Trigger reindexing.
709 /*************************************************************************
711 |* Copy style sheets of the named presentation layout from the source pool into
712 |* this pool. Copies only the style sheets which aren't yet in this pool.
713 |* If not NULL, pCreatedSheets is filled with pointers to the created style
716 |* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
718 \************************************************************************/
720 void SdStyleSheetPool::CopyLayoutSheets(std::u16string_view rLayoutName
, SdStyleSheetPool
& rSourcePool
, StyleSheetCopyResultVector
& rCreatedSheets
)
722 SfxStyleSheetBase
* pSheet
= nullptr;
724 std::vector
<OUString
> aNameList
;
725 CreateLayoutSheetNames(rLayoutName
,aNameList
);
727 for (const auto& rName
: aNameList
)
729 pSheet
= Find(rName
, SfxStyleFamily::Page
);
732 SfxStyleSheetBase
* pSourceSheet
= rSourcePool
.Find(rName
, SfxStyleFamily::Page
);
733 DBG_ASSERT(pSourceSheet
, "CopyLayoutSheets: Style sheet missing");
736 // In the case one comes with Methusalem-Docs.
737 SfxStyleSheetBase
& rNewSheet
= Make(rName
, SfxStyleFamily::Page
);
739 rNewSheet
.SetHelpId( file
, pSourceSheet
->GetHelpId( file
) );
740 rNewSheet
.GetItemSet().Put(pSourceSheet
->GetItemSet());
741 rCreatedSheets
.emplace_back(static_cast<SdStyleSheet
*>(&rNewSheet
), true);
746 // Special treatment for outline templates: create parent relation
747 std::vector
<SfxStyleSheetBase
*> aOutlineSheets
;
748 CreateOutlineSheetList(rLayoutName
,aOutlineSheets
);
750 if( aOutlineSheets
.empty() )
753 std::vector
<SfxStyleSheetBase
*>::iterator it
= aOutlineSheets
.begin();
754 SfxStyleSheetBase
* pParent
= *it
;
757 while (it
!= aOutlineSheets
.end())
764 if (pSheet
->GetParent().isEmpty())
765 pSheet
->SetParent(pParent
->GetName());
773 /*************************************************************************
775 |* Create list with names of the presentation templates of a layout.
776 |* The list and the containing strings are owned by the caller!
778 \************************************************************************/
780 void SdStyleSheetPool::CreateLayoutSheetNames(std::u16string_view rLayoutName
, std::vector
<OUString
> &aNameList
)
782 OUString
aPrefix(OUString::Concat(rLayoutName
) + SD_LT_SEPARATOR
);
784 for (sal_Int32 nLevel
= 1; nLevel
< 10; nLevel
++)
785 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_OUTLINE
" " + OUString::number( nLevel
) );
787 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_TITLE
);
788 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_SUBTITLE
);
789 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_NOTES
);
790 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_BACKGROUNDOBJECTS
);
791 aNameList
.emplace_back(aPrefix
+ STR_LAYOUT_BACKGROUND
);
794 /*************************************************************************
796 |* Create a list with pointer to presentation templates of a layout.
797 |* The list is owned by the caller!
799 \************************************************************************/
801 void SdStyleSheetPool::CreateLayoutSheetList(std::u16string_view rLayoutName
, SdStyleSheetVector
& rLayoutSheets
)
803 OUString
aLayoutNameWithSep(OUString::Concat(rLayoutName
) + SD_LT_SEPARATOR
);
805 SfxStyleSheetIterator
aIter(this, SfxStyleFamily::Page
);
806 SfxStyleSheetBase
* pSheet
= aIter
.First();
810 if (pSheet
->GetName().startsWith(aLayoutNameWithSep
))
811 rLayoutSheets
.emplace_back( static_cast< SdStyleSheet
* >( pSheet
) );
812 pSheet
= aIter
.Next();
816 /*************************************************************************
818 |* Create pseudo style sheets if necessary
820 \************************************************************************/
822 void SdStyleSheetPool::CreatePseudosIfNecessary()
825 const OUString aHelpFile
;
826 SfxStyleSheetBase
* pSheet
= nullptr;
827 SfxStyleSheetBase
* pParent
= nullptr;
829 SfxStyleSearchBits nUsedMask
= SfxStyleSearchBits::Used
;
831 aName
= SdResId(STR_PSEUDOSHEET_TITLE
);
832 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
834 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
835 pSheet
->SetParent( OUString() );
836 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
838 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_TITLE
);
840 aName
= SdResId(STR_PSEUDOSHEET_SUBTITLE
);
841 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
843 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
844 pSheet
->SetParent( OUString() );
845 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
847 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_SUBTITLE
);
849 aName
= SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS
);
850 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
852 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
853 pSheet
->SetParent( OUString() );
854 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
856 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_BACKGROUNDOBJECTS
);
858 aName
= SdResId(STR_PSEUDOSHEET_BACKGROUND
);
859 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
861 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
862 pSheet
->SetParent( OUString() );
863 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
865 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_BACKGROUND
);
867 aName
= SdResId(STR_PSEUDOSHEET_NOTES
);
868 if( (pSheet
= Find(aName
, SfxStyleFamily::Pseudo
)) == nullptr )
870 pSheet
= &Make(aName
, SfxStyleFamily::Pseudo
, nUsedMask
);
871 pSheet
->SetParent( OUString() );
872 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
874 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_NOTES
);
877 aName
= SdResId(STR_PSEUDOSHEET_OUTLINE
);
878 for (sal_Int32 nLevel
= 1; nLevel
< 10; nLevel
++)
880 OUString
aLevelName( aName
+ " " + OUString::number( nLevel
) );
882 if( (pSheet
= Find(aLevelName
, SfxStyleFamily::Pseudo
)) == nullptr )
884 pSheet
= &Make(aLevelName
, SfxStyleFamily::Pseudo
, nUsedMask
);
887 pSheet
->SetParent(pParent
->GetName());
889 static_cast<SfxStyleSheet
*>(pSheet
)->StartListening(*this);
891 pSheet
->SetHelpId( aHelpFile
, HID_PSEUDOSHEET_OUTLINE
+ nLevel
);
895 /*************************************************************************
897 |* Set the correct name in the program language to the standard styles
899 \************************************************************************/
903 struct StyleSheetIsUserDefinedPredicate
: svl::StyleSheetPredicate
905 StyleSheetIsUserDefinedPredicate()
908 bool Check(const SfxStyleSheetBase
& sheet
) override
910 return sheet
.IsUserDefined();
915 void SdStyleSheetPool::UpdateStdNames()
918 StyleSheetIsUserDefinedPredicate aPredicate
;
919 std::vector
<SfxStyleSheetBase
*> aEraseList
;
920 std::vector
<sal_Int32
> aUserDefinedStyles
= GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate
);
921 for (const auto& rStyle
: aUserDefinedStyles
)
923 SfxStyleSheetBase
* pStyle
= GetStyleSheetByPositionInIndex(rStyle
);
925 if( !pStyle
->IsUserDefined() )
927 OUString aOldName
= pStyle
->GetName();
928 sal_uLong nHelpId
= pStyle
->GetHelpId( aHelpFile
);
929 SfxStyleFamily eFam
= pStyle
->GetFamily();
931 bool bHelpKnown
= true;
935 case HID_STANDARD_STYLESHEET_NAME
: pNameId
= STR_STANDARD_STYLESHEET_NAME
; break;
936 case HID_POOLSHEET_OBJWITHOUTFILL
: pNameId
= STR_POOLSHEET_OBJWITHOUTFILL
; break;
937 case HID_POOLSHEET_OBJNOLINENOFILL
: pNameId
= STR_POOLSHEET_OBJNOLINENOFILL
;break;
938 case HID_POOLSHEET_TEXT
: pNameId
= STR_POOLSHEET_TEXT
; break;
939 case HID_POOLSHEET_A4
: pNameId
= STR_POOLSHEET_A4
; break;
940 case HID_POOLSHEET_A4_TITLE
: pNameId
= STR_POOLSHEET_A4_TITLE
; break;
941 case HID_POOLSHEET_A4_HEADLINE
: pNameId
= STR_POOLSHEET_A4_HEADLINE
; break;
942 case HID_POOLSHEET_A4_TEXT
: pNameId
= STR_POOLSHEET_A4_TEXT
; break;
943 case HID_POOLSHEET_A0
: pNameId
= STR_POOLSHEET_A0
; break;
944 case HID_POOLSHEET_A0_TITLE
: pNameId
= STR_POOLSHEET_A0_TITLE
; break;
945 case HID_POOLSHEET_A0_HEADLINE
: pNameId
= STR_POOLSHEET_A0_HEADLINE
; break;
946 case HID_POOLSHEET_A0_TEXT
: pNameId
= STR_POOLSHEET_A0_TEXT
; break;
947 case HID_POOLSHEET_GRAPHIC
: pNameId
= STR_POOLSHEET_GRAPHIC
; break;
948 case HID_POOLSHEET_SHAPES
: pNameId
= STR_POOLSHEET_SHAPES
; break;
949 case HID_POOLSHEET_FILLED
: pNameId
= STR_POOLSHEET_FILLED
; break;
950 case HID_POOLSHEET_FILLED_BLUE
: pNameId
= STR_POOLSHEET_FILLED_BLUE
; break;
951 case HID_POOLSHEET_FILLED_GREEN
: pNameId
= STR_POOLSHEET_FILLED_GREEN
; break;
952 case HID_POOLSHEET_FILLED_RED
: pNameId
= STR_POOLSHEET_FILLED_RED
; break;
953 case HID_POOLSHEET_FILLED_YELLOW
: pNameId
= STR_POOLSHEET_FILLED_YELLOW
; break;
954 case HID_POOLSHEET_OUTLINE
: pNameId
= STR_POOLSHEET_OUTLINE
; break;
955 case HID_POOLSHEET_OUTLINE_BLUE
: pNameId
= STR_POOLSHEET_OUTLINE_BLUE
; break;
956 case HID_POOLSHEET_OUTLINE_GREEN
: pNameId
= STR_POOLSHEET_OUTLINE_GREEN
; break;
957 case HID_POOLSHEET_OUTLINE_RED
: pNameId
= STR_POOLSHEET_OUTLINE_RED
; break;
958 case HID_POOLSHEET_OUTLINE_YELLOW
: pNameId
= STR_POOLSHEET_OUTLINE_YELLOW
; break;
959 case HID_POOLSHEET_LINES
: pNameId
= STR_POOLSHEET_LINES
; break;
960 case HID_POOLSHEET_MEASURE
: pNameId
= STR_POOLSHEET_MEASURE
; break;
961 case HID_POOLSHEET_LINES_DASHED
: pNameId
= STR_POOLSHEET_LINES_DASHED
; break;
963 case HID_PSEUDOSHEET_OUTLINE1
:
964 case HID_PSEUDOSHEET_OUTLINE2
:
965 case HID_PSEUDOSHEET_OUTLINE3
:
966 case HID_PSEUDOSHEET_OUTLINE4
:
967 case HID_PSEUDOSHEET_OUTLINE5
:
968 case HID_PSEUDOSHEET_OUTLINE6
:
969 case HID_PSEUDOSHEET_OUTLINE7
:
970 case HID_PSEUDOSHEET_OUTLINE8
:
971 case HID_PSEUDOSHEET_OUTLINE9
: pNameId
= STR_PSEUDOSHEET_OUTLINE
; break;
972 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS
: pNameId
= STR_PSEUDOSHEET_BACKGROUNDOBJECTS
; break;
973 case HID_PSEUDOSHEET_BACKGROUND
: pNameId
= STR_PSEUDOSHEET_BACKGROUND
; break;
974 case HID_PSEUDOSHEET_NOTES
: pNameId
= STR_PSEUDOSHEET_NOTES
; break;
976 case HID_SD_CELL_STYLE_DEFAULT
: pNameId
= STR_STANDARD_STYLESHEET_NAME
; break;
977 case HID_SD_CELL_STYLE_BANDED
: pNameId
= STR_POOLSHEET_BANDED_CELL
; break;
978 case HID_SD_CELL_STYLE_HEADER
: pNameId
= STR_POOLSHEET_HEADER
; break;
979 case HID_SD_CELL_STYLE_TOTAL
: pNameId
= STR_POOLSHEET_TOTAL
; break;
980 case HID_SD_CELL_STYLE_FIRST_COLUMN
: pNameId
= STR_POOLSHEET_FIRST_COLUMN
; break;
981 case HID_SD_CELL_STYLE_LAST_COLUMN
: pNameId
= STR_POOLSHEET_LAST_COLUMN
; break;
984 // 0 or wrong (old) HelpId
992 if (pNameId
== STR_PSEUDOSHEET_OUTLINE
)
994 aNewName
+= " " + OUString::number( sal_Int32( nHelpId
- HID_PSEUDOSHEET_OUTLINE
) );
998 if( !aNewName
.isEmpty() && aNewName
!= aOldName
)
1000 SfxStyleSheetBase
* pSheetFound
= Find( aNewName
, eFam
);
1004 // Sheet does not yet exist: rename old sheet
1005 pStyle
->SetName( aNewName
); // transform also parents
1009 // Sheet does exist: old sheet has to be removed
1010 aEraseList
.push_back( pStyle
);
1017 if (!aEraseList
.empty())
1019 // styles that could not be renamed, must be removed
1020 for (SfxStyleSheetBase
* p
: aEraseList
)
1026 void SdStyleSheetPool::setDefaultOutlineNumberFormatBulletAndIndent(sal_uInt16 i
, SvxNumberFormat
&rNumberFormat
)
1028 rNumberFormat
.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1029 rNumberFormat
.SetBulletRelSize(45);
1030 const auto nLSpace
= (i
+ 1) * 1200;
1031 rNumberFormat
.SetAbsLSpace(nLSpace
);
1032 sal_Int32 nFirstLineOffset
= -600;
1038 nFirstLineOffset
= -900;
1044 rNumberFormat
.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
1045 rNumberFormat
.SetBulletRelSize(75);
1046 nFirstLineOffset
= -900;
1052 nFirstLineOffset
= -800;
1058 rNumberFormat
.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
1059 rNumberFormat
.SetBulletRelSize(75);
1064 rNumberFormat
.SetFirstLineOffset(nFirstLineOffset
);
1067 // Set new SvxNumBulletItem for the respective style sheet
1068 void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase
* pSheet
,
1069 vcl::Font
& rBulletFont
)
1072 sal_uLong nHelpId
= pSheet
->GetHelpId( aHelpFile
);
1073 SfxItemSet
& rSet
= pSheet
->GetItemSet();
1077 case HID_STANDARD_STYLESHEET_NAME
:
1079 // Standard template
1080 SvxNumberFormat
aNumberFormat(SVX_NUM_CHAR_SPECIAL
);
1081 aNumberFormat
.SetBulletFont(&rBulletFont
);
1082 aNumberFormat
.SetBulletChar( 0x25CF ); // U+25CF: BLACK CIRCLE
1083 aNumberFormat
.SetBulletRelSize(45);
1084 aNumberFormat
.SetBulletColor(COL_AUTO
);
1085 aNumberFormat
.SetStart(1);
1086 aNumberFormat
.SetNumAdjust(SvxAdjust::Left
);
1088 SvxNumRule
aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE
| SvxNumRuleFlags::BULLET_COLOR
, SVX_MAX_NUM
, false);
1090 for( sal_uInt16 i
= 0; i
< aNumRule
.GetLevelCount(); i
++ )
1092 const auto nLSpace
= (i
+ 1) * 600;
1093 aNumberFormat
.SetAbsLSpace(nLSpace
);
1094 aNumberFormat
.SetFirstLineOffset(-600);
1095 aNumRule
.SetLevel( i
, aNumberFormat
);
1098 rSet
.Put( SvxNumBulletItem( std::move(aNumRule
), EE_PARA_NUMBULLET
) );
1099 static_cast<SfxStyleSheet
*>(pSheet
)->Broadcast(SfxHint( SfxHintId::DataChanged
) );
1103 case HID_PSEUDOSHEET_TITLE
:
1104 /* title gets same bullet as subtitle and not that page symbol anymore */
1105 case HID_PSEUDOSHEET_SUBTITLE
:
1107 // Subtitle template
1108 SvxNumBulletItem
const*const pItem(
1109 rSet
.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET
));
1110 const SvxNumRule
*const pDefaultRule
= pItem
? &pItem
->GetNumRule() : nullptr;
1111 DBG_ASSERT( pDefaultRule
, "Where is my default template? [CL]" );
1115 SvxNumRule
aNumRule(pDefaultRule
->GetFeatureFlags(), 10, false);
1116 for(sal_uInt16 i
=0; i
< aNumRule
.GetLevelCount(); i
++)
1118 SvxNumberFormat
aFrmt( pDefaultRule
->GetLevel(i
) );
1119 aFrmt
.SetNumberingType(SVX_NUM_CHAR_SPECIAL
);
1120 // #i93908# clear suffix for bullet lists
1121 aFrmt
.SetPrefix(OUString());
1122 aFrmt
.SetSuffix(OUString());
1124 aFrmt
.SetBulletRelSize(45);
1125 aFrmt
.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1126 aFrmt
.SetBulletFont(&rBulletFont
);
1127 aNumRule
.SetLevel(i
, aFrmt
);
1130 rSet
.Put( SvxNumBulletItem( std::move(aNumRule
), EE_PARA_NUMBULLET
) );
1131 static_cast<SfxStyleSheet
*>(pSheet
)->Broadcast(SfxHint( SfxHintId::DataChanged
) );
1136 case HID_PSEUDOSHEET_OUTLINE
+ 1 :
1139 SvxNumberFormat
aNumberFormat(SVX_NUM_CHAR_SPECIAL
);
1140 aNumberFormat
.SetBulletColor(COL_AUTO
);
1141 aNumberFormat
.SetStart(1);
1142 aNumberFormat
.SetNumAdjust(SvxAdjust::Left
);
1144 SvxNumRule
aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE
| SvxNumRuleFlags::BULLET_COLOR
,
1145 SVX_MAX_NUM
, false );
1146 for( sal_uInt16 i
= 0; i
< aNumRule
.GetLevelCount(); i
++ )
1148 setDefaultOutlineNumberFormatBulletAndIndent(i
, aNumberFormat
);
1149 rBulletFont
.SetFontSize(Size(0,846)); // 24 pt
1150 aNumberFormat
.SetBulletFont(&rBulletFont
);
1151 aNumRule
.SetLevel( i
, aNumberFormat
);
1154 rSet
.Put( SvxNumBulletItem( std::move(aNumRule
), EE_PARA_NUMBULLET
) );
1155 static_cast<SfxStyleSheet
*>(pSheet
)->Broadcast(SfxHint( SfxHintId::DataChanged
) );
1161 /*************************************************************************
1163 |* Create standard bullet font (without size)
1165 \************************************************************************/
1167 vcl::Font
SdStyleSheetPool::GetBulletFont()
1169 vcl::Font
aBulletFont( "OpenSymbol", Size(0, 1000) );
1170 aBulletFont
.SetCharSet(RTL_TEXTENCODING_UNICODE
);
1171 aBulletFont
.SetWeight(WEIGHT_NORMAL
);
1172 aBulletFont
.SetUnderline(LINESTYLE_NONE
);
1173 aBulletFont
.SetOverline(LINESTYLE_NONE
);
1174 aBulletFont
.SetStrikeout(STRIKEOUT_NONE
);
1175 aBulletFont
.SetItalic(ITALIC_NONE
);
1176 aBulletFont
.SetOutline(false);
1177 aBulletFont
.SetShadow(false);
1178 aBulletFont
.SetColor(COL_AUTO
);
1179 aBulletFont
.SetTransparent(true);
1184 void SdStyleSheetPool::AddStyleFamily( const SdPage
* pPage
)
1186 rtl::Reference
< SfxStyleSheetPool
> xPool( this );
1187 maStyleFamilyMap
[pPage
] = new SdStyleFamily( xPool
, pPage
);
1190 void SdStyleSheetPool::RemoveStyleFamily( const SdPage
* pPage
)
1192 SdStyleFamilyMap::iterator
iter( maStyleFamilyMap
.find( pPage
) );
1193 if( iter
== maStyleFamilyMap
.end() )
1196 SdStyleFamilyRef
xStyle( (*iter
).second
);
1197 maStyleFamilyMap
.erase( iter
);
1199 if( xStyle
.is() ) try
1208 void SdStyleSheetPool::throwIfDisposed()
1210 if( mpDoc
== nullptr )
1211 throw DisposedException();
1215 OUString SAL_CALL
SdStyleSheetPool::getImplementationName()
1217 return "SdStyleSheetPool";
1220 sal_Bool SAL_CALL
SdStyleSheetPool::supportsService( const OUString
& ServiceName
)
1222 return cppu::supportsService(this, ServiceName
);
1225 Sequence
< OUString
> SAL_CALL
SdStyleSheetPool::getSupportedServiceNames()
1227 return { "com.sun.star.style.StyleFamilies" };
1231 Any SAL_CALL
SdStyleSheetPool::getByName( const OUString
& aName
)
1235 if( mxGraphicFamily
->getName() == aName
)
1236 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( mxGraphicFamily
.get() ) ) );
1238 if( mxCellFamily
->getName() == aName
)
1239 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( mxCellFamily
.get() ) ) );
1241 if( msTableFamilyName
== aName
)
1242 return Any( mxTableFamily
);
1244 auto iter
= std::find_if(maStyleFamilyMap
.begin(), maStyleFamilyMap
.end(),
1245 [&aName
](const SdStyleFamilyMap::value_type
& rEntry
) { return rEntry
.second
->getName() == aName
; });
1246 if (iter
!= maStyleFamilyMap
.end())
1247 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( (*iter
).second
.get() ) ) );
1249 throw NoSuchElementException();
1252 Sequence
< OUString
> SAL_CALL
SdStyleSheetPool::getElementNames()
1256 Sequence
< OUString
> aNames( maStyleFamilyMap
.size() + 3 );
1257 OUString
* pNames
= aNames
.getArray();
1259 *pNames
++ = mxGraphicFamily
->getName();
1260 *pNames
++ = mxCellFamily
->getName();
1261 *pNames
++ = msTableFamilyName
;
1263 for( const auto& rEntry
: maStyleFamilyMap
)
1265 *pNames
++ = rEntry
.second
->getName();
1271 sal_Bool SAL_CALL
SdStyleSheetPool::hasByName( const OUString
& aName
)
1275 if( mxGraphicFamily
->getName() == aName
)
1278 if( mxCellFamily
->getName() == aName
)
1281 if( msTableFamilyName
== aName
)
1284 return std::any_of(maStyleFamilyMap
.begin(), maStyleFamilyMap
.end(),
1285 [&aName
](const SdStyleFamilyMap::value_type
& rEntry
) { return rEntry
.second
->getName() == aName
; });
1290 Type SAL_CALL
SdStyleSheetPool::getElementType()
1294 return cppu::UnoType
<XNameAccess
>::get();
1297 sal_Bool SAL_CALL
SdStyleSheetPool::hasElements()
1304 sal_Int32 SAL_CALL
SdStyleSheetPool::getCount()
1308 return maStyleFamilyMap
.size() + 3;
1311 Any SAL_CALL
SdStyleSheetPool::getByIndex( sal_Int32 Index
)
1316 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( mxGraphicFamily
.get() ) ) );
1319 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( mxCellFamily
.get() ) ) );
1322 return Any( mxTableFamily
);
1327 if( (Index
< 0) || (Index
>= sal::static_int_cast
<sal_Int32
>(maStyleFamilyMap
.size())) )
1328 throw IndexOutOfBoundsException();
1329 SdStyleFamilyMap::iterator
iter( maStyleFamilyMap
.begin() );
1330 std::advance(iter
, Index
);
1332 return Any( Reference
< XNameAccess
>( static_cast< XNameAccess
* >( (*iter
).second
.get() ) ) );
1339 void SAL_CALL
SdStyleSheetPool::dispose()
1344 mxGraphicFamily
->dispose();
1345 mxGraphicFamily
.clear();
1346 mxCellFamily
->dispose();
1347 mxCellFamily
.clear();
1349 Reference
< XComponent
> xComp( mxTableFamily
, UNO_QUERY
);
1352 mxTableFamily
= nullptr;
1354 SdStyleFamilyMap aTempMap
;
1355 aTempMap
.swap( maStyleFamilyMap
);
1357 for( auto& rEntry
: aTempMap
) try
1359 rEntry
.second
->dispose();
1370 void SAL_CALL
SdStyleSheetPool::addEventListener( const Reference
< XEventListener
>& /*xListener*/ )
1374 void SAL_CALL
SdStyleSheetPool::removeEventListener( const Reference
< XEventListener
>& /*aListener*/ )
1378 SdStyleSheetVector
SdStyleSheetPool::CreateChildList( SdStyleSheet
const * pSheet
)
1380 SdStyleSheetVector aResult
;
1382 const size_t nListenerCount
= pSheet
->GetSizeOfVector();
1383 for (size_t n
= 0; n
< nListenerCount
; ++n
)
1385 SdStyleSheet
* pChild
= dynamic_cast< SdStyleSheet
* >( pSheet
->GetListener(n
) );
1386 if(pChild
&& pChild
->GetParent() == pSheet
->GetName())
1388 aResult
.emplace_back( pChild
);
1395 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */