LibreOffice Module sw (master) 1
fldmgr.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_FLDMGR_HXX
20#define INCLUDED_SW_SOURCE_UIBASE_INC_FLDMGR_HXX
21
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>
31
32namespace com::sun::star{
33 namespace container{
34 class XNameAccess;
35 }
36 namespace text{
37 class XNumberingTypeInfo;
38 }
39}
40
41class SwWrtShell;
42class SwField;
43class SwFieldType;
44class SwPaM;
45class SbModule;
46class SvxMacroItem;
48namespace weld { class Widget; class Window; }
49enum class SwFieldIds : sal_uInt16;
50
51// the groups of fields
53{
60};
61
63{
64 sal_uInt16 nStart;
65 sal_uInt16 nEnd;
66};
67
68// the field manager handles the insertation of fields
69// with command strings
71{
73 sal_uInt16 m_nSubType;
74 const OUString m_sPar1;
75 const OUString m_sPar2;
76 sal_uInt32 m_nFormatId;
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()
85 std::optional<SwPaM> m_oAnnotationRange;
86
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) :
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) {}
98};
99
101{
102private:
104 SwWrtShell* m_pWrtShell; // can be ZERO too!
105 OUString m_aCurPar1;
106 OUString m_aCurPar2;
107 OUString m_sCurFrame;
108
109 OUString m_sMacroPath;
110 OUString m_sMacroName;
111
112 sal_uInt32 m_nCurFormat;
114
115 SAL_DLLPRIVATE LanguageType GetCurrLanguage() const;
116
117 css::uno::Reference<css::text::XNumberingTypeInfo> m_xNumberingInfo;
118 SAL_DLLPRIVATE css::uno::Reference<css::text::XNumberingTypeInfo> const & GetNumberingInfo()const;
119
120public:
121 explicit SwFieldMgr(SwWrtShell* pSh = nullptr);
122 ~SwFieldMgr();
123
124 void SetWrtShell( SwWrtShell* pShell )
125 { m_pWrtShell = pShell; }
126
127 // insert field using TypeID (TYP_ ...)
128 bool InsertField( SwInsertField_Data& rData );
129
130 // change the current field directly
131 void UpdateCurField(sal_uInt32 nFormat,
132 const OUString& rPar1,
133 const OUString& rPar2,
134 std::unique_ptr<SwField> _pField = nullptr);
135
136 const OUString& GetCurFieldPar1() const { return m_aCurPar1; }
137 const OUString& GetCurFieldPar2() const { return m_aCurPar2; }
138
139 // determine a field
140 SwField* GetCurField();
141
142 void InsertFieldType(SwFieldType const & rType);
143
144 bool ChooseMacro(weld::Window* pDialogParent);
145 void SetMacroPath(const OUString& rPath);
146 const OUString& GetMacroPath() const { return m_sMacroPath; }
147 const OUString& GetMacroName() const { return m_sMacroName; }
148
149 // previous and next of the same type
150 bool GoNextPrev( bool bNext = true, SwFieldType* pTyp = nullptr );
151 bool GoNext() { return GoNextPrev(); }
152 bool GoPrev() { return GoNextPrev( false ); }
153
154 bool IsDBNumeric(const OUString& rDBName, const OUString& rTableQryName,
155 bool bIsTable, const OUString& rFieldName);
156
157 // organise RefMark with names
158 bool CanInsertRefMark( std::u16string_view rStr );
159
160 // access to field types via ResId
161 size_t GetFieldTypeCount() const;
162 SwFieldType* GetFieldType(SwFieldIds nResId, size_t nField = 0) const;
163 SwFieldType* GetFieldType(SwFieldIds nResId, const OUString& rName) const;
164
165 void RemoveFieldType(SwFieldIds nResId, const OUString& rName);
166
167 // access via TypeId from the dialog
168 // Ids for a range of fields
169 static const SwFieldGroupRgn& GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId);
170 static sal_uInt16 GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType);
171
172 // the current field's TypeId
173 SwFieldTypesEnum GetCurTypeId() const;
174
175 // TypeId for a concrete position in the list
176 static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos);
177 // name of the type in the list of fields
178 static const OUString & GetTypeStr(sal_uInt16 nPos);
179
180 // Pos in the list of fields
181 static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId);
182
183 // subtypes to a type
184 void GetSubTypes(SwFieldTypesEnum nId, std::vector<OUString>& rToFill);
185
186 // format to a type
187 sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const;
188 OUString GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const;
189 sal_uInt16 GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const;
190 sal_uInt32 GetDefaultFormat(SwFieldTypesEnum nTypeId, bool bIsText, SvNumberFormatter* pFormatter);
191
192 // turn off evaluation of expression fields for insertation
193 // of many expression fields (see labels)
194
195 inline void SetEvalExpFields(bool bEval);
196 void EvalExpFields(SwWrtShell* pSh);
197};
198
199inline void SwFieldMgr::SetEvalExpFields(bool bEval)
200 { m_bEvalExp = bEval; }
201
202#endif
203
204/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::text::XNumberingTypeInfo > m_xNumberingInfo
Definition: fldmgr.hxx:117
OUString m_sMacroName
Definition: fldmgr.hxx:110
OUString m_aCurPar2
Definition: fldmgr.hxx:106
SwWrtShell * m_pWrtShell
Definition: fldmgr.hxx:104
bool m_bEvalExp
Definition: fldmgr.hxx:113
bool GoPrev()
Definition: fldmgr.hxx:152
SwField * m_pCurField
Definition: fldmgr.hxx:103
void SetWrtShell(SwWrtShell *pShell)
Definition: fldmgr.hxx:124
OUString m_sMacroPath
Definition: fldmgr.hxx:109
const OUString & GetMacroPath() const
Definition: fldmgr.hxx:146
void SetEvalExpFields(bool bEval)
Definition: fldmgr.hxx:199
sal_uInt32 m_nCurFormat
Definition: fldmgr.hxx:112
const OUString & GetCurFieldPar2() const
Definition: fldmgr.hxx:137
OUString m_sCurFrame
Definition: fldmgr.hxx:107
const OUString & GetMacroName() const
Definition: fldmgr.hxx:147
bool GoNext()
Definition: fldmgr.hxx:151
const OUString & GetCurFieldPar1() const
Definition: fldmgr.hxx:136
OUString m_aCurPar1
Definition: fldmgr.hxx:105
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:242
Base class of all fields.
Definition: fldbas.hxx:292
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:94
SwFieldIds
Definition: fldbas.hxx:45
SwFieldGroups
Definition: fldmgr.hxx:53
@ GRP_REG
Definition: fldmgr.hxx:57
@ GRP_DB
Definition: fldmgr.hxx:58
@ GRP_DOC
Definition: fldmgr.hxx:54
@ GRP_VAR
Definition: fldmgr.hxx:59
@ GRP_FKT
Definition: fldmgr.hxx:55
@ GRP_REF
Definition: fldmgr.hxx:56
def text(shape, orig_st)
OUString ChooseMacro(weld::Window *pParent, const uno::Reference< frame::XModel > &rxLimitToDocument, const uno::Reference< frame::XFrame > &xDocFrame, bool bChooseOnly)
QPRO_FUNC_TYPE nType
sal_uInt16 nStart
Definition: fldmgr.hxx:64
sal_uInt16 nEnd
Definition: fldmgr.hxx:65
const OUString m_sPar2
Definition: fldmgr.hxx:75
bool m_bIsAutomaticLanguage
Definition: fldmgr.hxx:79
SwWrtShell * m_pSh
Definition: fldmgr.hxx:77
sal_uInt16 m_nSubType
Definition: fldmgr.hxx:73
css::uno::Any m_aDBColumn
Definition: fldmgr.hxx:82
sal_uInt32 m_nFormatId
Definition: fldmgr.hxx:76
std::optional< SwPaM > m_oAnnotationRange
Marks the PostIt field's annotation start/end if it differs from the cursor selection.
Definition: fldmgr.hxx:85
css::uno::Any m_aDBDataSource
Definition: fldmgr.hxx:80
SwFieldTypesEnum m_nTypeId
Definition: fldmgr.hxx:72
const OUString m_sPar1
Definition: fldmgr.hxx:74
sal_Unicode m_cSeparator
Definition: fldmgr.hxx:78
SwInsertField_Data(SwFieldTypesEnum nType, sal_uInt16 nSub, OUString aPar1, OUString aPar2, sal_uInt32 nFormatId, SwWrtShell *pShell=nullptr, sal_Unicode cSep=' ', bool bIsAutoLanguage=true)
Definition: fldmgr.hxx:87
css::uno::Any m_aDBConnection
Definition: fldmgr.hxx:81
weld::Widget * m_pParent
Definition: fldmgr.hxx:83
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
sal_uInt16 sal_Unicode