docthemes: Save themes def. to a file when added to ColorSets
[LibreOffice.git] / sw / source / uibase / inc / fldmgr.hxx
blob48d4500513c4d1b6eb5386518dc0b342b41bf31b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_FLDMGR_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_FLDMGR_HXX
22 #include <fldbas.hxx>
23 #include <pam.hxx>
24 #include <swdllapi.h>
25 #include <com/sun/star/uno/Reference.h>
26 #include <com/sun/star/uno/Any.h>
27 #include <memory>
28 #include <optional>
29 #include <utility>
30 #include <vector>
32 namespace com::sun::star{
33 namespace container{
34 class XNameAccess;
36 namespace text{
37 class XNumberingTypeInfo;
41 class SwWrtShell;
42 class SwField;
43 class SwFieldType;
44 class SwPaM;
45 class SbModule;
46 class SvxMacroItem;
47 class SvNumberFormatter;
48 namespace weld { class Widget; class Window; }
49 enum class SwFieldIds : sal_uInt16;
51 // the groups of fields
52 enum SwFieldGroups
54 GRP_DOC,
55 GRP_FKT,
56 GRP_REF,
57 GRP_REG,
58 GRP_DB,
59 GRP_VAR
62 struct SwFieldGroupRgn
64 sal_uInt16 nStart;
65 sal_uInt16 nEnd;
68 // the field manager handles the insertation of fields
69 // with command strings
70 struct SwInsertField_Data
72 SwFieldTypesEnum m_nTypeId;
73 sal_uInt16 m_nSubType;
74 const OUString m_sPar1;
75 const OUString m_sPar2;
76 sal_uInt32 m_nFormatId;
77 SwWrtShell* m_pSh;
78 sal_Unicode m_cSeparator;
79 bool m_bIsAutomaticLanguage;
80 css::uno::Any m_aDBDataSource;
81 css::uno::Any m_aDBConnection;
82 css::uno::Any m_aDBColumn;
83 weld::Widget* m_pParent; // parent widget used for SwWrtShell::StartInputFieldDlg()
84 /// Marks the PostIt field's annotation start/end if it differs from the cursor selection.
85 std::optional<SwPaM> m_oAnnotationRange;
87 SwInsertField_Data(SwFieldTypesEnum nType, sal_uInt16 nSub, OUString aPar1, OUString aPar2,
88 sal_uInt32 nFormatId, SwWrtShell* pShell = nullptr, sal_Unicode cSep = ' ', bool bIsAutoLanguage = true) :
89 m_nTypeId(nType),
90 m_nSubType(nSub),
91 m_sPar1(std::move(aPar1)),
92 m_sPar2(std::move(aPar2)),
93 m_nFormatId(nFormatId),
94 m_pSh(pShell),
95 m_cSeparator(cSep),
96 m_bIsAutomaticLanguage(bIsAutoLanguage),
97 m_pParent(nullptr) {}
100 class SW_DLLPUBLIC SwFieldMgr
102 private:
103 SwField* m_pCurField;
104 SwWrtShell* m_pWrtShell; // can be ZERO too!
105 OUString m_aCurPar1;
106 OUString m_aCurPar2;
107 OUString m_sCurFrame;
109 OUString m_sMacroPath;
110 OUString m_sMacroName;
112 bool m_bEvalExp;
114 SAL_DLLPRIVATE LanguageType GetCurrLanguage() const;
116 css::uno::Reference<css::text::XNumberingTypeInfo> m_xNumberingInfo;
117 SAL_DLLPRIVATE css::uno::Reference<css::text::XNumberingTypeInfo> const & GetNumberingInfo()const;
119 public:
120 explicit SwFieldMgr(SwWrtShell* pSh = nullptr);
121 ~SwFieldMgr();
123 void SetWrtShell( SwWrtShell* pShell )
124 { m_pWrtShell = pShell; }
126 // insert field using TypeID (TYP_ ...)
127 bool InsertField( SwInsertField_Data& rData );
129 // change the current field directly
130 void UpdateCurField(sal_uInt32 nFormat,
131 const OUString& rPar1,
132 const OUString& rPar2,
133 std::unique_ptr<SwField> _pField = nullptr);
135 const OUString& GetCurFieldPar1() const { return m_aCurPar1; }
136 const OUString& GetCurFieldPar2() const { return m_aCurPar2; }
138 // determine a field
139 SwField* GetCurField();
141 void InsertFieldType(SwFieldType const & rType);
143 bool ChooseMacro(weld::Window* pDialogParent);
144 void SetMacroPath(const OUString& rPath);
145 const OUString& GetMacroPath() const { return m_sMacroPath; }
146 const OUString& GetMacroName() const { return m_sMacroName; }
148 // previous and next of the same type
149 bool GoNextPrev( bool bNext = true, SwFieldType* pTyp = nullptr );
150 bool GoNext() { return GoNextPrev(); }
151 bool GoPrev() { return GoNextPrev( false ); }
153 bool IsDBNumeric(const OUString& rDBName, const OUString& rTableQryName,
154 bool bIsTable, const OUString& rFieldName);
156 // organise RefMark with names
157 bool CanInsertRefMark( std::u16string_view rStr );
159 // access to field types via ResId
160 size_t GetFieldTypeCount() const;
161 SwFieldType* GetFieldType(SwFieldIds nResId, size_t nField = 0) const;
162 SwFieldType* GetFieldType(SwFieldIds nResId, const OUString& rName) const;
164 void RemoveFieldType(SwFieldIds nResId, const OUString& rName);
166 // access via TypeId from the dialog
167 // Ids for a range of fields
168 static const SwFieldGroupRgn& GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId);
169 static sal_uInt16 GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType);
171 // the current field's TypeId
172 SwFieldTypesEnum GetCurTypeId() const;
174 // TypeId for a concrete position in the list
175 static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos);
176 // name of the type in the list of fields
177 static const OUString & GetTypeStr(sal_uInt16 nPos);
179 // Pos in the list of fields
180 static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId);
182 // subtypes to a type
183 void GetSubTypes(SwFieldTypesEnum nId, std::vector<OUString>& rToFill);
185 // format to a type
186 sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const;
187 OUString GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const;
188 sal_uInt16 GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const;
189 sal_uInt32 GetDefaultFormat(SwFieldTypesEnum nTypeId, bool bIsText, SvNumberFormatter* pFormatter);
191 // turn off evaluation of expression fields for insertation
192 // of many expression fields (see labels)
194 inline void SetEvalExpFields(bool bEval);
195 void EvalExpFields(SwWrtShell* pSh);
198 inline void SwFieldMgr::SetEvalExpFields(bool bEval)
199 { m_bEvalExp = bEval; }
201 #endif
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */