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 <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 {
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()
84  std::unique_ptr<SwPaM> m_pAnnotationRange;
85 
86  SwInsertField_Data(SwFieldTypesEnum nType, sal_uInt16 nSub, const OUString& rPar1, const OUString& rPar2,
87  sal_uInt32 nFormatId, SwWrtShell* pShell = nullptr, sal_Unicode cSep = ' ', bool bIsAutoLanguage = true) :
88  m_nTypeId(nType),
89  m_nSubType(nSub),
90  m_sPar1(rPar1),
91  m_sPar2(rPar2),
92  m_nFormatId(nFormatId),
93  m_pSh(pShell),
94  m_cSeparator(cSep),
95  m_bIsAutomaticLanguage(bIsAutoLanguage),
96  m_pParent(nullptr) {}
97 };
98 
100 {
101 private:
103  SwWrtShell* m_pWrtShell; // can be ZERO too!
104  OUString m_aCurPar1;
105  OUString m_aCurPar2;
106  OUString m_sCurFrame;
107 
108  OUString m_sMacroPath;
109  OUString m_sMacroName;
110 
111  sal_uInt32 m_nCurFormat;
113 
114  SAL_DLLPRIVATE LanguageType GetCurrLanguage() const;
115 
116  css::uno::Reference<css::text::XNumberingTypeInfo> m_xNumberingInfo;
117  SAL_DLLPRIVATE css::uno::Reference<css::text::XNumberingTypeInfo> const & GetNumberingInfo()const;
118 
119 public:
120  explicit SwFieldMgr(SwWrtShell* pSh = nullptr);
121  ~SwFieldMgr();
122 
123  void SetWrtShell( SwWrtShell* pShell )
124  { m_pWrtShell = pShell; }
125 
126  // insert field using TypeID (TYP_ ...)
127  bool InsertField( const SwInsertField_Data& rData );
128 
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);
134 
135  const OUString& GetCurFieldPar1() const { return m_aCurPar1; }
136  const OUString& GetCurFieldPar2() const { return m_aCurPar2; }
137 
138  // determine a field
139  SwField* GetCurField();
140 
141  void InsertFieldType(SwFieldType const & rType);
142 
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; }
147 
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 ); }
152 
153  bool IsDBNumeric(const OUString& rDBName, const OUString& rTableQryName,
154  bool bIsTable, const OUString& rFieldName);
155 
156  // organise RefMark with names
157  bool CanInsertRefMark( const OUString& rStr );
158 
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;
163 
164  void RemoveFieldType(SwFieldIds nResId, const OUString& rName);
165 
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);
170 
171  // the current field's TypeId
172  SwFieldTypesEnum GetCurTypeId() const;
173 
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 OUString GetTypeStr(sal_uInt16 nPos);
178 
179  // Pos in the list of fields
180  static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId);
181 
182  // subtypes to a type
183  void GetSubTypes(SwFieldTypesEnum nId, std::vector<OUString>& rToFill);
184 
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);
190 
191  // turn off evaluation of expression fields for insertation
192  // of many expression fields (see labels)
193 
194  inline void SetEvalExpFields(bool bEval);
195  void EvalExpFields(SwWrtShell* pSh);
196 };
197 
198 inline void SwFieldMgr::SetEvalExpFields(bool bEval)
199  { m_bEvalExp = bEval; }
200 
201 #endif
202 
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:234
const OUString & GetCurFieldPar2() const
Definition: fldmgr.hxx:136
sal_uInt16 const nStart
Definition: fldmgr.hxx:63
css::uno::Any m_aDBColumn
Definition: fldmgr.hxx:81
bool m_bEvalExp
Definition: fldmgr.hxx:112
void SetEvalExpFields(bool bEval)
Definition: fldmgr.hxx:198
Base class of all fields.
Definition: fldbas.hxx:280
void SetWrtShell(SwWrtShell *pShell)
Definition: fldmgr.hxx:123
SwField * m_pCurField
Definition: fldmgr.hxx:102
css::uno::Reference< css::text::XNumberingTypeInfo > m_xNumberingInfo
Definition: fldmgr.hxx:116
OUString m_sCurFrame
Definition: fldmgr.hxx:106
bool GoPrev()
Definition: fldmgr.hxx:151
sal_uInt16 const m_nSubType
Definition: fldmgr.hxx:72
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
sal_uInt16 sal_Unicode
OUString m_aCurPar2
Definition: fldmgr.hxx:105
const OUString & GetMacroName() const
Definition: fldmgr.hxx:146
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
SwInsertField_Data(SwFieldTypesEnum 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:86
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
std::unique_ptr< SwPaM > m_pAnnotationRange
Marks the PostIt field's annotation start/end if it differs from the cursor selection.
Definition: fldmgr.hxx:84
sal_uInt32 m_nCurFormat
Definition: fldmgr.hxx:111
const OUString & GetMacroPath() const
Definition: fldmgr.hxx:145
SwWrtShell * m_pWrtShell
Definition: fldmgr.hxx:103
const OUString m_sPar1
Definition: fldmgr.hxx:73
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:87
SwFieldIds
Definition: fldbas.hxx:38
OUString m_sMacroName
Definition: fldmgr.hxx:109
SwFieldTypesEnum const m_nTypeId
Definition: fldmgr.hxx:71
const OUString & GetCurFieldPar1() const
Definition: fldmgr.hxx:135
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
sal_uInt16 const nEnd
Definition: fldmgr.hxx:64
const OUString m_sPar2
Definition: fldmgr.hxx:74
bool GoNext()
Definition: fldmgr.hxx:150
OUString m_sMacroPath
Definition: fldmgr.hxx:108
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:104