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