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