1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <tools/string.hxx>
24 #include "swtypes.hxx"
25 #include <com/sun/star/uno/Reference.h>
26 #include <com/sun/star/uno/Any.h>
29 namespace com
{namespace sun
{namespace star
{
34 class XNumberingTypeInfo
;
44 class SvNumberFormatter
;
47 /*--------------------------------------------------------------------
48 Description: the groups of fields
49 --------------------------------------------------------------------*/
66 /*--------------------------------------------------------------------
67 Description: the field manager handles the insertation of fields
69 --------------------------------------------------------------------*/
70 struct SwInsertFld_Data
78 sal_Unicode cSeparator
;
79 sal_Bool bIsAutomaticLanguage
;
80 ::com::sun::star::uno::Any aDBDataSource
;
81 ::com::sun::star::uno::Any aDBConnection
;
82 ::com::sun::star::uno::Any aDBColumn
;
83 Window
* pParent
; // parent dialog used for SwWrtShell::StartInputFldDlg()
85 SwInsertFld_Data(sal_uInt16 nType
, sal_uInt16 nSub
, const String
& rPar1
, const String
& rPar2
,
86 sal_uLong nFmtId
, SwWrtShell
* pShell
= NULL
, sal_Unicode cSep
= ' ', sal_Bool bIsAutoLanguage
= sal_True
) :
94 bIsAutomaticLanguage(bIsAutoLanguage
),
100 bIsAutomaticLanguage(sal_True
){}
104 class SW_DLLPUBLIC SwFldMgr
109 const SvxMacroItem
* pMacroItem
;
110 SwWrtShell
* pWrtShell
; // can be ZERO too!
121 SW_DLLPRIVATE sal_uInt16
GetCurrLanguage() const;
123 com::sun::star::uno::Reference
<com::sun::star::container::XNameAccess
> xDBContext
;
124 com::sun::star::uno::Reference
<com::sun::star::text::XNumberingTypeInfo
> xNumberingInfo
;
125 SW_DLLPRIVATE
com::sun::star::uno::Reference
<com::sun::star::text::XNumberingTypeInfo
> GetNumberingInfo()const;
128 SwFldMgr(SwWrtShell
* pSh
= 0);
131 void SetWrtShell( SwWrtShell
* pShell
)
132 { pWrtShell
= pShell
; }
134 // insert field using TypeID (TYP_ ...)
135 sal_Bool
InsertFld( const SwInsertFld_Data
& rData
, SwPaM
* pPam
= 0 );
137 // change the current field directly
138 void UpdateCurFld(sal_uLong nFormat
,
141 SwField
* _pField
= 0); // #111840#
143 inline const String
& GetCurFldPar1() const;
144 inline const String
& GetCurFldPar2() const;
145 inline sal_uLong
GetCurFldFmt() const;
148 SwField
* GetCurFld();
150 void InsertFldType(SwFieldType
& rType
);
152 sal_Bool
ChooseMacro(const String
&rSelMacro
= aEmptyStr
);
153 void SetMacroPath(const String
& rPath
);
154 inline const String
& GetMacroPath() const { return (sMacroPath
); }
155 inline const String
& GetMacroName() const { return (sMacroName
); }
156 inline void SetMacroModule(SbModule
* pMod
) { pModule
= pMod
; }
158 // previous and next of the same type
159 sal_Bool
GoNextPrev( sal_Bool bNext
= sal_True
, SwFieldType
* pTyp
= 0 );
160 sal_Bool
GoNext( SwFieldType
* pTyp
= 0 ) { return GoNextPrev( sal_True
, pTyp
); }
161 sal_Bool
GoPrev( SwFieldType
* pTyp
= 0 ) { return GoNextPrev( sal_False
, pTyp
); }
163 // query values from database fields (BASIC )
164 // String GetDataBaseFieldValue(const String &rDBName, const String &rFieldName, SwWrtShell* pSh);
165 sal_Bool
IsDBNumeric(const String
& rDBName
, const String
& rTblQryName
,
166 sal_Bool bIsTable
, const String
& rFldName
);
168 // organise RefMark with names
169 bool CanInsertRefMark( const String
& rStr
);
172 // access to field types via ResId
173 sal_uInt16
GetFldTypeCount(sal_uInt16 nResId
= USHRT_MAX
) const;
174 SwFieldType
* GetFldType(sal_uInt16 nResId
, sal_uInt16 nId
= 0) const;
175 SwFieldType
* GetFldType(sal_uInt16 nResId
, const String
& rName
) const;
177 void RemoveFldType(sal_uInt16 nResId
, const String
& rName
);
179 // access via TypeId from the dialog
180 // Ids for a range of fields
181 const SwFldGroupRgn
& GetGroupRange(sal_Bool bHtmlMode
, sal_uInt16 nGrpId
) const;
182 sal_uInt16
GetGroup(sal_Bool bHtmlMode
, sal_uInt16 nTypeId
, sal_uInt16 nSubType
= 0) const;
184 // the current field's TypeId
185 sal_uInt16
GetCurTypeId() const;
187 // TypeId for a concrete position in the list
188 static sal_uInt16
GetTypeId(sal_uInt16 nPos
);
189 // name of the type in the list of fields
190 static const String
& GetTypeStr(sal_uInt16 nPos
);
192 // Pos in the list of fields
193 static sal_uInt16
GetPos(sal_uInt16 nTypeId
);
195 // subtypes to a type
196 bool GetSubTypes(sal_uInt16 nId
, std::vector
<OUString
>& rToFill
);
199 sal_uInt16
GetFormatCount(sal_uInt16 nTypeId
, bool bIsText
, sal_Bool bHtmlMode
= sal_False
) const;
200 String
GetFormatStr(sal_uInt16 nTypeId
, sal_uLong nFormatId
) const;
201 sal_uInt16
GetFormatId(sal_uInt16 nTypeId
, sal_uLong nFormatId
) const;
202 sal_uLong
GetDefaultFormat(sal_uInt16 nTypeId
, bool bIsText
, SvNumberFormatter
* pFormatter
, double* pVal
= 0L);
204 // turn off evaluation of expression fields for insertation
205 // of many expressino fields (see labels)
207 inline void SetEvalExpFlds(sal_Bool bEval
);
208 void EvalExpFlds(SwWrtShell
* pSh
= NULL
);
211 inline void SwFldMgr::SetEvalExpFlds(sal_Bool bEval
)
212 { bEvalExp
= bEval
; }
214 inline const String
& SwFldMgr::GetCurFldPar1() const
217 inline const String
& SwFldMgr::GetCurFldPar2() const
220 inline sal_uLong
SwFldMgr::GetCurFldFmt() const
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */