xref: /aoo42x/main/sw/source/ui/config/optload.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
27cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <tools/shl.hxx>
32cdf0e10cSrcweir #include <swtypes.hxx>
33cdf0e10cSrcweir #include <helpid.h>
34cdf0e10cSrcweir #include <uiitems.hxx>
35cdf0e10cSrcweir #include <modcfg.hxx>
36cdf0e10cSrcweir #include "swmodule.hxx"
37cdf0e10cSrcweir #include "usrpref.hxx"
38cdf0e10cSrcweir #include "wrtsh.hxx"
39cdf0e10cSrcweir #include "linkenum.hxx"
40cdf0e10cSrcweir #include <uitool.hxx>
41cdf0e10cSrcweir #include <view.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include "globals.hrc"
44cdf0e10cSrcweir #include "cmdid.h"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include "optload.hrc"
47cdf0e10cSrcweir #include "optload.hxx"
48cdf0e10cSrcweir #include <svx/dlgutil.hxx>
49cdf0e10cSrcweir #include <svx/htmlmode.hxx>
50cdf0e10cSrcweir #include <fldmgr.hxx>
51cdf0e10cSrcweir #include <poolfmt.hxx>
52cdf0e10cSrcweir #include <expfld.hxx>
53cdf0e10cSrcweir #include <caption.hxx>
54cdf0e10cSrcweir #include <com/sun/star/document/PrinterIndependentLayout.hpp>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #include <svtools/insdlg.hxx>
57cdf0e10cSrcweir #include <sot/clsids.hxx>
58cdf0e10cSrcweir #include <unotools/configmgr.hxx>
59cdf0e10cSrcweir #include <docsh.hxx>
60cdf0e10cSrcweir #include <config.hrc>
61cdf0e10cSrcweir #include <SwStyleNameMapper.hxx>
62cdf0e10cSrcweir #include <numrule.hxx>
63cdf0e10cSrcweir #include <SwNodeNum.hxx>
64cdf0e10cSrcweir 
65cdf0e10cSrcweir #include <doc.hxx>
66cdf0e10cSrcweir #include <svl/cjkoptions.hxx>
67cdf0e10cSrcweir 
68cdf0e10cSrcweir using namespace ::com::sun::star;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir /* -----------------22.10.98 15:12-------------------
71cdf0e10cSrcweir  *
72cdf0e10cSrcweir  * --------------------------------------------------*/
SwLoadOptPage(Window * pParent,const SfxItemSet & rSet)73cdf0e10cSrcweir SwLoadOptPage::SwLoadOptPage( Window* pParent, const SfxItemSet& rSet ) :
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	SfxTabPage( pParent, SW_RES( TP_OPTLOAD_PAGE ), rSet ),
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     aUpdateFL           ( this, SW_RES( FL_UPDATE ) ),
78cdf0e10cSrcweir     aLinkFT             ( this, SW_RES( FT_LINK ) ),
79cdf0e10cSrcweir     aAlwaysRB           ( this, SW_RES( RB_ALWAYS ) ),
80cdf0e10cSrcweir     aRequestRB          ( this, SW_RES( RB_REQUEST ) ),
81cdf0e10cSrcweir     aNeverRB            ( this, SW_RES( RB_NEVER  ) ),
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     aFieldFT            ( this, SW_RES( FT_FIELD ) ),
84cdf0e10cSrcweir     aAutoUpdateFields   ( this, SW_RES( CB_AUTO_UPDATE_FIELDS ) ),
85cdf0e10cSrcweir     aAutoUpdateCharts   ( this, SW_RES( CB_AUTO_UPDATE_CHARTS ) ),
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     aSettingsFL         ( this, SW_RES( FL_SETTINGS ) ),
88cdf0e10cSrcweir     aMetricFT           ( this, SW_RES( FT_METRIC ) ),
89cdf0e10cSrcweir     aMetricLB           ( this, SW_RES( LB_METRIC ) ),
90cdf0e10cSrcweir     aTabFT              ( this, SW_RES( FT_TAB ) ),
91cdf0e10cSrcweir     aTabMF              ( this, SW_RES( MF_TAB ) ),
92cdf0e10cSrcweir 	aUseSquaredPageMode ( this, SW_RES( CB_USE_SQUARE_PAGE_MODE ) ),
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	pWrtShell	( NULL ),
95cdf0e10cSrcweir     bHTMLMode   ( sal_False ),
96cdf0e10cSrcweir     nLastTab	( 0 ),
97cdf0e10cSrcweir     nOldLinkMode( MANUAL )
98cdf0e10cSrcweir 
99cdf0e10cSrcweir {
100cdf0e10cSrcweir 	FreeResource();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     SvxStringArray aMetricArr( SW_RES( STR_ARR_METRIC ) );
103cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < aMetricArr.Count(); ++i )
104cdf0e10cSrcweir 	{
105cdf0e10cSrcweir 		String sMetric = aMetricArr.GetStringByPos( i );
106cdf0e10cSrcweir 		FieldUnit eFUnit = (FieldUnit)aMetricArr.GetValue( i );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 		switch ( eFUnit )
109cdf0e10cSrcweir 		{
110cdf0e10cSrcweir 			case FUNIT_MM:
111cdf0e10cSrcweir 			case FUNIT_CM:
112cdf0e10cSrcweir 			case FUNIT_POINT:
113cdf0e10cSrcweir 			case FUNIT_PICA:
114cdf0e10cSrcweir 			case FUNIT_INCH:
115cdf0e10cSrcweir 			{
116cdf0e10cSrcweir 				// nur diese Metriken benutzen
117cdf0e10cSrcweir 				sal_uInt16 nPos = aMetricLB.InsertEntry( sMetric );
118cdf0e10cSrcweir 				aMetricLB.SetEntryData( nPos, (void*)(long)eFUnit );
119cdf0e10cSrcweir 			}
120cdf0e10cSrcweir             default:; //prevent warning
121cdf0e10cSrcweir 		}
122cdf0e10cSrcweir 	}
123cdf0e10cSrcweir     aMetricLB.SetSelectHdl(LINK(this, SwLoadOptPage, MetricHdl));
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     const SfxPoolItem* pItem;
126cdf0e10cSrcweir     if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem )
127cdf0e10cSrcweir 		&& ((SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON)
128cdf0e10cSrcweir 	{
129cdf0e10cSrcweir         aTabFT.Hide();
130cdf0e10cSrcweir 		aTabMF.Hide();
131cdf0e10cSrcweir 	}
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	SvtCJKOptions aCJKOptions;
134cdf0e10cSrcweir 	if(!aCJKOptions.IsAsianTypographyEnabled())
135cdf0e10cSrcweir 		aUseSquaredPageMode.Hide();
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir /*-----------------18.01.97 12.43-------------------
139cdf0e10cSrcweir 
140cdf0e10cSrcweir --------------------------------------------------*/
141cdf0e10cSrcweir 
~SwLoadOptPage()142cdf0e10cSrcweir SwLoadOptPage::~SwLoadOptPage()
143cdf0e10cSrcweir {
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir /*-----------------18.01.97 12.43-------------------
147cdf0e10cSrcweir 
148cdf0e10cSrcweir --------------------------------------------------*/
149cdf0e10cSrcweir 
Create(Window * pParent,const SfxItemSet & rAttrSet)150cdf0e10cSrcweir SfxTabPage*	__EXPORT SwLoadOptPage::Create( Window* pParent,
151cdf0e10cSrcweir 								const SfxItemSet& rAttrSet )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir 	return new SwLoadOptPage(pParent, rAttrSet );
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir /*-----------------18.01.97 12.42-------------------
157cdf0e10cSrcweir 
158cdf0e10cSrcweir --------------------------------------------------*/
159cdf0e10cSrcweir 
FillItemSet(SfxItemSet & rSet)160cdf0e10cSrcweir sal_Bool __EXPORT SwLoadOptPage::FillItemSet( SfxItemSet& rSet )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
163cdf0e10cSrcweir 	SwModule* pMod = SW_MOD();
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     sal_uInt16 nNewLinkMode = AUTOMATIC;
166cdf0e10cSrcweir 	if (aNeverRB.IsChecked())
167cdf0e10cSrcweir 		nNewLinkMode = NEVER;
168cdf0e10cSrcweir 	else if (aRequestRB.IsChecked())
169cdf0e10cSrcweir 		nNewLinkMode = MANUAL;
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     SwFldUpdateFlags eFldFlags = aAutoUpdateFields.IsChecked() ?
172cdf0e10cSrcweir 		aAutoUpdateCharts.IsChecked() ? AUTOUPD_FIELD_AND_CHARTS : AUTOUPD_FIELD_ONLY : AUTOUPD_OFF;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	if(aAutoUpdateFields.IsChecked() != aAutoUpdateFields.GetSavedValue() ||
175cdf0e10cSrcweir 			aAutoUpdateCharts.IsChecked() != aAutoUpdateCharts.GetSavedValue())
176cdf0e10cSrcweir 	{
177cdf0e10cSrcweir         pMod->ApplyFldUpdateFlags(eFldFlags);
178cdf0e10cSrcweir 		if(pWrtShell)
179cdf0e10cSrcweir 		{
180cdf0e10cSrcweir             pWrtShell->SetFldUpdateFlags(eFldFlags);
181cdf0e10cSrcweir 			pWrtShell->SetModified();
182cdf0e10cSrcweir 		}
183cdf0e10cSrcweir 	}
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	if (nNewLinkMode != nOldLinkMode)
186cdf0e10cSrcweir 	{
187cdf0e10cSrcweir         pMod->ApplyLinkMode(nNewLinkMode);
188cdf0e10cSrcweir 		if (pWrtShell)
189cdf0e10cSrcweir 		{
190cdf0e10cSrcweir             pWrtShell->SetLinkUpdMode( nNewLinkMode );
191cdf0e10cSrcweir 			pWrtShell->SetModified();
192cdf0e10cSrcweir 		}
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 		bRet = sal_True;
195cdf0e10cSrcweir 	}
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 	const sal_uInt16 nMPos = aMetricLB.GetSelectEntryPos();
198cdf0e10cSrcweir 	if ( nMPos != aMetricLB.GetSavedValue() )
199cdf0e10cSrcweir 	{
200cdf0e10cSrcweir 		// Doppel-Cast fuer VA3.0
201cdf0e10cSrcweir 		sal_uInt16 nFieldUnit = (sal_uInt16)(long)aMetricLB.GetEntryData( nMPos );
202cdf0e10cSrcweir         rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, (sal_uInt16)nFieldUnit ) );
203cdf0e10cSrcweir         bRet = sal_True;
204cdf0e10cSrcweir 	}
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 	if(aTabMF.IsVisible() && aTabMF.GetText() != aTabMF.GetSavedValue())
207cdf0e10cSrcweir     {
208cdf0e10cSrcweir         rSet.Put(SfxUInt16Item(SID_ATTR_DEFTABSTOP,
209cdf0e10cSrcweir 					(sal_uInt16)aTabMF.Denormalize(aTabMF.GetValue(FUNIT_TWIP))));
210cdf0e10cSrcweir         bRet = sal_True;
211cdf0e10cSrcweir     }
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     sal_Bool bIsSquaredPageModeFlag = aUseSquaredPageMode.IsChecked();
214cdf0e10cSrcweir     if ( bIsSquaredPageModeFlag != aUseSquaredPageMode.GetSavedValue() )
215cdf0e10cSrcweir     {
216cdf0e10cSrcweir         pMod->ApplyDefaultPageMode( bIsSquaredPageModeFlag );
217cdf0e10cSrcweir         if ( pWrtShell )
218cdf0e10cSrcweir         {
219cdf0e10cSrcweir             SwDoc* pDoc = pWrtShell->GetDoc();
220cdf0e10cSrcweir             pDoc->SetDefaultPageMode( bIsSquaredPageModeFlag );
221cdf0e10cSrcweir             pWrtShell->SetModified();
222cdf0e10cSrcweir         }
223cdf0e10cSrcweir         bRet = sal_True;
224cdf0e10cSrcweir     }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     return bRet;
227cdf0e10cSrcweir }
228cdf0e10cSrcweir /*-----------------18.01.97 12.42-------------------
229cdf0e10cSrcweir 
230cdf0e10cSrcweir --------------------------------------------------*/
Reset(const SfxItemSet & rSet)231cdf0e10cSrcweir void __EXPORT SwLoadOptPage::Reset( const SfxItemSet& rSet)
232cdf0e10cSrcweir {
233cdf0e10cSrcweir 	const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref(sal_False);
234cdf0e10cSrcweir 	const SfxPoolItem* pItem;
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 	if(SFX_ITEM_SET == rSet.GetItemState(FN_PARAM_WRTSHELL, sal_False, &pItem))
237cdf0e10cSrcweir 		pWrtShell = (SwWrtShell*)((const SwPtrItem*)pItem)->GetValue();
238cdf0e10cSrcweir 
239cdf0e10cSrcweir     SwFldUpdateFlags eFldFlags = AUTOUPD_GLOBALSETTING;
240cdf0e10cSrcweir 	nOldLinkMode = GLOBALSETTING;
241cdf0e10cSrcweir 	if (pWrtShell)
242cdf0e10cSrcweir 	{
243cdf0e10cSrcweir         eFldFlags = pWrtShell->GetFldUpdateFlags(sal_True);
244cdf0e10cSrcweir 		nOldLinkMode = pWrtShell->GetLinkUpdMode(sal_True);
245cdf0e10cSrcweir 	}
246cdf0e10cSrcweir     if(GLOBALSETTING == nOldLinkMode)
247cdf0e10cSrcweir 		nOldLinkMode = pUsrPref->GetUpdateLinkMode();
248cdf0e10cSrcweir     if(AUTOUPD_GLOBALSETTING == eFldFlags)
249cdf0e10cSrcweir         eFldFlags = pUsrPref->GetFldUpdateFlags();
250cdf0e10cSrcweir 
251cdf0e10cSrcweir     aAutoUpdateFields.Check(eFldFlags != AUTOUPD_OFF);
252cdf0e10cSrcweir     aAutoUpdateCharts.Check(eFldFlags == AUTOUPD_FIELD_AND_CHARTS);
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	switch (nOldLinkMode)
255cdf0e10cSrcweir 	{
256cdf0e10cSrcweir 		case NEVER:		aNeverRB.Check();	break;
257cdf0e10cSrcweir 		case MANUAL:	aRequestRB.Check();	break;
258cdf0e10cSrcweir 		case AUTOMATIC:	aAlwaysRB.Check();	break;
259cdf0e10cSrcweir 	}
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 	aAutoUpdateFields.SaveValue();
262cdf0e10cSrcweir 	aAutoUpdateCharts.SaveValue();
263cdf0e10cSrcweir     aMetricLB.SetNoSelection();
264cdf0e10cSrcweir 	if ( rSet.GetItemState( SID_ATTR_METRIC ) >= SFX_ITEM_AVAILABLE )
265cdf0e10cSrcweir 	{
266cdf0e10cSrcweir 		const SfxUInt16Item& rItem = (SfxUInt16Item&)rSet.Get( SID_ATTR_METRIC );
267cdf0e10cSrcweir 		FieldUnit eFieldUnit = (FieldUnit)rItem.GetValue();
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < aMetricLB.GetEntryCount(); ++i )
270cdf0e10cSrcweir 		{
271cdf0e10cSrcweir 			if ( (int)(sal_IntPtr)aMetricLB.GetEntryData( i ) == (int)eFieldUnit )
272cdf0e10cSrcweir 			{
273cdf0e10cSrcweir 				aMetricLB.SelectEntryPos( i );
274cdf0e10cSrcweir 				break;
275cdf0e10cSrcweir 			}
276cdf0e10cSrcweir 		}
277cdf0e10cSrcweir 		::SetFieldUnit(aTabMF, eFieldUnit);
278cdf0e10cSrcweir 	}
279cdf0e10cSrcweir 	aMetricLB.SaveValue();
280cdf0e10cSrcweir 	if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_DEFTABSTOP, sal_False, &pItem))
281cdf0e10cSrcweir 	{
282cdf0e10cSrcweir 		nLastTab = ((SfxUInt16Item*)pItem)->GetValue();
283cdf0e10cSrcweir 		aTabMF.SetValue(aTabMF.Normalize(nLastTab), FUNIT_TWIP);
284cdf0e10cSrcweir 	}
285cdf0e10cSrcweir     aTabMF.SaveValue();
286cdf0e10cSrcweir 
287cdf0e10cSrcweir     if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem))
288cdf0e10cSrcweir 	{
289cdf0e10cSrcweir 		bHTMLMode = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON);
290cdf0e10cSrcweir 	}
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 	//default page mode loading
293cdf0e10cSrcweir 	if(pWrtShell)
294cdf0e10cSrcweir 	{
295cdf0e10cSrcweir     	sal_Bool bSquaredPageMode = pWrtShell->GetDoc()->IsSquaredPageMode();
296cdf0e10cSrcweir 		aUseSquaredPageMode.Check( bSquaredPageMode );
297cdf0e10cSrcweir    	 	aUseSquaredPageMode.SaveValue();
298cdf0e10cSrcweir 	}
299cdf0e10cSrcweir }
300cdf0e10cSrcweir /*-----------------13.01.97 14.44-------------------
301cdf0e10cSrcweir 	Metric des Deftabstops umschalten
302cdf0e10cSrcweir --------------------------------------------------*/
303cdf0e10cSrcweir 
IMPL_LINK(SwLoadOptPage,MetricHdl,ListBox *,EMPTYARG)304cdf0e10cSrcweir IMPL_LINK(SwLoadOptPage, MetricHdl, ListBox*, EMPTYARG)
305cdf0e10cSrcweir {
306cdf0e10cSrcweir 	const sal_uInt16 nMPos = aMetricLB.GetSelectEntryPos();
307cdf0e10cSrcweir 	if(nMPos != USHRT_MAX)
308cdf0e10cSrcweir 	{
309cdf0e10cSrcweir 		// Doppel-Cast fuer VA3.0
310cdf0e10cSrcweir 		FieldUnit eFieldUnit = (FieldUnit)(long)aMetricLB.GetEntryData( nMPos );
311cdf0e10cSrcweir 		sal_Bool bModified = aTabMF.IsModified();
312cdf0e10cSrcweir         long nVal = bModified ?
313cdf0e10cSrcweir             sal::static_int_cast<sal_Int32, sal_Int64 >( aTabMF.Denormalize( aTabMF.GetValue( FUNIT_TWIP ) )) :
314cdf0e10cSrcweir 				nLastTab;
315cdf0e10cSrcweir 		::SetFieldUnit( aTabMF, eFieldUnit );
316cdf0e10cSrcweir 		aTabMF.SetValue( aTabMF.Normalize( nVal ), FUNIT_TWIP );
317cdf0e10cSrcweir 		if(!bModified)
318cdf0e10cSrcweir 			aTabMF.ClearModifyFlag();
319cdf0e10cSrcweir 	}
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	return 0;
322cdf0e10cSrcweir }
323cdf0e10cSrcweir /*********************************************************************/
324cdf0e10cSrcweir /*                                                                   */
325cdf0e10cSrcweir /*********************************************************************/
326cdf0e10cSrcweir 
IMPL_LINK(SwLoadOptPage,CaptionHdl,PushButton *,EMPTYARG)327cdf0e10cSrcweir IMPL_LINK(SwLoadOptPage, CaptionHdl, PushButton*, EMPTYARG)
328cdf0e10cSrcweir {
329cdf0e10cSrcweir 	SwCaptionOptDlg aDlg(this, GetItemSet());
330cdf0e10cSrcweir 	aDlg.Execute();
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 	return 0;
333cdf0e10cSrcweir }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir /*--------------------------------------------------------------------
336cdf0e10cSrcweir 	Beschreibung:
337cdf0e10cSrcweir  --------------------------------------------------------------------*/
338cdf0e10cSrcweir 
SwCaptionOptDlg(Window * pParent,const SfxItemSet & rSet)339cdf0e10cSrcweir SwCaptionOptDlg::SwCaptionOptDlg(Window* pParent, const SfxItemSet& rSet) :
340cdf0e10cSrcweir 	SfxSingleTabDialog(pParent, rSet, 0)
341cdf0e10cSrcweir {
342cdf0e10cSrcweir 	// TabPage erzeugen
343cdf0e10cSrcweir     SetTabPage((SwCaptionOptPage*) SwCaptionOptPage::Create(this, rSet));
344cdf0e10cSrcweir }
345cdf0e10cSrcweir 
346cdf0e10cSrcweir /*--------------------------------------------------------------------
347cdf0e10cSrcweir 	Beschreibung:
348cdf0e10cSrcweir  --------------------------------------------------------------------*/
349cdf0e10cSrcweir 
~SwCaptionOptDlg()350cdf0e10cSrcweir SwCaptionOptDlg::~SwCaptionOptDlg()
351cdf0e10cSrcweir {
352cdf0e10cSrcweir }
353cdf0e10cSrcweir 
354cdf0e10cSrcweir /* -----------------22.10.98 15:12-------------------
355cdf0e10cSrcweir  *
356cdf0e10cSrcweir  * --------------------------------------------------*/
357cdf0e10cSrcweir 
SwCaptionPreview(Window * pParent,const ResId & rResId)358cdf0e10cSrcweir SwCaptionPreview::SwCaptionPreview( Window* pParent, const ResId& rResId )
359cdf0e10cSrcweir 	: Window( pParent, rResId )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir 	maDrawPos = Point( 4, 6 );
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 	Wallpaper	aBack( GetSettings().GetStyleSettings().GetWindowColor() );
364cdf0e10cSrcweir 	SetBackground( aBack );
365cdf0e10cSrcweir 	SetFillColor( aBack.GetColor() );
366cdf0e10cSrcweir 	SetLineColor( aBack.GetColor() );
367cdf0e10cSrcweir     SetBorderStyle( WINDOW_BORDER_MONO );
368cdf0e10cSrcweir     Font aFont(GetFont());
369cdf0e10cSrcweir     aFont.SetHeight(aFont.GetHeight() * 120 / 100 );
370cdf0e10cSrcweir     SetFont(aFont);
371cdf0e10cSrcweir }
372cdf0e10cSrcweir 
SetPreviewText(const String & rText)373cdf0e10cSrcweir void SwCaptionPreview::SetPreviewText( const String& rText )
374cdf0e10cSrcweir {
375cdf0e10cSrcweir 	if( rText != maText )
376cdf0e10cSrcweir 	{
377cdf0e10cSrcweir 		maText = rText;
378cdf0e10cSrcweir 		Invalidate();
379cdf0e10cSrcweir 	}
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
Paint(const Rectangle & rRect)382cdf0e10cSrcweir void SwCaptionPreview::Paint( const Rectangle& rRect )
383cdf0e10cSrcweir {
384cdf0e10cSrcweir 	Window::Paint( rRect );
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 	DrawRect( Rectangle( Point( 0, 0 ), GetSizePixel() ) );
387cdf0e10cSrcweir 	DrawText( Point( 4, 6 ), maText );
388cdf0e10cSrcweir }
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 
SwCaptionOptPage(Window * pParent,const SfxItemSet & rSet)391cdf0e10cSrcweir SwCaptionOptPage::SwCaptionOptPage( Window* pParent, const SfxItemSet& rSet )
392cdf0e10cSrcweir 	: SfxTabPage(pParent, SW_RES(TP_OPTCAPTION_PAGE), rSet),
393cdf0e10cSrcweir 	aCheckFT		(this, SW_RES(FT_OBJECTS	)),
394cdf0e10cSrcweir 	aCheckLB		(this, SW_RES(CLB_OBJECTS	)),
395cdf0e10cSrcweir     aFtCaptionOrder(this, SW_RES( FT_ORDER )),
396cdf0e10cSrcweir     aLbCaptionOrder(this, SW_RES( LB_ORDER )),
397cdf0e10cSrcweir     aPreview        (this, SW_RES(WIN_PREVIEW   )),
398cdf0e10cSrcweir     aSettingsGroupFL(this, SW_RES(FL_SETTINGS_2	)),
399cdf0e10cSrcweir 	aCategoryText	(this, SW_RES(TXT_CATEGORY	)),
400cdf0e10cSrcweir 	aCategoryBox 	(this, SW_RES(BOX_CATEGORY	)),
401cdf0e10cSrcweir 	aFormatText		(this, SW_RES(TXT_FORMAT	)),
402cdf0e10cSrcweir 	aFormatBox		(this, SW_RES(BOX_FORMAT	)),
403cdf0e10cSrcweir     aNumberingSeparatorFT(this, SW_RES(FT_NUM_SEP  )),
404cdf0e10cSrcweir     aNumberingSeparatorED(this, SW_RES(ED_NUM_SEP  )),
405cdf0e10cSrcweir 	aTextText		(this, SW_RES(TXT_TEXT		)),
406cdf0e10cSrcweir 	aTextEdit		(this, SW_RES(EDT_TEXT		)),
407cdf0e10cSrcweir 	aPosText		(this, SW_RES(TXT_POS		)),
408cdf0e10cSrcweir 	aPosBox			(this, SW_RES(BOX_POS		)),
409cdf0e10cSrcweir 	aNumCaptFL		(this, SW_RES(FL_NUMCAPT	)),
410cdf0e10cSrcweir 	aFtLevel		(this, SW_RES(FT_LEVEL		)),
411cdf0e10cSrcweir 	aLbLevel		(this, SW_RES(LB_LEVEL		)),
412cdf0e10cSrcweir 	aFtDelim		(this, SW_RES(FT_SEPARATOR	)),
413cdf0e10cSrcweir 	aEdDelim		(this, SW_RES(ED_SEPARATOR	)),
414cdf0e10cSrcweir 	aCategoryFL		(this, SW_RES(FL_CATEGORY	)),
415cdf0e10cSrcweir 	aCharStyleFT	(this, SW_RES(FT_CHARSTYLE	)),
416cdf0e10cSrcweir 	aCharStyleLB	(this, SW_RES(LB_CHARSTYLE	)),
417cdf0e10cSrcweir 	aApplyBorderCB	(this, SW_RES(CB_APPLYBORDER)),
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 	sSWTable    	(SW_RES(STR_TABLE			)),
420cdf0e10cSrcweir 	sSWFrame    	(SW_RES(STR_FRAME			)),
421cdf0e10cSrcweir 	sSWGraphic   	(SW_RES(STR_GRAPHIC			)),
422cdf0e10cSrcweir 	sOLE    		(SW_RES(STR_OLE				)),
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 	sBegin			(SW_RESSTR(STR_BEGINNING			)),
425cdf0e10cSrcweir 	sEnd			(SW_RESSTR(STR_END					)),
426cdf0e10cSrcweir 	sAbove			(SW_RESSTR(STR_ABOVE				)),
427cdf0e10cSrcweir 	sBelow			(SW_RESSTR(STR_CP_BELOW				)),
428cdf0e10cSrcweir     sNone           (SW_RESSTR( STR_CATEGORY_NONE )),
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 	pMgr			(new SwFldMgr()),
431cdf0e10cSrcweir 	bHTMLMode(sal_False)
432cdf0e10cSrcweir {
433cdf0e10cSrcweir 	Wallpaper	aBack( GetSettings().GetStyleSettings().GetWindowColor() );
434cdf0e10cSrcweir 	aPreview.SetBackground( aBack );
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 	SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_ABB, sIllustration );
437cdf0e10cSrcweir 	SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_TABLE, sTable );
438cdf0e10cSrcweir 	SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_FRAME, sText );
439cdf0e10cSrcweir     SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_DRAWING, sDrawing );
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 	sal_uInt16 i, nCount;
442cdf0e10cSrcweir 	SwWrtShell *pSh = ::GetActiveWrtShell();
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 	// aFormatBox
445cdf0e10cSrcweir 	sal_uInt16 nSelFmt = SVX_NUM_ARABIC;
446cdf0e10cSrcweir 	if (pSh)
447cdf0e10cSrcweir 	{
448cdf0e10cSrcweir 		nCount = pMgr->GetFldTypeCount();
449cdf0e10cSrcweir 		SwFieldType* pFldType;
450cdf0e10cSrcweir 		for ( i = nCount; i; )
451cdf0e10cSrcweir 			if( ( pFldType = pMgr->GetFldType(USHRT_MAX, --i))->GetName() ==
452cdf0e10cSrcweir 				aCategoryBox.GetText() )
453cdf0e10cSrcweir 			{
454cdf0e10cSrcweir 				nSelFmt = (sal_uInt16)((SwSetExpFieldType*)pFldType)->GetSeqFormat();
455cdf0e10cSrcweir 				break;
456cdf0e10cSrcweir 			}
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 		::FillCharStyleListBox( aCharStyleLB, pSh->GetView().GetDocShell(), sal_True, sal_True );
459cdf0e10cSrcweir 	}
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 	nCount = pMgr->GetFormatCount(TYP_SEQFLD, sal_False);
463cdf0e10cSrcweir 	for ( i = 0; i < nCount; ++i )
464cdf0e10cSrcweir 	{
465cdf0e10cSrcweir 		aFormatBox.InsertEntry( pMgr->GetFormatStr(TYP_SEQFLD, i) );
466cdf0e10cSrcweir 		sal_uInt16 nFmtId = pMgr->GetFormatId(TYP_SEQFLD, i);
467cdf0e10cSrcweir         aFormatBox.SetEntryData( i, reinterpret_cast<void*>(nFmtId) );
468cdf0e10cSrcweir 		if( nFmtId == nSelFmt )
469cdf0e10cSrcweir 			aFormatBox.SelectEntryPos( i );
470cdf0e10cSrcweir 	}
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 	for (i = 0; i < MAXLEVEL; i++)
473cdf0e10cSrcweir 		aLbLevel.InsertEntry(String::CreateFromInt32(i + 1));
474cdf0e10cSrcweir 
475cdf0e10cSrcweir     sal_Unicode nLvl = MAXLEVEL;
476cdf0e10cSrcweir 	String	sDelim( String::CreateFromAscii( ": " ) );
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 	if (pSh)
479cdf0e10cSrcweir 	{
480cdf0e10cSrcweir 		SwSetExpFieldType* pFldType = (SwSetExpFieldType*)pMgr->GetFldType(
481cdf0e10cSrcweir 											RES_SETEXPFLD, aCategoryBox.GetText() );
482cdf0e10cSrcweir 		if( pFldType )
483cdf0e10cSrcweir 		{
484cdf0e10cSrcweir 			sDelim = pFldType->GetDelimiter();
485cdf0e10cSrcweir 			nLvl = pFldType->GetOutlineLvl();
486cdf0e10cSrcweir 		}
487cdf0e10cSrcweir 	}
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 	aLbLevel.SelectEntryPos( nLvl < MAXLEVEL ? nLvl + 1 : 0 );
490cdf0e10cSrcweir 	aEdDelim.SetText( sDelim );
491cdf0e10cSrcweir 
492cdf0e10cSrcweir 	aCheckLB.SetHelpId(HID_OPTCAPTION_CLB);
493cdf0e10cSrcweir 
494cdf0e10cSrcweir 	FreeResource();
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 	Link aLk = LINK( this, SwCaptionOptPage, ModifyHdl );
497cdf0e10cSrcweir 	aCategoryBox.SetModifyHdl( aLk );
498cdf0e10cSrcweir     aNumberingSeparatorED.SetModifyHdl( aLk );
499cdf0e10cSrcweir 	aTextEdit	.SetModifyHdl( aLk );
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 	aLk = LINK(this, SwCaptionOptPage, SelectHdl);
502cdf0e10cSrcweir 	aCategoryBox.SetSelectHdl( aLk );
503cdf0e10cSrcweir 	aFormatBox	.SetSelectHdl( aLk );
504cdf0e10cSrcweir 
505cdf0e10cSrcweir     aLbCaptionOrder.SetSelectHdl( LINK(this, SwCaptionOptPage, OrderHdl));
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 	aCheckLB.SetSelectHdl( LINK(this, SwCaptionOptPage, ShowEntryHdl) );
508cdf0e10cSrcweir     aCheckLB.SetCheckButtonHdl( LINK(this, SwCaptionOptPage, ShowEntryHdl) );
509cdf0e10cSrcweir     aCheckLB.SetDeselectHdl( LINK(this, SwCaptionOptPage, SaveEntryHdl) );
510cdf0e10cSrcweir }
511cdf0e10cSrcweir 
512cdf0e10cSrcweir /*-----------------18.01.97 12.43-------------------
513cdf0e10cSrcweir 
514cdf0e10cSrcweir --------------------------------------------------*/
515cdf0e10cSrcweir 
~SwCaptionOptPage()516cdf0e10cSrcweir SwCaptionOptPage::~SwCaptionOptPage()
517cdf0e10cSrcweir {
518cdf0e10cSrcweir 	DelUserData();
519cdf0e10cSrcweir 	delete pMgr;
520cdf0e10cSrcweir }
521cdf0e10cSrcweir 
522cdf0e10cSrcweir /*-----------------18.01.97 12.43-------------------
523cdf0e10cSrcweir 
524cdf0e10cSrcweir --------------------------------------------------*/
525cdf0e10cSrcweir 
Create(Window * pParent,const SfxItemSet & rAttrSet)526cdf0e10cSrcweir SfxTabPage*	SwCaptionOptPage::Create( Window* pParent,
527cdf0e10cSrcweir 								const SfxItemSet& rAttrSet )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir 	return new SwCaptionOptPage(pParent, rAttrSet );
530cdf0e10cSrcweir }
531cdf0e10cSrcweir 
532cdf0e10cSrcweir /*-----------------18.01.97 12.42-------------------
533cdf0e10cSrcweir 
534cdf0e10cSrcweir --------------------------------------------------*/
535cdf0e10cSrcweir 
FillItemSet(SfxItemSet &)536cdf0e10cSrcweir sal_Bool SwCaptionOptPage::FillItemSet( SfxItemSet&  )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
539cdf0e10cSrcweir 	SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
540cdf0e10cSrcweir 
541cdf0e10cSrcweir 	SaveEntry(aCheckLB.FirstSelected());	// Aktuellen Eintrag uebernehmen
542cdf0e10cSrcweir 
543cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aCheckLB.First();
544cdf0e10cSrcweir 
545cdf0e10cSrcweir 	while (pEntry)
546cdf0e10cSrcweir 	{
547cdf0e10cSrcweir 		InsCaptionOpt* pData = (InsCaptionOpt*)pEntry->GetUserData();
548cdf0e10cSrcweir 		bRet |= pModOpt->SetCapOption(bHTMLMode, pData);
549cdf0e10cSrcweir 		pEntry = aCheckLB.Next(pEntry);
550cdf0e10cSrcweir 	}
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 	sal_uInt16 nCheckCount = aCheckLB.GetCheckedEntryCount();
553cdf0e10cSrcweir 	pModOpt->SetInsWithCaption( bHTMLMode, nCheckCount > 0 );
554cdf0e10cSrcweir 
555cdf0e10cSrcweir     sal_Int32 nPos = aLbCaptionOrder.GetSelectEntryPos();
556cdf0e10cSrcweir     pModOpt->SetCaptionOrderNumberingFirst(nPos == 1 ? sal_True : sal_False );
557cdf0e10cSrcweir 
558cdf0e10cSrcweir     return bRet;
559cdf0e10cSrcweir }
560cdf0e10cSrcweir 
561cdf0e10cSrcweir /*-----------------18.01.97 12.42-------------------
562cdf0e10cSrcweir 
563cdf0e10cSrcweir --------------------------------------------------*/
564cdf0e10cSrcweir 
Reset(const SfxItemSet & rSet)565cdf0e10cSrcweir void SwCaptionOptPage::Reset( const SfxItemSet& rSet)
566cdf0e10cSrcweir {
567cdf0e10cSrcweir 	const SfxPoolItem* pItem;
568cdf0e10cSrcweir 	if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem))
569cdf0e10cSrcweir 	{
570cdf0e10cSrcweir 		bHTMLMode = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON);
571cdf0e10cSrcweir 	}
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 	DelUserData();
574cdf0e10cSrcweir     aCheckLB.GetModel()->Clear();   // remove all entries
575cdf0e10cSrcweir 
576cdf0e10cSrcweir     // Writer objects
577cdf0e10cSrcweir     sal_uInt16 nPos = 0;
578cdf0e10cSrcweir     aCheckLB.InsertEntry(sSWTable);
579cdf0e10cSrcweir     SetOptions(nPos++, TABLE_CAP);
580cdf0e10cSrcweir     aCheckLB.InsertEntry(sSWFrame);
581cdf0e10cSrcweir     SetOptions(nPos++, FRAME_CAP);
582cdf0e10cSrcweir     aCheckLB.InsertEntry(sSWGraphic);
583cdf0e10cSrcweir     SetOptions(nPos++, GRAPHIC_CAP);
584cdf0e10cSrcweir 
585cdf0e10cSrcweir     // get Productname and -version
586cdf0e10cSrcweir     String sComplete, sWithoutVersion;
587cdf0e10cSrcweir     ::rtl::OUString sTemp;
588cdf0e10cSrcweir     uno::Any aAny =
589cdf0e10cSrcweir         ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME );
590cdf0e10cSrcweir     if ( aAny >>= sTemp )
591cdf0e10cSrcweir     {
592cdf0e10cSrcweir         sComplete = sTemp;
593cdf0e10cSrcweir         sWithoutVersion = sTemp;
594cdf0e10cSrcweir         aAny = ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTVERSION );
595cdf0e10cSrcweir         if ( !( aAny >>= sTemp ) )
596cdf0e10cSrcweir         {
597cdf0e10cSrcweir             DBG_ERRORFILE( "Couldn't get PRODUCTVERSION variable" );
598cdf0e10cSrcweir         }
599cdf0e10cSrcweir         else
600cdf0e10cSrcweir         {
601cdf0e10cSrcweir             sComplete += ' ';
602cdf0e10cSrcweir             sComplete += String( sTemp );
603cdf0e10cSrcweir         }
604cdf0e10cSrcweir     }
605cdf0e10cSrcweir     else
606cdf0e10cSrcweir     {
607cdf0e10cSrcweir         DBG_ERRORFILE( "Couldn't get PRODUCTNAME variable" );
608cdf0e10cSrcweir     }
609cdf0e10cSrcweir 
610cdf0e10cSrcweir     SvObjectServerList aObjS;
611cdf0e10cSrcweir     aObjS.FillInsertObjects();
612cdf0e10cSrcweir     aObjS.Remove( SvGlobalName( SO3_SW_CLASSID ) ); // remove Writer-ID
613cdf0e10cSrcweir 
614cdf0e10cSrcweir     for ( sal_uLong i = 0; i < aObjS.Count(); ++i )
615cdf0e10cSrcweir 	{
616cdf0e10cSrcweir 		const SvGlobalName &rOleId = aObjS[i].GetClassName();
617cdf0e10cSrcweir         const String* pClassName = &aObjS[i].GetHumanName();
618cdf0e10cSrcweir         if ( rOleId == SvGlobalName( SO3_OUT_CLASSID ) )
619cdf0e10cSrcweir 			pClassName = &sOLE;
620cdf0e10cSrcweir         String sClass( *pClassName );
621cdf0e10cSrcweir         // don't show product version
622cdf0e10cSrcweir         sClass.SearchAndReplace( sComplete, sWithoutVersion );
623cdf0e10cSrcweir         aCheckLB.InsertEntry( sClass );
624cdf0e10cSrcweir         SetOptions( nPos++, OLE_CAP, &rOleId );
625cdf0e10cSrcweir 	}
626cdf0e10cSrcweir     aLbCaptionOrder.SelectEntryPos(
627cdf0e10cSrcweir         SW_MOD()->GetModuleConfig()->IsCaptionOrderNumberingFirst() ? 1 : 0);
628cdf0e10cSrcweir 	ModifyHdl();
629cdf0e10cSrcweir }
630cdf0e10cSrcweir 
631cdf0e10cSrcweir /*-----------------18.01.97 12.42-------------------
632cdf0e10cSrcweir 
633cdf0e10cSrcweir --------------------------------------------------*/
634cdf0e10cSrcweir 
SetOptions(const sal_uInt16 nPos,const SwCapObjType eObjType,const SvGlobalName * pOleId)635cdf0e10cSrcweir void SwCaptionOptPage::SetOptions(const sal_uInt16 nPos,
636cdf0e10cSrcweir         const SwCapObjType eObjType, const SvGlobalName *pOleId)
637cdf0e10cSrcweir {
638cdf0e10cSrcweir 	SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
639cdf0e10cSrcweir     const InsCaptionOpt* pOpt = pModOpt->GetCapOption(bHTMLMode, eObjType, pOleId);
640cdf0e10cSrcweir 
641cdf0e10cSrcweir 	if (pOpt)
642cdf0e10cSrcweir 	{
643cdf0e10cSrcweir 		aCheckLB.SetEntryData(nPos, new InsCaptionOpt(*pOpt));
644cdf0e10cSrcweir 		aCheckLB.CheckEntryPos(nPos, pOpt->UseCaption());
645cdf0e10cSrcweir 	}
646cdf0e10cSrcweir 	else
647cdf0e10cSrcweir         aCheckLB.SetEntryData(nPos, new InsCaptionOpt(eObjType, pOleId));
648cdf0e10cSrcweir }
649cdf0e10cSrcweir 
650cdf0e10cSrcweir /*-----------------18.01.97 12.42-------------------
651cdf0e10cSrcweir 
652cdf0e10cSrcweir --------------------------------------------------*/
653cdf0e10cSrcweir 
DelUserData()654cdf0e10cSrcweir void SwCaptionOptPage::DelUserData()
655cdf0e10cSrcweir {
656cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aCheckLB.First();
657cdf0e10cSrcweir 
658cdf0e10cSrcweir 	while (pEntry)
659cdf0e10cSrcweir 	{
660cdf0e10cSrcweir 		delete (InsCaptionOpt*)pEntry->GetUserData();
661cdf0e10cSrcweir 		pEntry->SetUserData(0);
662cdf0e10cSrcweir 		pEntry = aCheckLB.Next(pEntry);
663cdf0e10cSrcweir 	}
664cdf0e10cSrcweir }
665cdf0e10cSrcweir 
666cdf0e10cSrcweir /* -----------------26.10.98 11:06-------------------
667cdf0e10cSrcweir  *
668cdf0e10cSrcweir  * --------------------------------------------------*/
669cdf0e10cSrcweir 
IMPL_LINK(SwCaptionOptPage,ShowEntryHdl,SvxCheckListBox *,EMPTYARG)670cdf0e10cSrcweir IMPL_LINK( SwCaptionOptPage, ShowEntryHdl, SvxCheckListBox *, EMPTYARG )
671cdf0e10cSrcweir {
672cdf0e10cSrcweir 	SvLBoxEntry* pSelEntry = aCheckLB.FirstSelected();
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 	if (pSelEntry)
675cdf0e10cSrcweir 	{
676cdf0e10cSrcweir         sal_Bool bChecked = aCheckLB.IsChecked((sal_uInt16)aCheckLB.GetModel()->GetAbsPos(pSelEntry));
677cdf0e10cSrcweir 
678cdf0e10cSrcweir         aSettingsGroupFL.Enable( bChecked );
679cdf0e10cSrcweir         aCategoryText.Enable( bChecked );
680cdf0e10cSrcweir         aCategoryBox.Enable( bChecked );
681cdf0e10cSrcweir         aFormatText.Enable( bChecked );
682cdf0e10cSrcweir         aFormatBox.Enable( bChecked );
683cdf0e10cSrcweir         sal_Bool bNumSep = bChecked && aLbCaptionOrder.GetSelectEntryPos() == 1;
684cdf0e10cSrcweir         aNumberingSeparatorED.Enable( bNumSep );
685cdf0e10cSrcweir         aNumberingSeparatorFT.Enable( bNumSep );
686cdf0e10cSrcweir         aTextText.Enable( bChecked );
687cdf0e10cSrcweir         aTextEdit.Enable( bChecked );
688cdf0e10cSrcweir         aPosText.Enable( bChecked );
689cdf0e10cSrcweir         aPosBox.Enable( bChecked );
690cdf0e10cSrcweir         aNumCaptFL.Enable( bChecked );
691cdf0e10cSrcweir         aFtLevel.Enable( bChecked );
692cdf0e10cSrcweir         aLbLevel.Enable( bChecked );
693cdf0e10cSrcweir         aFtDelim.Enable( bChecked );
694cdf0e10cSrcweir         aEdDelim.Enable( bChecked );
695cdf0e10cSrcweir         aCategoryFL.Enable( bChecked );
696cdf0e10cSrcweir         aCharStyleFT.Enable( bChecked );
697cdf0e10cSrcweir         aCharStyleLB.Enable( bChecked );
698cdf0e10cSrcweir         aApplyBorderCB.Enable( bChecked );
699cdf0e10cSrcweir         aPreview.Enable( bChecked );
700cdf0e10cSrcweir 
701cdf0e10cSrcweir         SwWrtShell *pSh = ::GetActiveWrtShell();
702cdf0e10cSrcweir 
703cdf0e10cSrcweir 		InsCaptionOpt* pOpt = (InsCaptionOpt*)pSelEntry->GetUserData();
704cdf0e10cSrcweir 
705cdf0e10cSrcweir 		aCategoryBox.Clear();
706cdf0e10cSrcweir         aCategoryBox.InsertEntry( sNone );
707cdf0e10cSrcweir         if (pSh)
708cdf0e10cSrcweir 		{
709cdf0e10cSrcweir 			sal_uInt16 nCount = pMgr->GetFldTypeCount();
710cdf0e10cSrcweir 
711cdf0e10cSrcweir 			for (sal_uInt16 i = 0; i < nCount; i++)
712cdf0e10cSrcweir 			{
713cdf0e10cSrcweir 				SwFieldType *pType = pMgr->GetFldType( USHRT_MAX, i );
714cdf0e10cSrcweir 				if( pType->Which() == RES_SETEXPFLD &&
715cdf0e10cSrcweir 					((SwSetExpFieldType *) pType)->GetType() & nsSwGetSetExpType::GSE_SEQ )
716cdf0e10cSrcweir                     aCategoryBox.InsertEntry(SwBoxEntry(pType->GetName()));
717cdf0e10cSrcweir 			}
718cdf0e10cSrcweir 		}
719cdf0e10cSrcweir 		else
720cdf0e10cSrcweir 		{
721cdf0e10cSrcweir             aCategoryBox.InsertEntry(SwBoxEntry(sIllustration));
722cdf0e10cSrcweir             aCategoryBox.InsertEntry(SwBoxEntry(sTable));
723cdf0e10cSrcweir             aCategoryBox.InsertEntry(SwBoxEntry(sText));
724cdf0e10cSrcweir             aCategoryBox.InsertEntry(SwBoxEntry(sDrawing));
725cdf0e10cSrcweir 		}
726cdf0e10cSrcweir 
727cdf0e10cSrcweir         if(pOpt->GetCategory().Len())
728cdf0e10cSrcweir             aCategoryBox.SetText(pOpt->GetCategory());
729cdf0e10cSrcweir         else
730cdf0e10cSrcweir             aCategoryBox.SetText( sNone );
731cdf0e10cSrcweir 		if (pOpt->GetCategory().Len() &&
732cdf0e10cSrcweir 			aCategoryBox.GetEntryPos(pOpt->GetCategory()) == COMBOBOX_ENTRY_NOTFOUND)
733cdf0e10cSrcweir 			aCategoryBox.InsertEntry(pOpt->GetCategory());
734cdf0e10cSrcweir 		if (!aCategoryBox.GetText().Len())
735cdf0e10cSrcweir 		{
736cdf0e10cSrcweir 			sal_uInt16 nPos = 0;
737cdf0e10cSrcweir 			switch(pOpt->GetObjType())
738cdf0e10cSrcweir 			{
739cdf0e10cSrcweir 				case OLE_CAP:
740cdf0e10cSrcweir                 case GRAPHIC_CAP:       nPos = 1;   break;
741cdf0e10cSrcweir                 case TABLE_CAP:         nPos = 2;   break;
742cdf0e10cSrcweir                 case FRAME_CAP:         nPos = 3;   break;
743cdf0e10cSrcweir 			}
744cdf0e10cSrcweir             aCategoryBox.SetText(aCategoryBox.GetEntry(nPos).GetName());
745cdf0e10cSrcweir 		}
746cdf0e10cSrcweir 
747cdf0e10cSrcweir 		for (sal_uInt16 i = 0; i < aFormatBox.GetEntryCount(); i++)
748cdf0e10cSrcweir 		{
749cdf0e10cSrcweir 			if (pOpt->GetNumType() == (sal_uInt16)(sal_uLong)aFormatBox.GetEntryData(i))
750cdf0e10cSrcweir 			{
751cdf0e10cSrcweir 				aFormatBox.SelectEntryPos(i);
752cdf0e10cSrcweir 				break;
753cdf0e10cSrcweir 			}
754cdf0e10cSrcweir 		}
755cdf0e10cSrcweir 		aTextEdit.SetText(pOpt->GetCaption());
756cdf0e10cSrcweir 
757cdf0e10cSrcweir 		aPosBox.Clear();
758cdf0e10cSrcweir 		switch (pOpt->GetObjType())
759cdf0e10cSrcweir 		{
760cdf0e10cSrcweir 			case GRAPHIC_CAP:
761cdf0e10cSrcweir 			case TABLE_CAP:
762cdf0e10cSrcweir 			case OLE_CAP:
763cdf0e10cSrcweir 				aPosBox.InsertEntry(sAbove);
764cdf0e10cSrcweir 				aPosBox.InsertEntry(sBelow);
765cdf0e10cSrcweir 				break;
766cdf0e10cSrcweir 			case FRAME_CAP:
767cdf0e10cSrcweir 				aPosBox.InsertEntry(sBegin);
768cdf0e10cSrcweir 				aPosBox.InsertEntry(sEnd);
769cdf0e10cSrcweir 				break;
770cdf0e10cSrcweir 		}
771cdf0e10cSrcweir 		aPosBox.SelectEntryPos(pOpt->GetPos());
772cdf0e10cSrcweir         aPosBox.Enable( pOpt->GetObjType() != GRAPHIC_CAP &&
773cdf0e10cSrcweir                 pOpt->GetObjType() != OLE_CAP &&
774cdf0e10cSrcweir                 aPosText.IsEnabled() );
775cdf0e10cSrcweir 		aPosBox.SelectEntryPos(pOpt->GetPos());
776cdf0e10cSrcweir 
777cdf0e10cSrcweir 		sal_uInt16 nLevelPos = ( pOpt->GetLevel() < MAXLEVEL ) ? pOpt->GetLevel() + 1 : 0;
778cdf0e10cSrcweir 		aLbLevel.SelectEntryPos( nLevelPos );
779cdf0e10cSrcweir 		aEdDelim.SetText(pOpt->GetSeparator());
780cdf0e10cSrcweir         aNumberingSeparatorED.SetText( pOpt->GetNumSeparator() );
781cdf0e10cSrcweir         if(pOpt->GetCharacterStyle().Len())
782cdf0e10cSrcweir             aCharStyleLB.SelectEntry( pOpt->GetCharacterStyle() );
783cdf0e10cSrcweir         else
784cdf0e10cSrcweir             aCharStyleLB.SelectEntryPos( 0 );
785cdf0e10cSrcweir         aApplyBorderCB.Enable( aCategoryBox.IsEnabled() &&
786cdf0e10cSrcweir                 pOpt->GetObjType() != TABLE_CAP && pOpt->GetObjType() != FRAME_CAP );
787cdf0e10cSrcweir         aApplyBorderCB.Check( pOpt->CopyAttributes() );
788cdf0e10cSrcweir 	}
789cdf0e10cSrcweir 
790cdf0e10cSrcweir 	ModifyHdl();
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 	return 0;
793cdf0e10cSrcweir }
794cdf0e10cSrcweir 
795cdf0e10cSrcweir /* -----------------26.10.98 11:06-------------------
796cdf0e10cSrcweir  *
797cdf0e10cSrcweir  * --------------------------------------------------*/
798cdf0e10cSrcweir 
IMPL_LINK(SwCaptionOptPage,SaveEntryHdl,SvxCheckListBox *,EMPTYARG)799cdf0e10cSrcweir IMPL_LINK( SwCaptionOptPage, SaveEntryHdl, SvxCheckListBox *, EMPTYARG )
800cdf0e10cSrcweir {
801cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aCheckLB.GetHdlEntry();
802cdf0e10cSrcweir 
803cdf0e10cSrcweir 	if (pEntry)		// Alles speichern
804cdf0e10cSrcweir 		SaveEntry(pEntry);
805cdf0e10cSrcweir 
806cdf0e10cSrcweir 	return 0;
807cdf0e10cSrcweir }
808cdf0e10cSrcweir 
809cdf0e10cSrcweir /* -----------------05.11.98 16:23-------------------
810cdf0e10cSrcweir  *
811cdf0e10cSrcweir  * --------------------------------------------------*/
812cdf0e10cSrcweir 
SaveEntry(SvLBoxEntry * pEntry)813cdf0e10cSrcweir void SwCaptionOptPage::SaveEntry(SvLBoxEntry* pEntry)
814cdf0e10cSrcweir {
815cdf0e10cSrcweir 	if (pEntry)
816cdf0e10cSrcweir 	{
817cdf0e10cSrcweir 		InsCaptionOpt* pOpt = (InsCaptionOpt*)pEntry->GetUserData();
818cdf0e10cSrcweir 
819cdf0e10cSrcweir 		pOpt->UseCaption() = aCheckLB.IsChecked((sal_uInt16)aCheckLB.GetModel()->GetAbsPos(pEntry));
820cdf0e10cSrcweir 		String aName( aCategoryBox.GetText() );
821cdf0e10cSrcweir         if(aName == sNone)
822cdf0e10cSrcweir             pOpt->SetCategory(aEmptyStr);
823cdf0e10cSrcweir         else
824cdf0e10cSrcweir         {
825cdf0e10cSrcweir             aName.EraseLeadingChars (' ');
826cdf0e10cSrcweir             aName.EraseTrailingChars(' ');
827cdf0e10cSrcweir             pOpt->SetCategory(aName);
828cdf0e10cSrcweir         }
829cdf0e10cSrcweir 		pOpt->SetNumType((sal_uInt16)(sal_uLong)aFormatBox.GetEntryData(aFormatBox.GetSelectEntryPos()));
830cdf0e10cSrcweir         pOpt->SetCaption(aTextEdit.IsEnabled() ? aTextEdit.GetText() : aEmptyStr );
831cdf0e10cSrcweir 		pOpt->SetPos(aPosBox.GetSelectEntryPos());
832cdf0e10cSrcweir 		sal_uInt16 nPos = aLbLevel.GetSelectEntryPos();
833cdf0e10cSrcweir 		sal_uInt16 nLevel = ( nPos > 0 && nPos != LISTBOX_ENTRY_NOTFOUND ) ? nPos - 1 : MAXLEVEL;
834cdf0e10cSrcweir 		pOpt->SetLevel(nLevel);
835cdf0e10cSrcweir 		pOpt->SetSeparator(aEdDelim.GetText());
836cdf0e10cSrcweir         pOpt->SetNumSeparator( aNumberingSeparatorED.GetText());
837cdf0e10cSrcweir         if(!aCharStyleLB.GetSelectEntryPos())
838cdf0e10cSrcweir             pOpt->SetCharacterStyle(aEmptyStr);
839cdf0e10cSrcweir         else
840cdf0e10cSrcweir             pOpt->SetCharacterStyle(aCharStyleLB.GetSelectEntry());
841cdf0e10cSrcweir         pOpt->CopyAttributes() = aApplyBorderCB.IsChecked();
842cdf0e10cSrcweir 	}
843cdf0e10cSrcweir }
844cdf0e10cSrcweir 
845cdf0e10cSrcweir /* -----------------26.10.98 11:06-------------------
846cdf0e10cSrcweir  *
847cdf0e10cSrcweir  * --------------------------------------------------*/
848cdf0e10cSrcweir 
IMPL_LINK(SwCaptionOptPage,ModifyHdl,Edit *,EMPTYARG)849cdf0e10cSrcweir IMPL_LINK( SwCaptionOptPage, ModifyHdl, Edit *, EMPTYARG )
850cdf0e10cSrcweir {
851cdf0e10cSrcweir 	String sFldTypeName = aCategoryBox.GetText();
852cdf0e10cSrcweir /*
853cdf0e10cSrcweir 	SwFieldType* pType = sFldTypeName.Len() ? pMgr->GetFldType(RES_SETEXPFLD, sFldTypeName) : 0;
854cdf0e10cSrcweir 
855cdf0e10cSrcweir 	((SfxSingleTabDialog*)GetParent())->GetOKButton()->Enable( (!pType || ((SwSetExpFieldType*)pType)->GetType() == GSE_SEQ)
856cdf0e10cSrcweir 									&& sFldTypeName.Len() != 0 );
857cdf0e10cSrcweir */
858cdf0e10cSrcweir 	SfxSingleTabDialog *pDlg = (SfxSingleTabDialog *)GetParent();
859cdf0e10cSrcweir 	PushButton *pBtn = pDlg->GetOKButton();
860cdf0e10cSrcweir 	if (pBtn)
861cdf0e10cSrcweir 		pBtn->Enable(sFldTypeName.Len() != 0);
862cdf0e10cSrcweir     sal_Bool bEnable = aCategoryBox.IsEnabled() && sFldTypeName != sNone;
863cdf0e10cSrcweir 
864cdf0e10cSrcweir     aFormatText.Enable(bEnable);
865cdf0e10cSrcweir     aFormatBox.Enable(bEnable);
866cdf0e10cSrcweir     aTextText.Enable(bEnable);
867cdf0e10cSrcweir     aTextEdit.Enable(bEnable);
868cdf0e10cSrcweir 
869cdf0e10cSrcweir 	DrawSample();
870cdf0e10cSrcweir 	return 0;
871cdf0e10cSrcweir }
872cdf0e10cSrcweir 
873cdf0e10cSrcweir /* -----------------26.10.98 10:58-------------------
874cdf0e10cSrcweir  *
875cdf0e10cSrcweir  * --------------------------------------------------*/
876cdf0e10cSrcweir 
IMPL_LINK_INLINE_START(SwCaptionOptPage,SelectHdl,ListBox *,EMPTYARG)877cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwCaptionOptPage, SelectHdl, ListBox *, EMPTYARG )
878cdf0e10cSrcweir {
879cdf0e10cSrcweir 	DrawSample();
880cdf0e10cSrcweir 	return 0;
881cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SwCaptionOptPage,SelectHdl,ListBox *,EMPTYARG)882cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwCaptionOptPage, SelectHdl, ListBox *, EMPTYARG )
883cdf0e10cSrcweir /*-- 02.11.2007 10:00:36---------------------------------------------------
884cdf0e10cSrcweir 
885cdf0e10cSrcweir   -----------------------------------------------------------------------*/
886cdf0e10cSrcweir IMPL_LINK( SwCaptionOptPage, OrderHdl, ListBox*, pBox )
887cdf0e10cSrcweir {
888cdf0e10cSrcweir     DrawSample();
889cdf0e10cSrcweir     sal_Int32 nPos = pBox->GetSelectEntryPos();
890cdf0e10cSrcweir     aNumberingSeparatorFT.Enable( nPos == 1 );
891cdf0e10cSrcweir     aNumberingSeparatorED.Enable( nPos == 1 );
892cdf0e10cSrcweir     return 0;
893cdf0e10cSrcweir }
894cdf0e10cSrcweir /* -----------------26.10.98 10:58-------------------
895cdf0e10cSrcweir  *
896cdf0e10cSrcweir  * --------------------------------------------------*/
897cdf0e10cSrcweir 
DrawSample()898cdf0e10cSrcweir void SwCaptionOptPage::DrawSample()
899cdf0e10cSrcweir {
900cdf0e10cSrcweir 	String aStr;
901cdf0e10cSrcweir 
902cdf0e10cSrcweir     if( aCategoryBox.GetText() != sNone)
903cdf0e10cSrcweir     {
904cdf0e10cSrcweir         //#i61007# order of captions
905cdf0e10cSrcweir         bool bOrderNumberingFirst = aLbCaptionOrder.GetSelectEntryPos() == 1;
906cdf0e10cSrcweir         // Nummer
907cdf0e10cSrcweir         sal_uInt16 nNumFmt = (sal_uInt16)(sal_uLong)aFormatBox.GetEntryData(
908cdf0e10cSrcweir                                         aFormatBox.GetSelectEntryPos() );
909cdf0e10cSrcweir         if( SVX_NUM_NUMBER_NONE != nNumFmt )
910cdf0e10cSrcweir         {
911cdf0e10cSrcweir             //#i61007# order of captions
912cdf0e10cSrcweir             if( !bOrderNumberingFirst )
913cdf0e10cSrcweir             {
914cdf0e10cSrcweir                 // Kategorie
915cdf0e10cSrcweir                 aStr += aCategoryBox.GetText();
916cdf0e10cSrcweir                 aStr += ' ';
917cdf0e10cSrcweir             }
918cdf0e10cSrcweir 
919cdf0e10cSrcweir             SwWrtShell *pSh = ::GetActiveWrtShell();
920cdf0e10cSrcweir             String sFldTypeName( aCategoryBox.GetText() );
921cdf0e10cSrcweir             if (pSh)
922cdf0e10cSrcweir             {
923cdf0e10cSrcweir                 SwSetExpFieldType* pFldType = (SwSetExpFieldType*)pMgr->GetFldType(
924cdf0e10cSrcweir                                                 RES_SETEXPFLD, sFldTypeName );
925cdf0e10cSrcweir                 if( pFldType && pFldType->GetOutlineLvl() < MAXLEVEL )
926cdf0e10cSrcweir                 {
927cdf0e10cSrcweir                     sal_uInt8 nLvl = pFldType->GetOutlineLvl();
928cdf0e10cSrcweir                     SwNumberTree::tNumberVector aNumVector;
929cdf0e10cSrcweir                     for( sal_uInt8 i = 0; i <= nLvl; ++i )
930cdf0e10cSrcweir                         aNumVector.push_back(1);
931cdf0e10cSrcweir 
932cdf0e10cSrcweir                     String sNumber( pSh->GetOutlineNumRule()->MakeNumString(
933cdf0e10cSrcweir                                                             aNumVector, sal_False ));
934cdf0e10cSrcweir                     if( sNumber.Len() )
935cdf0e10cSrcweir                         (aStr += sNumber) += pFldType->GetDelimiter();
936cdf0e10cSrcweir                 }
937cdf0e10cSrcweir             }
938cdf0e10cSrcweir 
939cdf0e10cSrcweir             switch( nNumFmt )
940cdf0e10cSrcweir             {
941cdf0e10cSrcweir                 case SVX_NUM_CHARS_UPPER_LETTER:    aStr += 'A'; break;
942cdf0e10cSrcweir                 case SVX_NUM_CHARS_UPPER_LETTER_N:  aStr += 'A'; break;
943cdf0e10cSrcweir                 case SVX_NUM_CHARS_LOWER_LETTER:    aStr += 'a'; break;
944cdf0e10cSrcweir                 case SVX_NUM_CHARS_LOWER_LETTER_N:  aStr += 'a'; break;
945cdf0e10cSrcweir                 case SVX_NUM_ROMAN_UPPER:           aStr += 'I'; break;
946cdf0e10cSrcweir                 case SVX_NUM_ROMAN_LOWER:           aStr += 'i'; break;
947cdf0e10cSrcweir                 //case ARABIC:
948cdf0e10cSrcweir                 default:                    aStr += '1'; break;
949cdf0e10cSrcweir             }
950cdf0e10cSrcweir         }
951cdf0e10cSrcweir         //#i61007# order of captions
952cdf0e10cSrcweir         if( bOrderNumberingFirst )
953cdf0e10cSrcweir         {
954cdf0e10cSrcweir             aStr += aNumberingSeparatorED.GetText();
955cdf0e10cSrcweir             aStr += aCategoryBox.GetText();
956cdf0e10cSrcweir         }
957cdf0e10cSrcweir         aStr += aTextEdit.GetText();
958cdf0e10cSrcweir     }
959cdf0e10cSrcweir     aPreview.SetPreviewText( aStr );
960cdf0e10cSrcweir }
961cdf0e10cSrcweir 
962cdf0e10cSrcweir /*------------------------------------------------------------------------
963cdf0e10cSrcweir  Beschreibung:	ComboBox ohne Spaces
964cdf0e10cSrcweir ------------------------------------------------------------------------*/
965cdf0e10cSrcweir 
KeyInput(const KeyEvent & rEvt)966cdf0e10cSrcweir void CaptionComboBox::KeyInput(const KeyEvent& rEvt)
967cdf0e10cSrcweir {
968cdf0e10cSrcweir 	if( rEvt.GetKeyCode().GetCode() != KEY_SPACE )
969cdf0e10cSrcweir 		SwComboBox::KeyInput(rEvt);
970cdf0e10cSrcweir }
971cdf0e10cSrcweir 
972cdf0e10cSrcweir 
973cdf0e10cSrcweir 
974