LibreOffice Module sd (master) 1
stlpool.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <com/sun/star/lang/DisposedException.hpp>
21#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
23#include <editeng/eeitem.hxx>
24#include <editeng/fhgtitem.hxx>
25#include <editeng/colritem.hxx>
27#include <editeng/shdditem.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>
51
52#include <editeng/lrspitem.hxx>
54#include <editeng/numdef.hxx>
55#include <svl/itempool.hxx>
57
58#include <stlpool.hxx>
59#include <sdresid.hxx>
60#include <stlsheet.hxx>
61#include <strings.hrc>
62#include <glob.hxx>
63#include <drawdoc.hxx>
64#include <svl/itemset.hxx>
65#include <app.hrc>
66#include <strings.hxx>
67
68#include <com/sun/star/drawing/LineStyle.hpp>
69#include <com/sun/star/drawing/TextFitToSizeType.hpp>
70
71using namespace ::com::sun::star;
72using namespace ::com::sun::star::uno;
73using namespace ::com::sun::star::lang;
74using namespace ::com::sun::star::style;
75using namespace ::com::sun::star::container;
76
77namespace
78{
79
80OUString lcl_findRenamedStyleName(std::vector< std::pair< OUString, OUString > > &rRenamedList, OUString const & aOriginalName )
81{
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;
86 return OUString();
87}
88
89SfxStyleSheet *lcl_findStyle(StyleSheetCopyResultVector& rStyles, std::u16string_view aStyleName)
90{
91 if( aStyleName.empty() )
92 return nullptr;
93 for (const auto& a : rStyles)
94 {
95 if (a.m_xStyleSheet->GetName() == aStyleName)
96 return a.m_xStyleSheet.get();
97 }
98 return nullptr;
99}
100
101}
102
104: SdStyleSheetPoolBase( _rPool )
105, mpActualStyleSheet(nullptr)
106, mpDoc(pDocument)
107{
108 if( !mpDoc )
109 return;
110
112
113 // create graphics family
114 mxGraphicFamily = new SdStyleFamily( xPool, SfxStyleFamily::Para );
115 mxCellFamily = new SdStyleFamily( xPool, SfxStyleFamily::Frame );
116
118 Reference< XNamed > xNamed( mxTableFamily, UNO_QUERY );
119 if( xNamed.is() )
120 msTableFamilyName = xNamed->getName();
121
122 // create presentation families, one for each master page
124 for( sal_uInt16 nPage = 0; nPage < nCount; ++nPage )
126}
127
129{
130 DBG_ASSERT( mpDoc == nullptr, "sd::SdStyleSheetPool::~SdStyleSheetPool(), dispose me first!" );
131}
132
134{
135 return new SdStyleSheet(rName, *this, eFamily, _nMask);
136}
137
138SfxStyleSheetBase* SdStyleSheetPool::GetTitleSheet(std::u16string_view rLayoutName)
139{
140 OUString aName = OUString::Concat(rLayoutName) + SD_LT_SEPARATOR + STR_LAYOUT_TITLE;
141 SfxStyleSheetBase* pResult = Find(aName, SfxStyleFamily::Page);
142 return pResult;
143}
144
145/*************************************************************************
146|*
147|* Create a list of outline text templates for a presentation layout.
148|* The caller has to delete the list.
149|*
150\************************************************************************/
151
152void SdStyleSheetPool::CreateOutlineSheetList (std::u16string_view rLayoutName, std::vector<SfxStyleSheetBase*> &rOutlineStyles)
153{
154 OUString aName = OUString::Concat(rLayoutName) + SD_LT_SEPARATOR + STR_LAYOUT_OUTLINE;
155
156 for (sal_Int32 nSheet = 1; nSheet < 10; nSheet++)
157 {
158 OUString aFullName(aName + " " + OUString::number( nSheet ) );
159 SfxStyleSheetBase* pSheet = Find(aFullName, SfxStyleFamily::Page);
160
161 if (pSheet)
162 rOutlineStyles.push_back(pSheet);
163 }
164}
165
166/*************************************************************************
167|*
168|* Create style sheets with default values for the named presentation layout
169|*
170\************************************************************************/
171
172void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName, bool bCheck /*= sal_False*/ )
173{
174 const SfxStyleSearchBits nUsedMask = SfxStyleSearchBits::All & ~SfxStyleSearchBits::UserDefined;
175
176 bool bCreated = false;
177
178 SfxStyleSheetBase* pSheet = nullptr;
179
180 OUString aPrefix(OUString::Concat(rLayoutName) + SD_LT_SEPARATOR);
181
182 vcl::Font aLatinFont, aCJKFont, aCTLFont;
183
184 mpDoc->getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
185
186 // Font for title and outline
187 SvxFontItem aSvxFontItem( aLatinFont.GetFamilyType(), aLatinFont.GetFamilyName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
188 aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
189
190 SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamilyType(), aCJKFont.GetFamilyName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
191 aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
192
193 SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamilyType(), aCTLFont.GetFamilyName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
194 aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
195
196 vcl::Font aBulletFont( GetBulletFont() );
197
198 /**************************************************************************
199 * outline levels
200 **************************************************************************/
201 OUString aName(STR_LAYOUT_OUTLINE);
202 const OUString aHelpFile;
203
204 SvxLRSpaceItem aSvxLRSpaceItem( EE_PARA_LRSPACE );
205 SvxULSpaceItem aSvxULSpaceItem( EE_PARA_ULSPACE );
206
207 for( sal_Int32 nLevel = 1; nLevel < 10; nLevel++)
208 {
209 OUString aLevelName( aPrefix + aName + " " + OUString::number( nLevel ) ) ;
210
211 if (!Find(aLevelName, SfxStyleFamily::Page))
212 {
213 bCreated = true;
214 pSheet = &Make(aLevelName, SfxStyleFamily::Page,nUsedMask);
215 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_OUTLINE + nLevel );
216
217 pSheet->SetParent( OUString() );
218
219 // attributing for level 1, the others levels inherit
220 if (nLevel == 1)
221 {
222 SfxItemSet& rSet = pSheet->GetItemSet();
223
224 rSet.Put(aSvxFontItem);
225 rSet.Put(aSvxFontItemCJK);
226 rSet.Put(aSvxFontItemCTL);
236 rSet.Put( SvxCaseMapItem(SvxCaseMap::NotMapped, EE_CHAR_CASEMAP ) );
239 rSet.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE, EE_CHAR_EMPHASISMARK ) );
240 rSet.Put( SvxCharReliefItem(FontRelief::NONE, EE_CHAR_RELIEF) );
243 rSet.Put( XLineStyleItem(css::drawing::LineStyle_NONE) );
244 rSet.Put( XFillStyleItem(drawing::FillStyle_NONE) );
245 rSet.Put( SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_AUTOFIT) );
247 // #i16874# enable kerning by default but only for new documents
249
251 PutNumBulletItem( pSheet, f );
252 }
253
254 sal_uLong nFontSize = 20;
255 sal_uInt16 nUpper = 100;
256
257 switch (nLevel)
258 {
259 case 1:
260 {
261 nFontSize = 32;
262 nUpper = 500;
263 }
264 break;
265
266 case 2:
267 {
268 nFontSize = 28;
269 nUpper = 400;
270 }
271 break;
272
273 case 3:
274 {
275 nFontSize = 24;
276 nUpper = 300;
277 }
278 break;
279
280 case 4:
281 {
282 nUpper = 200;
283 }
284 break;
285 }
286
287 // FontSize
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 ) );
293
294 // Line distance (upwards). Stuff around here cleaned up in i35937
295 aSvxULSpaceItem.SetUpper(nUpper);
296 pSheet->GetItemSet().Put(aSvxULSpaceItem);
297 }
298 }
299
300 // if we created outline styles, we need to chain them
301 if( bCreated )
302 {
303 SfxStyleSheetBase* pParent = nullptr;
304 for (sal_Int32 nLevel = 1; nLevel < 10; nLevel++)
305 {
306 OUString aLevelName( aPrefix + aName + " " + OUString::number( nLevel ) );
307
308 pSheet = Find(aLevelName, SfxStyleFamily::Page);
309
310 DBG_ASSERT( pSheet, "missing layout style!");
311
312 if( pSheet )
313 {
314 if (pParent)
315 pSheet->SetParent(pParent->GetName());
316 pParent = pSheet;
317 }
318 }
319 }
320
321 /**************************************************************************
322 * Title
323 **************************************************************************/
324 aName = aPrefix + STR_LAYOUT_TITLE;
325
326 if (!Find(aName, SfxStyleFamily::Page))
327 {
328 bCreated = true;
329
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);
345 rTitleSet.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT ) ); // 44 pt
346 rTitleSet.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 44 pt
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 ));
358 rTitleSet.Put(SvxAdjustItem(SvxAdjust::Center, EE_PARA_JUST ));
360 // #i16874# enable kerning by default but only for new documents
361 rTitleSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
362
363 aBulletFont.SetFontSize(Size(0,1552)); // 44 pt
364 PutNumBulletItem( pSheet, aBulletFont );
365 }
366
367 /**************************************************************************
368 * Subtitle
369 **************************************************************************/
370 aName = aPrefix + STR_LAYOUT_SUBTITLE;
371
372 if (!Find(aName, SfxStyleFamily::Page))
373 {
374 bCreated = true;
375
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 ) );
391 rSubtitleSet.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT ) ); // 32 pt
392 rSubtitleSet.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 32 pt
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 ));
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);
410
411 vcl::Font aTmpFont( GetBulletFont() );
412 aTmpFont.SetFontSize(Size(0, 1129)); // 32 pt
413 PutNumBulletItem( pSheet, aTmpFont );
414 }
415
416 /**************************************************************************
417 * Notes
418 **************************************************************************/
419 aName = aPrefix + STR_LAYOUT_NOTES;
420
421 if (!Find(aName, SfxStyleFamily::Page))
422 {
423 bCreated = true;
424
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);
440 rNotesSet.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT ) ); // 20 pt
441 rNotesSet.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 20 pt
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 ) );
456
457/* #i35937# */
458
459 }
460
461 /**************************************************************************
462 * Background objects
463 **************************************************************************/
465
466 if (!Find(aName, SfxStyleFamily::Page))
467 {
468 bCreated = true;
469
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));
481 }
482
483 /**************************************************************************
484 * Background
485 **************************************************************************/
486 aName = aPrefix + STR_LAYOUT_BACKGROUND;
487
488 if (!Find(aName, SfxStyleFamily::Page))
489 {
490 bCreated = true;
491
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 ) );
500 }
501
502 DBG_ASSERT( !bCheck || !bCreated, "missing layout style sheets detected!" );
503}
504
505/*************************************************************************
506|*
507|* Copy graphic style sheets from source pool into this pool
508|*
509|* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
510|*
511\************************************************************************/
512
514{
515 CopySheets( rSourcePool, SfxStyleFamily::Para );
516}
517
519{
520 CopySheets( rSourcePool, SfxStyleFamily::Frame );
521}
522
524{
525 XStyleVector aTmpSheets;
526 CopyTableStyles(rSourcePool, aTmpSheets);
527}
528
529void SdStyleSheetPool::CopyTableStyles(SdStyleSheetPool const & rSourcePool, XStyleVector& rCreatedSheets)
530{
531 Reference< XIndexAccess > xSource( rSourcePool.mxTableFamily, UNO_QUERY );
532 Reference< XNameContainer > xTarget( mxTableFamily, UNO_QUERY );
533 Reference< XSingleServiceFactory > xFactory( mxTableFamily, UNO_QUERY );
534
535 if( !xSource || !xFactory )
536 return;
537
538 for( sal_Int32 nIndex = 0; nIndex < xSource->getCount(); nIndex++ ) try
539 {
540 Reference< XNameAccess > xSourceTableStyle( xSource->getByIndex( nIndex ), UNO_QUERY_THROW );
541 Reference< XNameReplace > xNewTableStyle( xFactory->createInstance(), UNO_QUERY_THROW );
542
543 const Sequence< OUString > aStyleNames( xSourceTableStyle->getElementNames() );
544 for( const OUString& aName : aStyleNames )
545 {
546 Reference< XStyle > xSourceStyle( xSourceTableStyle->getByName( aName ), UNO_QUERY );
547 Reference< XStyle > xTargetStyle;
548 if( xSourceStyle.is() ) try
549 {
550 mxCellFamily->getByName( xSourceStyle->getName() ) >>= xTargetStyle;
551 }
552 catch( Exception& )
553 {
554 TOOLS_WARN_EXCEPTION( "sd", "sd::SdStyleSheetPool::CopyTableStyles()" );
555 }
556
557 xNewTableStyle->replaceByName( aName, Any( xTargetStyle ) );
558 }
559
560 const OUString sName(Reference<XStyle>(xSourceTableStyle, UNO_QUERY_THROW)->getName());
561 if( xTarget->hasByName( sName ) )
562 Reference<XComponent>(xNewTableStyle, UNO_QUERY_THROW)->dispose();
563 else
564 {
565 rCreatedSheets.emplace_back(xNewTableStyle, UNO_QUERY_THROW);
566 xTarget->insertByName( sName, Any( xNewTableStyle ) );
567 }
568 }
569 catch( Exception& )
570 {
571 TOOLS_WARN_EXCEPTION( "sd", "sd::SdStyleSheetPool::CopyTableStyles()");
572 }
573}
574
576{
577 CopySheets( rSourcePool, SfxStyleFamily::Frame, rCreatedSheets );
578}
579
580void SdStyleSheetPool::RenameAndCopyGraphicSheets(SdStyleSheetPool& rSourcePool, StyleSheetCopyResultVector& rCreatedSheets, std::u16string_view rRenameSuffix)
581{
582 CopySheets( rSourcePool, SfxStyleFamily::Para, rCreatedSheets, rRenameSuffix );
583}
584
586{
588 CopySheets(rSourcePool, eFamily, aTmpSheets);
589}
590
592{
593 CopySheets(rSourcePool, eFamily, rCreatedSheets, u"");
594}
595
596namespace
597{
598
599struct HasFamilyPredicate : svl::StyleSheetPredicate
600{
601 explicit HasFamilyPredicate(SfxStyleFamily eFamily)
602 : meFamily(eFamily) {}
603
604 bool Check(const SfxStyleSheetBase& sheet) override
605 {
606 return sheet.GetFamily() == meFamily;
607 }
608 SfxStyleFamily meFamily;
609};
610
611}
612
613void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, StyleSheetCopyResultVector& rCreatedSheets, std::u16string_view rRenameSuffix)
614{
615 std::vector< std::pair< rtl::Reference< SfxStyleSheetBase >, OUString > > aNewStyles;
616 std::vector< std::pair< OUString, OUString > > aRenamedList;
617
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);
621
622 for (const auto& rPos : aSheetsWithFamily)
623 {
624 SfxStyleSheetBase* pSheet = rSourcePool.GetStyleSheetByPositionInIndex( rPos );
625 if( !pSheet )
626 continue;
627 OUString aName( pSheet->GetName() );
628
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())
634 {
635 // if we have a rename suffix, try to find a new name
636 pExistingSheet =
637 GetStyleSheetByPositionInIndex(aSheetsWithName.front());
638 if (!rRenameSuffix.empty() &&
639 !pExistingSheet->GetItemSet().Equals(pSheet->GetItemSet(), false))
640 {
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,
643 // do nothing.
644 OUString aTmpName = aName + rRenameSuffix;
645 sal_Int32 nSuffix = 1;
646 do
647 {
648 aTmpName = aName + rRenameSuffix + OUString::number(nSuffix);
649 pExistingSheet = Find(aTmpName, eFamily);
650 nSuffix++;
651 } while (pExistingSheet &&
652 !pExistingSheet->GetItemSet().Equals(pSheet->GetItemSet(), false));
653 aName = aTmpName;
654 bAddToList = true;
655 }
656 }
657 // we do not already have a sheet with the same name and contents. Create a new one.
658 if (!pExistingSheet)
659 {
660 assert(!Find(aName, eFamily));
661 rtl::Reference< SfxStyleSheetBase > xNewSheet( &Make( aName, eFamily ) );
662
663 xNewSheet->SetMask( pSheet->GetMask() );
664
665 // Also set parent relation for copied style sheets
666 OUString aParent( pSheet->GetParent() );
667 if( !aParent.isEmpty() )
668 aNewStyles.emplace_back( xNewSheet, aParent );
669
670 if( !bAddToList )
671 {
672 OUString aHelpFile;
673 xNewSheet->SetHelpId( aHelpFile, pSheet->GetHelpId( aHelpFile ) );
674 }
675 xNewSheet->GetItemSet().Put( pSheet->GetItemSet() );
676
677 rCreatedSheets.emplace_back(static_cast<SdStyleSheet*>(xNewSheet.get()), true);
678 aRenamedList.emplace_back( pSheet->GetName(), aName );
679 }
680 else if (bAddToList)
681 {
682 // Add to list - used for renaming
683 rCreatedSheets.emplace_back(static_cast<SdStyleSheet*>(pExistingSheet), false);
684 aRenamedList.emplace_back( pSheet->GetName(), aName );
685 }
686 }
687
688 // set parents on newly added stylesheets
689 for( auto& rStyle : aNewStyles )
690 {
691 if( !rRenameSuffix.empty() )
692 {
693 SfxStyleSheet *pParent = lcl_findStyle(rCreatedSheets, lcl_findRenamedStyleName(aRenamedList, rStyle.second));
694 if( pParent )
695 {
696 rStyle.first->SetParent( pParent->GetName() );
697 continue;
698 }
699 }
700 DBG_ASSERT( rSourcePool.Find( rStyle.second, eFamily ), "StyleSheet has invalid parent: Family mismatch" );
701 rStyle.first->SetParent( rStyle.second );
702 }
703 // we have changed names of style sheets. Trigger reindexing.
704 Reindex();
705}
706
707/*************************************************************************
708|*
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
712|* sheets.
713|*
714|* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
715|*
716\************************************************************************/
717
718void SdStyleSheetPool::CopyLayoutSheets(std::u16string_view rLayoutName, SdStyleSheetPool& rSourcePool, StyleSheetCopyResultVector& rCreatedSheets)
719{
720 SfxStyleSheetBase* pSheet = nullptr;
721
722 std::vector<OUString> aNameList;
723 CreateLayoutSheetNames(rLayoutName,aNameList);
724
725 for (const auto& rName : aNameList)
726 {
727 pSheet = Find(rName, SfxStyleFamily::Page);
728 if (!pSheet)
729 {
730 SfxStyleSheetBase* pSourceSheet = rSourcePool.Find(rName, SfxStyleFamily::Page);
731 DBG_ASSERT(pSourceSheet, "CopyLayoutSheets: Style sheet missing");
732 if (pSourceSheet)
733 {
734 // In the case one comes with Methusalem-Docs.
735 SfxStyleSheetBase& rNewSheet = Make(rName, SfxStyleFamily::Page);
736 OUString file;
737 rNewSheet.SetHelpId( file, pSourceSheet->GetHelpId( file ) );
738 rNewSheet.GetItemSet().Put(pSourceSheet->GetItemSet());
739 rCreatedSheets.emplace_back(static_cast<SdStyleSheet*>(&rNewSheet), true);
740 }
741 }
742 }
743
744 // Special treatment for outline templates: create parent relation
745 std::vector<SfxStyleSheetBase*> aOutlineSheets;
746 CreateOutlineSheetList(rLayoutName,aOutlineSheets);
747
748 if( aOutlineSheets.empty() )
749 return;
750
751 std::vector<SfxStyleSheetBase*>::iterator it = aOutlineSheets.begin();
752 SfxStyleSheetBase* pParent = *it;
753 ++it;
754
755 while (it != aOutlineSheets.end())
756 {
757 pSheet = *it;
758
759 if (!pSheet)
760 break;
761
762 if (pSheet->GetParent().isEmpty())
763 pSheet->SetParent(pParent->GetName());
764
765 pParent = pSheet;
766
767 ++it;
768 }
769}
770
771/*************************************************************************
772|*
773|* Create list with names of the presentation templates of a layout.
774|* The list and the containing strings are owned by the caller!
775|*
776\************************************************************************/
777
778void SdStyleSheetPool::CreateLayoutSheetNames(std::u16string_view rLayoutName, std::vector<OUString> &aNameList)
779{
780 OUString aPrefix(OUString::Concat(rLayoutName) + SD_LT_SEPARATOR);
781
782 for (sal_Int32 nLevel = 1; nLevel < 10; nLevel++)
783 aNameList.emplace_back(aPrefix + STR_LAYOUT_OUTLINE + " " + OUString::number( nLevel ) );
784
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);
790}
791
792/*************************************************************************
793|*
794|* Create a list with pointer to presentation templates of a layout.
795|* The list is owned by the caller!
796|*
797\************************************************************************/
798
799void SdStyleSheetPool::CreateLayoutSheetList(std::u16string_view rLayoutName, SdStyleSheetVector& rLayoutSheets )
800{
801 OUString aLayoutNameWithSep(OUString::Concat(rLayoutName) + SD_LT_SEPARATOR);
802
803 SfxStyleSheetIterator aIter(this, SfxStyleFamily::Page);
804 SfxStyleSheetBase* pSheet = aIter.First();
805
806 while (pSheet)
807 {
808 if (pSheet->GetName().startsWith(aLayoutNameWithSep))
809 rLayoutSheets.emplace_back( static_cast< SdStyleSheet* >( pSheet ) );
810 pSheet = aIter.Next();
811 }
812}
813
814/*************************************************************************
815|*
816|* Create pseudo style sheets if necessary
817|*
818\************************************************************************/
819
821{
822 OUString aName;
823 const OUString aHelpFile;
824 SfxStyleSheetBase* pSheet = nullptr;
825 SfxStyleSheetBase* pParent = nullptr;
826
827 SfxStyleSearchBits nUsedMask = SfxStyleSearchBits::Used;
828
829 aName = SdResId(STR_PSEUDOSHEET_TITLE);
830 if( (pSheet = Find(aName, SfxStyleFamily::Pseudo)) == nullptr )
831 {
832 pSheet = &Make(aName, SfxStyleFamily::Pseudo, nUsedMask);
833 pSheet->SetParent( OUString() );
834 static_cast<SfxStyleSheet*>(pSheet)->StartListening(*this);
835 }
836 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_TITLE );
837
838 aName = SdResId(STR_PSEUDOSHEET_SUBTITLE);
839 if( (pSheet = Find(aName, SfxStyleFamily::Pseudo)) == nullptr )
840 {
841 pSheet = &Make(aName, SfxStyleFamily::Pseudo, nUsedMask);
842 pSheet->SetParent( OUString() );
843 static_cast<SfxStyleSheet*>(pSheet)->StartListening(*this);
844 }
845 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_SUBTITLE );
846
847 aName = SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS);
848 if( (pSheet = Find(aName, SfxStyleFamily::Pseudo)) == nullptr )
849 {
850 pSheet = &Make(aName, SfxStyleFamily::Pseudo, nUsedMask);
851 pSheet->SetParent( OUString() );
852 static_cast<SfxStyleSheet*>(pSheet)->StartListening(*this);
853 }
854 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUNDOBJECTS );
855
856 aName = SdResId(STR_PSEUDOSHEET_BACKGROUND);
857 if( (pSheet = Find(aName, SfxStyleFamily::Pseudo)) == nullptr )
858 {
859 pSheet = &Make(aName, SfxStyleFamily::Pseudo, nUsedMask);
860 pSheet->SetParent( OUString() );
861 static_cast<SfxStyleSheet*>(pSheet)->StartListening(*this);
862 }
863 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUND );
864
865 aName = SdResId(STR_PSEUDOSHEET_NOTES);
866 if( (pSheet = Find(aName, SfxStyleFamily::Pseudo)) == nullptr )
867 {
868 pSheet = &Make(aName, SfxStyleFamily::Pseudo, nUsedMask);
869 pSheet->SetParent( OUString() );
870 static_cast<SfxStyleSheet*>(pSheet)->StartListening(*this);
871 }
872 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_NOTES );
873
874 pParent = nullptr;
875 aName = SdResId(STR_PSEUDOSHEET_OUTLINE);
876 for (sal_Int32 nLevel = 1; nLevel < 10; nLevel++)
877 {
878 OUString aLevelName( aName + " " + OUString::number( nLevel ) );
879
880 if( (pSheet = Find(aLevelName, SfxStyleFamily::Pseudo)) == nullptr )
881 {
882 pSheet = &Make(aLevelName, SfxStyleFamily::Pseudo, nUsedMask);
883
884 if (pParent)
885 pSheet->SetParent(pParent->GetName());
886 pParent = pSheet;
887 static_cast<SfxStyleSheet*>(pSheet)->StartListening(*this);
888 }
889 pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_OUTLINE + nLevel );
890 }
891}
892
893/*************************************************************************
894|*
895|* Set the correct name in the program language to the standard styles
896|*
897\************************************************************************/
898
899namespace
900{
901struct StyleSheetIsUserDefinedPredicate : svl::StyleSheetPredicate
902{
903 StyleSheetIsUserDefinedPredicate()
904 {}
905
906 bool Check(const SfxStyleSheetBase& sheet) override
907 {
908 return sheet.IsUserDefined();
909 }
910};
911}
912
914{
915 OUString aHelpFile;
916 StyleSheetIsUserDefinedPredicate aPredicate;
917 std::vector<SfxStyleSheetBase*> aEraseList;
918 std::vector<sal_Int32> aUserDefinedStyles = GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate);
919 for (const auto& rStyle : aUserDefinedStyles)
920 {
921 SfxStyleSheetBase* pStyle = GetStyleSheetByPositionInIndex(rStyle);
922
923 if( !pStyle->IsUserDefined() )
924 {
925 OUString aOldName = pStyle->GetName();
926 sal_uLong nHelpId = pStyle->GetHelpId( aHelpFile );
927 SfxStyleFamily eFam = pStyle->GetFamily();
928
929 bool bHelpKnown = true;
930 TranslateId pNameId;
931 switch( nHelpId )
932 {
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;
960
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;
973
974 default:
975 // 0 or wrong (old) HelpId
976 bHelpKnown = false;
977 }
978 if( bHelpKnown )
979 {
980 OUString aNewName;
981 if (pNameId)
982 {
983 if (pNameId == STR_PSEUDOSHEET_OUTLINE)
984 {
985 aNewName += " " + OUString::number( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE ) );
986 }
987 }
988
989 if( !aNewName.isEmpty() && aNewName != aOldName )
990 {
991 SfxStyleSheetBase* pSheetFound = Find( aNewName, eFam );
992
993 if ( !pSheetFound )
994 {
995 // Sheet does not yet exist: rename old sheet
996 pStyle->SetName( aNewName ); // transform also parents
997 }
998 else
999 {
1000 // Sheet does exist: old sheet has to be removed
1001 aEraseList.push_back( pStyle );
1002 }
1003 }
1004 }
1005 }
1006 }
1007
1008 if (!aEraseList.empty())
1009 {
1010 // styles that could not be renamed, must be removed
1011 for (SfxStyleSheetBase* p : aEraseList)
1012 Remove( p );
1013 Reindex();
1014 }
1015}
1016
1018{
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;
1024
1025 switch(i)
1026 {
1027 case 0:
1028 {
1029 nFirstLineOffset = -900;
1030 }
1031 break;
1032
1033 case 1:
1034 {
1035 rNumberFormat.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
1036 rNumberFormat.SetBulletRelSize(75);
1037 nFirstLineOffset = -900;
1038 }
1039 break;
1040
1041 case 2:
1042 {
1043 nFirstLineOffset = -800;
1044 }
1045 break;
1046
1047 case 3:
1048 {
1049 rNumberFormat.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
1050 rNumberFormat.SetBulletRelSize(75);
1051 }
1052 break;
1053 }
1054
1055 rNumberFormat.SetFirstLineOffset(nFirstLineOffset);
1056}
1057
1058// Set new SvxNumBulletItem for the respective style sheet
1060 vcl::Font& rBulletFont )
1061{
1062 OUString aHelpFile;
1063 sal_uLong nHelpId = pSheet->GetHelpId( aHelpFile );
1064 SfxItemSet& rSet = pSheet->GetItemSet();
1065
1066 switch ( nHelpId )
1067 {
1068 case HID_STANDARD_STYLESHEET_NAME :
1069 {
1070 // Standard template
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);
1078
1079 SvxNumRule aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE | SvxNumRuleFlags::BULLET_COLOR, SVX_MAX_NUM, false);
1080
1081 for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
1082 {
1083 const auto nLSpace = (i + 1) * 600;
1084 aNumberFormat.SetAbsLSpace(nLSpace);
1085 aNumberFormat.SetFirstLineOffset(-600);
1086 aNumRule.SetLevel( i, aNumberFormat );
1087 }
1088
1089 rSet.Put( SvxNumBulletItem( std::move(aNumRule), EE_PARA_NUMBULLET ) );
1090 static_cast<SfxStyleSheet*>(pSheet)->Broadcast(SfxHint( SfxHintId::DataChanged ) );
1091 }
1092 break;
1093
1094 case HID_PSEUDOSHEET_TITLE:
1095 /* title gets same bullet as subtitle and not that page symbol anymore */
1096 case HID_PSEUDOSHEET_SUBTITLE :
1097 {
1098 // Subtitle template
1099 SvxNumBulletItem const*const pItem(
1101 const SvxNumRule *const pDefaultRule = pItem ? &pItem->GetNumRule() : nullptr;
1102 DBG_ASSERT( pDefaultRule, "Where is my default template? [CL]" );
1103
1104 if(pDefaultRule)
1105 {
1106 SvxNumRule aNumRule(pDefaultRule->GetFeatureFlags(), 10, false);
1107 for(sal_uInt16 i=0; i < aNumRule.GetLevelCount(); i++)
1108 {
1109 SvxNumberFormat aFrmt( pDefaultRule->GetLevel(i) );
1111 // #i93908# clear suffix for bullet lists
1112 aFrmt.SetListFormat("", "", i);
1113 aFrmt.SetStart(1);
1114 aFrmt.SetBulletRelSize(45);
1115 aFrmt.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1116 aFrmt.SetBulletFont(&rBulletFont);
1117 aNumRule.SetLevel(i, aFrmt);
1118 }
1119
1120 rSet.Put( SvxNumBulletItem( std::move(aNumRule), EE_PARA_NUMBULLET ) );
1121 static_cast<SfxStyleSheet*>(pSheet)->Broadcast(SfxHint( SfxHintId::DataChanged ) );
1122 }
1123 }
1124 break;
1125
1126 case HID_PSEUDOSHEET_OUTLINE + 1 :
1127 {
1128 // Outline template
1130 aNumberFormat.SetBulletColor(COL_AUTO);
1131 aNumberFormat.SetStart(1);
1132 aNumberFormat.SetNumAdjust(SvxAdjust::Left);
1133
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++ )
1137 {
1139 rBulletFont.SetFontSize(Size(0,846)); // 24 pt
1140 aNumberFormat.SetBulletFont(&rBulletFont);
1141 aNumRule.SetLevel( i, aNumberFormat );
1142 }
1143
1144 rSet.Put( SvxNumBulletItem( std::move(aNumRule), EE_PARA_NUMBULLET ) );
1145 static_cast<SfxStyleSheet*>(pSheet)->Broadcast(SfxHint( SfxHintId::DataChanged ) );
1146 }
1147 break;
1148 }
1149}
1150
1151/*************************************************************************
1152|*
1153|* Create standard bullet font (without size)
1154|*
1155\************************************************************************/
1156
1158{
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);
1170
1171 return aBulletFont;
1172}
1173
1175{
1177 maStyleFamilyMap[pPage] = new SdStyleFamily( xPool, pPage );
1178}
1179
1181{
1182 SdStyleFamilyMap::iterator iter( maStyleFamilyMap.find( pPage ) );
1183 if( iter == maStyleFamilyMap.end() )
1184 return;
1185
1186 SdStyleFamilyRef xStyle( (*iter).second );
1187 maStyleFamilyMap.erase( iter );
1188
1189 if( xStyle.is() ) try
1190 {
1191 xStyle->dispose();
1192 }
1193 catch( Exception& )
1194 {
1195 }
1196}
1197
1199{
1200 if( mpDoc == nullptr )
1201 throw DisposedException();
1202}
1203
1204// XServiceInfo
1206{
1207 return "SdStyleSheetPool";
1208}
1209
1210sal_Bool SAL_CALL SdStyleSheetPool::supportsService( const OUString& ServiceName )
1211{
1212 return cppu::supportsService(this, ServiceName);
1213}
1214
1215Sequence< OUString > SAL_CALL SdStyleSheetPool::getSupportedServiceNames()
1216{
1217 return { "com.sun.star.style.StyleFamilies" };
1218}
1219
1220// XNameAccess
1221Any SAL_CALL SdStyleSheetPool::getByName( const OUString& aName )
1222{
1224
1225 if( mxGraphicFamily->getName() == aName )
1226 return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxGraphicFamily.get() ) ) );
1227
1228 if( mxCellFamily->getName() == aName )
1229 return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxCellFamily.get() ) ) );
1230
1231 if( msTableFamilyName == aName )
1232 return Any( mxTableFamily );
1233
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() ) ) );
1238
1239 throw NoSuchElementException();
1240}
1241
1242Sequence< OUString > SAL_CALL SdStyleSheetPool::getElementNames()
1243{
1245
1246 Sequence< OUString > aNames( maStyleFamilyMap.size() + 3 );
1247 OUString* pNames = aNames.getArray();
1248
1249 *pNames++ = mxGraphicFamily->getName();
1250 *pNames++ = mxCellFamily->getName();
1251 *pNames++ = msTableFamilyName;
1252
1253 for( const auto& rEntry : maStyleFamilyMap )
1254 {
1255 *pNames++ = rEntry.second->getName();
1256 }
1257
1258 return aNames;
1259}
1260
1261sal_Bool SAL_CALL SdStyleSheetPool::hasByName( const OUString& aName )
1262{
1264
1265 if( mxGraphicFamily->getName() == aName )
1266 return true;
1267
1268 if( mxCellFamily->getName() == aName )
1269 return true;
1270
1271 if( msTableFamilyName == aName )
1272 return true;
1273
1274 return std::any_of(maStyleFamilyMap.begin(), maStyleFamilyMap.end(),
1275 [&aName](const SdStyleFamilyMap::value_type& rEntry) { return rEntry.second->getName() == aName; });
1276}
1277
1278// XElementAccess
1279
1281{
1283
1285}
1286
1288{
1289 return true;
1290}
1291
1292// XIndexAccess
1293
1294sal_Int32 SAL_CALL SdStyleSheetPool::getCount()
1295{
1297
1298 return maStyleFamilyMap.size() + 3;
1299}
1300
1302{
1303 switch( Index )
1304 {
1305 case 0:
1306 return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxGraphicFamily.get() ) ) );
1307
1308 case 1:
1309 return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxCellFamily.get() ) ) );
1310
1311 case 2:
1312 return Any( mxTableFamily );
1313
1314 default:
1315 {
1316 Index -= 3;
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);
1321
1322 return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( (*iter).second.get() ) ) );
1323 }
1324 }
1325}
1326
1327// XComponent
1328
1330{
1331 if( !mpDoc )
1332 return;
1333
1334 mxGraphicFamily->dispose();
1335 mxGraphicFamily.clear();
1336 mxCellFamily->dispose();
1337 mxCellFamily.clear();
1338
1339 Reference< XComponent > xComp( mxTableFamily, UNO_QUERY );
1340 if( xComp.is() )
1341 xComp->dispose();
1342 mxTableFamily = nullptr;
1343
1344 SdStyleFamilyMap aTempMap;
1345 aTempMap.swap( maStyleFamilyMap );
1346
1347 for( auto& rEntry : aTempMap ) try
1348 {
1349 rEntry.second->dispose();
1350 }
1351 catch( Exception& )
1352 {
1353 }
1354
1355 mpDoc = nullptr;
1356
1357 Clear();
1358}
1359
1360void SAL_CALL SdStyleSheetPool::addEventListener( const Reference< XEventListener >& /*xListener*/ )
1361{
1362}
1363
1364void SAL_CALL SdStyleSheetPool::removeEventListener( const Reference< XEventListener >& /*aListener*/ )
1365{
1366}
1367
1369{
1370 SdStyleSheetVector aResult;
1371
1372 pSheet->ForAllListeners(
1373 [&pSheet, &aResult] (SfxListener* pListener)
1374 {
1375 SdStyleSheet* pChild = dynamic_cast< SdStyleSheet* >( pListener );
1376 if(pChild && pChild->GetParent() == pSheet->GetName())
1377 {
1378 aResult.emplace_back( pChild );
1379 }
1380 return false;
1381 });
1382
1383 return aResult;
1384}
1385
1386/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
constexpr auto convertPointToMm100(N n)
sal_uInt16 GetMasterSdPageCount(PageKind ePgKind) const
Definition: drawdoc2.cxx:222
SAL_DLLPRIVATE void getDefaultFonts(vcl::Font &rLatinFont, vcl::Font &rCJKFont, vcl::Font &rCTLFont)
return the document fonts for latin, cjk and ctl according to the current languages set at this docum...
Definition: drawdoc4.cxx:1233
SdPage * GetMasterSdPage(sal_uInt16 nPgNum, PageKind ePgKind)
Definition: drawdoc2.cxx:217
static SAL_DLLPRIVATE sal_uInt32 convertFontHeightToCTL(sal_uInt32 nWesternFontHeight)
converts the given western font height to a corresponding ctl font height, depending on the system la...
Definition: drawdoc4.cxx:1250
SdStyleSheetPool(SfxItemPool const &rPool, SdDrawDocument *pDocument)
Definition: stlpool.cxx:103
css::uno::Reference< css::container::XNameAccess > mxTableFamily
Definition: stlpool.hxx:138
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: stlpool.cxx:1364
void RenameAndCopyGraphicSheets(SdStyleSheetPool &rSourcePool, StyleSheetCopyResultVector &rCreatedSheets, std::u16string_view rRenameSuffix)
Definition: stlpool.cxx:580
SdDrawDocument * mpDoc
Definition: stlpool.hxx:134
void CopySheets(SdStyleSheetPool &rSourcePool, SfxStyleFamily eFamily)
Definition: stlpool.cxx:585
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: stlpool.cxx:1221
static void PutNumBulletItem(SfxStyleSheetBase *pSheet, vcl::Font &rBulletFont)
Definition: stlpool.cxx:1059
SfxStyleSheetBase * GetTitleSheet(std::u16string_view rLayoutName)
Definition: stlpool.cxx:138
void CopyCellSheets(SdStyleSheetPool &rSourcePool)
Definition: stlpool.cxx:518
SdStyleFamilyRef mxCellFamily
Definition: stlpool.hxx:136
static vcl::Font GetBulletFont()
Definition: stlpool.cxx:1157
static void setDefaultOutlineNumberFormatBulletAndIndent(sal_uInt16 i, SvxNumberFormat &rNumberFormat)
Definition: stlpool.cxx:1017
void CreateOutlineSheetList(std::u16string_view rLayoutName, std::vector< SfxStyleSheetBase * > &rOutlineStyles)
Definition: stlpool.cxx:152
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: stlpool.cxx:1215
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: stlpool.cxx:1301
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: stlpool.cxx:1210
void CopyLayoutSheets(std::u16string_view rLayoutName, SdStyleSheetPool &rSourcePool, StyleSheetCopyResultVector &rCreatedSheets)
Definition: stlpool.cxx:718
void AddStyleFamily(const SdPage *pPage)
Definition: stlpool.cxx:1174
static SdStyleSheetVector CreateChildList(SdStyleSheet const *pSheet)
Definition: stlpool.cxx:1368
SdStyleFamilyMap maStyleFamilyMap
Definition: stlpool.hxx:137
SdStyleFamilyRef mxGraphicFamily
Definition: stlpool.hxx:135
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: stlpool.cxx:1261
void UpdateStdNames()
Definition: stlpool.cxx:913
virtual rtl::Reference< SfxStyleSheetBase > Create(const OUString &rName, SfxStyleFamily eFamily, SfxStyleSearchBits nMask) override
Definition: stlpool.cxx:133
void throwIfDisposed()
Definition: stlpool.cxx:1198
virtual void SAL_CALL dispose() override
Definition: stlpool.cxx:1329
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: stlpool.cxx:1360
virtual sal_Int32 SAL_CALL getCount() override
Definition: stlpool.cxx:1294
virtual OUString SAL_CALL getImplementationName() override
Definition: stlpool.cxx:1205
OUString msTableFamilyName
Definition: stlpool.hxx:139
void CopyGraphicSheets(SdStyleSheetPool &rSourcePool)
Definition: stlpool.cxx:513
virtual ~SdStyleSheetPool() override
Definition: stlpool.cxx:128
static void CreateLayoutSheetNames(std::u16string_view rLayoutName, std::vector< OUString > &aNameList)
Definition: stlpool.cxx:778
void CopyTableStyles(SdStyleSheetPool const &rSourcePool)
Definition: stlpool.cxx:523
void CreateLayoutSheetList(std::u16string_view rLayoutName, SdStyleSheetVector &rLayoutSheets)
Definition: stlpool.cxx:799
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: stlpool.cxx:1242
void RemoveStyleFamily(const SdPage *pPage)
Definition: stlpool.cxx:1180
virtual css::uno::Type SAL_CALL getElementType() override
Definition: stlpool.cxx:1280
virtual sal_Bool SAL_CALL hasElements() override
Definition: stlpool.cxx:1287
void CreatePseudosIfNecessary()
Definition: stlpool.cxx:820
SD_DLLPUBLIC void CreateLayoutStyleSheets(std::u16string_view rLayoutName, bool bCheck=false)
creates all layout style sheets for the given layout name if they don't exist yet.
Definition: stlpool.cxx:172
SfxItemPool * GetSecondaryPool() const
const SfxPoolItem * GetPoolDefaultItem(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
bool Equals(const SfxItemSet &, bool bComparePool) const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
SfxStyleSearchBits GetMask() const
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true)
virtual const OUString & GetParent() const
const OUString & GetName() const
SfxStyleFamily GetFamily() const
virtual sal_uLong GetHelpId(OUString &rFile)
virtual void SetHelpId(const OUString &r, sal_uLong nId)
bool IsUserDefined() const
virtual bool SetParent(const OUString &)
virtual SfxItemSet & GetItemSet()
virtual SfxStyleSheetBase * Next()
virtual SfxStyleSheetBase * First()
void SetTextLeft(const tools::Long nL, const sal_uInt16 nProp=100)
const SvxNumRule & GetNumRule() const
sal_uInt16 GetLevelCount() const
SvxNumRuleFlags GetFeatureFlags() const
const SvxNumberFormat & GetLevel(sal_uInt16 nLevel) const
void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat &rFmt, bool bIsValid=true)
void SetStart(sal_uInt16 nSet)
void SetAbsLSpace(sal_Int32 nSet)
void SetBulletFont(const vcl::Font *pFont)
void SetListFormat(const OUString &rPrefix, const OUString &rSuffix, int nLevel)
void SetBulletColor(Color nSet)
void SetNumAdjust(SvxAdjust eSet)
void SetBulletRelSize(sal_uInt16 nSet)
void SetFirstLineOffset(sal_Int32 nSet)
void SetBulletChar(sal_UCS4 cSet)
void SetNumberingType(SvxNumType nSet)
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
css::uno::Type const & get()
void SetFontSize(const Size &)
FontFamily GetFamilyType()
void SetOutline(bool bOutline)
void SetTransparent(bool bTransparent)
void SetColor(const Color &)
const OUString & GetStyleName() const
void SetItalic(FontItalic)
void SetWeight(FontWeight)
const OUString & GetFamilyName() const
void SetUnderline(FontLineStyle)
void SetCharSet(rtl_TextEncoding)
FontPitch GetPitch()
void SetOverline(FontLineStyle)
rtl_TextEncoding GetCharSet() const
void SetShadow(bool bShadow)
void SetStrikeout(FontStrikeout)
constexpr ::Color COL_GRAY(0x80, 0x80, 0x80)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
int nCount
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
float u
constexpr TypedWhichId< SvxContourItem > EE_CHAR_OUTLINE(EE_CHAR_START+8)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+16)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< SvxAutoKernItem > EE_CHAR_PAIRKERNING(EE_CHAR_START+11)
constexpr TypedWhichId< SvxShadowedItem > EE_CHAR_SHADOW(EE_CHAR_START+9)
constexpr TypedWhichId< SvxULSpaceItem > EE_PARA_ULSPACE(EE_PARA_START+14)
constexpr TypedWhichId< SvxOverlineItem > EE_CHAR_OVERLINE(EE_CHAR_START+29)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
constexpr TypedWhichId< SvxLRSpaceItem > EE_PARA_LRSPACE(EE_PARA_START+13)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CTL(EE_CHAR_START+22)
constexpr TypedWhichId< SvxCrossedOutItem > EE_CHAR_STRIKEOUT(EE_CHAR_START+6)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
constexpr TypedWhichId< SvxEmphasisMarkItem > EE_CHAR_EMPHASISMARK(EE_CHAR_START+25)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CJK(EE_CHAR_START+21)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CJK(EE_CHAR_START+23)
constexpr TypedWhichId< SvxCaseMapItem > EE_CHAR_CASEMAP(EE_CHAR_START+30)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_BKGCOLOR(EE_CHAR_START+32)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CTL(EE_CHAR_START+24)
constexpr TypedWhichId< SvxNumBulletItem > EE_PARA_NUMBULLET(EE_PARA_START+5)
constexpr TypedWhichId< SvxCharReliefItem > EE_CHAR_RELIEF(EE_CHAR_START+26)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
Reference< XInterface > xTarget
Reference< XSingleServiceFactory > xFactory
LINESTYLE_NONE
STRIKEOUT_NONE
ITALIC_NONE
WEIGHT_NORMAL
OUString sName
constexpr OUStringLiteral SD_LT_SEPARATOR
Definition: glob.hxx:49
sal_Int32 nIndex
OUString aName
void * p
uno_Any a
sal_Int32 nFirstLineOffset
void Clear(EHistoryType eHistory)
@ Exception
Type
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
Reference< XNameAccess > CreateTableDesignFamily()
#define SVX_MAX_NUM
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
XColorItem makeSdrShadowColorItem(const Color &rTheColor)
SdrOnOffItem makeSdrShadowItem(bool bShadow)
SdrMetricItem makeSdrShadowXDistItem(tools::Long nDist)
SdrMetricItem makeSdrShadowYDistItem(tools::Long nDist)
SdrOnOffItem makeSdrTextAutoGrowHeightItem(bool bAuto)
SDRTEXTVERTADJUST_CENTER
SDRTEXTHORZADJUST_BLOCK
static SfxItemSet & rSet
sal_uIntPtr sal_uLong
std::map< const SdPage *, SdStyleFamilyRef > SdStyleFamilyMap
Definition: stlpool.hxx:39
::cppu::ImplInheritanceHelper< SfxStyleSheetPool, css::lang::XServiceInfo, css::container::XIndexAccess, css::container::XNameAccess, css::lang::XComponent > SdStyleSheetPoolBase
Definition: stlpool.hxx:47
std::vector< css::uno::Reference< css::style::XStyle > > XStyleVector
Definition: stlsheet.hxx:171
std::vector< rtl::Reference< SdStyleSheet > > SdStyleSheetVector
Definition: stlsheet.hxx:170
std::vector< StyleSheetCopyResult > StyleSheetCopyResultVector
Definition: stlsheet.hxx:184
constexpr OUStringLiteral STR_LAYOUT_TITLE
Definition: strings.hxx:15
constexpr OUStringLiteral STR_LAYOUT_OUTLINE
Definition: strings.hxx:16
constexpr OUStringLiteral STR_LAYOUT_SUBTITLE
Definition: strings.hxx:20
constexpr OUStringLiteral STR_LAYOUT_BACKGROUNDOBJECTS
Definition: strings.hxx:18
constexpr OUStringLiteral STR_LAYOUT_NOTES
Definition: strings.hxx:19
constexpr OUStringLiteral STR_LAYOUT_BACKGROUND
Definition: strings.hxx:17
virtual bool Check(const SfxStyleSheetBase &styleSheet)=0
SfxStyleFamily
SfxStyleSearchBits
SVX_NUM_CHAR_SPECIAL
unsigned char sal_Bool