xref: /aoo42x/main/sw/source/ui/fldui/flddinf.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
32*cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <sfx2/request.hxx>
36*cdf0e10cSrcweir #include <sfx2/frame.hxx>
37*cdf0e10cSrcweir #include <vcl/svapp.hxx>
38*cdf0e10cSrcweir #include <svl/zforlist.hxx>
39*cdf0e10cSrcweir #include <svl/zformat.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <helpid.h>
42*cdf0e10cSrcweir #include <swtypes.hxx>
43*cdf0e10cSrcweir #include <globals.hrc>
44*cdf0e10cSrcweir #include <fldbas.hxx>
45*cdf0e10cSrcweir #include <docufld.hxx>
46*cdf0e10cSrcweir #include <wrtsh.hxx>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include <fldui.hrc>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #ifndef _FLDTDLG_HRC
51*cdf0e10cSrcweir #include <fldtdlg.hrc>
52*cdf0e10cSrcweir #endif
53*cdf0e10cSrcweir #ifndef _FLDDINF_HXX
54*cdf0e10cSrcweir #include <flddinf.hxx>
55*cdf0e10cSrcweir #endif
56*cdf0e10cSrcweir #include <swmodule.hxx>
57*cdf0e10cSrcweir #ifndef _VIEW_HXX
58*cdf0e10cSrcweir #include <view.hxx>
59*cdf0e10cSrcweir #endif
60*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
61*cdf0e10cSrcweir #include <com/sun/star/util/Time.hpp>
62*cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp>
63*cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp>
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir #define USER_DATA_VERSION_1 "1"
66*cdf0e10cSrcweir #define USER_DATA_VERSION USER_DATA_VERSION_1
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir using namespace nsSwDocInfoSubType;
69*cdf0e10cSrcweir using namespace com::sun::star;
70*cdf0e10cSrcweir /*--------------------------------------------------------------------
71*cdf0e10cSrcweir 	Beschreibung:
72*cdf0e10cSrcweir  --------------------------------------------------------------------*/
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir SwFldDokInfPage::SwFldDokInfPage(Window* pWindow, const SfxItemSet& rCoreSet ) :
75*cdf0e10cSrcweir 	SwFldPage( pWindow, SW_RES( TP_FLD_DOKINF ), rCoreSet ),
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	aTypeFT		(this, SW_RES(FT_DOKINFTYPE)),
78*cdf0e10cSrcweir 	aTypeTLB	(this, SW_RES(TLB_DOKINFTYPE)),
79*cdf0e10cSrcweir 	aSelectionFT(this, SW_RES(FT_DOKINFSELECTION)),
80*cdf0e10cSrcweir 	aSelectionLB(this, SW_RES(LB_DOKINFSELECTION)),
81*cdf0e10cSrcweir 	aFormatFT	(this, SW_RES(FT_DOKINFFORMAT)),
82*cdf0e10cSrcweir 	aFormatLB	(this, SW_RES(LB_DOKINFFORMAT)),
83*cdf0e10cSrcweir 	aFixedCB	(this, SW_RES(CB_DOKINFFIXEDCONTENT)),
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     pSelEntry   (0),
86*cdf0e10cSrcweir     aInfoStr    (SW_RES(STR_DOKINF_INFO))
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir 	FreeResource();
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	aTypeTLB.SetHelpId(HID_FIELD_DINF_TYPE);
91*cdf0e10cSrcweir 	aTypeTLB.SetSelectionMode(SINGLE_SELECTION);
92*cdf0e10cSrcweir 	aTypeTLB.SetStyle(aTypeTLB.GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|WB_SORT|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
93*cdf0e10cSrcweir 	// Font nicht setzen, damit der Font des Controls uebernommen wird!
94*cdf0e10cSrcweir 	// Sonst bei falschem Font Bug an OV.
95*cdf0e10cSrcweir 	aTypeTLB.SetSpaceBetweenEntries(0);
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 	aTypeTLB.SetNodeDefaultImages();
98*cdf0e10cSrcweir     //enable 'active' language selection
99*cdf0e10cSrcweir     aFormatLB.SetShowLanguageControl(sal_True);
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 	SFX_ITEMSET_ARG( &rCoreSet, pItem, SfxUnoAnyItem, SID_DOCINFO, sal_False );
102*cdf0e10cSrcweir 	if ( pItem )
103*cdf0e10cSrcweir         pItem->GetValue() >>= xCustomPropertySet;
104*cdf0e10cSrcweir }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir /*--------------------------------------------------------------------
107*cdf0e10cSrcweir 	Beschreibung:
108*cdf0e10cSrcweir  --------------------------------------------------------------------*/
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir __EXPORT SwFldDokInfPage::~SwFldDokInfPage()
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir /*--------------------------------------------------------------------
115*cdf0e10cSrcweir 	Beschreibung:
116*cdf0e10cSrcweir  --------------------------------------------------------------------*/
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir void __EXPORT SwFldDokInfPage::Reset(const SfxItemSet& )
119*cdf0e10cSrcweir {
120*cdf0e10cSrcweir 	Init();	// Allgemeine initialisierung
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 	// TypeListBox initialisieren
123*cdf0e10cSrcweir 	aTypeTLB.SetUpdateMode(sal_False);
124*cdf0e10cSrcweir 	aTypeTLB.Clear();
125*cdf0e10cSrcweir 	pSelEntry = 0;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 	// SubTypes in der TypeLB anzeigen
128*cdf0e10cSrcweir 	sal_uInt16 nTypeId = TYP_DOCINFOFLD;
129*cdf0e10cSrcweir 	SvLBoxEntry* pEntry = 0;
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	SvLBoxEntry* pInfo = 0;
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	sal_uInt16 nSubType = USHRT_MAX;
134*cdf0e10cSrcweir 	if (IsFldEdit())
135*cdf0e10cSrcweir     {
136*cdf0e10cSrcweir         const SwField* pCurField = GetCurField();
137*cdf0e10cSrcweir         nSubType = ((SwDocInfoField*)pCurField)->GetSubType() & 0xff;
138*cdf0e10cSrcweir         if( nSubType == DI_CUSTOM )
139*cdf0e10cSrcweir         {
140*cdf0e10cSrcweir             m_sOldCustomFieldName = static_cast<const SwDocInfoField*>(pCurField)->GetName();
141*cdf0e10cSrcweir         }
142*cdf0e10cSrcweir         aFormatLB.SetAutomaticLanguage(pCurField->IsAutomaticLanguage());
143*cdf0e10cSrcweir         SwWrtShell *pSh = GetWrtShell();
144*cdf0e10cSrcweir         if(pSh)
145*cdf0e10cSrcweir         {
146*cdf0e10cSrcweir             const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetFormat());
147*cdf0e10cSrcweir             if(pFormat)
148*cdf0e10cSrcweir                 aFormatLB.SetLanguage(pFormat->GetLanguage());
149*cdf0e10cSrcweir         }
150*cdf0e10cSrcweir     }
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 	sal_uInt16 nSelEntryData = USHRT_MAX;
153*cdf0e10cSrcweir 	String sUserData = GetUserData();
154*cdf0e10cSrcweir 	if(sUserData.GetToken(0, ';').EqualsIgnoreCaseAscii(USER_DATA_VERSION_1))
155*cdf0e10cSrcweir 	{
156*cdf0e10cSrcweir 		String sVal = sUserData.GetToken(1, ';');
157*cdf0e10cSrcweir         nSelEntryData = static_cast< sal_uInt16 >(sVal.ToInt32());
158*cdf0e10cSrcweir 	}
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     SvStringsDtor aLst;
161*cdf0e10cSrcweir     GetFldMgr().GetSubTypes(nTypeId, aLst);
162*cdf0e10cSrcweir     for (sal_uInt16 i = 0; i < aLst.Count(); ++i)
163*cdf0e10cSrcweir 	{
164*cdf0e10cSrcweir 		if (!IsFldEdit() || nSubType == i)
165*cdf0e10cSrcweir 		{
166*cdf0e10cSrcweir 			if (DI_CUSTOM == i)
167*cdf0e10cSrcweir 			{
168*cdf0e10cSrcweir                 if(xCustomPropertySet.is() )
169*cdf0e10cSrcweir 				{
170*cdf0e10cSrcweir                     uno::Reference< beans::XPropertySetInfo > xSetInfo = xCustomPropertySet->getPropertySetInfo();
171*cdf0e10cSrcweir                     const uno::Sequence< beans::Property > rProperties = xSetInfo->getProperties();
172*cdf0e10cSrcweir //                    uno::Sequence< ::rtl::OUString > aPropertyNames(rProperties.getLength());
173*cdf0e10cSrcweir //                    for (sal_Int32 i = 0; i < rProperties.getLength(); ++i) {
174*cdf0e10cSrcweir //                        aPropertyNames[i] = rProperties[i].Name;
175*cdf0e10cSrcweir //                    }
176*cdf0e10cSrcweir                     //if ( !IsFldEdit() )
177*cdf0e10cSrcweir                     if( rProperties.getLength() )
178*cdf0e10cSrcweir                     {
179*cdf0e10cSrcweir                         pInfo = aTypeTLB.InsertEntry( String(SW_RES( STR_CUSTOM )) );
180*cdf0e10cSrcweir 						pInfo->SetUserData(reinterpret_cast<void*>(USHRT_MAX));
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir                         for (sal_Int32 n=0; n < rProperties.getLength(); n++)
183*cdf0e10cSrcweir                         {
184*cdf0e10cSrcweir                             rtl::OUString sEntry = rProperties[n].Name;
185*cdf0e10cSrcweir                             pEntry = aTypeTLB.InsertEntry(sEntry, pInfo);
186*cdf0e10cSrcweir                             if(m_sOldCustomFieldName.equals( sEntry ))
187*cdf0e10cSrcweir                             {
188*cdf0e10cSrcweir                                 pSelEntry = pEntry;
189*cdf0e10cSrcweir                                 aTypeTLB.Expand( pInfo );
190*cdf0e10cSrcweir                             }
191*cdf0e10cSrcweir                             pEntry->SetUserData(reinterpret_cast<void*>(i));
192*cdf0e10cSrcweir                         }
193*cdf0e10cSrcweir                     }
194*cdf0e10cSrcweir 				}
195*cdf0e10cSrcweir 			}
196*cdf0e10cSrcweir 			else
197*cdf0e10cSrcweir 			{
198*cdf0e10cSrcweir 				if (!(IsFldDlgHtmlMode() && (i == DI_EDIT || i == DI_THEMA || i == DI_PRINT)))
199*cdf0e10cSrcweir 				{
200*cdf0e10cSrcweir                     pEntry = aTypeTLB.InsertEntry(*aLst[i]);
201*cdf0e10cSrcweir                     pEntry->SetUserData(reinterpret_cast<void*>(i));
202*cdf0e10cSrcweir 				}
203*cdf0e10cSrcweir 			}
204*cdf0e10cSrcweir 			if(nSelEntryData == i)
205*cdf0e10cSrcweir 				pSelEntry = pEntry;
206*cdf0e10cSrcweir 		}
207*cdf0e10cSrcweir 	}
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 	// alte Pos selektieren
210*cdf0e10cSrcweir 	if (pSelEntry != 0)
211*cdf0e10cSrcweir 	{
212*cdf0e10cSrcweir 		aTypeTLB.Select(pSelEntry);
213*cdf0e10cSrcweir 		nSubType = (sal_uInt16)(sal_uLong)pSelEntry->GetUserData();
214*cdf0e10cSrcweir 	}
215*cdf0e10cSrcweir     else if ( aTypeTLB.GetEntry(0) )
216*cdf0e10cSrcweir 	{
217*cdf0e10cSrcweir 		pSelEntry = aTypeTLB.GetEntry(0);
218*cdf0e10cSrcweir 		nSubType = (sal_uInt16)(sal_uLong)pSelEntry->GetUserData();
219*cdf0e10cSrcweir 	}
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 	FillSelectionLB(nSubType);
222*cdf0e10cSrcweir     if ( pSelEntry )
223*cdf0e10cSrcweir         TypeHdl();
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 	aTypeTLB.SetUpdateMode(sal_True);
226*cdf0e10cSrcweir 	aTypeTLB.SetSelectHdl(LINK(this, SwFldDokInfPage, TypeHdl));
227*cdf0e10cSrcweir 	aTypeTLB.SetDoubleClickHdl(LINK(this, SwFldDokInfPage, InsertHdl));
228*cdf0e10cSrcweir 	aSelectionLB.SetSelectHdl(LINK(this, SwFldDokInfPage, SubTypeHdl));
229*cdf0e10cSrcweir 	aSelectionLB.SetDoubleClickHdl(LINK(this, SwFldDokInfPage, InsertHdl));
230*cdf0e10cSrcweir 	aFormatLB.SetDoubleClickHdl(LINK(this, SwFldDokInfPage, InsertHdl));
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 	if (IsFldEdit())
233*cdf0e10cSrcweir 	{
234*cdf0e10cSrcweir 		nOldSel = aSelectionLB.GetSelectEntryPos();
235*cdf0e10cSrcweir 		nOldFormat = GetCurField()->GetFormat();
236*cdf0e10cSrcweir 		aFixedCB.SaveValue();
237*cdf0e10cSrcweir 	}
238*cdf0e10cSrcweir }
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir /*--------------------------------------------------------------------
241*cdf0e10cSrcweir 	Beschreibung:
242*cdf0e10cSrcweir  --------------------------------------------------------------------*/
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir IMPL_LINK( SwFldDokInfPage, TypeHdl, ListBox *, EMPTYARG )
245*cdf0e10cSrcweir {
246*cdf0e10cSrcweir 	// Alte ListBoxPos sichern
247*cdf0e10cSrcweir 	SvLBoxEntry* pOldEntry = pSelEntry;
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 	// Aktuelle ListBoxPos
250*cdf0e10cSrcweir 	pSelEntry = aTypeTLB.FirstSelected();
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 	if(!pSelEntry)
253*cdf0e10cSrcweir 	{
254*cdf0e10cSrcweir 		pSelEntry = aTypeTLB.GetEntry(0);
255*cdf0e10cSrcweir 		aTypeTLB.Select(pSelEntry);
256*cdf0e10cSrcweir 	}
257*cdf0e10cSrcweir 	else
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 	if (pOldEntry != pSelEntry)
260*cdf0e10cSrcweir 		FillSelectionLB((sal_uInt16)(sal_uLong)pSelEntry->GetUserData());
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir 	SubTypeHdl();
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir 	return 0;
265*cdf0e10cSrcweir }
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir /*--------------------------------------------------------------------
268*cdf0e10cSrcweir 	Beschreibung:
269*cdf0e10cSrcweir  --------------------------------------------------------------------*/
270*cdf0e10cSrcweir IMPL_LINK( SwFldDokInfPage, SubTypeHdl, ListBox *, EMPTYARG )
271*cdf0e10cSrcweir {
272*cdf0e10cSrcweir 	sal_uInt16 nSubType = (sal_uInt16)(sal_uLong)pSelEntry->GetUserData();
273*cdf0e10cSrcweir 	sal_uInt16 nPos = aSelectionLB.GetSelectEntryPos();
274*cdf0e10cSrcweir 	sal_uInt16 nExtSubType;
275*cdf0e10cSrcweir 	sal_uInt16 nNewType = 0;
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir 	if (nSubType != DI_EDIT)
278*cdf0e10cSrcweir 	{
279*cdf0e10cSrcweir 		if (nPos == LISTBOX_ENTRY_NOTFOUND)
280*cdf0e10cSrcweir 		{
281*cdf0e10cSrcweir 			if (!aSelectionLB.GetEntryCount())
282*cdf0e10cSrcweir 			{
283*cdf0e10cSrcweir 				aFormatLB.Clear();
284*cdf0e10cSrcweir 				aFormatLB.Enable(sal_False);
285*cdf0e10cSrcweir 				aFormatFT.Enable(sal_False);
286*cdf0e10cSrcweir                 if( nSubType == DI_CUSTOM )
287*cdf0e10cSrcweir                 {
288*cdf0e10cSrcweir                     //find out which type the custom field has - for a start set to DATE format
289*cdf0e10cSrcweir                     ::rtl::OUString sName = aTypeTLB.GetEntryText(pSelEntry);
290*cdf0e10cSrcweir                     try
291*cdf0e10cSrcweir                     {
292*cdf0e10cSrcweir                         uno::Any aVal = xCustomPropertySet->getPropertyValue( sName );
293*cdf0e10cSrcweir                         const uno::Type& rValueType = aVal.getValueType();
294*cdf0e10cSrcweir                         if( rValueType == ::getCppuType( (util::DateTime*)0 ))
295*cdf0e10cSrcweir                         {
296*cdf0e10cSrcweir                             nNewType = NUMBERFORMAT_DATETIME;
297*cdf0e10cSrcweir                         }
298*cdf0e10cSrcweir                         else if( rValueType == ::getCppuType( (util::Date*)0 ))
299*cdf0e10cSrcweir                         {
300*cdf0e10cSrcweir                             nNewType = NUMBERFORMAT_DATE;
301*cdf0e10cSrcweir                         }
302*cdf0e10cSrcweir                         else if( rValueType == ::getCppuType( (util::Time*)0 ))
303*cdf0e10cSrcweir                         {
304*cdf0e10cSrcweir                             nNewType = NUMBERFORMAT_TIME;
305*cdf0e10cSrcweir                         }
306*cdf0e10cSrcweir                     }
307*cdf0e10cSrcweir                     catch( const uno::Exception& )
308*cdf0e10cSrcweir                     {
309*cdf0e10cSrcweir                     }
310*cdf0e10cSrcweir                 }
311*cdf0e10cSrcweir                 else
312*cdf0e10cSrcweir                     return 0;
313*cdf0e10cSrcweir 			}
314*cdf0e10cSrcweir 			nPos = 0;
315*cdf0e10cSrcweir 		}
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 		nExtSubType = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nPos);
318*cdf0e10cSrcweir 	}
319*cdf0e10cSrcweir 	else
320*cdf0e10cSrcweir 		nExtSubType = DI_SUB_TIME;
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir 	sal_uInt16 nOldType = 0;
323*cdf0e10cSrcweir 	sal_Bool bEnable = sal_False;
324*cdf0e10cSrcweir 	sal_Bool bOneArea = sal_False;
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 	if (aFormatLB.IsEnabled())
327*cdf0e10cSrcweir 		nOldType = aFormatLB.GetFormatType();
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 	switch (nExtSubType)
330*cdf0e10cSrcweir 	{
331*cdf0e10cSrcweir 		case DI_SUB_AUTHOR:
332*cdf0e10cSrcweir 			break;
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir 		case DI_SUB_DATE:
335*cdf0e10cSrcweir 			nNewType = NUMBERFORMAT_DATE;
336*cdf0e10cSrcweir 			bOneArea = sal_True;
337*cdf0e10cSrcweir 			break;
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir 		case DI_SUB_TIME:
340*cdf0e10cSrcweir 			nNewType = NUMBERFORMAT_TIME;
341*cdf0e10cSrcweir 			bOneArea = sal_True;
342*cdf0e10cSrcweir 			break;
343*cdf0e10cSrcweir 	}
344*cdf0e10cSrcweir 	if (!nNewType)
345*cdf0e10cSrcweir 	{
346*cdf0e10cSrcweir 		aFormatLB.Clear();
347*cdf0e10cSrcweir 	}
348*cdf0e10cSrcweir 	else
349*cdf0e10cSrcweir 	{
350*cdf0e10cSrcweir 		if (nOldType != nNewType)
351*cdf0e10cSrcweir 		{
352*cdf0e10cSrcweir 			aFormatLB.SetFormatType(nNewType);
353*cdf0e10cSrcweir 			aFormatLB.SetOneArea(bOneArea);
354*cdf0e10cSrcweir 		}
355*cdf0e10cSrcweir 		bEnable = sal_True;
356*cdf0e10cSrcweir 	}
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir 	sal_uLong nFormat = IsFldEdit() ? ((SwDocInfoField*)GetCurField())->GetFormat() : 0;
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir 	sal_uInt16 nOldSubType = IsFldEdit() ? (((SwDocInfoField*)GetCurField())->GetSubType() & 0xff00) : 0;
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir 	if (IsFldEdit())
363*cdf0e10cSrcweir 	{
364*cdf0e10cSrcweir         nPos = aSelectionLB.GetSelectEntryPos();
365*cdf0e10cSrcweir 		if (nPos != LISTBOX_ENTRY_NOTFOUND )
366*cdf0e10cSrcweir 		{
367*cdf0e10cSrcweir 			nSubType = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nPos);
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir 			nOldSubType &= ~DI_SUB_FIXED;
370*cdf0e10cSrcweir 			if (nOldSubType == nSubType)
371*cdf0e10cSrcweir 			{
372*cdf0e10cSrcweir 				if (!nFormat && (nNewType == NUMBERFORMAT_DATE || nNewType == NUMBERFORMAT_TIME))
373*cdf0e10cSrcweir 				{
374*cdf0e10cSrcweir                     SwWrtShell *pSh = GetWrtShell();
375*cdf0e10cSrcweir                     if(pSh)
376*cdf0e10cSrcweir                     {
377*cdf0e10cSrcweir                         SvNumberFormatter* pFormatter = pSh->GetNumberFormatter();
378*cdf0e10cSrcweir                         LanguageType eLang = aFormatLB.GetCurLanguage();
379*cdf0e10cSrcweir                         if (nNewType == NUMBERFORMAT_DATE)
380*cdf0e10cSrcweir                             nFormat = pFormatter->GetFormatIndex( NF_DATE_SYSTEM_SHORT, eLang);
381*cdf0e10cSrcweir                         else if (nNewType == NUMBERFORMAT_TIME)
382*cdf0e10cSrcweir                             nFormat = pFormatter->GetFormatIndex( NF_TIME_HHMM, eLang);
383*cdf0e10cSrcweir                     }
384*cdf0e10cSrcweir 				}
385*cdf0e10cSrcweir 				aFormatLB.SetDefFormat(nFormat);
386*cdf0e10cSrcweir 			}
387*cdf0e10cSrcweir 		}
388*cdf0e10cSrcweir         else if( (nSubType == DI_CUSTOM)  && (nNewType != 0) )
389*cdf0e10cSrcweir         {
390*cdf0e10cSrcweir     		aFormatLB.SetDefFormat(nFormat);
391*cdf0e10cSrcweir         }
392*cdf0e10cSrcweir 	}
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir 	aFormatLB.Enable(bEnable);
395*cdf0e10cSrcweir 	aFormatFT.Enable(bEnable);
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 	if (bEnable && aFormatLB.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND)
398*cdf0e10cSrcweir 	{
399*cdf0e10cSrcweir 		aFormatLB.SelectEntryPos(0);
400*cdf0e10cSrcweir 	}
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir 	return 0;
403*cdf0e10cSrcweir }
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir /*--------------------------------------------------------------------
406*cdf0e10cSrcweir 	Beschreibung:
407*cdf0e10cSrcweir  --------------------------------------------------------------------*/
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir sal_uInt16 SwFldDokInfPage::FillSelectionLB(sal_uInt16 nSubType)
410*cdf0e10cSrcweir {
411*cdf0e10cSrcweir 	// Format-Listbox fuellen
412*cdf0e10cSrcweir 	sal_uInt16 nTypeId = TYP_DOCINFOFLD;
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir 	EnableInsert(nSubType != USHRT_MAX);
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir 	if (nSubType == USHRT_MAX)	// Info-Text
417*cdf0e10cSrcweir 		nSubType = DI_SUBTYPE_BEGIN;
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir 	aSelectionLB.Clear();
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir 	sal_uInt16 nSize = 0;
422*cdf0e10cSrcweir 	sal_uInt16 nSelPos = USHRT_MAX;
423*cdf0e10cSrcweir 	sal_uInt16 nExtSubType = IsFldEdit() ? (((SwDocInfoField*)GetCurField())->GetSubType() & 0xff00) : 0;
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir 	if (IsFldEdit())
426*cdf0e10cSrcweir 	{
427*cdf0e10cSrcweir 		aFixedCB.Check((nExtSubType & DI_SUB_FIXED) != 0);
428*cdf0e10cSrcweir 		nExtSubType = ((nExtSubType & ~DI_SUB_FIXED) >> 8) - 1;
429*cdf0e10cSrcweir 	}
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir 	if (nSubType < DI_CREATE || nSubType == DI_DOCNO || nSubType == DI_EDIT|| nSubType == DI_CUSTOM )
432*cdf0e10cSrcweir 	{
433*cdf0e10cSrcweir 		// Format Box ist fuer Title und Time leer
434*cdf0e10cSrcweir 	}
435*cdf0e10cSrcweir 	else
436*cdf0e10cSrcweir 	{
437*cdf0e10cSrcweir 		nSize = GetFldMgr().GetFormatCount(nTypeId, sal_False, IsFldDlgHtmlMode());
438*cdf0e10cSrcweir 		for (sal_uInt16 i = 0; i < nSize; i++)
439*cdf0e10cSrcweir 		{
440*cdf0e10cSrcweir 			sal_uInt16 nPos = aSelectionLB.InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
441*cdf0e10cSrcweir             aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(GetFldMgr().GetFormatId(nTypeId, i)));
442*cdf0e10cSrcweir 			if (IsFldEdit() && i == nExtSubType)
443*cdf0e10cSrcweir 				nSelPos = nPos;
444*cdf0e10cSrcweir 		}
445*cdf0e10cSrcweir 	}
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir 	sal_Bool bEnable = nSize != 0;
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir 	if (nSize)
450*cdf0e10cSrcweir 	{
451*cdf0e10cSrcweir 		if (!aSelectionLB.GetSelectEntryCount())
452*cdf0e10cSrcweir 			aSelectionLB.SelectEntryPos(nSelPos == USHRT_MAX ? 0 : nSelPos);
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 		bEnable = sal_True;
455*cdf0e10cSrcweir 	}
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 	aSelectionFT.Enable(bEnable);
458*cdf0e10cSrcweir 	aSelectionLB.Enable(bEnable);
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir 	return nSize;
461*cdf0e10cSrcweir }
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir /*--------------------------------------------------------------------
464*cdf0e10cSrcweir 	Beschreibung:
465*cdf0e10cSrcweir  --------------------------------------------------------------------*/
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir sal_Bool __EXPORT SwFldDokInfPage::FillItemSet(SfxItemSet& )
468*cdf0e10cSrcweir {
469*cdf0e10cSrcweir 	if (!pSelEntry || (sal_uInt16)(sal_uLong)pSelEntry->GetUserData() == USHRT_MAX)
470*cdf0e10cSrcweir 		return sal_False;
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir 	sal_uInt16 nTypeId = TYP_DOCINFOFLD;
473*cdf0e10cSrcweir 	sal_uInt16 nSubType = (sal_uInt16)(sal_uLong)pSelEntry->GetUserData();
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir 	sal_uLong nFormat = 0;
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir 	sal_uInt16 nPos = aSelectionLB.GetSelectEntryPos();
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir     ::rtl::OUString aName;
480*cdf0e10cSrcweir     if (DI_CUSTOM == nSubType)
481*cdf0e10cSrcweir         aName = aTypeTLB.GetEntryText(pSelEntry);
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
484*cdf0e10cSrcweir 		nSubType |= (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nPos);
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir 	if (aFixedCB.IsChecked())
487*cdf0e10cSrcweir 		nSubType |= DI_SUB_FIXED;
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir 	nPos = aFormatLB.GetSelectEntryPos();
490*cdf0e10cSrcweir 	if(nPos != LISTBOX_ENTRY_NOTFOUND)
491*cdf0e10cSrcweir 		nFormat = aFormatLB.GetFormat();
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir 	if (!IsFldEdit() || nOldSel != aSelectionLB.GetSelectEntryPos() ||
494*cdf0e10cSrcweir 		nOldFormat != nFormat || aFixedCB.GetState() != aFixedCB.GetSavedValue()
495*cdf0e10cSrcweir         || (DI_CUSTOM == nSubType && !aName.equals( m_sOldCustomFieldName )))
496*cdf0e10cSrcweir 	{
497*cdf0e10cSrcweir         InsertFld(nTypeId, nSubType, aName, aEmptyStr, nFormat,
498*cdf0e10cSrcweir                 ' ', aFormatLB.IsAutomaticLanguage());
499*cdf0e10cSrcweir 	}
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir 	return sal_False;
502*cdf0e10cSrcweir }
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir /*--------------------------------------------------------------------
505*cdf0e10cSrcweir 	Beschreibung:
506*cdf0e10cSrcweir  --------------------------------------------------------------------*/
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir SfxTabPage* __EXPORT SwFldDokInfPage::Create( 	Window* pParent,
509*cdf0e10cSrcweir 						const SfxItemSet& rAttrSet )
510*cdf0e10cSrcweir {
511*cdf0e10cSrcweir 	return ( new SwFldDokInfPage( pParent, rAttrSet ) );
512*cdf0e10cSrcweir }
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir /*--------------------------------------------------------------------
515*cdf0e10cSrcweir 	Beschreibung:
516*cdf0e10cSrcweir  --------------------------------------------------------------------*/
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir sal_uInt16 SwFldDokInfPage::GetGroup()
519*cdf0e10cSrcweir {
520*cdf0e10cSrcweir 	return GRP_REG;
521*cdf0e10cSrcweir }
522*cdf0e10cSrcweir /* -----------------12.01.99 11:21-------------------
523*cdf0e10cSrcweir  *
524*cdf0e10cSrcweir  * --------------------------------------------------*/
525*cdf0e10cSrcweir void	SwFldDokInfPage::FillUserData()
526*cdf0e10cSrcweir {
527*cdf0e10cSrcweir 	String sData( String::CreateFromAscii(
528*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( USER_DATA_VERSION )));
529*cdf0e10cSrcweir 	sData += ';';
530*cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aTypeTLB.FirstSelected();
531*cdf0e10cSrcweir     sal_uInt16 nTypeSel = pEntry ? sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(pEntry->GetUserData())) : USHRT_MAX;
532*cdf0e10cSrcweir 	sData += String::CreateFromInt32( nTypeSel );
533*cdf0e10cSrcweir 	SetUserData(sData);
534*cdf0e10cSrcweir }
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir 
538