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: docufld.cxx,v $
10 * $Revision: 1.51.16.5 $
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"
34 #include <textapi.hxx>
36 #include <tools/pstm.hxx>
37 #include <hintids.hxx>
38 #include <com/sun/star/text/XText.hpp>
39 #include <com/sun/star/script/XTypeConverter.hpp>
40 #include <com/sun/star/text/SetVariableType.hpp>
41 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
42 #include <com/sun/star/text/UserDataPart.hpp>
43 #include <com/sun/star/text/ChapterFormat.hpp>
44 #include <com/sun/star/text/XTextField.hpp>
45 #include <com/sun/star/text/PlaceholderType.hpp>
46 #include <com/sun/star/text/TemplateDisplayFormat.hpp>
47 #include <com/sun/star/text/UserFieldFormat.hpp>
48 #include <com/sun/star/text/PageNumberType.hpp>
49 #include <com/sun/star/text/ReferenceFieldPart.hpp>
50 #ifndef _COM_SUN_STAR_TEXT_FilenameDisplayFormat_HPP_
51 #include <com/sun/star/text/FilenameDisplayFormat.hpp>
53 #include <com/sun/star/text/XDependentTextField.hpp>
54 #include <com/sun/star/text/DocumentStatistic.hpp>
55 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
56 #include <com/sun/star/document/XDocumentProperties.hpp>
57 #include <com/sun/star/util/Date.hpp>
58 #include <unotools/localedatawrapper.hxx>
59 #include <svx/unolingu.hxx>
60 #include <comphelper/processfactory.hxx>
61 #include <comphelper/types.hxx>
62 #include <comphelper/string.hxx>
63 #include <tools/urlobj.hxx>
64 #ifndef _APP_HXX //autogen
65 #include <vcl/svapp.hxx>
67 #include <svtools/urihelper.hxx>
68 #include <svtools/useroptions.hxx>
69 #include <svtools/syslocale.hxx>
71 #include <tools/time.hxx>
72 #include <tools/datetime.hxx>
74 #include <com/sun/star/beans/PropertyAttribute.hpp>
76 #include <tools/shl.hxx>
77 #include <swmodule.hxx>
78 #include <sfx2/app.hxx>
79 #include <sfx2/docfile.hxx>
80 #include <sfx2/doctempl.hxx>
83 #include <charfmt.hxx>
84 #include <docstat.hxx>
85 #include <pagedesc.hxx>
86 #include <fmtpdsc.hxx>
88 #include <rootfrm.hxx> // AuthorField
89 #include <pagefrm.hxx> //
90 #include <cntfrm.hxx> //
96 #include <shellres.hxx>
97 #include <docufld.hxx>
101 #include <expfld.hxx>
102 #include <poolfmt.hxx>
107 #include <unofldmid.h>
109 #include <swunohelper.hxx>
111 #include <comcore.hrc>
114 #include <svx/outliner.hxx>
115 #include <svx/outlobj.hxx>
117 #define URL_DECODE INetURLObject::DECODE_UNAMBIGUOUS
119 using ::rtl::OUString
;
120 using namespace ::com::sun::star
;
121 using namespace ::com::sun::star::uno
;
122 using namespace nsSwDocInfoSubType
;
124 /*--------------------------------------------------------------------
125 Beschreibung: SwPageNumberFieldType
126 --------------------------------------------------------------------*/
128 SwPageNumberFieldType::SwPageNumberFieldType()
129 : SwFieldType( RES_PAGENUMBERFLD
),
130 nNumberingType( SVX_NUM_ARABIC
),
133 bVirtuell( sal_False
)
137 String
& SwPageNumberFieldType::Expand( sal_uInt32 nFmt
, short nOff
,
138 const String
& rUserStr
, String
& rRet
) const
140 sal_uInt32 nTmpFmt
= (SVX_NUM_PAGEDESC
== nFmt
) ? (sal_uInt32
)nNumberingType
: nFmt
;
141 long nTmp
= nNum
+ nOff
;
143 if( 0 >= nTmp
|| SVX_NUM_NUMBER_NONE
== nTmpFmt
|| (!bVirtuell
&& nTmp
> nMax
) )
145 else if( SVX_NUM_CHAR_SPECIAL
== nTmpFmt
)
148 rRet
= FormatNumber( (sal_uInt16
)nTmp
, nTmpFmt
);
152 SwFieldType
* SwPageNumberFieldType::Copy() const
154 SwPageNumberFieldType
*pTmp
= new SwPageNumberFieldType();
158 pTmp
->nNumberingType
= nNumberingType
;
159 pTmp
->bVirtuell
= bVirtuell
;
164 /*--------------------------------------------------------------------
165 Beschreibung: Verschiedene Expandierung
166 --------------------------------------------------------------------*/
168 void SwPageNumberFieldType::ChangeExpansion( SwDoc
* pDoc
, sal_uInt16 nPage
,
169 sal_uInt16 nNumPages
, sal_Bool bVirt
,
170 const sal_Int16
* pNumFmt
)
175 nNumberingType
= *pNumFmt
;
177 bVirtuell
= sal_False
;
180 // dann muss das Flag ueberprueft werden, denn das Layout setzt
182 const SfxItemPool
&rPool
= pDoc
->GetAttrPool();
183 const SwFmtPageDesc
*pDesc
;
184 sal_uInt16 nMaxItems
= rPool
.GetItemCount( RES_PAGEDESC
);
185 for( sal_uInt16 n
= 0; n
< nMaxItems
; ++n
)
186 if( 0 != (pDesc
= (SwFmtPageDesc
*)rPool
.GetItem( RES_PAGEDESC
, n
) )
187 && pDesc
->GetNumOffset() && pDesc
->GetDefinedIn() )
189 if( pDesc
->GetDefinedIn()->ISA( SwCntntNode
))
191 SwClientIter
aIter( *(SwModify
*)pDesc
->GetDefinedIn() );
192 if( aIter
.First( TYPE( SwFrm
) ) )
194 bVirtuell
= sal_True
;
198 else if( pDesc
->GetDefinedIn()->ISA( SwFmt
))
200 SwAutoFmtGetDocNode
aGetHt( &pDoc
->GetNodes() );
201 bVirtuell
= !pDesc
->GetDefinedIn()->GetInfo( aGetHt
);
208 /*--------------------------------------------------------------------
209 Beschreibung: SwPageNumberField
210 --------------------------------------------------------------------*/
212 SwPageNumberField::SwPageNumberField(SwPageNumberFieldType
* pTyp
,
213 sal_uInt16 nSub
, sal_uInt32 nFmt
, short nOff
)
214 : SwField(pTyp
, nFmt
), nSubType(nSub
), nOffset(nOff
)
218 String
SwPageNumberField::Expand() const
221 SwPageNumberFieldType
* pFldType
= (SwPageNumberFieldType
*)GetTyp();
223 if( PG_NEXT
== nSubType
&& 1 != nOffset
)
225 if( pFldType
->Expand( GetFormat(), 1, sUserStr
, sRet
).Len() )
226 pFldType
->Expand( GetFormat(), nOffset
, sUserStr
, sRet
);
228 else if( PG_PREV
== nSubType
&& -1 != nOffset
)
230 if( pFldType
->Expand( GetFormat(), -1, sUserStr
, sRet
).Len() )
231 pFldType
->Expand( GetFormat(), nOffset
, sUserStr
, sRet
);
234 pFldType
->Expand( GetFormat(), nOffset
, sUserStr
, sRet
);
238 SwField
* SwPageNumberField::Copy() const
240 SwPageNumberField
*pTmp
=
241 new SwPageNumberField((SwPageNumberFieldType
*)GetTyp(), nSubType
, GetFormat(), nOffset
);
242 pTmp
->SetLanguage( GetLanguage() );
243 pTmp
->SetUserString( sUserStr
);
247 String
SwPageNumberField::GetPar2() const
249 return String::CreateFromInt32(nOffset
);
252 void SwPageNumberField::SetPar2(const String
& rStr
)
254 nOffset
= (short)rStr
.ToInt32();
257 sal_uInt16
SwPageNumberField::GetSubType() const
262 /*-----------------05.03.98 10:25-------------------
264 --------------------------------------------------*/
265 BOOL
SwPageNumberField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
269 case FIELD_PROP_FORMAT
:
270 rAny
<<= (sal_Int16
)GetFormat();
272 case FIELD_PROP_USHORT1
:
275 case FIELD_PROP_SUBTYPE
:
277 text::PageNumberType eType
;
278 eType
= text::PageNumberType_CURRENT
;
279 if(nSubType
== PG_PREV
)
280 eType
= text::PageNumberType_PREV
;
281 else if(nSubType
== PG_NEXT
)
282 eType
= text::PageNumberType_NEXT
;
283 rAny
.setValue(&eType
, ::getCppuType((const text::PageNumberType
*)0));
286 case FIELD_PROP_PAR1
:
287 rAny
<<= OUString(sUserStr
);
291 DBG_ERROR("illegal property");
295 /*-----------------05.03.98 10:25-------------------
297 --------------------------------------------------*/
298 BOOL
SwPageNumberField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
304 case FIELD_PROP_FORMAT
:
307 // TODO: woher kommen die defines?
308 if(nSet
<= SVX_NUM_PAGEDESC
)
311 //exception(wrong_value)
315 case FIELD_PROP_USHORT1
:
319 case FIELD_PROP_SUBTYPE
:
320 switch( SWUnoHelper::GetEnumAsInt32( rAny
) )
322 case text::PageNumberType_CURRENT
:
323 nSubType
= PG_RANDOM
;
325 case text::PageNumberType_PREV
:
328 case text::PageNumberType_NEXT
:
335 case FIELD_PROP_PAR1
:
336 ::GetString( rAny
, sUserStr
);
340 DBG_ERROR("illegal property");
344 /*--------------------------------------------------------------------
345 Beschreibung: SwAuthorFieldType
346 --------------------------------------------------------------------*/
348 SwAuthorFieldType::SwAuthorFieldType()
349 : SwFieldType( RES_AUTHORFLD
)
353 String
SwAuthorFieldType::Expand(ULONG nFmt
) const
356 SvtUserOptions
& rOpt
= SW_MOD()->GetUserOptions();
357 if((nFmt
& 0xff) == AF_NAME
)
358 sRet
= rOpt
.GetFullName();
364 SwFieldType
* SwAuthorFieldType::Copy() const
366 return new SwAuthorFieldType
;
369 /*--------------------------------------------------------------------
370 Beschreibung: SwAuthorField
371 --------------------------------------------------------------------*/
373 SwAuthorField::SwAuthorField(SwAuthorFieldType
* pTyp
, sal_uInt32 nFmt
)
374 : SwField(pTyp
, nFmt
)
376 aContent
= ((SwAuthorFieldType
*)GetTyp())->Expand(GetFormat());
379 String
SwAuthorField::Expand() const
382 ((SwAuthorField
*)this)->aContent
=
383 ((SwAuthorFieldType
*)GetTyp())->Expand(GetFormat());
388 SwField
* SwAuthorField::Copy() const
390 SwAuthorField
*pTmp
= new SwAuthorField( (SwAuthorFieldType
*)GetTyp(),
392 pTmp
->SetExpansion(aContent
);
396 /*-----------------05.03.98 11:15-------------------
398 --------------------------------------------------*/
399 BOOL
SwAuthorField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
404 case FIELD_PROP_BOOL1
:
405 bVal
= (GetFormat() & 0xff) == AF_NAME
;
406 rAny
.setValue(&bVal
, ::getBooleanCppuType());
409 case FIELD_PROP_BOOL2
:
411 rAny
.setValue(&bVal
, ::getBooleanCppuType());
414 case FIELD_PROP_PAR1
:
415 rAny
<<= rtl::OUString(GetContent());
419 DBG_ERROR("illegal property");
423 /*-----------------05.03.98 11:15-------------------
425 --------------------------------------------------*/
426 BOOL
SwAuthorField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
430 case FIELD_PROP_BOOL1
:
431 SetFormat( *(sal_Bool
*)rAny
.getValue() ? AF_NAME
: AF_SHORTCUT
);
434 case FIELD_PROP_BOOL2
:
435 if( *(sal_Bool
*)rAny
.getValue() )
436 SetFormat( GetFormat() | AF_FIXED
);
438 SetFormat( GetFormat() & ~AF_FIXED
);
441 case FIELD_PROP_PAR1
:
442 ::GetString( rAny
, aContent
);
446 DBG_ERROR("illegal property");
451 /*--------------------------------------------------------------------
452 Beschreibung: SwFileNameFieldType
453 --------------------------------------------------------------------*/
455 SwFileNameFieldType::SwFileNameFieldType(SwDoc
*pDocument
)
456 : SwFieldType( RES_FILENAMEFLD
)
461 String
SwFileNameFieldType::Expand(ULONG nFmt
) const
464 const SwDocShell
* pDShell
= pDoc
->GetDocShell();
465 if( pDShell
&& pDShell
->HasName() )
467 const INetURLObject
& rURLObj
= pDShell
->GetMedium()->GetURLObject();
468 switch( nFmt
& ~FF_FIXED
)
472 if( INET_PROT_FILE
== rURLObj
.GetProtocol() )
474 INetURLObject
aTemp(rURLObj
);
475 aTemp
.removeSegment();
476 // #101947# last slash should belong to the pathname
477 aRet
= aTemp
.PathToFileName();//GetFull();
481 aRet
= URIHelper::removePassword(
482 rURLObj
.GetMainURL( INetURLObject::NO_DECODE
),
483 INetURLObject::WAS_ENCODED
, URL_DECODE
);
484 aRet
.Erase( aRet
.Search( String(rURLObj
.GetLastName(
491 aRet
= rURLObj
.GetLastName( URL_DECODE
);
495 aRet
= rURLObj
.GetBase();
499 if( INET_PROT_FILE
== rURLObj
.GetProtocol() )
500 aRet
= rURLObj
.GetFull();
502 aRet
= URIHelper::removePassword(
503 rURLObj
.GetMainURL( INetURLObject::NO_DECODE
),
504 INetURLObject::WAS_ENCODED
, URL_DECODE
);
510 SwFieldType
* SwFileNameFieldType::Copy() const
512 SwFieldType
*pTmp
= new SwFileNameFieldType(pDoc
);
515 /*--------------------------------------------------------------------
516 Beschreibung: SwFileNameField
517 --------------------------------------------------------------------*/
519 SwFileNameField::SwFileNameField(SwFileNameFieldType
* pTyp
, sal_uInt32 nFmt
)
520 : SwField(pTyp
, nFmt
)
522 aContent
= ((SwFileNameFieldType
*)GetTyp())->Expand(GetFormat());
525 String
SwFileNameField::Expand() const
528 ((SwFileNameField
*)this)->aContent
= ((SwFileNameFieldType
*)GetTyp())->Expand(GetFormat());
533 SwField
* SwFileNameField::Copy() const
535 SwFileNameField
*pTmp
=
536 new SwFileNameField((SwFileNameFieldType
*)GetTyp(), GetFormat());
537 pTmp
->SetExpansion(aContent
);
542 /*-----------------05.03.98 08:59-------------------
544 --------------------------------------------------*/
545 BOOL
SwFileNameField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
549 case FIELD_PROP_FORMAT
:
552 switch( GetFormat() &(~FF_FIXED
) )
555 nRet
= text::FilenameDisplayFormat::PATH
;
558 nRet
= text::FilenameDisplayFormat::NAME
;
561 nRet
= text::FilenameDisplayFormat::NAME_AND_EXT
;
563 default: nRet
= text::FilenameDisplayFormat::FULL
;
569 case FIELD_PROP_BOOL2
:
571 BOOL bVal
= IsFixed();
572 rAny
.setValue(&bVal
, ::getBooleanCppuType());
576 case FIELD_PROP_PAR3
:
577 rAny
<<= OUString(GetContent());
580 DBG_ERROR("illegal property");
584 /*-----------------05.03.98 09:01-------------------
586 --------------------------------------------------*/
587 BOOL
SwFileNameField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
591 case FIELD_PROP_FORMAT
:
593 //JP 24.10.2001: int32 because in UnoField.cxx a putvalue is
594 // called with a int32 value! But normally we need
598 BOOL bFixed
= IsFixed();
601 case text::FilenameDisplayFormat::PATH
:
604 case text::FilenameDisplayFormat::NAME
:
605 nType
= FF_NAME_NOEXT
;
607 case text::FilenameDisplayFormat::NAME_AND_EXT
:
610 default: nType
= FF_PATHNAME
;
618 case FIELD_PROP_BOOL2
:
619 if( *(sal_Bool
*)rAny
.getValue() )
620 SetFormat( GetFormat() | FF_FIXED
);
622 SetFormat( GetFormat() & ~FF_FIXED
);
625 case FIELD_PROP_PAR3
:
626 ::GetString( rAny
, aContent
);
630 DBG_ERROR("illegal property");
634 /*--------------------------------------------------------------------
635 Beschreibung: SwTemplNameFieldType
636 --------------------------------------------------------------------*/
638 SwTemplNameFieldType::SwTemplNameFieldType(SwDoc
*pDocument
)
639 : SwFieldType( RES_TEMPLNAMEFLD
)
644 String
SwTemplNameFieldType::Expand(ULONG nFmt
) const
646 ASSERT( nFmt
< FF_END
, "Expand: kein guelt. Fmt!" );
649 SwDocShell
*pDocShell(pDoc
->GetDocShell());
650 DBG_ASSERT(pDocShell
, "no SwDocShell");
652 uno::Reference
<document::XDocumentPropertiesSupplier
> xDPS(
653 pDocShell
->GetModel(), uno::UNO_QUERY_THROW
);
654 uno::Reference
<document::XDocumentProperties
> xDocProps(
655 xDPS
->getDocumentProperties());
656 DBG_ASSERT(xDocProps
.is(), "Doc has no DocumentProperties");
658 if( FF_UI_NAME
== nFmt
)
659 aRet
= xDocProps
->getTemplateName();
660 else if( !xDocProps
->getTemplateURL().equalsAscii("") )
662 if( FF_UI_RANGE
== nFmt
)
664 // fuers besorgen vom RegionNamen !!
665 SfxDocumentTemplates aFac
;
668 aFac
.GetLogicNames( xDocProps
->getTemplateURL(), aRet
, sTmp
);
672 INetURLObject
aPathName( xDocProps
->getTemplateURL() );
673 if( FF_NAME
== nFmt
)
674 aRet
= aPathName
.GetName(URL_DECODE
);
675 else if( FF_NAME_NOEXT
== nFmt
)
676 aRet
= aPathName
.GetBase();
679 if( FF_PATH
== nFmt
)
681 aPathName
.removeSegment();
682 aRet
= aPathName
.GetFull();
685 aRet
= aPathName
.GetFull();
693 SwFieldType
* SwTemplNameFieldType::Copy() const
695 SwFieldType
*pTmp
= new SwTemplNameFieldType(pDoc
);
698 /*--------------------------------------------------------------------
699 Beschreibung: SwTemplNameField
700 --------------------------------------------------------------------*/
702 SwTemplNameField::SwTemplNameField(SwTemplNameFieldType
* pTyp
, sal_uInt32 nFmt
)
703 : SwField(pTyp
, nFmt
)
706 String
SwTemplNameField::Expand() const
708 return((SwTemplNameFieldType
*)GetTyp())->Expand(GetFormat());
711 SwField
* SwTemplNameField::Copy() const
713 SwTemplNameField
*pTmp
=
714 new SwTemplNameField((SwTemplNameFieldType
*)GetTyp(), GetFormat());
718 /*-----------------05.03.98 08:59-------------------
720 --------------------------------------------------*/
721 BOOL
SwTemplNameField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
725 case FIELD_PROP_FORMAT
:
728 switch( GetFormat() )
730 case FF_PATH
: nRet
= text::FilenameDisplayFormat::PATH
; break;
731 case FF_NAME_NOEXT
: nRet
= text::FilenameDisplayFormat::NAME
; break;
732 case FF_NAME
: nRet
= text::FilenameDisplayFormat::NAME_AND_EXT
; break;
733 case FF_UI_RANGE
: nRet
= text::TemplateDisplayFormat::AREA
; break;
734 case FF_UI_NAME
: nRet
= text::TemplateDisplayFormat::TITLE
; break;
735 default: nRet
= text::FilenameDisplayFormat::FULL
;
742 DBG_ERROR("illegal property");
746 /*-----------------05.03.98 09:01-------------------
748 --------------------------------------------------*/
749 BOOL
SwTemplNameField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
753 case FIELD_PROP_FORMAT
:
755 //JP 24.10.2001: int32 because in UnoField.cxx a putvalue is
756 // called with a int32 value! But normally we need
762 case text::FilenameDisplayFormat::PATH
:
765 case text::FilenameDisplayFormat::NAME
:
766 SetFormat(FF_NAME_NOEXT
);
768 case text::FilenameDisplayFormat::NAME_AND_EXT
:
771 case text::TemplateDisplayFormat::AREA
:
772 SetFormat(FF_UI_RANGE
);
774 case text::TemplateDisplayFormat::TITLE
:
775 SetFormat(FF_UI_NAME
);
777 default: SetFormat(FF_PATHNAME
);
782 DBG_ERROR("illegal property");
786 /*--------------------------------------------------------------------
787 Beschreibung: SwDocStatFieldType
788 --------------------------------------------------------------------*/
790 SwDocStatFieldType::SwDocStatFieldType(SwDoc
* pDocument
)
791 : SwFieldType( RES_DOCSTATFLD
), nNumberingType( SVX_NUM_ARABIC
)
796 String
SwDocStatFieldType::Expand(sal_uInt16 nSubType
, sal_uInt32 nFmt
) const
799 const SwDocStat
& rDStat
= pDoc
->GetDocStat();
802 case DS_TBL
: nVal
= rDStat
.nTbl
; break;
803 case DS_GRF
: nVal
= rDStat
.nGrf
; break;
804 case DS_OLE
: nVal
= rDStat
.nOLE
; break;
805 case DS_PARA
: nVal
= rDStat
.nPara
; break;
806 case DS_WORD
: nVal
= rDStat
.nWord
; break;
807 case DS_CHAR
: nVal
= rDStat
.nChar
; break;
809 if( pDoc
->GetRootFrm() )
810 ((SwDocStat
&)rDStat
).nPage
= pDoc
->GetRootFrm()->GetPageNum();
812 if( SVX_NUM_PAGEDESC
== nFmt
)
813 nFmt
= (sal_uInt32
)nNumberingType
;
816 ASSERT( sal_False
, "SwDocStatFieldType::Expand: unbekannter SubType" );
820 if( nVal
<= SHRT_MAX
)
821 sRet
= FormatNumber( (sal_uInt16
)nVal
, nFmt
);
823 sRet
= String::CreateFromInt32( nVal
);
827 SwFieldType
* SwDocStatFieldType::Copy() const
829 SwDocStatFieldType
*pTmp
= new SwDocStatFieldType(pDoc
);
833 /*--------------------------------------------------------------------
834 Beschreibung: SwDocStatFieldType
835 Aus historischen Gruenden steht in nFormat der
837 --------------------------------------------------------------------*/
839 SwDocStatField::SwDocStatField(SwDocStatFieldType
* pTyp
, sal_uInt16 nSub
, sal_uInt32 nFmt
)
840 : SwField(pTyp
, nFmt
),
844 String
SwDocStatField::Expand() const
846 return((SwDocStatFieldType
*)GetTyp())->Expand(nSubType
, GetFormat());
849 SwField
* SwDocStatField::Copy() const
851 SwDocStatField
*pTmp
= new SwDocStatField(
852 (SwDocStatFieldType
*)GetTyp(), nSubType
, GetFormat() );
856 sal_uInt16
SwDocStatField::GetSubType() const
861 void SwDocStatField::SetSubType(sal_uInt16 nSub
)
866 void SwDocStatField::ChangeExpansion( const SwFrm
* pFrm
)
868 if( DS_PAGE
== nSubType
&& SVX_NUM_PAGEDESC
== GetFormat() )
869 ((SwDocStatFieldType
*)GetTyp())->SetNumFormat(
870 pFrm
->FindPageFrm()->GetPageDesc()->GetNumType().GetNumberingType() );
873 /*-----------------05.03.98 11:38-------------------
875 --------------------------------------------------*/
876 BOOL
SwDocStatField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
880 case FIELD_PROP_USHORT2
:
881 rAny
<<= (sal_Int16
)GetFormat();
884 DBG_ERROR("illegal property");
888 /*-----------------05.03.98 11:38-------------------
890 --------------------------------------------------*/
891 BOOL
SwDocStatField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
896 case FIELD_PROP_USHORT2
:
900 if(nSet
<= SVX_NUM_CHARS_LOWER_LETTER_N
&&
901 nSet
!= SVX_NUM_CHAR_SPECIAL
&&
902 nSet
!= SVX_NUM_BITMAP
)
911 DBG_ERROR("illegal property");
916 /*--------------------------------------------------------------------
917 Beschreibung: DokumentinfoFields
918 --------------------------------------------------------------------*/
920 SwDocInfoFieldType::SwDocInfoFieldType(SwDoc
* pDc
)
921 : SwValueFieldType( pDc
, RES_DOCINFOFLD
)
925 /* ---------------------------------------------------------------------------
927 ---------------------------------------------------------------------------*/
928 SwFieldType
* SwDocInfoFieldType::Copy() const
930 SwDocInfoFieldType
* pTyp
= new SwDocInfoFieldType(GetDoc());
934 void lcl_GetLocalDataWrapper( ULONG nLang
,
935 const LocaleDataWrapper
**ppAppLocalData
,
936 const LocaleDataWrapper
**ppLocalData
)
938 SvtSysLocale aLocale
;
939 *ppAppLocalData
= &aLocale
.GetLocaleData();
940 *ppLocalData
= *ppAppLocalData
;
941 if( nLang
!= SvxLocaleToLanguage( (*ppLocalData
)->getLocale() ) )
942 *ppLocalData
= new LocaleDataWrapper(
943 ::comphelper::getProcessServiceFactory(),
944 SvxCreateLocale( static_cast<LanguageType
>(nLang
) ) );
947 /* ---------------------------------------------------------------------------
949 ---------------------------------------------------------------------------*/
950 String
SwDocInfoFieldType::Expand( sal_uInt16 nSub
, sal_uInt32 nFormat
,
951 sal_uInt16 nLang
, const String
& rName
) const
954 const LocaleDataWrapper
*pAppLocalData
= 0, *pLocalData
= 0;
955 SwDocShell
*pDocShell(GetDoc()->GetDocShell());
956 DBG_ASSERT(pDocShell
, "no SwDocShell");
957 if (!pDocShell
) { return aStr
; }
959 uno::Reference
<document::XDocumentPropertiesSupplier
> xDPS(
960 pDocShell
->GetModel(), uno::UNO_QUERY_THROW
);
961 uno::Reference
<document::XDocumentProperties
> xDocProps(
962 xDPS
->getDocumentProperties());
963 DBG_ASSERT(xDocProps
.is(), "Doc has no DocumentProperties");
965 sal_uInt16 nExtSub
= nSub
& 0xff00;
966 nSub
&= 0xff; // ExtendedSubTypes nicht beachten
970 case DI_TITEL
: aStr
= xDocProps
->getTitle(); break;
971 case DI_THEMA
: aStr
= xDocProps
->getSubject(); break;
972 case DI_KEYS
: aStr
= ::comphelper::string::convertCommaSeparated(
973 xDocProps
->getKeywords());
975 case DI_COMMENT
:aStr
= xDocProps
->getDescription(); break;
976 case DI_DOCNO
: aStr
= String::CreateFromInt32(
977 xDocProps
->getEditingCycles() );
982 lcl_GetLocalDataWrapper( nLang
, &pAppLocalData
, &pLocalData
);
983 sal_Int32 dur
= xDocProps
->getEditingDuration();
984 aStr
= pLocalData
->getTime( Time(dur
/3600, (dur
%3600)/60, dur
%60),
985 sal_False
, sal_False
);
989 sal_Int32 dur
= xDocProps
->getEditingDuration();
990 double fVal
= Time(dur
/3600, (dur
%3600)/60, dur
%60).GetTimeInDays();
991 aStr
= ExpandValue(fVal
, nFormat
, nLang
);
996 ::rtl::OUString sVal
;
1000 uno::Reference
< beans::XPropertySet
> xSet(
1001 xDocProps
->getUserDefinedProperties(),
1002 uno::UNO_QUERY_THROW
);
1003 aAny
= xSet
->getPropertyValue( rName
);
1005 uno::Reference
< script::XTypeConverter
> xConverter( comphelper::getProcessServiceFactory()
1006 ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")), uno::UNO_QUERY
);
1008 aNew
= xConverter
->convertToSimpleType( aAny
, uno::TypeClass_STRING
);
1011 catch (uno::Exception
&) {}
1017 String
aName( xDocProps
->getAuthor() );
1018 util::DateTime
uDT( xDocProps
->getCreationDate() );
1019 Date
aD(uDT
.Day
, uDT
.Month
, uDT
.Year
);
1020 Time
aT(uDT
.Hours
, uDT
.Minutes
, uDT
.Seconds
, uDT
.HundredthSeconds
);
1021 DateTime
aDate(aD
,aT
);
1022 if( nSub
== DI_CREATE
)
1023 ; // das wars schon!!
1024 else if( nSub
== DI_CHANGE
)
1026 aName
= xDocProps
->getModifiedBy();
1027 uDT
= xDocProps
->getModificationDate();
1028 Date
bD(uDT
.Day
, uDT
.Month
, uDT
.Year
);
1029 Time
bT(uDT
.Hours
, uDT
.Minutes
, uDT
.Seconds
, uDT
.HundredthSeconds
);
1030 DateTime
bDate(bD
,bT
);
1033 else if( nSub
== DI_PRINT
)
1035 aName
= xDocProps
->getPrintedBy();
1036 uDT
= xDocProps
->getPrintDate();
1037 Date
bD(uDT
.Day
, uDT
.Month
, uDT
.Year
);
1038 Time
bT(uDT
.Hours
, uDT
.Minutes
, uDT
.Seconds
, uDT
.HundredthSeconds
);
1039 DateTime
bDate(bD
,bT
);
1045 if (aDate
.IsValid())
1047 switch (nExtSub
& ~DI_SUB_FIXED
)
1056 lcl_GetLocalDataWrapper( nLang
, &pAppLocalData
,
1058 aStr
= pLocalData
->getTime( aDate
,
1059 sal_False
, sal_False
);
1063 // Numberformatter anwerfen!
1064 double fVal
= SwDateTimeField::GetDateTime( GetDoc(),
1066 aStr
= ExpandValue(fVal
, nFormat
, nLang
);
1073 lcl_GetLocalDataWrapper( nLang
, &pAppLocalData
,
1075 aStr
= pLocalData
->getDate( aDate
);
1079 // Numberformatter anwerfen!
1080 double fVal
= SwDateTimeField::GetDateTime( GetDoc(),
1082 aStr
= ExpandValue(fVal
, nFormat
, nLang
);
1091 if( pAppLocalData
!= pLocalData
)
1097 /* ---------------------------------------------------------------------------
1099 ---------------------------------------------------------------------------*/
1100 SwDocInfoField::SwDocInfoField(SwDocInfoFieldType
* pTyp
, sal_uInt16 nSub
, const String
& rName
, sal_uInt32 nFmt
) :
1101 SwValueField(pTyp
, nFmt
), nSubType(nSub
)
1104 aContent
= ((SwDocInfoFieldType
*)GetTyp())->Expand(nSubType
, nFmt
, GetLanguage(), aName
);
1107 SwDocInfoField::SwDocInfoField(SwDocInfoFieldType
* pTyp
, sal_uInt16 nSub
, const String
& rName
, const String
& rValue
, sal_uInt32 nFmt
) :
1108 SwValueField(pTyp
, nFmt
), nSubType(nSub
)
1114 /* ---------------------------------------------------------------------------
1116 ---------------------------------------------------------------------------*/
1117 String
SwDocInfoField::Expand() const
1119 if ( ( nSubType
& 0xFF ) == DI_CUSTOM
)
1121 // custom properties currently need special treatment
1122 // we don't have a secure way to detect "real" custom properties in Word Import of text fields
1123 // so we treat *every* unknown property as a custom property, even the "built-in" section in Word's document summary information stream
1124 // as these properties have not been inserted when the document summary information was imported, we do it here
1125 // this approach is still a lot better than the old one to import such fields as "user fields" and simple text
1126 SwDocShell
* pDocShell
= GetDoc()->GetDocShell();
1131 uno::Reference
<document::XDocumentPropertiesSupplier
> xDPS( pDocShell
->GetModel(), uno::UNO_QUERY_THROW
);
1132 uno::Reference
<document::XDocumentProperties
> xDocProps( xDPS
->getDocumentProperties());
1133 uno::Reference
< beans::XPropertySet
> xSet( xDocProps
->getUserDefinedProperties(), uno::UNO_QUERY_THROW
);
1134 uno::Reference
< beans::XPropertySetInfo
> xSetInfo
= xSet
->getPropertySetInfo();
1137 if( xSetInfo
->hasPropertyByName( aName
) )
1138 aAny
= xSet
->getPropertyValue( aName
);
1139 if ( aAny
.getValueType() != ::getVoidCppuType() )
1141 // "void" type means that the property has not been inserted until now
1144 // if the field is "fixed" we don't update it from the property
1145 ::rtl::OUString sVal
;
1146 uno::Reference
< script::XTypeConverter
> xConverter( comphelper::getProcessServiceFactory()
1147 ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")), uno::UNO_QUERY
);
1148 uno::Any aNew
= xConverter
->convertToSimpleType( aAny
, uno::TypeClass_STRING
);
1150 ((SwDocInfoField
*)this)->aContent
= sVal
;
1155 // property is "void" - means it has not been added until now - do it!
1156 aAny
<<= ::rtl::OUString(aContent
);
1157 uno::Reference
< beans::XPropertyContainer
> xCont( xSet
, uno::UNO_QUERY
);
1158 xCont
->addProperty( aName
, ::com::sun::star::beans::PropertyAttribute::REMOVEABLE
, aAny
);
1161 catch (uno::Exception
&) {}
1163 else if ( !IsFixed() )
1164 ((SwDocInfoField
*)this)->aContent
= ((SwDocInfoFieldType
*)GetTyp())->Expand(nSubType
, GetFormat(), GetLanguage(), aName
);
1168 /* ---------------------------------------------------------------------------
1170 ---------------------------------------------------------------------------*/
1171 String
SwDocInfoField::GetCntnt(sal_Bool bName
) const
1175 String
aStr(SwFieldType::GetTypeStr(GetTypeId()));
1178 sal_uInt16 nSub
= nSubType
& 0xff;
1187 aStr
+= *ViewShell::GetShellRes()->aDocInfoLst
[ nSub
- DI_SUBTYPE_BEGIN
];
1191 ( aStr
+= ' ' ) += ViewShell::GetShellRes()->aFixedStr
;
1196 /* ---------------------------------------------------------------------------
1198 ---------------------------------------------------------------------------*/
1199 SwField
* SwDocInfoField::Copy() const
1201 SwDocInfoField
* pFld
= new SwDocInfoField((SwDocInfoFieldType
*)GetTyp(), nSubType
, aName
, GetFormat());
1202 pFld
->SetAutomaticLanguage(IsAutomaticLanguage());
1203 pFld
->aContent
= aContent
;
1207 /* ---------------------------------------------------------------------------
1209 ---------------------------------------------------------------------------*/
1210 sal_uInt16
SwDocInfoField::GetSubType() const
1214 /* ---------------------------------------------------------------------------
1216 ---------------------------------------------------------------------------*/
1217 void SwDocInfoField::SetSubType(sal_uInt16 nSub
)
1221 /* ---------------------------------------------------------------------------
1223 ---------------------------------------------------------------------------*/
1224 void SwDocInfoField::SetLanguage(sal_uInt16 nLng
)
1227 SwField::SetLanguage(nLng
);
1229 SwValueField::SetLanguage(nLng
);
1231 /* ---------------------------------------------------------------------------
1233 ---------------------------------------------------------------------------*/
1234 BOOL
SwDocInfoField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
1238 case FIELD_PROP_PAR1
:
1239 rAny
<<= OUString(aContent
);
1242 case FIELD_PROP_PAR4
:
1243 rAny
<<= OUString(aName
);
1246 case FIELD_PROP_USHORT1
:
1247 rAny
<<= (sal_Int16
)aContent
.ToInt32();
1250 case FIELD_PROP_BOOL1
:
1252 sal_Bool bVal
= 0 != (nSubType
& DI_SUB_FIXED
);
1253 rAny
.setValue(&bVal
, ::getBooleanCppuType());
1256 case FIELD_PROP_FORMAT
:
1257 rAny
<<= (sal_Int32
)GetFormat();
1260 case FIELD_PROP_DOUBLE
:
1262 double fVal
= GetValue();
1263 rAny
.setValue(&fVal
, ::getCppuType(&fVal
));
1266 case FIELD_PROP_PAR3
:
1267 rAny
<<= rtl::OUString(Expand());
1269 case FIELD_PROP_BOOL2
:
1271 sal_uInt16 nExtSub
= (nSubType
& 0xff00) & ~DI_SUB_FIXED
;
1272 sal_Bool bVal
= (nExtSub
== DI_SUB_DATE
);
1273 rAny
.setValue(&bVal
, ::getBooleanCppuType());
1277 return SwField::QueryValue(rAny
, nWhichId
);
1281 /* ---------------------------------------------------------------------------
1283 ---------------------------------------------------------------------------*/
1284 BOOL
SwDocInfoField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
1286 sal_Int32 nValue
= 0;
1289 case FIELD_PROP_PAR1
:
1290 if( nSubType
& DI_SUB_FIXED
)
1291 ::GetString( rAny
, aContent
);
1294 case FIELD_PROP_USHORT1
:
1295 if( nSubType
& DI_SUB_FIXED
)
1298 aContent
= String::CreateFromInt32(nValue
);
1302 case FIELD_PROP_BOOL1
:
1303 if(*(sal_Bool
*)rAny
.getValue())
1304 nSubType
|= DI_SUB_FIXED
;
1306 nSubType
&= ~DI_SUB_FIXED
;
1308 case FIELD_PROP_FORMAT
:
1316 case FIELD_PROP_PAR3
:
1317 ::GetString( rAny
, aContent
);
1319 case FIELD_PROP_BOOL2
:
1321 if(*(sal_Bool
*)rAny
.getValue())
1322 nSubType
|= DI_SUB_DATE
;
1324 nSubType
|= DI_SUB_TIME
;
1327 return SwField::PutValue(rAny
, nWhichId
);
1332 /*--------------------------------------------------------------------
1333 Beschreibung: SwHiddenTxtFieldType by JP
1334 --------------------------------------------------------------------*/
1336 SwHiddenTxtFieldType::SwHiddenTxtFieldType( sal_Bool bSetHidden
)
1337 : SwFieldType( RES_HIDDENTXTFLD
), bHidden( bSetHidden
)
1340 SwFieldType
* SwHiddenTxtFieldType::Copy() const
1342 return new SwHiddenTxtFieldType( bHidden
);
1344 /* ---------------------------------------------------------------------------
1346 ---------------------------------------------------------------------------*/
1347 void SwHiddenTxtFieldType::SetHiddenFlag( sal_Bool bSetHidden
)
1349 if( bHidden
!= bSetHidden
)
1351 bHidden
= bSetHidden
;
1352 UpdateFlds(); // alle HiddenText benachrichtigen
1355 /* ---------------------------------------------------------------------------
1357 ---------------------------------------------------------------------------*/
1358 SwHiddenTxtField::SwHiddenTxtField( SwHiddenTxtFieldType
* pFldType
,
1359 sal_Bool bConditional
,
1360 const String
& rCond
,
1364 SwField( pFldType
), aCond(rCond
), nSubType(nSub
),
1365 bCanToggle(bConditional
), bIsHidden(bHidden
), bValid(sal_False
)
1367 if(nSubType
== TYP_CONDTXTFLD
)
1369 sal_uInt16 nPos
= 0;
1370 aTRUETxt
= rStr
.GetToken(0, '|', nPos
);
1372 if(nPos
!= STRING_NOTFOUND
)
1374 aFALSETxt
= rStr
.GetToken(0, '|', nPos
);
1375 if(nPos
!= STRING_NOTFOUND
)
1377 aContent
= rStr
.GetToken(0, '|', nPos
);
1385 /* ---------------------------------------------------------------------------
1387 ---------------------------------------------------------------------------*/
1388 SwHiddenTxtField::SwHiddenTxtField( SwHiddenTxtFieldType
* pFldType
,
1389 const String
& rCond
,
1390 const String
& rTrue
,
1391 const String
& rFalse
,
1393 : SwField( pFldType
), aTRUETxt(rTrue
), aFALSETxt(rFalse
), aCond(rCond
), nSubType(nSub
),
1394 bIsHidden(sal_True
), bValid(sal_False
)
1396 bCanToggle
= aCond
.Len() > 0;
1398 /* ---------------------------------------------------------------------------
1400 ---------------------------------------------------------------------------*/
1401 String
SwHiddenTxtField::Expand() const
1403 // Type: !Hidden -> immer anzeigen
1404 // Hide -> Werte die Bedingung aus
1406 if( TYP_CONDTXTFLD
== nSubType
)
1411 if( bCanToggle
&& !bIsHidden
)
1414 else if( !((SwHiddenTxtFieldType
*)GetTyp())->GetHiddenFlag() ||
1415 ( bCanToggle
&& bIsHidden
))
1421 /*--------------------------------------------------------------------
1422 Beschreibung: Aktuellen Field-Value holen und cachen
1423 --------------------------------------------------------------------*/
1425 void SwHiddenTxtField::Evaluate(SwDoc
* pDoc
)
1427 ASSERT(pDoc
, Wo ist das Dokument Seniore
);
1429 if( TYP_CONDTXTFLD
== nSubType
)
1431 SwNewDBMgr
* pMgr
= pDoc
->GetNewDBMgr();
1436 if (bCanToggle
&& !bIsHidden
)
1437 sTmpName
= aTRUETxt
;
1439 sTmpName
= aFALSETxt
;
1441 // OS 21.08.97: #42943# Datenbankausdruecke muessen sich von
1442 // einfachem Text unterscheiden. also wird der einfache Text
1443 // bevorzugt in Anfuehrungszeichen gesetzt.
1444 // Sind diese vorhanden werden umschliessende entfernt.
1445 // Wenn nicht, dann wird auf die Tauglichkeit als Datenbankname
1446 // geprueft. Nur wenn zwei oder mehr Punkte vorhanden sind und kein
1447 // Anfuehrungszeichen enthalten ist, gehen wir von einer DB aus.
1448 if(sTmpName
.Len() > 1 && sTmpName
.GetChar(0) == '\"' &&
1449 sTmpName
.GetChar((sTmpName
.Len() - 1))== '\"')
1451 aContent
= sTmpName
.Copy(1, sTmpName
.Len() - 2);
1454 else if(sTmpName
.Search('\"') == STRING_NOTFOUND
&&
1455 sTmpName
.GetTokenCount('.') > 2)
1457 ::ReplacePoint(sTmpName
);
1458 if(sTmpName
.GetChar(0) == '[' && sTmpName
.GetChar(sTmpName
.Len()-1) == ']')
1459 { // Eckige Klammern entfernen
1460 sTmpName
.Erase(0, 1);
1461 sTmpName
.Erase(sTmpName
.Len()-1, 1);
1466 String
sDBName( GetDBName( sTmpName
, pDoc
));
1467 String
sDataSource(sDBName
.GetToken(0, DB_DELIM
));
1468 String
sDataTableOrQuery(sDBName
.GetToken(1, DB_DELIM
));
1469 if( pMgr
->IsInMerge() && sDBName
.Len() &&
1470 pMgr
->IsDataSourceOpen( sDataSource
,
1471 sDataTableOrQuery
, sal_False
))
1474 sal_uInt32 nTmpFormat
;
1475 pMgr
->GetMergeColumnCnt(GetColumnName( sTmpName
),
1476 GetLanguage(), aContent
, &fNumber
, &nTmpFormat
);
1479 else if( sDBName
.Len() && sDataSource
.Len() &&
1480 sDataTableOrQuery
.Len() )
1486 /* ---------------------------------------------------------------------------
1488 ---------------------------------------------------------------------------*/
1489 String
SwHiddenTxtField::GetCntnt(sal_Bool bName
) const
1493 String
aStr(SwFieldType::GetTypeStr(nSubType
));
1499 if(nSubType
== TYP_CONDTXTFLD
)
1501 static char __READONLY_DATA cTmp
[] = " : ";
1502 aStr
.AppendAscii(cTmp
);
1509 /* ---------------------------------------------------------------------------
1511 ---------------------------------------------------------------------------*/
1512 SwField
* SwHiddenTxtField::Copy() const
1514 SwHiddenTxtField
* pFld
=
1515 new SwHiddenTxtField((SwHiddenTxtFieldType
*)GetTyp(), aCond
,
1516 aTRUETxt
, aFALSETxt
);
1517 pFld
->bIsHidden
= bIsHidden
;
1518 pFld
->bValid
= bValid
;
1519 pFld
->aContent
= aContent
;
1520 pFld
->SetFormat(GetFormat());
1521 pFld
->nSubType
= nSubType
;
1526 /*--------------------------------------------------------------------
1527 Beschreibung: Bedingung setzen
1528 --------------------------------------------------------------------*/
1530 void SwHiddenTxtField::SetPar1(const String
& rStr
)
1533 bCanToggle
= aCond
.Len() > 0;
1535 /* ---------------------------------------------------------------------------
1537 ---------------------------------------------------------------------------*/
1538 const String
& SwHiddenTxtField::GetPar1() const
1543 /*--------------------------------------------------------------------
1544 Beschreibung: True/False Text
1545 --------------------------------------------------------------------*/
1547 void SwHiddenTxtField::SetPar2(const String
& rStr
)
1549 if(nSubType
== TYP_CONDTXTFLD
)
1551 sal_uInt16 nPos
= rStr
.Search('|');
1552 aTRUETxt
= rStr
.Copy(0, nPos
);
1554 if(nPos
!= STRING_NOTFOUND
)
1555 aFALSETxt
= rStr
.Copy(nPos
+ 1);
1560 /* ---------------------------------------------------------------------------
1562 ---------------------------------------------------------------------------*/
1563 String
SwHiddenTxtField::GetPar2() const
1565 String
aRet(aTRUETxt
);
1566 if(nSubType
== TYP_CONDTXTFLD
)
1573 /* ---------------------------------------------------------------------------
1575 ---------------------------------------------------------------------------*/
1576 sal_uInt16
SwHiddenTxtField::GetSubType() const
1580 /* ---------------------------------------------------------------------------
1582 ---------------------------------------------------------------------------*/
1583 BOOL
SwHiddenTxtField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
1585 const String
* pOut
= 0;
1588 case FIELD_PROP_PAR1
:
1591 case FIELD_PROP_PAR2
:
1594 case FIELD_PROP_PAR3
:
1597 case FIELD_PROP_PAR4
:
1600 case FIELD_PROP_BOOL1
:
1602 sal_Bool bHidden
= bIsHidden
;
1603 rAny
.setValue(&bHidden
, ::getBooleanCppuType());
1607 DBG_ERROR("illegal property");
1610 rAny
<<= OUString( *pOut
);
1613 /* ---------------------------------------------------------------------------
1615 ---------------------------------------------------------------------------*/
1616 BOOL
SwHiddenTxtField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
1620 case FIELD_PROP_PAR1
:
1623 SetPar1(::GetString( rAny
, sVal
));
1626 case FIELD_PROP_PAR2
:
1627 ::GetString( rAny
, aTRUETxt
);
1629 case FIELD_PROP_PAR3
:
1630 ::GetString( rAny
, aFALSETxt
);
1632 case FIELD_PROP_BOOL1
:
1633 bIsHidden
= *(sal_Bool
*)rAny
.getValue();
1635 case FIELD_PROP_PAR4
:
1636 ::GetString( rAny
, aContent
);
1640 DBG_ERROR("illegal property");
1645 //------------------------------------------------------------------------------
1647 String
SwHiddenTxtField::GetColumnName(const String
& rName
)
1649 sal_uInt16 nPos
= rName
.Search(DB_DELIM
);
1650 if( STRING_NOTFOUND
!= nPos
)
1652 nPos
= rName
.Search(DB_DELIM
, nPos
+ 1);
1654 if( STRING_NOTFOUND
!= nPos
)
1655 return rName
.Copy(nPos
+ 1);
1660 //------------------------------------------------------------------------------
1662 String
SwHiddenTxtField::GetDBName(const String
& rName
, SwDoc
*pDoc
)
1664 sal_uInt16 nPos
= rName
.Search(DB_DELIM
);
1665 if( STRING_NOTFOUND
!= nPos
)
1667 nPos
= rName
.Search(DB_DELIM
, nPos
+ 1);
1669 if( STRING_NOTFOUND
!= nPos
)
1670 return rName
.Copy( 0, nPos
);
1672 SwDBData aData
= pDoc
->GetDBData();
1673 String sRet
= aData
.sDataSource
;
1675 sRet
+= String(aData
.sCommand
);
1679 /*--------------------------------------------------------------------
1680 Beschreibung: Der Feldtyp fuer Zeilenhoehe 0
1681 --------------------------------------------------------------------*/
1683 SwHiddenParaFieldType::SwHiddenParaFieldType()
1684 : SwFieldType( RES_HIDDENPARAFLD
)
1688 SwFieldType
* SwHiddenParaFieldType::Copy() const
1690 SwHiddenParaFieldType
* pTyp
= new SwHiddenParaFieldType();
1694 /*--------------------------------------------------------------------
1695 Beschreibung: Das Feld Zeilenhoehe 0
1696 --------------------------------------------------------------------*/
1698 SwHiddenParaField::SwHiddenParaField(SwHiddenParaFieldType
* pTyp
, const String
& rStr
)
1699 : SwField(pTyp
), aCond(rStr
)
1701 bIsHidden
= sal_False
;
1703 /* ---------------------------------------------------------------------------
1705 ---------------------------------------------------------------------------*/
1706 String
SwHiddenParaField::Expand() const
1710 /* ---------------------------------------------------------------------------
1712 ---------------------------------------------------------------------------*/
1713 SwField
* SwHiddenParaField::Copy() const
1715 SwHiddenParaField
* pFld
= new SwHiddenParaField((SwHiddenParaFieldType
*)GetTyp(), aCond
);
1716 pFld
->bIsHidden
= bIsHidden
;
1720 /*-----------------05.03.98 13:25-------------------
1722 --------------------------------------------------*/
1723 BOOL
SwHiddenParaField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
1727 case FIELD_PROP_PAR1
:
1728 rAny
<<= OUString(aCond
);
1730 case FIELD_PROP_BOOL1
:
1732 sal_Bool bHidden
= bIsHidden
;
1733 rAny
.setValue(&bHidden
, ::getBooleanCppuType());
1738 DBG_ERROR("illegal property");
1742 /*-----------------05.03.98 13:25-------------------
1744 --------------------------------------------------*/
1745 BOOL
SwHiddenParaField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
1749 case FIELD_PROP_PAR1
:
1750 ::GetString( rAny
, aCond
);
1752 case FIELD_PROP_BOOL1
:
1753 bIsHidden
= *(sal_Bool
*)rAny
.getValue();
1757 DBG_ERROR("illegal property");
1762 /*--------------------------------------------------------------------
1763 Beschreibung: Bedingung setzen
1764 --------------------------------------------------------------------*/
1766 void SwHiddenParaField::SetPar1(const String
& rStr
)
1770 /* ---------------------------------------------------------------------------
1772 ---------------------------------------------------------------------------*/
1773 const String
& SwHiddenParaField::GetPar1() const
1778 /*--------------------------------------------------------------------
1779 Beschreibung: PostIt
1780 --------------------------------------------------------------------*/
1782 SwPostItFieldType::SwPostItFieldType(SwDoc
*pDoc
)
1783 : SwFieldType( RES_POSTITFLD
),mpDoc(pDoc
)
1785 /* ---------------------------------------------------------------------------
1787 ---------------------------------------------------------------------------*/
1788 SwFieldType
* SwPostItFieldType::Copy() const
1790 return new SwPostItFieldType(mpDoc
);
1794 /*--------------------------------------------------------------------
1795 Beschreibung: SwPostItFieldType
1796 --------------------------------------------------------------------*/
1798 SwPostItField::SwPostItField( SwPostItFieldType
* pT
,
1799 const String
& rAuthor
, const String
& rTxt
, const DateTime
& rDateTime
)
1800 : SwField( pT
), sTxt( rTxt
), sAuthor( rAuthor
), aDateTime( rDateTime
), mpText(0), m_pTextObject(0)
1805 SwPostItField::~SwPostItField()
1807 if ( m_pTextObject
)
1809 m_pTextObject
->DisposeEditSource();
1810 m_pTextObject
->release();
1814 /* ---------------------------------------------------------------------------
1816 ---------------------------------------------------------------------------*/
1817 String
SwPostItField::Expand() const
1823 String
SwPostItField::GetDescription() const
1825 return SW_RES(STR_NOTE
);
1828 /* ---------------------------------------------------------------------------
1830 ---------------------------------------------------------------------------*/
1831 SwField
* SwPostItField::Copy() const
1833 SwPostItField
* pRet
= new SwPostItField( (SwPostItFieldType
*)GetTyp(), sAuthor
,
1836 pRet
->SetTextObject( new OutlinerParaObject(*mpText
) );
1839 /*--------------------------------------------------------------------
1840 Beschreibung: Author setzen
1841 --------------------------------------------------------------------*/
1843 void SwPostItField::SetPar1(const String
& rStr
)
1848 const String
& SwPostItField::GetPar1() const
1853 /*--------------------------------------------------------------------
1854 Beschreibung: Text fuers PostIt setzen
1855 --------------------------------------------------------------------*/
1857 void SwPostItField::SetPar2(const String
& rStr
)
1861 /* ---------------------------------------------------------------------------
1863 ---------------------------------------------------------------------------*/
1864 String
SwPostItField::GetPar2() const
1869 const OutlinerParaObject
* SwPostItField::GetTextObject() const
1874 void SwPostItField::SetTextObject( OutlinerParaObject
* pText
)
1880 /*-----------------05.03.98 13:42-------------------
1882 --------------------------------------------------*/
1883 BOOL
SwPostItField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
1887 case FIELD_PROP_PAR1
:
1888 rAny
<<= OUString(sAuthor
);
1890 case FIELD_PROP_PAR2
:
1892 rAny
<<= OUString(sTxt
);
1895 case FIELD_PROP_TEXT
:
1897 if ( !m_pTextObject
)
1899 SwPostItFieldType
* pGetType
= (SwPostItFieldType
*)GetTyp();
1900 SwDoc
* pDoc
= pGetType
->GetDoc();
1901 SwTextAPIEditSource
* pObj
= new SwTextAPIEditSource( pDoc
);
1902 const_cast <SwPostItField
*> (this)->m_pTextObject
= new SwTextAPIObject( pObj
);
1903 m_pTextObject
->acquire();
1907 m_pTextObject
->SetText( *mpText
);
1909 m_pTextObject
->SetString( sTxt
);
1911 uno::Reference
< text::XText
> xText( m_pTextObject
);
1915 case FIELD_PROP_DATE
:
1917 util::Date aSetDate
;
1918 aSetDate
.Day
= aDateTime
.GetDay();
1919 aSetDate
.Month
= aDateTime
.GetMonth();
1920 aSetDate
.Year
= aDateTime
.GetYear();
1921 rAny
.setValue(&aSetDate
, ::getCppuType((util::Date
*)0));
1924 case FIELD_PROP_DATE_TIME
:
1926 util::DateTime DateTimeValue
;
1927 DateTimeValue
.HundredthSeconds
= aDateTime
.Get100Sec();
1928 DateTimeValue
.Seconds
= aDateTime
.GetSec();
1929 DateTimeValue
.Minutes
= aDateTime
.GetMin();
1930 DateTimeValue
.Hours
= aDateTime
.GetHour();
1931 DateTimeValue
.Day
= aDateTime
.GetDay();
1932 DateTimeValue
.Month
= aDateTime
.GetMonth();
1933 DateTimeValue
.Year
= aDateTime
.GetYear();
1934 rAny
<<= DateTimeValue
;
1938 DBG_ERROR("illegal property");
1944 /*-----------------05.03.98 13:42-------------------
1946 --------------------------------------------------*/
1947 BOOL
SwPostItField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
1951 case FIELD_PROP_PAR1
:
1952 ::GetString( rAny
, sAuthor
);
1954 case FIELD_PROP_PAR2
:
1955 ::GetString( rAny
, sTxt
);
1956 //#i100374# new string via api, delete complex text object so SwPostItNote picks up the new string
1963 case FIELD_PROP_TEXT
:
1964 DBG_ERROR("Not implemented!");
1965 // ::GetString( rAny, sTxt );
1967 case FIELD_PROP_DATE
:
1968 if( rAny
.getValueType() == ::getCppuType((util::Date
*)0) )
1970 util::Date aSetDate
= *(util::Date
*)rAny
.getValue();
1971 aDateTime
= Date(aSetDate
.Day
, aSetDate
.Month
, aSetDate
.Year
);
1974 case FIELD_PROP_DATE_TIME
:
1976 util::DateTime aDateTimeValue
;
1977 if(!(rAny
>>= aDateTimeValue
))
1979 aDateTime
.Set100Sec(aDateTimeValue
.HundredthSeconds
);
1980 aDateTime
.SetSec(aDateTimeValue
.Seconds
);
1981 aDateTime
.SetMin(aDateTimeValue
.Minutes
);
1982 aDateTime
.SetHour(aDateTimeValue
.Hours
);
1983 aDateTime
.SetDay(aDateTimeValue
.Day
);
1984 aDateTime
.SetMonth(aDateTimeValue
.Month
);
1985 aDateTime
.SetYear(aDateTimeValue
.Year
);
1989 DBG_ERROR("illegal property");
1993 /*--------------------------------------------------------------------
1994 Beschreibung: DokumentinfoFields
1995 --------------------------------------------------------------------*/
1997 SwExtUserFieldType::SwExtUserFieldType()
1998 : SwFieldType( RES_EXTUSERFLD
)
2001 /* ---------------------------------------------------------------------------
2003 ---------------------------------------------------------------------------*/
2004 SwFieldType
* SwExtUserFieldType::Copy() const
2006 SwExtUserFieldType
* pTyp
= new SwExtUserFieldType
;
2009 /* ---------------------------------------------------------------------------
2011 ---------------------------------------------------------------------------*/
2012 String
SwExtUserFieldType::Expand(sal_uInt16 nSub
, sal_uInt32
) const
2015 sal_uInt16 nRet
= USHRT_MAX
;
2018 case EU_FIRSTNAME
: nRet
= USER_OPT_FIRSTNAME
; break;
2019 case EU_NAME
: nRet
= USER_OPT_LASTNAME
; break;
2020 case EU_SHORTCUT
: nRet
= USER_OPT_ID
; break;
2022 case EU_COMPANY
: nRet
= USER_OPT_COMPANY
; break;
2023 case EU_STREET
: nRet
= USER_OPT_STREET
; break;
2024 case EU_TITLE
: nRet
= USER_OPT_TITLE
; break;
2025 case EU_POSITION
: nRet
= USER_OPT_POSITION
; break;
2026 case EU_PHONE_PRIVATE
: nRet
= USER_OPT_TELEPHONEHOME
; break;
2027 case EU_PHONE_COMPANY
: nRet
= USER_OPT_TELEPHONEWORK
; break;
2028 case EU_FAX
: nRet
= USER_OPT_FAX
; break;
2029 case EU_EMAIL
: nRet
= USER_OPT_EMAIL
; break;
2030 case EU_COUNTRY
: nRet
= USER_OPT_COUNTRY
; break;
2031 case EU_ZIP
: nRet
= USER_OPT_ZIP
; break;
2032 case EU_CITY
: nRet
= USER_OPT_CITY
; break;
2033 case EU_STATE
: nRet
= USER_OPT_STATE
; break;
2034 case EU_FATHERSNAME
: nRet
= USER_OPT_FATHERSNAME
; break;
2035 case EU_APARTMENT
: nRet
= USER_OPT_APARTMENT
; break;
2036 default: ASSERT( !this, "Field unknown");
2038 if( USHRT_MAX
!= nRet
)
2040 SvtUserOptions
& rUserOpt
= SW_MOD()->GetUserOptions();
2041 aRet
= rUserOpt
.GetToken( nRet
);
2045 /* ---------------------------------------------------------------------------
2047 ---------------------------------------------------------------------------*/
2048 SwExtUserField::SwExtUserField(SwExtUserFieldType
* pTyp
, sal_uInt16 nSubTyp
, sal_uInt32 nFmt
) :
2049 SwField(pTyp
, nFmt
), nType(nSubTyp
)
2051 aContent
= ((SwExtUserFieldType
*)GetTyp())->Expand(nType
, GetFormat());
2053 /* ---------------------------------------------------------------------------
2055 ---------------------------------------------------------------------------*/
2056 String
SwExtUserField::Expand() const
2059 ((SwExtUserField
*)this)->aContent
= ((SwExtUserFieldType
*)GetTyp())->Expand(nType
, GetFormat());
2063 /* ---------------------------------------------------------------------------
2065 ---------------------------------------------------------------------------*/
2066 SwField
* SwExtUserField::Copy() const
2068 SwExtUserField
* pFld
= new SwExtUserField((SwExtUserFieldType
*)GetTyp(), nType
, GetFormat());
2069 pFld
->SetExpansion(aContent
);
2073 /* ---------------------------------------------------------------------------
2075 ---------------------------------------------------------------------------*/
2076 sal_uInt16
SwExtUserField::GetSubType() const
2080 /* ---------------------------------------------------------------------------
2082 ---------------------------------------------------------------------------*/
2083 void SwExtUserField::SetSubType(sal_uInt16 nSub
)
2088 /*-----------------05.03.98 14:14-------------------
2090 --------------------------------------------------*/
2091 BOOL
SwExtUserField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
2095 case FIELD_PROP_PAR1
:
2096 rAny
<<= OUString(aContent
);
2099 case FIELD_PROP_USHORT1
:
2101 sal_Int16 nTmp
= nType
;
2105 case FIELD_PROP_BOOL1
:
2107 sal_Bool bTmp
= IsFixed();
2108 rAny
.setValue(&bTmp
, ::getBooleanCppuType());
2112 DBG_ERROR("illegal property");
2116 /*-----------------05.03.98 14:14-------------------
2118 --------------------------------------------------*/
2119 BOOL
SwExtUserField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
2123 case FIELD_PROP_PAR1
:
2124 ::GetString( rAny
, aContent
);
2127 case FIELD_PROP_USHORT1
:
2134 case FIELD_PROP_BOOL1
:
2135 if( *(sal_Bool
*)rAny
.getValue() )
2136 SetFormat(GetFormat() | AF_FIXED
);
2138 SetFormat(GetFormat() & ~AF_FIXED
);
2141 DBG_ERROR("illegal property");
2145 //-------------------------------------------------------------------------
2147 /*--------------------------------------------------------------------
2148 Beschreibung: Relatives Seitennummern - Feld
2149 --------------------------------------------------------------------*/
2151 SwRefPageSetFieldType::SwRefPageSetFieldType()
2152 : SwFieldType( RES_REFPAGESETFLD
)
2155 /* ---------------------------------------------------------------------------
2157 ---------------------------------------------------------------------------*/
2158 SwFieldType
* SwRefPageSetFieldType::Copy() const
2160 return new SwRefPageSetFieldType
;
2162 /* ---------------------------------------------------------------------------
2164 ---------------------------------------------------------------------------*/
2165 // ueberlagert, weil es nichts zum Updaten gibt!
2166 void SwRefPageSetFieldType::Modify( SfxPoolItem
*, SfxPoolItem
* )
2170 /*--------------------------------------------------------------------
2171 Beschreibung: Relative Seitennummerierung
2172 --------------------------------------------------------------------*/
2174 SwRefPageSetField::SwRefPageSetField( SwRefPageSetFieldType
* pTyp
,
2175 short nOff
, sal_Bool bFlag
)
2176 : SwField( pTyp
), nOffset( nOff
), bOn( bFlag
)
2179 /* ---------------------------------------------------------------------------
2181 ---------------------------------------------------------------------------*/
2182 String
SwRefPageSetField::Expand() const
2186 /* ---------------------------------------------------------------------------
2188 ---------------------------------------------------------------------------*/
2189 SwField
* SwRefPageSetField::Copy() const
2191 return new SwRefPageSetField( (SwRefPageSetFieldType
*)GetTyp(), nOffset
, bOn
);
2193 /* ---------------------------------------------------------------------------
2195 ---------------------------------------------------------------------------*/
2196 String
SwRefPageSetField::GetPar2() const
2198 return String::CreateFromInt32( GetOffset() );
2200 /* ---------------------------------------------------------------------------
2202 ---------------------------------------------------------------------------*/
2203 void SwRefPageSetField::SetPar2(const String
& rStr
)
2205 SetOffset( (short) rStr
.ToInt32() );
2208 /*-----------------05.03.98 14:52-------------------
2210 --------------------------------------------------*/
2211 BOOL
SwRefPageSetField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
2215 case FIELD_PROP_BOOL1
:
2216 rAny
.setValue(&bOn
, ::getBooleanCppuType());
2218 case FIELD_PROP_USHORT1
:
2219 rAny
<<= (sal_Int16
)nOffset
;
2222 DBG_ERROR("illegal property");
2226 /*-----------------05.03.98 14:52-------------------
2228 --------------------------------------------------*/
2229 BOOL
SwRefPageSetField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
2233 case FIELD_PROP_BOOL1
:
2234 bOn
= *(sal_Bool
*)rAny
.getValue();
2236 case FIELD_PROP_USHORT1
:
2240 DBG_ERROR("illegal property");
2244 /*--------------------------------------------------------------------
2245 Beschreibung: relatives Seitennummern - Abfrage Feld
2246 --------------------------------------------------------------------*/
2248 SwRefPageGetFieldType::SwRefPageGetFieldType( SwDoc
* pDc
)
2249 : SwFieldType( RES_REFPAGEGETFLD
), pDoc( pDc
), nNumberingType( SVX_NUM_ARABIC
)
2252 /* ---------------------------------------------------------------------------
2254 ---------------------------------------------------------------------------*/
2255 SwFieldType
* SwRefPageGetFieldType::Copy() const
2257 SwRefPageGetFieldType
* pNew
= new SwRefPageGetFieldType( pDoc
);
2258 pNew
->nNumberingType
= nNumberingType
;
2261 /* ---------------------------------------------------------------------------
2263 ---------------------------------------------------------------------------*/
2264 void SwRefPageGetFieldType::Modify( SfxPoolItem
* pOld
, SfxPoolItem
* pNew
)
2266 // Update auf alle GetReferenz-Felder
2267 if( !pNew
&& !pOld
&& GetDepends() )
2269 // sammel erstmal alle SetPageRefFelder ein.
2270 _SetGetExpFlds
aTmpLst( 10, 5 );
2271 if( MakeSetList( aTmpLst
) )
2273 SwClientIter
aIter( *this );
2274 if( aIter
.GoStart() )
2276 // nur die GetRef-Felder Updaten
2277 SwFmtFld
* pFmtFld
= (SwFmtFld
*)aIter();
2278 if( pFmtFld
->GetTxtFld() )
2279 UpdateField( pFmtFld
->GetTxtFld(), aTmpLst
);
2284 // weiter an die Text-Felder, diese "Expandieren" den Text
2285 SwModify::Modify( pOld
, pNew
);
2287 /* ---------------------------------------------------------------------------
2289 ---------------------------------------------------------------------------*/
2290 sal_uInt16
SwRefPageGetFieldType::MakeSetList( _SetGetExpFlds
& rTmpLst
)
2292 SwClientIter
aIter( *pDoc
->GetSysFldType( RES_REFPAGESETFLD
));
2293 if( aIter
.GoStart() )
2295 // nur die GetRef-Felder Updaten
2296 SwFmtFld
* pFmtFld
= (SwFmtFld
*)aIter();
2297 const SwTxtFld
* pTFld
= pFmtFld
->GetTxtFld();
2300 const SwTxtNode
& rTxtNd
= pTFld
->GetTxtNode();
2302 // immer den ersten !! (in Tab-Headline, Kopf-/Fuss )
2304 const SwCntntFrm
* pFrm
= rTxtNd
.GetFrm( &aPt
, 0, sal_False
);
2306 _SetGetExpFld
* pNew
;
2309 pFrm
->IsInDocBody() ||
2310 // --> FME 2004-07-27 #i31868#
2311 // Check if pFrm is not yet connected to the layout.
2312 !pFrm
->FindPageFrm() )
2315 // einen sdbcx::Index fuers bestimmen vom TextNode anlegen
2316 SwNodeIndex
aIdx( rTxtNd
);
2317 pNew
= new _SetGetExpFld( aIdx
, pTFld
);
2321 // einen sdbcx::Index fuers bestimmen vom TextNode anlegen
2322 SwPosition
aPos( pDoc
->GetNodes().GetEndOfPostIts() );
2324 ASSERT( GetBodyTxtNode( *pDoc
, aPos
, *pFrm
),
2325 "wo steht das Feld" );
2327 GetBodyTxtNode( *pDoc
, aPos
, *pFrm
);
2329 pNew
= new _SetGetExpFld( aPos
.nNode
, pTFld
,
2333 if( !rTmpLst
.Insert( pNew
))
2338 return rTmpLst
.Count();
2340 /* ---------------------------------------------------------------------------
2342 ---------------------------------------------------------------------------*/
2343 void SwRefPageGetFieldType::UpdateField( SwTxtFld
* pTxtFld
,
2344 _SetGetExpFlds
& rSetList
)
2346 SwRefPageGetField
* pGetFld
= (SwRefPageGetField
*)pTxtFld
->GetFld().GetFld();
2347 pGetFld
->SetText( aEmptyStr
);
2349 // dann suche mal das richtige RefPageSet-Field
2350 SwTxtNode
* pTxtNode
= (SwTxtNode
*)&pTxtFld
->GetTxtNode();
2351 if( pTxtNode
->StartOfSectionIndex() >
2352 pDoc
->GetNodes().GetEndOfExtras().GetIndex() )
2354 SwNodeIndex
aIdx( *pTxtNode
);
2355 _SetGetExpFld
aEndFld( aIdx
, pTxtFld
);
2358 rSetList
.Seek_Entry( &aEndFld
, &nLast
);
2362 const SwTxtFld
* pRefTxtFld
= rSetList
[ nLast
]->GetFld();
2363 const SwRefPageSetField
* pSetFld
=
2364 (SwRefPageSetField
*)pRefTxtFld
->GetFld().GetFld();
2365 if( pSetFld
->IsOn() )
2367 // dann bestimme mal den entsp. Offset
2369 const SwCntntFrm
* pFrm
= pTxtNode
->GetFrm( &aPt
, 0, sal_False
);
2370 const SwCntntFrm
* pRefFrm
= pRefTxtFld
->GetTxtNode().GetFrm( &aPt
, 0, sal_False
);
2371 const SwPageFrm
* pPgFrm
= 0;
2372 sal_uInt16 nDiff
= ( pFrm
&& pRefFrm
)
2373 ? (pPgFrm
= pFrm
->FindPageFrm())->GetPhyPageNum() -
2374 pRefFrm
->FindPageFrm()->GetPhyPageNum() + 1
2377 sal_uInt32 nTmpFmt
= SVX_NUM_PAGEDESC
== pGetFld
->GetFormat()
2379 ? (sal_uInt32
)SVX_NUM_ARABIC
2380 : pPgFrm
->GetPageDesc()->GetNumType().GetNumberingType() )
2381 : pGetFld
->GetFormat();
2382 short nPageNum
= static_cast<short>(Max(0, pSetFld
->GetOffset() + (short)nDiff
));
2383 pGetFld
->SetText( FormatNumber( nPageNum
, nTmpFmt
) );
2387 // dann die Formatierung anstossen
2388 ((SwFmtFld
&)pTxtFld
->GetFld()).Modify( 0, 0 );
2391 /*--------------------------------------------------------------------
2392 Beschreibung: Relative Seitennummerierung Abfragen
2393 --------------------------------------------------------------------*/
2395 SwRefPageGetField::SwRefPageGetField( SwRefPageGetFieldType
* pTyp
,
2397 : SwField( pTyp
, nFmt
)
2400 /* ---------------------------------------------------------------------------
2402 ---------------------------------------------------------------------------*/
2403 String
SwRefPageGetField::Expand() const
2407 /* ---------------------------------------------------------------------------
2409 ---------------------------------------------------------------------------*/
2410 SwField
* SwRefPageGetField::Copy() const
2412 SwRefPageGetField
* pCpy
= new SwRefPageGetField(
2413 (SwRefPageGetFieldType
*)GetTyp(), GetFormat() );
2414 pCpy
->SetText( sTxt
);
2417 /* ---------------------------------------------------------------------------
2419 ---------------------------------------------------------------------------*/
2420 void SwRefPageGetField::ChangeExpansion( const SwFrm
* pFrm
,
2421 const SwTxtFld
* pFld
)
2423 // nur Felder in Footer, Header, FootNote, Flys
2424 SwTxtNode
* pTxtNode
= (SwTxtNode
*)&pFld
->GetTxtNode();
2425 SwRefPageGetFieldType
* pGetType
= (SwRefPageGetFieldType
*)GetTyp();
2426 SwDoc
* pDoc
= pGetType
->GetDoc();
2427 if( pFld
->GetTxtNode().StartOfSectionIndex() >
2428 pDoc
->GetNodes().GetEndOfExtras().GetIndex() )
2433 ASSERT( !pFrm
->IsInDocBody(), "Flag ist nicht richtig, Frame steht im DocBody" );
2435 // sammel erstmal alle SetPageRefFelder ein.
2436 _SetGetExpFlds
aTmpLst( 10, 5 );
2437 if( !pGetType
->MakeSetList( aTmpLst
) )
2440 // einen sdbcx::Index fuers bestimmen vom TextNode anlegen
2441 SwPosition
aPos( SwNodeIndex( pDoc
->GetNodes() ) );
2442 pTxtNode
= (SwTxtNode
*) GetBodyTxtNode( *pDoc
, aPos
, *pFrm
);
2444 // Wenn kein Layout vorhanden, kommt es in Kopf und Fusszeilen dazu
2445 // das ChangeExpansion uebers Layout-Formatieren aufgerufen wird
2446 // aber kein TxtNode vorhanden ist
2451 _SetGetExpFld
aEndFld( aPos
.nNode
, pFld
, &aPos
.nContent
);
2454 aTmpLst
.Seek_Entry( &aEndFld
, &nLast
);
2457 return ; // es gibt kein entsprechendes Set - Feld vor mir
2459 const SwTxtFld
* pRefTxtFld
= aTmpLst
[ nLast
]->GetFld();
2460 const SwRefPageSetField
* pSetFld
=
2461 (SwRefPageSetField
*)pRefTxtFld
->GetFld().GetFld();
2463 const SwCntntFrm
* pRefFrm
= pRefTxtFld
? pRefTxtFld
->GetTxtNode().GetFrm( &aPt
, 0, sal_False
) : 0;
2464 if( pSetFld
->IsOn() && pRefFrm
)
2466 // dann bestimme mal den entsp. Offset
2467 const SwPageFrm
* pPgFrm
= pFrm
->FindPageFrm();
2468 sal_uInt16 nDiff
= pPgFrm
->GetPhyPageNum() -
2469 pRefFrm
->FindPageFrm()->GetPhyPageNum() + 1;
2471 SwRefPageGetField
* pGetFld
= (SwRefPageGetField
*)pFld
->GetFld().GetFld();
2472 sal_uInt32 nTmpFmt
= SVX_NUM_PAGEDESC
== pGetFld
->GetFormat()
2473 ? pPgFrm
->GetPageDesc()->GetNumType().GetNumberingType()
2474 : pGetFld
->GetFormat();
2475 short nPageNum
= static_cast<short>(Max(0, pSetFld
->GetOffset() + (short)nDiff
));
2476 pGetFld
->SetText( FormatNumber( nPageNum
, nTmpFmt
) );
2479 /*-----------------05.03.98 14:52-------------------
2481 --------------------------------------------------*/
2482 BOOL
SwRefPageGetField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
2486 case FIELD_PROP_USHORT1
:
2487 rAny
<<= (sal_Int16
)GetFormat();
2489 case FIELD_PROP_PAR1
:
2490 rAny
<<= OUString(sTxt
);
2493 DBG_ERROR("illegal property");
2497 /*-----------------05.03.98 14:52-------------------
2499 --------------------------------------------------*/
2500 BOOL
SwRefPageGetField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
2504 case FIELD_PROP_USHORT1
:
2508 if(nSet
<= SVX_NUM_PAGEDESC
)
2511 //exception(wrong_value)
2516 case FIELD_PROP_PAR1
:
2524 DBG_ERROR("illegal property");
2529 /*--------------------------------------------------------------------
2530 Beschreibung: Feld zum Anspringen und Editieren
2531 --------------------------------------------------------------------*/
2533 SwJumpEditFieldType::SwJumpEditFieldType( SwDoc
* pD
)
2534 : SwFieldType( RES_JUMPEDITFLD
), pDoc( pD
), aDep( this, 0 )
2537 /* ---------------------------------------------------------------------------
2539 ---------------------------------------------------------------------------*/
2540 SwFieldType
* SwJumpEditFieldType::Copy() const
2542 return new SwJumpEditFieldType( pDoc
);
2544 /* ---------------------------------------------------------------------------
2546 ---------------------------------------------------------------------------*/
2547 SwCharFmt
* SwJumpEditFieldType::GetCharFmt()
2549 SwCharFmt
* pFmt
= pDoc
->GetCharFmtFromPool( RES_POOLCHR_JUMPEDIT
);
2551 // noch nicht registriert ?
2552 if( !aDep
.GetRegisteredIn() )
2553 pFmt
->Add( &aDep
); // anmelden
2557 /* ---------------------------------------------------------------------------
2559 ---------------------------------------------------------------------------*/
2560 SwJumpEditField::SwJumpEditField( SwJumpEditFieldType
* pTyp
, sal_uInt32 nForm
,
2561 const String
& rTxt
, const String
& rHelp
)
2562 : SwField( pTyp
, nForm
), sTxt( rTxt
), sHelp( rHelp
)
2565 /* ---------------------------------------------------------------------------
2567 ---------------------------------------------------------------------------*/
2568 String
SwJumpEditField::Expand() const
2574 /* ---------------------------------------------------------------------------
2576 ---------------------------------------------------------------------------*/
2577 SwField
* SwJumpEditField::Copy() const
2579 return new SwJumpEditField( (SwJumpEditFieldType
*)GetTyp(), GetFormat(),
2582 /* ---------------------------------------------------------------------------
2584 ---------------------------------------------------------------------------*/
2587 const String
& SwJumpEditField::GetPar1() const
2591 /* ---------------------------------------------------------------------------
2593 ---------------------------------------------------------------------------*/
2594 void SwJumpEditField::SetPar1(const String
& rStr
)
2600 /* ---------------------------------------------------------------------------
2602 ---------------------------------------------------------------------------*/
2603 String
SwJumpEditField::GetPar2() const
2607 /* ---------------------------------------------------------------------------
2609 ---------------------------------------------------------------------------*/
2610 void SwJumpEditField::SetPar2(const String
& rStr
)
2615 /*-----------------05.03.98 15:00-------------------
2617 --------------------------------------------------*/
2618 BOOL
SwJumpEditField::QueryValue( uno::Any
& rAny
, USHORT nWhichId
) const
2622 case FIELD_PROP_USHORT1
:
2625 switch( GetFormat() )
2627 case JE_FMT_TABLE
: nRet
= text::PlaceholderType::TABLE
; break;
2628 case JE_FMT_FRAME
: nRet
= text::PlaceholderType::TEXTFRAME
; break;
2629 case JE_FMT_GRAPHIC
:nRet
= text::PlaceholderType::GRAPHIC
; break;
2630 case JE_FMT_OLE
: nRet
= text::PlaceholderType::OBJECT
; break;
2631 // case JE_FMT_TEXT:
2633 nRet
= text::PlaceholderType::TEXT
; break;
2638 case FIELD_PROP_PAR1
:
2639 rAny
<<= OUString(sHelp
);
2641 case FIELD_PROP_PAR2
:
2642 rAny
<<= OUString(sTxt
);
2645 DBG_ERROR("illegal property");
2649 /*-----------------05.03.98 15:00-------------------
2651 --------------------------------------------------*/
2652 BOOL
SwJumpEditField::PutValue( const uno::Any
& rAny
, USHORT nWhichId
)
2656 case FIELD_PROP_USHORT1
:
2658 //JP 24.10.2001: int32 because in UnoField.cxx a putvalue is
2659 // called with a int32 value! But normally we need
2660 // here only a int16
2665 case text::PlaceholderType::TEXT
: SetFormat(JE_FMT_TEXT
); break;
2666 case text::PlaceholderType::TABLE
: SetFormat(JE_FMT_TABLE
); break;
2667 case text::PlaceholderType::TEXTFRAME
: SetFormat(JE_FMT_FRAME
); break;
2668 case text::PlaceholderType::GRAPHIC
: SetFormat(JE_FMT_GRAPHIC
); break;
2669 case text::PlaceholderType::OBJECT
: SetFormat(JE_FMT_OLE
); break;
2673 case FIELD_PROP_PAR1
:
2674 ::GetString( rAny
, sHelp
);
2676 case FIELD_PROP_PAR2
:
2677 ::GetString( rAny
, sTxt
);
2680 DBG_ERROR("illegal property");
2686 /*--------------------------------------------------------------------
2687 Beschreibung: Combined Character Fieldtype / Field
2688 --------------------------------------------------------------------*/
2690 SwCombinedCharFieldType::SwCombinedCharFieldType()
2691 : SwFieldType( RES_COMBINED_CHARS
)
2695 SwFieldType
* SwCombinedCharFieldType::Copy() const
2697 return new SwCombinedCharFieldType
;
2700 /* --------------------------------------------------------------------*/
2702 SwCombinedCharField::SwCombinedCharField( SwCombinedCharFieldType
* pFTyp
,
2703 const String
& rChars
)
2704 : SwField( pFTyp
, 0 ),
2705 sCharacters( rChars
.Copy( 0, MAX_COMBINED_CHARACTERS
))
2709 String
SwCombinedCharField::Expand() const
2714 SwField
* SwCombinedCharField::Copy() const
2716 return new SwCombinedCharField( (SwCombinedCharFieldType
*)GetTyp(),
2720 const String
& SwCombinedCharField::GetPar1() const
2725 void SwCombinedCharField::SetPar1(const String
& rStr
)
2727 sCharacters
= rStr
.Copy( 0, MAX_COMBINED_CHARACTERS
);
2730 BOOL
SwCombinedCharField::QueryValue( uno::Any
& rAny
,
2731 USHORT nWhichId
) const
2735 case FIELD_PROP_PAR1
:
2736 rAny
<<= rtl::OUString( sCharacters
);
2739 DBG_ERROR("illegal property");
2744 BOOL
SwCombinedCharField::PutValue( const uno::Any
& rAny
,
2749 case FIELD_PROP_PAR1
:
2750 ::GetString( rAny
, sCharacters
).Erase( MAX_COMBINED_CHARACTERS
);
2753 DBG_ERROR("illegal property");