LibreOffice Module sw (master)  1
uinums.hxx
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 #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 
25 #include <memory>
26 #include <vector>
27 
28 class SfxPoolItem;
29 class SwWrtShell;
30 class SvStream;
31 
32 namespace sw { class StoredChapterNumberingRules; }
33 
34 #define MAX_NUM_RULES 9
35 
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;
45  OUString sCharFormatName;
46  sal_uInt16 nCharPoolId;
47  std::vector<std::unique_ptr<SfxPoolItem>> m_Items;
48 
49  SwNumFormatGlobal& operator=( const SwNumFormatGlobal& ) = delete;
50 
51  public:
52  SwNumFormatGlobal( const SwNumFormat& rFormat );
55 
56  SwNumFormat MakeNumFormat(SwWrtShell& rSh) const;
57  };
58 
59  std::unique_ptr<SwNumFormatGlobal> aFormats[ MAXLEVEL ];
60 
62  friend class SwChapterNumRules;
63  void SetName(const OUString& rSet) {maName = rSet;}
64  void SetNumFormat(size_t, SwNumFormat const&, OUString const&);
66 
67 public:
68  SwNumRulesWithName(const SwNumRule &, const OUString &);
71 
72  SwNumRulesWithName &operator=(const SwNumRulesWithName &);
73 
74  const OUString& GetName() const { return maName; }
75  std::unique_ptr<SwNumRule> MakeNumRule(SwWrtShell& rSh) const;
76 
77  void GetNumFormat(size_t, SwNumFormat const*&, OUString const*&) const;
78 };
79 
81 {
82 public:
83  enum { nMaxRules = MAX_NUM_RULES }; // currently 9 defined forms
84 private:
85  std::unique_ptr<SwNumRulesWithName> pNumRules[ MAX_NUM_RULES ];
86 
87  void Init();
88  void Save();
89 
90 public:
93 
94  inline const SwNumRulesWithName* GetRules(sal_uInt16 nIdx) const;
95  void CreateEmptyNumRule(sal_uInt16 nIdx); // for import
96  void ApplyNumRules( const SwNumRulesWithName &rCopy,
97  sal_uInt16 nIdx);
98 };
99 
100 inline const SwNumRulesWithName *SwChapterNumRules::GetRules(sal_uInt16 nIdx) const
101 {
102  assert(nIdx < nMaxRules);
103  return pNumRules[nIdx].get();
104 }
105 
106 
107 namespace sw
108 {
109 
111  SwChapterNumRules & rRules, SvStream & rStream, OUString const&);
113  SwChapterNumRules & rRules, SvStream & rStream, OUString const&);
114 
115 } // namespace sw
116 
117 #endif
118 
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Init()
void ImportStoredChapterNumberingRules(SwChapterNumRules &rRules, SvStream &rStream, OUString const &rFileName)
#define MAX_NUM_RULES
Definition: uinums.hxx:34
Dialog to specify the properties of drop-down form field.
Definition: accfrmobj.cxx:40
void ExportStoredChapterNumberingRules(SwChapterNumRules &rRules, SvStream &rStream, OUString const &rFileName)
void SetName(const OUString &rSet)
Definition: uinums.hxx:63
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
const SwNumRulesWithName * GetRules(sal_uInt16 nIdx) const
Definition: uinums.hxx:100
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
std::vector< std::unique_ptr< SfxPoolItem > > m_Items
Definition: uinums.hxx:47
SwNumRulesWithName & operator=(const SwNumRulesWithName &)
Definition: uinums.cxx:139
OUString maName
Definition: uinums.hxx:38
std::unique_ptr< SwNumRulesWithName > pNumRules[MAX_NUM_RULES]
Definition: uinums.hxx:85
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
const OUString & GetName() const
Definition: uinums.hxx:74
std::unique_ptr< SwNumFormatGlobal > aFormats[MAXLEVEL]
Definition: uinums.hxx:59