xref: /core/include/svl/stylepool.hxx (revision b09deb07)
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 #ifndef INCLUDED_SVL_STYLEPOOL_HXX
20 #define INCLUDED_SVL_STYLEPOOL_HXX
21 
22 #include <memory>
23 #include <rtl/ustring.hxx>
24 #include <svl/itemset.hxx>
25 
26 class StylePoolImpl;
27 class IStylePoolIteratorAccess;
28 
29 class SVL_DLLPUBLIC StylePool final
30 {
31 private:
32     std::unique_ptr<StylePoolImpl> pImpl;
33 public:
34     explicit StylePool( SfxItemSet const * pIgnorableItems = nullptr );
35 
36     /** Insert a SfxItemSet into the style pool.
37 
38         The pool makes a copy of the provided SfxItemSet.
39 
40         @param SfxItemSet
41         the SfxItemSet to insert
42 
43         @return a shared pointer to the SfxItemSet
44     */
45     std::shared_ptr<SfxItemSet> insertItemSet( const SfxItemSet& rSet );
46 
47     /** Create an iterator
48 
49         The iterator walks through the StylePool
50         OD 2008-03-07 #i86923#
51         introduce optional parameter to control, if unused SfxItemsSet are skipped or not
52         introduce optional parameter to control, if ignorable items are skipped or not
53 
54         @attention every change, e.g. destruction, of the StylePool could cause undefined effects.
55 
56         @param bSkipUnusedItemSets
57         input parameter - boolean, indicating if unused SfxItemSets are skipped or not
58 
59         @param bSkipIgnorableItems
60         input parameter - boolean, indicating if ignorable items are skipped or not
61 
62         @postcond the iterator "points before the first" SfxItemSet of the pool.
63         The first StylePoolIterator::getNext() call will deliver the first SfxItemSet.
64     */
65     IStylePoolIteratorAccess* createIterator( const bool bSkipUnusedItemSets = false,
66                                                       const bool bSkipIgnorableItems = false );
67 
68     ~StylePool();
69 
70     static OUString nameOf( const std::shared_ptr<SfxItemSet>& pSet );
71 };
72 
73 class SVL_DLLPUBLIC IStylePoolIteratorAccess
74 {
75 public:
76     /** Delivers a shared pointer to the next SfxItemSet of the pool
77         If there is no more SfxItemSet, the delivered share_pointer is empty.
78     */
79     virtual std::shared_ptr<SfxItemSet> getNext() = 0;
80     virtual ~IStylePoolIteratorAccess() {};
81 };
82 #endif
83 
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
85