LibreOffice Module sw (master) 1
dbfld.cxx
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
20#include <float.h>
21#include <o3tl/any.hxx>
22#include <osl/diagnose.h>
23#include <svl/numformat.hxx>
24#include <com/sun/star/sdbc/DataType.hpp>
25#include <fmtfld.hxx>
26#include <txtfld.hxx>
27#include <calc.hxx>
28#include <doc.hxx>
30#include <docary.hxx>
31#include <fldbas.hxx>
32#include <dbfld.hxx>
33#include <dbmgr.hxx>
34#include <unofldmid.h>
35#include <o3tl/string_view.hxx>
36#include <utility>
37
38using namespace ::com::sun::star::sdbc;
39using namespace ::com::sun::star;
40
42static OUString lcl_DBSeparatorConvert(const OUString& aContent)
43{
44 return aContent.replaceAll(OUStringChar(DB_DELIM), ".");
45}
46
47// database field type
48
49SwDBFieldType::SwDBFieldType(SwDoc* pDocPtr, const OUString& rNam, SwDBData aDBData ) :
51 m_aDBData(std::move(aDBData)),
52 m_sName(rNam),
53 m_sColumn(rNam),
54 m_nRefCnt(0)
55{
56 if(!m_aDBData.sDataSource.isEmpty() || !m_aDBData.sCommand.isEmpty())
57 {
59 + OUStringChar(DB_DELIM)
61 + OUStringChar(DB_DELIM)
62 + m_sName;
63 }
64}
65
67{
68}
69
70std::unique_ptr<SwFieldType> SwDBFieldType::Copy() const
71{
72 return std::make_unique<SwDBFieldType>(GetDoc(), m_sColumn, m_aDBData);
73}
74
75OUString SwDBFieldType::GetName() const
76{
77 return m_sName;
78}
79
81{
82 OSL_ENSURE(m_nRefCnt > 0, "RefCount < 0!");
83
84 if (--m_nRefCnt > 0)
85 return;
86
87 size_t nPos = 0;
88 for (auto const & pFieldType : *GetDoc()->getIDocumentFieldsAccess().GetFieldTypes())
89 {
90 if (pFieldType.get() == this)
91 break;
92 ++nPos;
93 }
94 if (nPos < GetDoc()->getIDocumentFieldsAccess().GetFieldTypes()->size())
95 {
97 delete this;
98 }
99}
100
101void SwDBFieldType::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
102{
103 switch( nWhichId )
104 {
105 case FIELD_PROP_PAR1:
106 rAny <<= m_aDBData.sDataSource;
107 break;
108 case FIELD_PROP_PAR2:
109 rAny <<= m_aDBData.sCommand;
110 break;
111 case FIELD_PROP_PAR3:
112 rAny <<= m_sColumn;
113 break;
115 rAny <<= m_aDBData.nCommandType;
116 break;
117 default:
118 assert(false);
119 }
120}
121
122void SwDBFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
123{
124 switch( nWhichId )
125 {
126 case FIELD_PROP_PAR1:
127 rAny >>= m_aDBData.sDataSource;
128 break;
129 case FIELD_PROP_PAR2:
130 rAny >>= m_aDBData.sCommand;
131 break;
132 case FIELD_PROP_PAR3:
133 {
134 OUString sTmp;
135 rAny >>= sTmp;
136 if( sTmp != m_sColumn )
137 {
138 m_sColumn = sTmp;
139 std::vector<SwFormatField*> vFields;
140 GatherFields(vFields);
141 for(auto pFormatField: vFields)
142 {
143 SwDBField* pDBField = static_cast<SwDBField*>(pFormatField->GetField());
144 pDBField->ClearInitialized();
145 pDBField->InitContent();
146 }
147 }
148 }
149 break;
151 rAny >>= m_aDBData.nCommandType;
152 break;
153 default:
154 assert(false);
155 }
156}
157
158// database field
159
160SwDBField::SwDBField(SwDBFieldType* pTyp, sal_uInt32 nFormat)
161 : SwValueField(pTyp, nFormat),
162 m_nSubType(0),
163 m_bIsInBodyText(true),
164 m_bValidValue(false),
165 m_bInitialized(false)
166{
167 if (GetTyp())
168 static_cast<SwDBFieldType*>(GetTyp())->AddRef();
169 InitContent();
170}
171
173{
174 if (GetTyp())
175 static_cast<SwDBFieldType*>(GetTyp())->ReleaseRef();
176}
177
179{
180 if (!IsInitialized())
181 {
182 m_aContent = "<" + static_cast<const SwDBFieldType*>(GetTyp())->GetColumnName() + ">";
183 }
184}
185
186void SwDBField::InitContent(const OUString& rExpansion)
187{
188 if (rExpansion.startsWith("<") && rExpansion.endsWith(">"))
189 {
190 const OUString sColumn( rExpansion.copy( 1, rExpansion.getLength() - 2 ) );
191 if( ::GetAppCmpStrIgnore().isEqual( sColumn,
192 static_cast<SwDBFieldType *>(GetTyp())->GetColumnName() ))
193 {
194 InitContent();
195 return;
196 }
197 }
198 SetExpansion( rExpansion );
199}
200
201OUString SwDBField::ExpandImpl(SwRootFrame const*const) const
202{
205 return OUString();
206}
207
208std::unique_ptr<SwField> SwDBField::Copy() const
209{
210 std::unique_ptr<SwDBField> pTmp(new SwDBField(static_cast<SwDBFieldType*>(GetTyp()), GetFormat()));
211 pTmp->m_aContent = m_aContent;
212 pTmp->m_bIsInBodyText = m_bIsInBodyText;
213 pTmp->m_bValidValue = m_bValidValue;
214 pTmp->m_bInitialized = m_bInitialized;
215 pTmp->m_nSubType = m_nSubType;
216 pTmp->SetValue(GetValue());
217 pTmp->m_sFieldCode = m_sFieldCode;
218
219 return std::unique_ptr<SwField>(pTmp.release());
220}
221
223{
224 const OUString rDBName = static_cast<SwDBFieldType*>(GetTyp())->GetName();
225
226 OUString sContent( rDBName.getToken(0, DB_DELIM) );
227
228 if (sContent.getLength() > 1)
229 {
230 sContent += OUStringChar(DB_DELIM)
231 + o3tl::getToken(rDBName, 1, DB_DELIM)
232 + OUStringChar(DB_DELIM)
233 + o3tl::getToken(rDBName, 2, DB_DELIM);
234 }
235 return lcl_DBSeparatorConvert(sContent);
236}
237
238void SwDBField::ChgValue( double d, bool bVal )
239{
240 m_bValidValue = bVal;
241 SetValue(d);
242
243 if( m_bValidValue )
245}
246
248{
249 SwFieldType* pOld = SwValueField::ChgTyp( pNewType );
250
251 static_cast<SwDBFieldType*>(pNewType)->AddRef();
252 static_cast<SwDBFieldType*>(pOld)->ReleaseRef();
253
254 return pOld;
255}
256
257bool SwDBField::FormatValue( SvNumberFormatter const * pDocFormatter, OUString const &aString, sal_uInt32 nFormat,
258 double &aNumber, sal_Int32 nColumnType, SwDBField *pField )
259{
260 bool bValidValue = false;
261
262 if( DBL_MAX != aNumber )
263 {
264 if( DataType::DATE == nColumnType || DataType::TIME == nColumnType ||
265 DataType::TIMESTAMP == nColumnType )
266 {
267 Date aStandard( 1, 1, 1900 );
268 if( pDocFormatter->GetNullDate() != aStandard )
269 aNumber += (aStandard - pDocFormatter->GetNullDate());
270 }
271 bValidValue = true;
272 if( pField )
273 pField->SetValue( aNumber );
274 }
275 else
276 {
277 SwSbxValue aVal;
278 aVal.PutString( aString );
279
280 if (aVal.IsNumeric())
281 {
282 if( pField )
283 pField->SetValue(aVal.GetDouble());
284 else
285 aNumber = aVal.GetDouble();
286
287 if (nFormat && nFormat != SAL_MAX_UINT32 && !pDocFormatter->IsTextFormat(nFormat))
288 bValidValue = true; // because of bug #60339 not for all strings
289 }
290 else
291 {
292 // if string length > 0 then true, else false
293 if( pField )
294 pField->SetValue(aString.isEmpty() ? 0 : 1);
295 else
296 aNumber = aString.isEmpty() ? 0 : 1;
297 }
298 }
299
300 return bValidValue;
301}
302
305{
306 SwDBManager* pMgr = GetDoc()->GetDBManager();
307
308 // first delete
309 m_bValidValue = false;
310 double nValue = DBL_MAX;
311 const SwDBData& aTmpData = GetDBData();
312
313 if(!pMgr || !pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand, true))
314 return ;
315
316 sal_uInt32 nFormat = 0;
317
318 // search corresponding column name
319 OUString aColNm( static_cast<SwDBFieldType*>(GetTyp())->GetColumnName() );
320
321 SvNumberFormatter* pDocFormatter = GetDoc()->GetNumberFormatter();
324 {
325 nFormat = pMgr->GetColumnFormat( aTmpData.sDataSource, aTmpData.sCommand,
326 aColNm, pDocFormatter, GetLanguage() );
327 SetFormat( nFormat );
328 }
329
330 sal_Int32 nColumnType = nValue == DBL_MAX
331 ? 0
332 : pMgr->GetColumnType(aTmpData.sDataSource, aTmpData.sCommand, aColNm);
333
334 m_bValidValue = FormatValue( pDocFormatter, m_aContent, nFormat, nValue, nColumnType, this );
335
336 if( DBL_MAX != nValue )
338
339 m_bInitialized = true;
340}
341
343OUString SwDBField::GetPar1() const
344{
345 return static_cast<const SwDBFieldType*>(GetTyp())->GetName();
346}
347
348sal_uInt16 SwDBField::GetSubType() const
349{
350 return m_nSubType;
351}
352
353void SwDBField::SetSubType(sal_uInt16 nType)
354{
356}
357
358bool SwDBField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
359{
360 switch( nWhichId )
361 {
362 case FIELD_PROP_BOOL1:
364 break;
365 case FIELD_PROP_BOOL2:
367 break;
369 rAny <<= static_cast<sal_Int32>(GetFormat());
370 break;
371 case FIELD_PROP_PAR1:
372 rAny <<= m_aContent;
373 break;
374 case FIELD_PROP_PAR2:
375 rAny <<= m_sFieldCode;
376 break;
377 default:
378 OSL_FAIL("illegal property");
379 }
380 return true;
381}
382
383bool SwDBField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
384{
385 switch( nWhichId )
386 {
387 case FIELD_PROP_BOOL1:
388 if( *o3tl::doAccess<bool>(rAny) )
390 else
392 break;
393 case FIELD_PROP_BOOL2:
394 {
395 sal_uInt16 nSubTyp = GetSubType();
396 bool bVisible = false;
397 if(!(rAny >>= bVisible))
398 return false;
399 if(bVisible)
401 else
403 SetSubType(nSubTyp);
404 //invalidate text node
405 auto pType = GetTyp();
406 if(!pType)
407 break;
408 std::vector<SwFormatField*> vFields;
409 pType->GatherFields(vFields, false);
410 for(auto pFormatField: vFields)
411 {
412 SwTextField* pTextField = pFormatField->GetTextField();
413 if(pTextField && static_cast<SwDBField*>(pFormatField->GetField()) == this)
414 {
415 //notify the change
416 pTextField->NotifyContentChange(*pFormatField);
417 break;
418 }
419 }
420 }
421 break;
423 {
424 sal_Int32 nTemp = 0;
425 rAny >>= nTemp;
426 SetFormat(nTemp);
427 }
428 break;
429 case FIELD_PROP_PAR1:
430 rAny >>= m_aContent;
431 break;
432 case FIELD_PROP_PAR2:
433 rAny >>= m_sFieldCode;
434 break;
435 default:
436 OSL_FAIL("illegal property");
437 }
438 return true;
439}
440
441// base class for all further database fields
442
443SwDBNameInfField::SwDBNameInfField(SwFieldType* pTyp, SwDBData aDBData, sal_uInt32 nFormat) :
444 SwField(pTyp, nFormat),
445 m_aDBData(std::move(aDBData)),
446 m_nSubType(0)
447{
448}
449
451{
452 SwDBData aRet;
453 if(!m_aDBData.sDataSource.isEmpty())
454 aRet = m_aDBData;
455 else
456 aRet = pDoc->GetDBData();
457 return aRet;
458}
459
461{
462 m_aDBData = rDBData;
463}
464
466{
467 OUString sStr( SwField::GetFieldName() );
468 if (!m_aDBData.sDataSource.isEmpty())
469 {
470 sStr += ":"
472 + OUStringChar(DB_DELIM)
474 }
475 return lcl_DBSeparatorConvert(sStr);
476}
477
478bool SwDBNameInfField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
479{
480 switch( nWhichId )
481 {
482 case FIELD_PROP_PAR1:
483 rAny <<= m_aDBData.sDataSource;
484 break;
485 case FIELD_PROP_PAR2:
486 rAny <<= m_aDBData.sCommand;
487 break;
489 rAny <<= m_aDBData.nCommandType;
490 break;
491 case FIELD_PROP_BOOL2:
493 break;
494 default:
495 assert(false);
496 }
497 return true;
498}
499
500bool SwDBNameInfField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
501{
502 switch( nWhichId )
503 {
504 case FIELD_PROP_PAR1:
505 rAny >>= m_aDBData.sDataSource;
506 break;
507 case FIELD_PROP_PAR2:
508 rAny >>= m_aDBData.sCommand;
509 break;
511 rAny >>= m_aDBData.nCommandType;
512 break;
513 case FIELD_PROP_BOOL2:
514 {
515 sal_uInt16 nSubTyp = GetSubType();
516 bool bVisible = false;
517 if(!(rAny >>= bVisible))
518 return false;
519 if(bVisible)
521 else
523 SetSubType(nSubTyp);
524 }
525 break;
526 default:
527 assert(false);
528 }
529 return true;
530}
531
533{
534 return m_nSubType;
535}
536
537void SwDBNameInfField::SetSubType(sal_uInt16 nType)
538{
540}
541
542// next dataset
543
546{
547}
548
549std::unique_ptr<SwFieldType> SwDBNextSetFieldType::Copy() const
550{
551 return std::make_unique<SwDBNextSetFieldType>();
552}
553
554// SwDBSetField
555
557 OUString aCond,
558 const SwDBData& rDBData) :
559 SwDBNameInfField(pTyp, rDBData), m_aCond(std::move(aCond)), m_bCondValid(true)
560{}
561
562OUString SwDBNextSetField::ExpandImpl(SwRootFrame const*const) const
563{
564 return OUString();
565}
566
567std::unique_ptr<SwField> SwDBNextSetField::Copy() const
568{
569 std::unique_ptr<SwDBNextSetField> pTmp(new SwDBNextSetField(static_cast<SwDBNextSetFieldType*>(GetTyp()),
570 m_aCond, GetDBData()));
571 pTmp->SetSubType(GetSubType());
572 pTmp->m_bCondValid = m_bCondValid;
573 return std::unique_ptr<SwField>(pTmp.release());
574}
575
577{
578 SwDBManager* pMgr = rDoc.GetDBManager();
579 const SwDBData& rData = GetDBData();
580 if( !m_bCondValid ||
581 !pMgr || !pMgr->IsDataSourceOpen(rData.sDataSource, rData.sCommand, false))
582 return ;
583 pMgr->ToNextRecord(rData.sDataSource, rData.sCommand);
584}
585
588{
589 return m_aCond;
590}
591
593void SwDBNextSetField::SetPar1(const OUString& rStr)
594{
595 m_aCond = rStr;
596}
597
598bool SwDBNextSetField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
599{
600 bool bRet = true;
601 switch( nWhichId )
602 {
603 case FIELD_PROP_PAR3:
604 rAny <<= m_aCond;
605 break;
606 default:
607 bRet = SwDBNameInfField::QueryValue( rAny, nWhichId );
608 }
609 return bRet;
610}
611
612bool SwDBNextSetField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
613{
614 bool bRet = true;
615 switch( nWhichId )
616 {
617 case FIELD_PROP_PAR3:
618 rAny >>= m_aCond;
619 break;
620 default:
621 bRet = SwDBNameInfField::PutValue( rAny, nWhichId );
622 }
623 return bRet;
624}
625
626// dataset with certain ID
627
630{
631}
632
633std::unique_ptr<SwFieldType> SwDBNumSetFieldType::Copy() const
634{
635 return std::make_unique<SwDBNumSetFieldType>();
636}
637
639 OUString aCond,
640 OUString aDBNum,
641 const SwDBData& rDBData) :
642 SwDBNameInfField(pTyp, rDBData),
643 m_aCond(std::move(aCond)),
644 m_aPar2(std::move(aDBNum)),
645 m_bCondValid(true)
646{}
647
648OUString SwDBNumSetField::ExpandImpl(SwRootFrame const*const) const
649{
650 return OUString();
651}
652
653std::unique_ptr<SwField> SwDBNumSetField::Copy() const
654{
655 std::unique_ptr<SwDBNumSetField> pTmp(new SwDBNumSetField(static_cast<SwDBNumSetFieldType*>(GetTyp()),
657 pTmp->m_bCondValid = m_bCondValid;
658 pTmp->SetSubType(GetSubType());
659 return std::unique_ptr<SwField>(pTmp.release());
660}
661
663{
664 SwDBManager* pMgr = rDoc.GetDBManager();
665 const SwDBData& aTmpData = GetDBData();
666
667 if( m_bCondValid && pMgr && pMgr->IsInMerge() &&
668 pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand, true))
669 { // condition OK -> adjust current Set
670 pMgr->ToRecordId(std::max(o3tl::narrowing<sal_uInt16>(m_aPar2.toInt32()), sal_uInt16(1))-1);
671 }
672}
673
676{
677 return m_aCond;
678}
679
681void SwDBNumSetField::SetPar1(const OUString& rStr)
682{
683 m_aCond = rStr;
684}
685
688{
689 return m_aPar2;
690}
691
693void SwDBNumSetField::SetPar2(const OUString& rStr)
694{
695 m_aPar2 = rStr;
696}
697
698bool SwDBNumSetField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
699{
700 bool bRet = true;
701 switch( nWhichId )
702 {
703 case FIELD_PROP_PAR3:
704 rAny <<= m_aCond;
705 break;
707 rAny <<= m_aPar2.toInt32();
708 break;
709 default:
710 bRet = SwDBNameInfField::QueryValue(rAny, nWhichId );
711 }
712 return bRet;
713}
714
715bool SwDBNumSetField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
716{
717 bool bRet = true;
718 switch( nWhichId )
719 {
720 case FIELD_PROP_PAR3:
721 rAny >>= m_aCond;
722 break;
724 {
725 sal_Int32 nVal = 0;
726 rAny >>= nVal;
727 m_aPar2 = OUString::number(nVal);
728 }
729 break;
730 default:
731 bRet = SwDBNameInfField::PutValue(rAny, nWhichId );
732 }
733 return bRet;
734}
735
738{
739 m_pDoc = pDocument;
740}
741
743{
744 const SwDBData aData = m_pDoc->GetDBData();
745 return aData.sDataSource + "." + aData.sCommand;
746}
747
748std::unique_ptr<SwFieldType> SwDBNameFieldType::Copy() const
749{
750 return std::make_unique<SwDBNameFieldType>(m_pDoc);
751}
752
753// name of the connected database
754
756 : SwDBNameInfField(pTyp, rDBData, 0)
757{}
758
759OUString SwDBNameField::ExpandImpl(SwRootFrame const*const) const
760{
762 return static_cast<SwDBNameFieldType*>(GetTyp())->Expand();
763 return OUString();
764}
765
766std::unique_ptr<SwField> SwDBNameField::Copy() const
767{
768 std::unique_ptr<SwDBNameField> pTmp(new SwDBNameField(static_cast<SwDBNameFieldType*>(GetTyp()), GetDBData()));
769 pTmp->ChangeFormat(GetFormat());
770 pTmp->SetLanguage(GetLanguage());
771 pTmp->SetSubType(GetSubType());
772 return std::unique_ptr<SwField>(pTmp.release());
773}
774
775bool SwDBNameField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
776{
777 return SwDBNameInfField::QueryValue(rAny, nWhichId );
778}
779
780bool SwDBNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
781{
782 return SwDBNameInfField::PutValue(rAny, nWhichId );
783}
784
787{
788}
789
790std::unique_ptr<SwFieldType> SwDBSetNumberFieldType::Copy() const
791{
792 return std::make_unique<SwDBSetNumberFieldType>();
793}
794
795// set-number of the connected database
796
798 const SwDBData& rDBData,
799 sal_uInt32 nFormat)
800 : SwDBNameInfField(pTyp, rDBData, nFormat), m_nNumber(0)
801{}
802
804{
806 return OUString();
807 return FormatNumber(m_nNumber, static_cast<SvxNumType>(GetFormat()));
808}
809
811{
812 SwDBManager* pMgr = rDoc.GetDBManager();
813
814 const SwDBData& aTmpData = GetDBData();
815 if (!pMgr || !pMgr->IsInMerge() ||
816 !pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand, false))
817 return;
819}
820
821std::unique_ptr<SwField> SwDBSetNumberField::Copy() const
822{
823 std::unique_ptr<SwDBSetNumberField> pTmp(
825 pTmp->SetLanguage(GetLanguage());
826 pTmp->SetSetNumber(m_nNumber);
827 pTmp->SetSubType(GetSubType());
828 return std::unique_ptr<SwField>(pTmp.release());
829}
830
831bool SwDBSetNumberField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
832{
833 bool bRet = true;
834 switch( nWhichId )
835 {
837 rAny <<= static_cast<sal_Int16>(GetFormat());
838 break;
840 rAny <<= m_nNumber;
841 break;
842 default:
843 bRet = SwDBNameInfField::QueryValue( rAny, nWhichId );
844 }
845 return bRet;
846}
847
848bool SwDBSetNumberField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
849{
850 bool bRet = true;
851 switch( nWhichId )
852 {
854 {
855 sal_Int16 nSet = 0;
856 rAny >>= nSet;
857 if(nSet < css::style::NumberingType::NUMBER_NONE )
858 SetFormat(nSet);
859 }
860 break;
862 rAny >>= m_nNumber;
863 break;
864 default:
865 bRet = SwDBNameInfField::PutValue( rAny, nWhichId );
866 }
867 return bRet;
868}
869
870/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double d
virtual void RemoveFieldType(size_t nField)=0
bool IsNumeric() const
bool PutString(const OUString &)
bool IsTextFormat(sal_uInt32 nFIndex) const
const Date & GetNullDate() const
virtual ~SwDBFieldType() override
Definition: dbfld.cxx:66
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: dbfld.cxx:122
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: dbfld.cxx:70
void ReleaseRef()
Definition: dbfld.cxx:80
tools::Long m_nRefCnt
Definition: dbfld.hxx:34
SwDBFieldType(SwDoc *pDocPtr, const OUString &rColumnName, SwDBData aDBData)
Definition: dbfld.cxx:49
OUString m_sName
only used in GetName() !
Definition: dbfld.hxx:32
OUString m_sColumn
Definition: dbfld.hxx:33
virtual OUString GetName() const override
Only in derived classes.
Definition: dbfld.cxx:75
SwDBData m_aDBData
Definition: dbfld.hxx:31
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: dbfld.cxx:101
void ChgValue(double d, bool bVal)
For calculations in expressions.
Definition: dbfld.cxx:238
void InitContent()
Evaluation for header and footer.
Definition: dbfld.cxx:178
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: dbfld.cxx:358
bool m_bValidValue
Definition: dbfld.hxx:63
bool m_bInitialized
Definition: dbfld.hxx:64
virtual ~SwDBField() override
Definition: dbfld.cxx:172
virtual void SetSubType(sal_uInt16 nType) override
Definition: dbfld.cxx:353
OUString m_sFieldCode
contains Word's field code
Definition: dbfld.hxx:60
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: dbfld.cxx:383
virtual OUString GetFieldName() const override
get name or content
Definition: dbfld.cxx:222
virtual std::unique_ptr< SwField > Copy() const override
Definition: dbfld.cxx:208
bool IsInitialized() const
Definition: dbfld.hxx:95
bool m_bIsInBodyText
Definition: dbfld.hxx:62
void SetExpansion(const OUString &rStr)
Current text.
Definition: dbfld.hxx:114
void Evaluate()
Get the evaluation via DBManager string.
Definition: dbfld.cxx:304
sal_uInt16 m_nSubType
Definition: dbfld.hxx:61
SwDBField(SwDBFieldType *, sal_uInt32 nFormat=0)
Definition: dbfld.cxx:160
virtual OUString GetPar1() const override
Get name.
Definition: dbfld.cxx:343
static bool FormatValue(SvNumberFormatter const *pDocFormatter, OUString const &aString, sal_uInt32 nFormat, double &aNumber, sal_Int32 nColumnType, SwDBField *pField=nullptr)
Definition: dbfld.cxx:257
void ClearInitialized()
Definition: dbfld.hxx:96
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: dbfld.cxx:201
OUString m_aContent
Definition: dbfld.hxx:59
const SwDBData & GetDBData() const
DBName.
Definition: dbfld.hxx:106
virtual sal_uInt16 GetSubType() const override
Definition: dbfld.cxx:348
virtual SwFieldType * ChgTyp(SwFieldType *) override
Set a new type.
Definition: dbfld.cxx:247
bool IsInMerge() const
Definition: dbmgr.hxx:343
bool IsDataSourceOpen(const OUString &rDataSource, const OUString &rTableOrQuery, bool bMergeShell)
check if a data source is open
Definition: dbmgr.cxx:2010
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)
Definition: dbmgr.cxx:2283
sal_Int32 GetColumnType(const OUString &rDBName, const OUString &rTableName, const OUString &rColNm)
Definition: dbmgr.cxx:1823
bool GetMergeColumnCnt(const OUString &rColumnName, LanguageType nLanguage, OUString &rResult, double *pNumber)
Definition: dbmgr.cxx:2094
void ToNextRecord(const OUString &rDataSource, const OUString &rTableOrQuery)
Definition: dbmgr.cxx:2177
sal_uInt32 GetSelectedRecordId(const OUString &rDataSource, const OUString &rTableOrQuery, sal_Int32 nCommandType=-1)
Definition: dbmgr.cxx:2365
SwDBNameFieldType(SwDoc *)
Definition: dbfld.cxx:736
SwDoc * m_pDoc
Definition: dbfld.hxx:237
OUString Expand() const
Definition: dbfld.cxx:742
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: dbfld.cxx:748
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: dbfld.cxx:775
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: dbfld.cxx:780
SwDBNameField(SwDBNameFieldType *, const SwDBData &rDBData)
Definition: dbfld.cxx:755
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: dbfld.cxx:759
virtual std::unique_ptr< SwField > Copy() const override
Definition: dbfld.cxx:766
void SetDBData(const SwDBData &rDBData)
Definition: dbfld.cxx:460
virtual OUString GetFieldName() const override
get name or content
Definition: dbfld.cxx:465
const SwDBData & GetDBData() const
Definition: dbfld.hxx:128
sal_uInt16 m_nSubType
Definition: dbfld.hxx:125
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: dbfld.cxx:500
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: dbfld.cxx:478
SwDBData m_aDBData
Definition: dbfld.hxx:124
virtual void SetSubType(sal_uInt16 nType) override
Definition: dbfld.cxx:537
SwDBNameInfField(SwFieldType *pTyp, SwDBData aDBData, sal_uInt32 nFormat=0)
Definition: dbfld.cxx:443
virtual sal_uInt16 GetSubType() const override
Definition: dbfld.cxx:532
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: dbfld.cxx:549
OUString m_aCond
Definition: dbfld.hxx:161
bool m_bCondValid
Definition: dbfld.hxx:162
SwDBNextSetField(SwDBNextSetFieldType *, OUString aCond, const SwDBData &rDBData)
Definition: dbfld.cxx:556
void Evaluate(const SwDoc &)
Definition: dbfld.cxx:576
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: dbfld.cxx:562
virtual std::unique_ptr< SwField > Copy() const override
Definition: dbfld.cxx:567
virtual void SetPar1(const OUString &rStr) override
set condition
Definition: dbfld.cxx:593
virtual OUString GetPar1() const override
get condition
Definition: dbfld.cxx:587
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: dbfld.cxx:612
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: dbfld.cxx:598
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: dbfld.cxx:633
bool m_bCondValid
Definition: dbfld.hxx:203
void Evaluate(const SwDoc &)
Definition: dbfld.cxx:662
virtual void SetPar2(const OUString &rStr) override
set condition
Definition: dbfld.cxx:693
virtual OUString GetPar2() const override
get condition
Definition: dbfld.cxx:687
virtual std::unique_ptr< SwField > Copy() const override
Definition: dbfld.cxx:653
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: dbfld.cxx:648
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: dbfld.cxx:715
OUString m_aPar2
Definition: dbfld.hxx:202
OUString m_aCond
Definition: dbfld.hxx:201
SwDBNumSetField(SwDBNumSetFieldType *, OUString aCond, OUString aDBNum, const SwDBData &rDBData)
Definition: dbfld.cxx:638
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: dbfld.cxx:698
virtual OUString GetPar1() const override
get LogDBName
Definition: dbfld.cxx:675
virtual void SetPar1(const OUString &rStr) override
set LogDBName
Definition: dbfld.cxx:681
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: dbfld.cxx:790
SwDBSetNumberField(SwDBSetNumberFieldType *, const SwDBData &rDBData, sal_uInt32 nFormat=0)
Definition: dbfld.cxx:797
virtual std::unique_ptr< SwField > Copy() const override
Definition: dbfld.cxx:821
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: dbfld.cxx:848
tools::Long m_nNumber
Definition: dbfld.hxx:269
void Evaluate(const SwDoc &)
Definition: dbfld.cxx:810
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: dbfld.cxx:803
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: dbfld.cxx:831
Definition: doc.hxx:192
SwDBData const & GetDBData()
Definition: docfld.cxx:383
SwDBManager * GetDBManager() const
Definition: doc.hxx:674
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:358
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1414
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:242
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
Definition: fldbas.cxx:203
Base class of all fields.
Definition: fldbas.hxx:292
void SetFormat(sal_uInt32 const nSet)
Definition: fldbas.hxx:307
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:403
virtual OUString GetFieldName() const
get name or content
Definition: fldbas.cxx:305
SwFieldType * GetTyp() const
Definition: fldbas.hxx:398
LanguageType GetLanguage() const
Language at field position.
Definition: fldbas.hxx:408
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
double GetDouble() const
Definition: calc.cxx:1467
virtual void NotifyContentChange(SwFormatField &rFormatField)
Definition: atrfld.cxx:600
Fields containing values that have to be formatted via number formatter.
Definition: fldbas.hxx:415
SwDoc * GetDoc() const
Definition: fldbas.hxx:425
virtual SwFieldType * ChgTyp(SwFieldType *) override
Set a new type.
Definition: fldbas.cxx:646
OUString ExpandValue(const double &rVal, sal_uInt32 nFormat, LanguageType nLng) const
Definition: fldbas.hxx:466
virtual double GetValue() const
Definition: fldbas.cxx:745
SwDoc * GetDoc() const
Definition: fldbas.hxx:459
virtual void SetValue(const double &rVal)
Definition: fldbas.cxx:750
static OUString lcl_DBSeparatorConvert(const OUString &aContent)
replace database separator by dots for display
Definition: dbfld.cxx:42
virtual OUString GetName() const override
OUString m_sName
OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, LanguageType nLang)
expand numbering
Definition: fldbas.cxx:516
SwFieldIds
Definition: fldbas.hxx:45
sal_Int16 nValue
const ::utl::TransliterationWrapper & GetAppCmpStrIgnore()
Definition: init.cxx:786
sal_uInt16 nPos
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
size
const SwExtendedSubType SUB_INVISIBLE
Invisible.
Definition: fldbas.hxx:213
const SwExtendedSubType SUB_OWN_FMT
SwDBField: Don't accept formatting from database.
Definition: fldbas.hxx:214
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
QPRO_FUNC_TYPE nType
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
OUString sDataSource
Definition: swdbdata.hxx:30
OUString sCommand
Definition: swdbdata.hxx:31
SvxNumType
#define DB_DELIM
Definition: swtypes.hxx:130
bool bVisible
#define SAL_MAX_UINT32
#define FIELD_PROP_BOOL1
Definition: unofldmid.h:28
#define FIELD_PROP_PAR3
Definition: unofldmid.h:25
#define FIELD_PROP_BOOL2
Definition: unofldmid.h:29
#define FIELD_PROP_USHORT1
Definition: unofldmid.h:31
#define FIELD_PROP_FORMAT
Definition: unofldmid.h:26
#define FIELD_PROP_SHORT1
Definition: unofldmid.h:37
#define FIELD_PROP_PAR1
Definition: unofldmid.h:23
#define FIELD_PROP_PAR2
Definition: unofldmid.h:24