22#include <osl/diagnose.h>
24#include <com/sun/star/sdbc/DataType.hpp>
44 return aContent.replaceAll(OUStringChar(
DB_DELIM),
".");
51 m_aDBData(
std::move(aDBData)),
82 OSL_ENSURE(
m_nRefCnt > 0,
"RefCount < 0!");
88 for (
auto const & pFieldType : *
GetDoc()->getIDocumentFieldsAccess().GetFieldTypes())
90 if (pFieldType.get() ==
this)
94 if (
nPos <
GetDoc()->getIDocumentFieldsAccess().GetFieldTypes()->
size())
139 std::vector<SwFormatField*> vFields;
141 for(
auto pFormatField: vFields)
163 m_bIsInBodyText(true),
164 m_bValidValue(false),
165 m_bInitialized(false)
188 if (rExpansion.startsWith(
"<") && rExpansion.endsWith(
">"))
190 const OUString sColumn( rExpansion.copy( 1, rExpansion.getLength() - 2 ) );
219 return std::unique_ptr<SwField>(pTmp.release());
226 OUString sContent( rDBName.getToken(0,
DB_DELIM) );
228 if (sContent.getLength() > 1)
258 double &aNumber, sal_Int32 nColumnType,
SwDBField *pField )
260 bool bValidValue =
false;
262 if( DBL_MAX != aNumber )
264 if( DataType::DATE == nColumnType || DataType::TIME == nColumnType ||
265 DataType::TIMESTAMP == nColumnType )
267 Date aStandard( 1, 1, 1900 );
269 aNumber += (aStandard - pDocFormatter->
GetNullDate());
294 pField->
SetValue(aString.isEmpty() ? 0 : 1);
296 aNumber = aString.isEmpty() ? 0 : 1;
316 sal_uInt32 nFormat = 0;
330 sal_Int32 nColumnType =
nValue == DBL_MAX
369 rAny <<= static_cast<sal_Int32>(
GetFormat());
378 OSL_FAIL(
"illegal property");
388 if( *o3tl::doAccess<bool>(rAny) )
408 std::vector<SwFormatField*> vFields;
409 pType->GatherFields(vFields,
false);
410 for(
auto pFormatField: vFields)
412 SwTextField* pTextField = pFormatField->GetTextField();
413 if(pTextField &&
static_cast<SwDBField*
>(pFormatField->GetField()) ==
this)
436 OSL_FAIL(
"illegal property");
445 m_aDBData(
std::move(aDBData)),
551 return std::make_unique<SwDBNextSetFieldType>();
573 return std::unique_ptr<SwField>(pTmp.release());
635 return std::make_unique<SwDBNumSetFieldType>();
643 m_aCond(
std::move(aCond)),
644 m_aPar2(
std::move(aDBNum)),
659 return std::unique_ptr<SwField>(pTmp.release());
670 pMgr->
ToRecordId(std::max(o3tl::narrowing<sal_uInt16>(
m_aPar2.toInt32()), sal_uInt16(1))-1);
727 m_aPar2 = OUString::number(nVal);
745 return aData.sDataSource +
"." +
aData.sCommand;
750 return std::make_unique<SwDBNameFieldType>(
m_pDoc);
772 return std::unique_ptr<SwField>(pTmp.release());
792 return std::make_unique<SwDBSetNumberFieldType>();
823 std::unique_ptr<SwDBSetNumberField> pTmp(
828 return std::unique_ptr<SwField>(pTmp.release());
837 rAny <<= static_cast<sal_Int16>(
GetFormat());
857 if(nSet < css::style::NumberingType::NUMBER_NONE )
virtual void RemoveFieldType(size_t nField)=0
bool PutString(const OUString &)
virtual ~SwDBFieldType() override
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
virtual std::unique_ptr< SwFieldType > Copy() const override
SwDBFieldType(SwDoc *pDocPtr, const OUString &rColumnName, SwDBData aDBData)
OUString m_sName
only used in GetName() !
virtual OUString GetName() const override
Only in derived classes.
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
void ChgValue(double d, bool bVal)
For calculations in expressions.
void InitContent()
Evaluation for header and footer.
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
virtual ~SwDBField() override
virtual void SetSubType(sal_uInt16 nType) override
OUString m_sFieldCode
contains Word's field code
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
virtual OUString GetFieldName() const override
get name or content
virtual std::unique_ptr< SwField > Copy() const override
bool IsInitialized() const
void SetExpansion(const OUString &rStr)
Current text.
void Evaluate()
Get the evaluation via DBManager string.
SwDBField(SwDBFieldType *, sal_uInt32 nFormat=0)
virtual OUString GetPar1() const override
Get name.
static bool FormatValue(SvNumberFormatter const *pDocFormatter, OUString const &aString, sal_uInt32 nFormat, double &aNumber, sal_Int32 nColumnType, SwDBField *pField=nullptr)
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
const SwDBData & GetDBData() const
DBName.
virtual sal_uInt16 GetSubType() const override
virtual SwFieldType * ChgTyp(SwFieldType *) override
Set a new type.
bool IsDataSourceOpen(const OUString &rDataSource, const OUString &rTableOrQuery, bool bMergeShell)
check if a data source is open
static sal_uLong GetColumnFormat(css::uno::Reference< css::sdbc::XDataSource > const &xSource, css::uno::Reference< css::sdbc::XConnection > const &xConnection, css::uno::Reference< css::beans::XPropertySet > const &xColumn, SvNumberFormatter *pNFormatr, LanguageType nLanguage)
bool ToRecordId(sal_Int32 nSet)
sal_Int32 GetColumnType(const OUString &rDBName, const OUString &rTableName, const OUString &rColNm)
bool GetMergeColumnCnt(const OUString &rColumnName, LanguageType nLanguage, OUString &rResult, double *pNumber)
void ToNextRecord(const OUString &rDataSource, const OUString &rTableOrQuery)
sal_uInt32 GetSelectedRecordId(const OUString &rDataSource, const OUString &rTableOrQuery, sal_Int32 nCommandType=-1)
SwDBNameFieldType(SwDoc *)
virtual std::unique_ptr< SwFieldType > Copy() const override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
SwDBNameField(SwDBNameFieldType *, const SwDBData &rDBData)
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
virtual std::unique_ptr< SwField > Copy() const override
void SetDBData(const SwDBData &rDBData)
virtual OUString GetFieldName() const override
get name or content
const SwDBData & GetDBData() const
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
virtual void SetSubType(sal_uInt16 nType) override
SwDBNameInfField(SwFieldType *pTyp, SwDBData aDBData, sal_uInt32 nFormat=0)
virtual sal_uInt16 GetSubType() const override
virtual std::unique_ptr< SwFieldType > Copy() const override
SwDBNextSetField(SwDBNextSetFieldType *, OUString aCond, const SwDBData &rDBData)
void Evaluate(const SwDoc &)
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
virtual std::unique_ptr< SwField > Copy() const override
virtual void SetPar1(const OUString &rStr) override
set condition
virtual OUString GetPar1() const override
get condition
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
virtual std::unique_ptr< SwFieldType > Copy() const override
void Evaluate(const SwDoc &)
virtual void SetPar2(const OUString &rStr) override
set condition
virtual OUString GetPar2() const override
get condition
virtual std::unique_ptr< SwField > Copy() const override
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
SwDBNumSetField(SwDBNumSetFieldType *, OUString aCond, OUString aDBNum, const SwDBData &rDBData)
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
virtual OUString GetPar1() const override
get LogDBName
virtual void SetPar1(const OUString &rStr) override
set LogDBName
virtual std::unique_ptr< SwFieldType > Copy() const override
SwDBSetNumberField(SwDBSetNumberFieldType *, const SwDBData &rDBData, sal_uInt32 nFormat=0)
virtual std::unique_ptr< SwField > Copy() const override
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
void Evaluate(const SwDoc &)
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
SwDBData const & GetDBData()
SwDBManager * GetDBManager() const
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Instances of SwFields and those derived from it occur 0 to n times.
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
Base class of all fields.
void SetFormat(sal_uInt32 const nSet)
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
virtual OUString GetFieldName() const
get name or content
SwFieldType * GetTyp() const
LanguageType GetLanguage() const
Language at field position.
The root element of a Writer document layout.
virtual void NotifyContentChange(SwFormatField &rFormatField)
Fields containing values that have to be formatted via number formatter.
virtual SwFieldType * ChgTyp(SwFieldType *) override
Set a new type.
OUString ExpandValue(const double &rVal, sal_uInt32 nFormat, LanguageType nLng) const
virtual double GetValue() const
virtual void SetValue(const double &rVal)
static OUString lcl_DBSeparatorConvert(const OUString &aContent)
replace database separator by dots for display
virtual OUString GetName() const override
OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, LanguageType nLang)
expand numbering
const ::utl::TransliterationWrapper & GetAppCmpStrIgnore()
constexpr OUStringLiteral aData
const SwExtendedSubType SUB_INVISIBLE
Invisible.
const SwExtendedSubType SUB_OWN_FMT
SwDBField: Don't accept formatting from database.
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
#define FIELD_PROP_USHORT1
#define FIELD_PROP_FORMAT
#define FIELD_PROP_SHORT1