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 .
22 #include <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/container/XIndexAccess.hpp>
24 #include <com/sun/star/lang/XComponent.hpp>
26 #include <cppuhelper/implbase.hxx>
27 #include <vcl/font.hxx>
29 #include <string_view>
32 #include "stlfamily.hxx"
33 #include "stlsheet.hxx"
39 class SvxNumberFormat
;
41 typedef std::map
< const SdPage
*, SdStyleFamilyRef
> SdStyleFamilyMap
;
43 typedef ::cppu::ImplInheritanceHelper
< SfxStyleSheetPool
,
44 css::lang::XServiceInfo
,
45 css::container::XIndexAccess
,
46 css::container::XNameAccess
,
47 css::lang::XComponent
> SdStyleSheetPoolBase
;
49 class SAL_DLLPUBLIC_RTTI SdStyleSheetPool final
: public SdStyleSheetPoolBase
, public SfxListener
51 friend class SdDrawDocument
;
53 SdStyleSheetPool(SfxItemPool
const& rPool
, SdDrawDocument
* pDocument
);
55 void SetActualStyleSheet(SfxStyleSheetBase
* pActStyleSheet
) { mpActualStyleSheet
= pActStyleSheet
; }
56 SfxStyleSheetBase
* GetActualStyleSheet() { return mpActualStyleSheet
; }
58 SfxStyleSheetBase
* GetTitleSheet(std::u16string_view rLayoutName
);
60 // Caller has to delete the list
61 void CreateOutlineSheetList(std::u16string_view rLayoutName
, std::vector
<SfxStyleSheetBase
*> &rOutlineStyles
);
63 /** creates all layout style sheets for the given layout name if they
66 @param rLayoutName Must be the name of a master page
67 @param bCheck If set to true, the debug version will assert if a style
68 had to be created. This is used to assert errors in documents
69 when styles are missing.
71 SD_DLLPUBLIC
void CreateLayoutStyleSheets(std::u16string_view rLayoutName
, bool bCheck
= false );
72 static void CreateLayoutSheetNames(std::u16string_view rLayoutName
, std::vector
<OUString
> &aNameList
);
73 void CreateLayoutSheetList(std::u16string_view rLayoutName
, SdStyleSheetVector
& rLayoutSheets
);
74 void CopyLayoutSheets(std::u16string_view rLayoutName
, SdStyleSheetPool
& rSourcePool
, StyleSheetCopyResultVector
& rCreatedSheets
);
75 void CopyGraphicSheets(SdStyleSheetPool
& rSourcePool
);
76 void CopyCellSheets(SdStyleSheetPool
& rSourcePool
);
77 void CopyTableStyles(SdStyleSheetPool
const & rSourcePool
);
78 void CopyTableStyles(SdStyleSheetPool
const & rSourcePool
, XStyleVector
& rCreatedSheets
);
79 void CopyCellSheets(SdStyleSheetPool
& rSourcePool
, StyleSheetCopyResultVector
& rCreatedSheets
);
80 void RenameAndCopyGraphicSheets(SdStyleSheetPool
& rSourcePool
, StyleSheetCopyResultVector
& rCreatedSheets
, std::u16string_view rRenameSuffix
);
82 void CreatePseudosIfNecessary();
83 void UpdateStdNames();
84 static void PutNumBulletItem( SfxStyleSheetBase
* pSheet
, vcl::Font
& rBulletFont
);
85 static vcl::Font
GetBulletFont();
87 SdDrawDocument
* GetDoc() const { return mpDoc
; }
89 static SdStyleSheetVector
CreateChildList( SdStyleSheet
const * pSheet
);
91 static void setDefaultOutlineNumberFormatBulletAndIndent(sal_uInt16 i
, SvxNumberFormat
&rNumberFormat
);
94 /// @throws css::uno::RuntimeException
95 void throwIfDisposed();
98 virtual OUString SAL_CALL
getImplementationName() override
;
99 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
100 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
103 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
104 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
105 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
108 virtual css::uno::Type SAL_CALL
getElementType() override
;
109 virtual sal_Bool SAL_CALL
hasElements() override
;
112 virtual sal_Int32 SAL_CALL
getCount() override
;
113 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
116 virtual void SAL_CALL
dispose( ) override
;
117 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
118 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
121 void CopySheets(SdStyleSheetPool
& rSourcePool
, SfxStyleFamily eFamily
);
122 void CopySheets(SdStyleSheetPool
& rSourcePool
, SfxStyleFamily eFamily
, StyleSheetCopyResultVector
& rCreatedSheets
);
123 void CopySheets(SdStyleSheetPool
& rSourcePool
, SfxStyleFamily eFamily
, StyleSheetCopyResultVector
& rCreatedSheets
, std::u16string_view rRenameSuffix
);
125 virtual rtl::Reference
<SfxStyleSheetBase
> Create(const OUString
& rName
, SfxStyleFamily eFamily
, SfxStyleSearchBits nMask
) override
;
127 using SfxStyleSheetPool::Create
;
128 virtual ~SdStyleSheetPool() override
;
130 void AddStyleFamily( const SdPage
* pPage
);
131 void RemoveStyleFamily( const SdPage
* pPage
);
133 SfxStyleSheetBase
* mpActualStyleSheet
;
134 SdDrawDocument
* mpDoc
;
135 SdStyleFamilyRef mxGraphicFamily
;
136 SdStyleFamilyRef mxCellFamily
;
137 SdStyleFamilyMap maStyleFamilyMap
;
138 css::uno::Reference
< css::container::XNameAccess
> mxTableFamily
;
139 OUString msTableFamilyName
;
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */