1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbfld.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #include <sfx2/app.hxx>
37 #include <svtools/zforlist.hxx>
38 #include <svx/pageitem.hxx>
39 #include <svx/dataaccessdescriptor.hxx>
40 #include <com/sun/star/sdbc/DataType.hpp>
57 #include <unofldmid.h>
61 using namespace ::com::sun::star::sdbc
;
62 using namespace ::com::sun::star
;
63 using ::rtl::OUString
;
65 /*--------------------------------------------------------------------
66 Beschreibung: Datenbanktrenner durch Punkte fuer Anzeige ersetzen
67 --------------------------------------------------------------------*/
69 String
lcl_DBTrennConv(const String
& aContent
)
71 String
sTmp(aContent
);
72 sal_Unicode
* pStr
= sTmp
.GetBufferAccess();
73 for( USHORT i
= sTmp
.Len(); i
; --i
, ++pStr
)
74 if( DB_DELIM
== *pStr
)
79 /*--------------------------------------------------------------------
80 Beschreibung: DatenbankFeldTyp
81 --------------------------------------------------------------------*/
83 SwDBFieldType::SwDBFieldType(SwDoc
* pDocPtr
, const String
& rNam
, const SwDBData
& rDBData
) :
84 SwValueFieldType( pDocPtr
, RES_DBFLD
),
89 if(aDBData
.sDataSource
.getLength() || aDBData
.sCommand
.getLength())
91 sName
= aDBData
.sDataSource
;
93 sName
+= (String
)aDBData
.sCommand
;
96 sName
+= GetColumnName();
98 //------------------------------------------------------------------------------
100 SwFieldType
* SwDBFieldType::Copy() const
102 SwDBFieldType
* pTmp
= new SwDBFieldType(GetDoc(), sColumn
, aDBData
);
106 //------------------------------------------------------------------------------
107 const String
& SwDBFieldType::GetName() const
112 //------------------------------------------------------------------------------
114 void SwDBFieldType::ReleaseRef()
116 ASSERT(nRefCnt
> 0, "RefCount kleiner 0!");
120 USHORT nPos
= GetDoc()->GetFldTypes()->GetPos(this);
122 if (nPos
!= USHRT_MAX
)
124 GetDoc()->RemoveFldType(nPos
);
130 /* -----------------24.02.99 14:51-------------------
132 * --------------------------------------------------*/
133 BOOL
SwDBFieldType::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
137 case FIELD_PROP_PAR1
:
138 rAny
<<= aDBData
.sDataSource
;
140 case FIELD_PROP_PAR2
:
141 rAny
<<= aDBData
.sCommand
;
143 case FIELD_PROP_PAR3
:
144 rAny
<<= OUString(sColumn
);
146 case FIELD_PROP_SHORT1
:
147 rAny
<<= aDBData
.nCommandType
;
150 DBG_ERROR("illegal property");
154 /* -----------------24.02.99 14:51-------------------
156 * --------------------------------------------------*/
157 BOOL
SwDBFieldType::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
161 case FIELD_PROP_PAR1
:
162 rAny
>>= aDBData
.sDataSource
;
164 case FIELD_PROP_PAR2
:
165 rAny
>>= aDBData
.sCommand
;
167 case FIELD_PROP_PAR3
:
170 ::GetString( rAny
, sTmp
);
171 if( sTmp
!= sColumn
)
174 SwClientIter
aIter( *this );
175 SwFmtFld
* pFld
= (SwFmtFld
*)aIter
.First( TYPE( SwFmtFld
));
179 SwTxtFld
*pTxtFld
= pFld
->GetTxtFld();
180 if(pTxtFld
&& pTxtFld
->GetTxtNode().GetNodes().IsDocNodes() )
182 SwDBField
* pDBField
= (SwDBField
*)pFld
->GetFld();
183 pDBField
->ClearInitialized();
184 pDBField
->InitContent();
186 pFld
= (SwFmtFld
*)aIter
.Next();
191 case FIELD_PROP_SHORT1
:
192 rAny
>>= aDBData
.nCommandType
;
195 DBG_ERROR("illegal property");
199 /*--------------------------------------------------------------------
200 Beschreibung: SwDBField
201 --------------------------------------------------------------------*/
203 SwDBField::SwDBField(SwDBFieldType
* pTyp
, ULONG nFmt
)
204 : SwValueField(pTyp
, nFmt
),
211 ((SwDBFieldType
*)GetTyp())->AddRef();
215 //------------------------------------------------------------------------------
217 SwDBField::~SwDBField()
220 ((SwDBFieldType
*)GetTyp())->ReleaseRef();
223 //------------------------------------------------------------------------------
225 void SwDBField::InitContent()
227 if (!IsInitialized())
230 aContent
+= ((SwDBFieldType
*)GetTyp())->GetColumnName();
235 //------------------------------------------------------------------------------
237 void SwDBField::InitContent(const String
& rExpansion
)
239 if (rExpansion
.Len() > 2)
241 if (rExpansion
.GetChar(0) == '<' &&
242 rExpansion
.GetChar(rExpansion
.Len() - 1) == '>')
244 String
sColumn( rExpansion
.Copy( 1, rExpansion
.Len() - 2 ) );
245 if( ::GetAppCmpStrIgnore().isEqual( sColumn
,
246 ((SwDBFieldType
*)GetTyp())->GetColumnName() ))
253 SetExpansion( rExpansion
);
256 //------------------------------------------------------------------------------
258 String
SwDBField::Expand() const
262 if(0 ==(GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE
))
263 sRet
= lcl_DBTrennConv(aContent
);
267 //------------------------------------------------------------------------------
269 SwField
* SwDBField::Copy() const
271 SwDBField
*pTmp
= new SwDBField((SwDBFieldType
*)GetTyp(), GetFormat());
272 pTmp
->aContent
= aContent
;
273 pTmp
->bIsInBodyTxt
= bIsInBodyTxt
;
274 pTmp
->bValidValue
= bValidValue
;
275 pTmp
->bInitialized
= bInitialized
;
276 pTmp
->nSubType
= nSubType
;
277 pTmp
->SetValue(GetValue());
278 pTmp
->sFieldCode
= sFieldCode
;
283 String
SwDBField::GetCntnt(BOOL bName
) const
287 const String
& rDBName
= ((SwDBFieldType
*)GetTyp())->GetName();
289 //Funktion tut nichts!
290 //String sContent( SFX_APP()->LocalizeDBName(INI2NATIONAL,
291 // rDBName.GetToken(0, DB_DELIM)));
292 String
sContent( rDBName
.GetToken(0, DB_DELIM
) );
294 if (sContent
.Len() > 1)
296 sContent
+= DB_DELIM
;
297 sContent
+= rDBName
.GetToken(1, DB_DELIM
);
298 sContent
+= DB_DELIM
;
299 sContent
+= rDBName
.GetToken(2, DB_DELIM
);
301 return lcl_DBTrennConv(sContent
);
306 //------------------------------------------------------------------------------
308 void SwDBField::ChgValue( double d
, BOOL bVal
)
314 aContent
= ((SwValueFieldType
*)GetTyp())->ExpandValue(d
, GetFormat(), GetLanguage());
317 /*--------------------------------------------------------------------
319 --------------------------------------------------------------------*/
321 SwFieldType
* SwDBField::ChgTyp( SwFieldType
* pNewType
)
323 SwFieldType
* pOld
= SwValueField::ChgTyp( pNewType
);
325 ((SwDBFieldType
*)pNewType
)->AddRef();
326 ((SwDBFieldType
*)pOld
)->ReleaseRef();
331 /*--------------------------------------------------------------------
332 Beschreibung: Aktuellen Field-Value holen und chachen
333 --------------------------------------------------------------------*/
335 void SwDBField::Evaluate()
337 SwNewDBMgr
* pMgr
= GetDoc()->GetNewDBMgr();
341 double nValue
= DBL_MAX
;
342 const SwDBData
& aTmpData
= GetDBData();
344 if(!pMgr
|| !pMgr
->IsDataSourceOpen(aTmpData
.sDataSource
, aTmpData
.sCommand
, sal_True
))
349 // Passenden Spaltennamen suchen
350 String
aColNm( ((SwDBFieldType
*)GetTyp())->GetColumnName() );
352 SvNumberFormatter
* pDocFormatter
= GetDoc()->GetNumberFormatter();
353 pMgr
->GetMergeColumnCnt(aColNm
, GetLanguage(), aContent
, &nValue
, &nFmt
);
354 if( !( nSubType
& nsSwExtendedSubType::SUB_OWN_FMT
) )
355 SetFormat( nFmt
= pMgr
->GetColumnFmt( aTmpData
.sDataSource
, aTmpData
.sCommand
,
356 aColNm
, pDocFormatter
, GetLanguage() ));
358 if( DBL_MAX
!= nValue
)
360 sal_Int32 nColumnType
= pMgr
->GetColumnType(aTmpData
.sDataSource
, aTmpData
.sCommand
, aColNm
);
361 if( DataType::DATE
== nColumnType
|| DataType::TIME
== nColumnType
||
362 DataType::TIMESTAMP
== nColumnType
)
365 Date
aStandard(1,1,1900);
366 if (*pDocFormatter
->GetNullDate() != aStandard
)
367 nValue
+= (aStandard
- *pDocFormatter
->GetNullDate());
371 aContent
= ((SwValueFieldType
*)GetTyp())->ExpandValue(nValue
, GetFormat(), GetLanguage());
376 aVal
.PutString( aContent
);
378 if (aVal
.IsNumeric())
380 SetValue(aVal
.GetDouble());
382 SvNumberFormatter
* pFormatter
= GetDoc()->GetNumberFormatter();
383 if (nFmt
&& nFmt
!= SAL_MAX_UINT32
&& !pFormatter
->IsTextFormat(nFmt
))
384 bValidValue
= TRUE
; // Wegen Bug #60339 nicht mehr bei allen Strings
388 // Bei Strings TRUE wenn Laenge > 0 sonst FALSE
389 SetValue(aContent
.Len() ? 1 : 0);
395 /*--------------------------------------------------------------------
396 Beschreibung: Namen erfragen
397 --------------------------------------------------------------------*/
399 const String
& SwDBField::GetPar1() const
401 return ((SwDBFieldType
*)GetTyp())->GetName();
404 /*--------------------------------------------------------------------
406 --------------------------------------------------------------------*/
408 USHORT
SwDBField::GetSubType() const
413 /*--------------------------------------------------------------------
415 --------------------------------------------------------------------*/
417 void SwDBField::SetSubType(USHORT nType
)
422 /*-----------------06.03.98 16:15-------------------
424 --------------------------------------------------*/
425 BOOL
SwDBField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
429 case FIELD_PROP_BOOL1
:
431 BOOL bTemp
= 0 == (GetSubType()&nsSwExtendedSubType::SUB_OWN_FMT
);
432 rAny
.setValue(&bTemp
, ::getBooleanCppuType());
435 case FIELD_PROP_BOOL2
:
437 sal_Bool bVal
= 0 == (GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE
);
438 rAny
.setValue(&bVal
, ::getBooleanCppuType());
441 case FIELD_PROP_FORMAT
:
442 rAny
<<= (sal_Int32
)GetFormat();
444 case FIELD_PROP_PAR1
:
445 rAny
<<= OUString(aContent
);
447 case FIELD_PROP_PAR2
:
448 rAny
<<= OUString(sFieldCode
);
451 DBG_ERROR("illegal property");
456 /*-----------------06.03.98 16:15-------------------
458 --------------------------------------------------*/
459 BOOL
SwDBField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
463 case FIELD_PROP_BOOL1
:
464 if( *(sal_Bool
*)rAny
.getValue() )
465 SetSubType(GetSubType()&~nsSwExtendedSubType::SUB_OWN_FMT
);
467 SetSubType(GetSubType()|nsSwExtendedSubType::SUB_OWN_FMT
);
469 case FIELD_PROP_BOOL2
:
471 USHORT nSubTyp
= GetSubType();
472 sal_Bool bVisible
= sal_False
;
473 if(!(rAny
>>= bVisible
))
476 nSubTyp
&= ~nsSwExtendedSubType::SUB_INVISIBLE
;
478 nSubTyp
|= nsSwExtendedSubType::SUB_INVISIBLE
;
480 //invalidate text node
483 SwClientIter
aIter( *GetTyp() );
484 SwFmtFld
* pFld
= (SwFmtFld
*)aIter
.First( TYPE( SwFmtFld
));
487 SwTxtFld
*pTxtFld
= pFld
->GetTxtFld();
488 if(pTxtFld
&& (SwDBField
*)pFld
->GetFld() == this )
491 pTxtFld
->NotifyContentChange(*pFld
);
494 pFld
= (SwFmtFld
*)aIter
.Next();
499 case FIELD_PROP_FORMAT
:
506 case FIELD_PROP_PAR1
:
507 ::GetString( rAny
, aContent
);
509 case FIELD_PROP_PAR2
:
510 ::GetString( rAny
, sFieldCode
);
513 DBG_ERROR("illegal property");
518 /*--------------------------------------------------------------------
519 Beschreibung: Basisklasse fuer alle weiteren Datenbankfelder
520 --------------------------------------------------------------------*/
522 SwDBNameInfField::SwDBNameInfField(SwFieldType
* pTyp
, const SwDBData
& rDBData
, ULONG nFmt
) :
529 //------------------------------------------------------------------------------
531 SwDBData
SwDBNameInfField::GetDBData(SwDoc
* pDoc
)
534 if(aDBData
.sDataSource
.getLength())
537 aRet
= pDoc
->GetDBData();
542 void SwDBNameInfField::SetDBData(const SwDBData
& rDBData
)
547 //------------------------------------------------------------------------------
549 String
SwDBNameInfField::GetCntnt(BOOL bName
) const
551 String
sStr(SwField::GetCntnt(bName
));
555 if (aDBData
.sDataSource
.getLength())
558 sStr
+= String(aDBData
.sDataSource
);
560 sStr
+= String(aDBData
.sCommand
);
563 return lcl_DBTrennConv(sStr
);
566 /*-----------------06.03.98 16:55-------------------
568 --------------------------------------------------*/
569 BOOL
SwDBNameInfField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
573 case FIELD_PROP_PAR1
:
574 rAny
<<= aDBData
.sDataSource
;
576 case FIELD_PROP_PAR2
:
577 rAny
<<= aDBData
.sCommand
;
579 case FIELD_PROP_SHORT1
:
580 rAny
<<= aDBData
.nCommandType
;
582 case FIELD_PROP_BOOL2
:
584 sal_Bool bVal
= 0 == (GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE
);
585 rAny
.setValue(&bVal
, ::getBooleanCppuType());
589 DBG_ERROR("illegal property");
593 /*-----------------06.03.98 16:55-------------------
595 --------------------------------------------------*/
596 BOOL
SwDBNameInfField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
600 case FIELD_PROP_PAR1
:
601 rAny
>>= aDBData
.sDataSource
;
603 case FIELD_PROP_PAR2
:
604 rAny
>>= aDBData
.sCommand
;
606 case FIELD_PROP_SHORT1
:
607 rAny
>>= aDBData
.nCommandType
;
609 case FIELD_PROP_BOOL2
:
611 USHORT nSubTyp
= GetSubType();
612 sal_Bool bVisible
= sal_False
;
613 if(!(rAny
>>= bVisible
))
616 nSubTyp
&= ~nsSwExtendedSubType::SUB_INVISIBLE
;
618 nSubTyp
|= nsSwExtendedSubType::SUB_INVISIBLE
;
623 DBG_ERROR("illegal property");
627 /* -----------------4/10/2003 15:03------------------
629 --------------------------------------------------*/
630 USHORT
SwDBNameInfField::GetSubType() const
634 /* -----------------4/10/2003 15:03------------------
636 --------------------------------------------------*/
637 void SwDBNameInfField::SetSubType(USHORT nType
)
642 /*--------------------------------------------------------------------
643 Beschreibung: NaechsterDatensatz
644 --------------------------------------------------------------------*/
646 SwDBNextSetFieldType::SwDBNextSetFieldType()
647 : SwFieldType( RES_DBNEXTSETFLD
)
651 //------------------------------------------------------------------------------
653 SwFieldType
* SwDBNextSetFieldType::Copy() const
655 SwDBNextSetFieldType
* pTmp
= new SwDBNextSetFieldType();
658 /*--------------------------------------------------------------------
659 Beschreibung: SwDBSetField
660 --------------------------------------------------------------------*/
662 SwDBNextSetField::SwDBNextSetField(SwDBNextSetFieldType
* pTyp
,
665 const SwDBData
& rDBData
) :
666 SwDBNameInfField(pTyp
, rDBData
), aCond(rCond
), bCondValid(TRUE
)
669 //------------------------------------------------------------------------------
671 String
SwDBNextSetField::Expand() const
676 //------------------------------------------------------------------------------
678 SwField
* SwDBNextSetField::Copy() const
680 SwDBNextSetField
*pTmp
= new SwDBNextSetField((SwDBNextSetFieldType
*)GetTyp(),
681 aCond
, aEmptyStr
, GetDBData());
682 pTmp
->SetSubType(GetSubType());
683 pTmp
->bCondValid
= bCondValid
;
686 //------------------------------------------------------------------------------
688 void SwDBNextSetField::Evaluate(SwDoc
* pDoc
)
690 SwNewDBMgr
* pMgr
= pDoc
->GetNewDBMgr();
691 const SwDBData
& rData
= GetDBData();
693 !pMgr
|| !pMgr
->IsDataSourceOpen(rData
.sDataSource
, rData
.sCommand
, sal_False
))
695 pMgr
->ToNextRecord(rData
.sDataSource
, rData
.sCommand
);
698 /*--------------------------------------------------------------------
699 Beschreibung: Bedingung
700 --------------------------------------------------------------------*/
702 const String
& SwDBNextSetField::GetPar1() const
707 void SwDBNextSetField::SetPar1(const String
& rStr
)
711 /*-----------------06.03.98 16:16-------------------
713 --------------------------------------------------*/
714 BOOL
SwDBNextSetField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
719 case FIELD_PROP_PAR3
:
720 rAny
<<= OUString(aCond
);
723 bRet
= SwDBNameInfField::QueryValue( rAny
, nWhichId
);
727 /*-----------------06.03.98 16:16-------------------
729 --------------------------------------------------*/
730 BOOL
SwDBNextSetField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
735 case FIELD_PROP_PAR3
:
736 ::GetString( rAny
, aCond
);
739 bRet
= SwDBNameInfField::PutValue( rAny
, nWhichId
);
744 /*--------------------------------------------------------------------
746 --------------------------------------------------------------------*/
748 String SwDBNextSetField::GetPar2() const
753 void SwDBNextSetField::SetPar2(const String& rStr)
759 /*--------------------------------------------------------------------
760 Beschreibung: Datensatz mit bestimmter ID
761 --------------------------------------------------------------------*/
763 SwDBNumSetFieldType::SwDBNumSetFieldType() :
764 SwFieldType( RES_DBNUMSETFLD
)
768 //------------------------------------------------------------------------------
770 SwFieldType
* SwDBNumSetFieldType::Copy() const
772 SwDBNumSetFieldType
* pTmp
= new SwDBNumSetFieldType();
776 /*--------------------------------------------------------------------
777 Beschreibung: SwDBSetField
778 --------------------------------------------------------------------*/
780 SwDBNumSetField::SwDBNumSetField(SwDBNumSetFieldType
* pTyp
,
782 const String
& rDBNum
,
783 const SwDBData
& rDBData
) :
784 SwDBNameInfField(pTyp
, rDBData
),
790 //------------------------------------------------------------------------------
792 String
SwDBNumSetField::Expand() const
797 //------------------------------------------------------------------------------
799 SwField
* SwDBNumSetField::Copy() const
801 SwDBNumSetField
*pTmp
= new SwDBNumSetField((SwDBNumSetFieldType
*)GetTyp(),
802 aCond
, aPar2
, GetDBData());
803 pTmp
->bCondValid
= bCondValid
;
804 pTmp
->SetSubType(GetSubType());
808 void SwDBNumSetField::Evaluate(SwDoc
* pDoc
)
810 SwNewDBMgr
* pMgr
= pDoc
->GetNewDBMgr();
811 const SwDBData
& aTmpData
= GetDBData();
813 if( bCondValid
&& pMgr
&& pMgr
->IsInMerge() &&
814 pMgr
->IsDataSourceOpen(aTmpData
.sDataSource
, aTmpData
.sCommand
, sal_True
))
815 { // Bedingug OK -> aktuellen Set einstellen
816 pMgr
->ToRecordId(Max((USHORT
)aPar2
.ToInt32(), USHORT(1))-1);
820 /*--------------------------------------------------------------------
821 Beschreibung: LogDBName
822 --------------------------------------------------------------------*/
824 const String
& SwDBNumSetField::GetPar1() const
829 void SwDBNumSetField::SetPar1(const String
& rStr
)
834 /*--------------------------------------------------------------------
835 Beschreibung: Bedingung
836 --------------------------------------------------------------------*/
838 String
SwDBNumSetField::GetPar2() const
843 void SwDBNumSetField::SetPar2(const String
& rStr
)
847 /*-----------------06.03.98 16:16-------------------
849 --------------------------------------------------*/
850 BOOL
SwDBNumSetField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
855 case FIELD_PROP_PAR3
:
856 rAny
<<= OUString(aCond
);
858 case FIELD_PROP_FORMAT
:
859 rAny
<<= (sal_Int32
)aPar2
.ToInt32();
862 bRet
= SwDBNameInfField::QueryValue(rAny
, nWhichId
);
866 /*-----------------06.03.98 16:16-------------------
868 --------------------------------------------------*/
869 BOOL
SwDBNumSetField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
874 case FIELD_PROP_PAR3
:
875 ::GetString( rAny
, aCond
);
877 case FIELD_PROP_FORMAT
:
881 aPar2
= String::CreateFromInt32(nVal
);
885 bRet
= SwDBNameInfField::PutValue(rAny
, nWhichId
);
890 /*--------------------------------------------------------------------
891 Beschreibung: SwDBNameFieldType
892 --------------------------------------------------------------------*/
894 SwDBNameFieldType::SwDBNameFieldType(SwDoc
* pDocument
)
895 : SwFieldType( RES_DBNAMEFLD
)
899 //------------------------------------------------------------------------------
901 String
SwDBNameFieldType::Expand(ULONG
) const
903 const SwDBData aData
= pDoc
->GetDBData();
904 String
sRet(aData
.sDataSource
);
906 sRet
+= (String
)aData
.sCommand
;
909 //------------------------------------------------------------------------------
911 SwFieldType
* SwDBNameFieldType::Copy() const
913 SwDBNameFieldType
*pTmp
= new SwDBNameFieldType(pDoc
);
917 //------------------------------------------------------------------------------
919 /*--------------------------------------------------------------------
920 Beschreibung: Name der angedockten DB
921 --------------------------------------------------------------------*/
923 SwDBNameField::SwDBNameField(SwDBNameFieldType
* pTyp
, const SwDBData
& rDBData
, ULONG nFmt
)
924 : SwDBNameInfField(pTyp
, rDBData
, nFmt
)
927 //------------------------------------------------------------------------------
929 String
SwDBNameField::Expand() const
932 if(0 ==(GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE
))
933 sRet
= ((SwDBNameFieldType
*)GetTyp())->Expand(GetFormat());
937 //------------------------------------------------------------------------------
939 SwField
* SwDBNameField::Copy() const
941 SwDBNameField
*pTmp
= new SwDBNameField((SwDBNameFieldType
*)GetTyp(), GetDBData());
942 pTmp
->ChangeFormat(GetFormat());
943 pTmp
->SetLanguage(GetLanguage());
944 pTmp
->SetSubType(GetSubType());
948 /*-----------------06.03.98 16:16-------------------
950 --------------------------------------------------*/
951 BOOL
SwDBNameField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
953 return SwDBNameInfField::QueryValue(rAny
, nWhichId
);
955 /*-----------------06.03.98 16:16-------------------
957 --------------------------------------------------*/
958 BOOL
SwDBNameField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
960 return SwDBNameInfField::PutValue(rAny
, nWhichId
);
962 /*--------------------------------------------------------------------
963 Beschreibung: SwDBNameFieldType
964 --------------------------------------------------------------------*/
966 SwDBSetNumberFieldType::SwDBSetNumberFieldType()
967 : SwFieldType( RES_DBSETNUMBERFLD
)
971 //------------------------------------------------------------------------------
973 SwFieldType
* SwDBSetNumberFieldType::Copy() const
975 SwDBSetNumberFieldType
*pTmp
= new SwDBSetNumberFieldType
;
979 //------------------------------------------------------------------------------
981 /*--------------------------------------------------------------------
982 Beschreibung: SetNumber der angedockten DB
983 --------------------------------------------------------------------*/
985 SwDBSetNumberField::SwDBSetNumberField(SwDBSetNumberFieldType
* pTyp
,
986 const SwDBData
& rDBData
,
988 : SwDBNameInfField(pTyp
, rDBData
, nFmt
), nNumber(0)
991 //------------------------------------------------------------------------------
993 String
SwDBSetNumberField::Expand() const
995 if(0 !=(GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE
) || nNumber
== 0)
998 return FormatNumber((USHORT
)nNumber
, GetFormat());
999 //return(nNumber == 0 ? aEmptyStr : FormatNumber(nNumber, GetFormat()));
1002 //------------------------------------------------------------------------------
1004 void SwDBSetNumberField::Evaluate(SwDoc
* pDoc
)
1006 SwNewDBMgr
* pMgr
= pDoc
->GetNewDBMgr();
1008 const SwDBData
& aTmpData
= GetDBData();
1009 if (!pMgr
|| !pMgr
->IsInMerge() ||
1010 !pMgr
->IsDataSourceOpen(aTmpData
.sDataSource
, aTmpData
.sCommand
, sal_False
))
1012 nNumber
= pMgr
->GetSelectedRecordId();
1016 //------------------------------------------------------------------------------
1018 SwField
* SwDBSetNumberField::Copy() const
1020 SwDBSetNumberField
*pTmp
=
1021 new SwDBSetNumberField((SwDBSetNumberFieldType
*)GetTyp(), GetDBData(), GetFormat());
1022 pTmp
->SetLanguage(GetLanguage());
1023 pTmp
->SetSetNumber(nNumber
);
1024 pTmp
->SetSubType(GetSubType());
1027 /*-----------------06.03.98 16:15-------------------
1029 --------------------------------------------------*/
1030 BOOL
SwDBSetNumberField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
1035 case FIELD_PROP_USHORT1
:
1036 rAny
<<= (sal_Int16
)GetFormat();
1038 case FIELD_PROP_FORMAT
:
1042 bRet
= SwDBNameInfField::QueryValue( rAny
, nWhichId
);
1046 /*-----------------06.03.98 16:15-------------------
1048 --------------------------------------------------*/
1049 BOOL
SwDBSetNumberField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
1054 case FIELD_PROP_USHORT1
:
1058 if(nSet
< (INT16
) SVX_NUMBER_NONE
)
1061 //exception(wrong_value)
1066 case FIELD_PROP_FORMAT
:
1070 bRet
= SwDBNameInfField::PutValue( rAny
, nWhichId
);