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_UI_INC_UINUMS_HXX
20 : #define INCLUDED_SW_SOURCE_UI_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 : #define MAX_NUM_RULES 9
31 :
32 : typedef boost::ptr_vector<SfxPoolItem> _SwNumFmtsAttrs;
33 :
34 : class SW_DLLPUBLIC SwNumRulesWithName
35 : {
36 : OUString maName;
37 : // the NumRule's formats _have_ to be independent of a document
38 : // (They should always be there!)
39 : class SAL_DLLPRIVATE _SwNumFmtGlobal
40 : {
41 : SwNumFmt aFmt;
42 : OUString sCharFmtName;
43 : sal_uInt16 nCharPoolId;
44 : _SwNumFmtsAttrs aItems;
45 :
46 : _SwNumFmtGlobal& operator=( const _SwNumFmtGlobal& );
47 :
48 : public:
49 : _SwNumFmtGlobal( const SwNumFmt& rFmt );
50 : _SwNumFmtGlobal( const _SwNumFmtGlobal& );
51 : _SwNumFmtGlobal( SvStream&, sal_uInt16 nVersion );
52 : ~_SwNumFmtGlobal();
53 :
54 : void Store( SvStream& );
55 : void ChgNumFmt( SwWrtShell& rSh, SwNumFmt& rChg ) const;
56 : };
57 :
58 : _SwNumFmtGlobal* aFmts[ MAXLEVEL ];
59 :
60 : protected:
61 : void SetName(const OUString& rSet) {maName = rSet;}
62 :
63 : public:
64 : SwNumRulesWithName(const SwNumRule &, const OUString &);
65 : SwNumRulesWithName( const SwNumRulesWithName & );
66 : SwNumRulesWithName(SvStream &, sal_uInt16 nVersion);
67 : ~SwNumRulesWithName();
68 :
69 : const SwNumRulesWithName &operator=(const SwNumRulesWithName &);
70 :
71 0 : const OUString& GetName() const { return maName; }
72 : void MakeNumRule( SwWrtShell& rSh, SwNumRule& rChg ) const;
73 :
74 : void Store( SvStream& );
75 : };
76 :
77 : class SwBaseNumRules
78 : {
79 : public:
80 : enum { nMaxRules = MAX_NUM_RULES }; // currently 9 defined forms
81 : protected:
82 : SwNumRulesWithName *pNumRules[ MAX_NUM_RULES ];
83 : OUString sFileName;
84 : sal_uInt16 nVersion;
85 : sal_Bool bModified;
86 :
87 : virtual int Load(SvStream&);
88 : virtual sal_Bool Store(SvStream&);
89 :
90 : void Init();
91 :
92 : public:
93 : SwBaseNumRules(const OUString& rFileName);
94 : virtual ~SwBaseNumRules();
95 :
96 : inline const SwNumRulesWithName* GetRules(sal_uInt16 nIdx) const;
97 : virtual void ApplyNumRules(
98 : const SwNumRulesWithName &rCopy,
99 : sal_uInt16 nIdx);
100 :
101 : };
102 :
103 : class SwChapterNumRules : public SwBaseNumRules
104 : {
105 :
106 : public:
107 : SwChapterNumRules();
108 : virtual ~SwChapterNumRules();
109 :
110 : virtual void ApplyNumRules( const SwNumRulesWithName &rCopy,
111 : sal_uInt16 nIdx) SAL_OVERRIDE;
112 : };
113 :
114 : // INLINE METHODE --------------------------------------------------------
115 0 : inline const SwNumRulesWithName *SwBaseNumRules::GetRules(sal_uInt16 nIdx) const
116 : {
117 : OSL_ENSURE(nIdx < nMaxRules, "Array der NumRules ueberindiziert.");
118 0 : return pNumRules[nIdx];
119 : }
120 :
121 : #endif
122 :
123 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|