Line data Source code
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_SW_SOURCE_UIBASE_INC_UINUMS_HXX
20 : #define INCLUDED_SW_SOURCE_UIBASE_INC_UINUMS_HXX
21 :
22 : #include <numrule.hxx>
23 : #include "swdllapi.h"
24 : #include <boost/ptr_container/ptr_vector.hpp>
25 :
26 : class SfxPoolItem;
27 : class SwWrtShell;
28 : class SvStream;
29 :
30 : namespace sw { class StoredChapterNumberingRules; }
31 :
32 : #define MAX_NUM_RULES 9
33 :
34 : typedef boost::ptr_vector<SfxPoolItem> _SwNumFormatsAttrs;
35 :
36 : class SW_DLLPUBLIC SwNumRulesWithName
37 : {
38 : OUString maName;
39 : // the NumRule's formats _have_ to be independent of a document
40 : // (They should always be there!)
41 : class SAL_DLLPRIVATE _SwNumFormatGlobal
42 : {
43 : friend class SwNumRulesWithName;
44 : SwNumFormat aFormat;
45 : OUString sCharFormatName;
46 : sal_uInt16 nCharPoolId;
47 : _SwNumFormatsAttrs aItems;
48 :
49 : _SwNumFormatGlobal& operator=( const _SwNumFormatGlobal& ) SAL_DELETED_FUNCTION;
50 :
51 : public:
52 : _SwNumFormatGlobal( const SwNumFormat& rFormat );
53 : _SwNumFormatGlobal( const _SwNumFormatGlobal& );
54 : ~_SwNumFormatGlobal();
55 :
56 : void ChgNumFormat( SwWrtShell& rSh, SwNumFormat& rChg ) const;
57 : };
58 :
59 : _SwNumFormatGlobal* aFormats[ MAXLEVEL ];
60 :
61 : protected:
62 : friend class sw::StoredChapterNumberingRules;
63 : friend class SwChapterNumRules;
64 0 : void SetName(const OUString& rSet) {maName = rSet;}
65 : void SetNumFormat(size_t, SwNumFormat const&, OUString const&);
66 : SwNumRulesWithName();
67 :
68 : public:
69 : SwNumRulesWithName(const SwNumRule &, const OUString &);
70 : SwNumRulesWithName( const SwNumRulesWithName & );
71 : ~SwNumRulesWithName();
72 :
73 : const SwNumRulesWithName &operator=(const SwNumRulesWithName &);
74 :
75 0 : const OUString& GetName() const { return maName; }
76 : void MakeNumRule( SwWrtShell& rSh, SwNumRule& rChg ) const;
77 :
78 :
79 : void GetNumFormat(size_t, SwNumFormat const*&, OUString const*&) const;
80 : };
81 :
82 : class SW_DLLPUBLIC SwChapterNumRules
83 : {
84 : public:
85 : enum { nMaxRules = MAX_NUM_RULES }; // currently 9 defined forms
86 : protected:
87 : SwNumRulesWithName *pNumRules[ MAX_NUM_RULES ];
88 :
89 : void Init();
90 : void Save();
91 :
92 : public:
93 : SwChapterNumRules();
94 : virtual ~SwChapterNumRules();
95 :
96 : inline const SwNumRulesWithName* GetRules(sal_uInt16 nIdx) const;
97 : void CreateEmptyNumRule(sal_uInt16 nIdx); // for import
98 : void ApplyNumRules( const SwNumRulesWithName &rCopy,
99 : sal_uInt16 nIdx);
100 :
101 : };
102 :
103 0 : inline const SwNumRulesWithName *SwChapterNumRules::GetRules(sal_uInt16 nIdx) const
104 : {
105 : assert(nIdx < nMaxRules);
106 0 : return pNumRules[nIdx];
107 : }
108 :
109 :
110 : namespace sw
111 : {
112 :
113 : void ExportStoredChapterNumberingRules(
114 : SwChapterNumRules & rRules, SvStream & rStream, OUString const&);
115 : void ImportStoredChapterNumberingRules(
116 : SwChapterNumRules & rRules, SvStream & rStream, OUString const&);
117 :
118 : } // namespace sw
119 :
120 : #endif
121 :
122 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|