xref: /trunk/main/sw/source/ui/frmdlg/cption.cxx (revision efeef26f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 #ifdef SW_DLLIMPLEMENTATION
27 #undef SW_DLLIMPLEMENTATION
28 #endif
29 
30 
31 
32 #ifndef _VIEW_HXX
33 #include <view.hxx>
34 #endif
35 #include <wrtsh.hxx>
36 #include <cption.hxx>
37 #include <fldmgr.hxx>
38 #include <expfld.hxx>
39 #include <numrule.hxx>
40 #include <poolfmt.hxx>
41 #include <docsh.hxx>
42 #include <frmfmt.hxx>
43 #include <calc.hxx>
44 #include <uitool.hxx>
45 #include <doc.hxx>
46 #include <modcfg.hxx>
47 #include <swmodule.hxx>
48 #include <com/sun/star/frame/XStorable.hpp>
49 #include <com/sun/star/text/GraphicCrop.hpp>
50 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
51 #include <com/sun/star/text/XTextTableCursor.hpp>
52 #include <com/sun/star/text/XTextTablesSupplier.hpp>
53 #include <com/sun/star/text/TableColumnSeparator.hpp>
54 #include <com/sun/star/text/XTextTable.hpp>
55 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
56 #include <com/sun/star/text/XTextEmbeddedObject.hpp>
57 #include <com/sun/star/text/XTextFramesSupplier.hpp>
58 #include <com/sun/star/text/XTextFrame.hpp>
59 
60 #ifndef _FRMUI_HRC
61 #include <frmui.hrc>
62 #endif
63 #ifndef _CPTION_HRC
64 #include <cption.hrc>
65 #endif
66 #include <SwStyleNameMapper.hxx>
67 using namespace ::com::sun::star;
68 
69 extern String* GetOldGrfCat();
70 extern String* GetOldTabCat();
71 extern String* GetOldFrmCat();
72 extern String* GetOldDrwCat();
73 
74 class SwSequenceOptionDialog : public SvxStandardDialog
75 {
76     FixedLine       aFlHeader;
77 	FixedText 		aFtLevel;
78 	ListBox 		aLbLevel;
79 	FixedText 		aFtDelim;
80 	Edit 			aEdDelim;
81 
82     FixedLine       aFlCatAndFrame;
83 	FixedText		aFtCharStyle;
84 	ListBox			aLbCharStyle;
85     CheckBox        aApplyBorderAndShadowCB;
86 
87     //#i61007# order of captions
88     FixedLine       aFlCaptionOrder;
89     FixedText       aFtCaptionOrder;
90     ListBox         aLbCaptionOrder;
91 
92     OKButton        aOKButton;
93 	CancelButton	aCancelButton;
94 	HelpButton 		aHelpButton;
95 
96     SwView&         rView;
97 	String			aFldTypeName;
98 
99 public:
100 	SwSequenceOptionDialog( Window *pParent, SwView &rV,
101 							const String& rSeqFldType );
102 	virtual ~SwSequenceOptionDialog();
103 	virtual void Apply();
104 
IsApplyBorderAndShadow(void)105     bool IsApplyBorderAndShadow( void ) { return aApplyBorderAndShadowCB.IsChecked(); }
SetApplyBorderAndShadow(bool bSet)106     void SetApplyBorderAndShadow( bool bSet )  { aApplyBorderAndShadowCB.Check(bSet); }
107 
108     //#i61007# order of captions
IsOrderNumberingFirst() const109     bool IsOrderNumberingFirst() const {return aLbCaptionOrder.GetSelectEntryPos() == 1;}
SetOrderNumberingFirst(bool bSet)110     void SetOrderNumberingFirst(bool bSet) { aLbCaptionOrder.SelectEntryPos( bSet ? 1 : 0 ); }
111 
112     void    SetCharacterStyle(const String& rStyle);
113     String  GetCharacterStyle() const;
114 };
115 
SwCaptionDialog(Window * pParent,SwView & rV)116 SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) :
117 
118 	SvxStandardDialog( pParent, SW_RES(DLG_CAPTION) ),
119 
120     aTextText     (this, SW_RES(TXT_TEXT    )),
121     aTextEdit     (this, SW_RES(EDT_TEXT    )),
122     aSettingsFL  (this, SW_RES(FL_SETTINGS)),
123     aCategoryText (this, SW_RES(TXT_CATEGORY)),
124     aCategoryBox  (this, SW_RES(BOX_CATEGORY)),
125     aFormatText   (this, SW_RES(TXT_FORMAT  )),
126     aFormatBox    (this, SW_RES(BOX_FORMAT  )),
127     aNumberingSeparatorFT(this, SW_RES(FT_NUM_SEP  )),
128     aNumberingSeparatorED(this, SW_RES(ED_NUM_SEP  )),
129     aSepText      (this, SW_RES(TXT_SEP     )),
130     aSepEdit      (this, SW_RES(EDT_SEP     )),
131     aPosText      (this, SW_RES(TXT_POS     )),
132     aPosBox       (this, SW_RES(BOX_POS     )),
133     aOKButton     (this, SW_RES(BTN_OK      )),
134     aCancelButton (this, SW_RES(BTN_CANCEL  )),
135     aHelpButton   (this, SW_RES(BTN_HELP    )),
136     aAutoCaptionButton(this, SW_RES(BTN_AUTOCAPTION)),
137 	aOptionButton (this, SW_RES(BTN_OPTION  )),
138     sNone(      SW_RES( STR_CATEGORY_NONE )),
139 	aPrevWin      (this, SW_RES(WIN_SAMPLE  )),
140 	rView( rV ),
141     pMgr( new SwFldMgr(rView.GetWrtShellPtr()) ),
142     bCopyAttributes( sal_False ),
143     bOrderNumberingFirst( SW_MOD()->GetModuleConfig()->IsCaptionOrderNumberingFirst() )
144 {
145     //#i61007# order of captions
146     if( bOrderNumberingFirst )
147         ApplyCaptionOrder();
148     SwWrtShell &rSh = rView.GetWrtShell();
149  	uno::Reference< frame::XModel >  xModel = rView.GetDocShell()->GetBaseModel();
150 
151 	eType = rSh.GetSelectionType();
152 	if ( eType & nsSelectionType::SEL_OLE )
153 	{
154 		eType = nsSelectionType::SEL_GRF;
155 	 	uno::Reference< text::XTextEmbeddedObjectsSupplier >  xObjs(xModel, uno::UNO_QUERY);
156 		xNameAccess = xObjs->getEmbeddedObjects();
157 	}
158 
159 	Link aLk = LINK( this, SwCaptionDialog, ModifyHdl );
160 	aCategoryBox.SetModifyHdl( aLk );
161 	aTextEdit	.SetModifyHdl( aLk );
162     aNumberingSeparatorED.SetModifyHdl ( aLk );
163 	aSepEdit	.SetModifyHdl( aLk );
164 
165 	aLk = LINK(this, SwCaptionDialog, SelectHdl);
166 	aCategoryBox.SetSelectHdl( aLk );
167 	aFormatBox	.SetSelectHdl( aLk );
168 	aOptionButton.SetClickHdl( LINK( this, SwCaptionDialog, OptionHdl ) );
169 	aAutoCaptionButton.SetClickHdl(LINK(this, SwCaptionDialog, CaptionHdl));
170 
171     aCategoryBox.InsertEntry( sNone );
172 	sal_uInt16 i, nCount = pMgr->GetFldTypeCount();
173 	for (i = 0; i < nCount; i++)
174 	{
175 		SwFieldType *pType = pMgr->GetFldType( USHRT_MAX, i );
176 		if( pType->Which() == RES_SETEXPFLD &&
177 			((SwSetExpFieldType *) pType)->GetType() & nsSwGetSetExpType::GSE_SEQ )
178             aCategoryBox.InsertEntry(pType->GetName());
179 	}
180 
181     String* pString = 0;
182 	sal_uInt16 nPoolId = 0;
183 	if (eType & nsSelectionType::SEL_GRF)
184 	{
185 		nPoolId = RES_POOLCOLL_LABEL_ABB;
186         pString = ::GetOldGrfCat();
187 		bCopyAttributes = sal_True;
188 		sObjectName = rSh.GetFlyName();
189 		//if not OLE
190 		if(!xNameAccess.is())
191 		{
192 		 uno::Reference< text::XTextGraphicObjectsSupplier >  xGraphics(xModel, uno::UNO_QUERY);
193 			xNameAccess = xGraphics->getGraphicObjects();
194 		}
195 
196 	}
197 	else if( eType & nsSelectionType::SEL_TBL )
198 	{
199 		nPoolId = RES_POOLCOLL_LABEL_TABLE;
200         pString = ::GetOldTabCat();
201 		uno::Reference< text::XTextTablesSupplier >  xTables(xModel, uno::UNO_QUERY);
202 		xNameAccess = xTables->getTextTables();
203 		sObjectName = rSh.GetTableFmt()->GetName();
204 	}
205 	else if( eType & nsSelectionType::SEL_FRM )
206 	{
207 		nPoolId = RES_POOLCOLL_LABEL_FRAME;
208         pString = ::GetOldFrmCat();
209 	 	uno::Reference< text::XTextFramesSupplier >  xFrms(xModel, uno::UNO_QUERY);
210 		xNameAccess = xFrms->getTextFrames();
211 		sObjectName = rSh.GetFlyName();
212 	}
213 	else if( eType == nsSelectionType::SEL_TXT )
214 	{
215 		nPoolId = RES_POOLCOLL_LABEL_FRAME;
216         pString = ::GetOldFrmCat();
217 	}
218 	else if( eType & nsSelectionType::SEL_DRW )
219 	{
220 		nPoolId = RES_POOLCOLL_LABEL_DRAWING;
221         pString = ::GetOldDrwCat();
222 	}
223 	if( nPoolId )
224 	{
225 		if( pString && pString->Len())
226 			aCategoryBox.SetText( *pString );
227 		else
228 			aCategoryBox.SetText(
229 					SwStyleNameMapper::GetUIName( nPoolId, aEmptyStr ));
230 	}
231 
232     // aFormatBox
233 	sal_uInt16 nSelFmt = SVX_NUM_ARABIC;
234 	nCount = pMgr->GetFldTypeCount();
235 	SwFieldType* pFldType;
236 	for ( i = nCount; i; )
237 		if( ( pFldType = pMgr->GetFldType(USHRT_MAX, --i))->GetName() ==
238             aCategoryBox.GetText() )
239 		{
240 			nSelFmt = (sal_uInt16)((SwSetExpFieldType*)pFldType)->GetSeqFormat();
241 			break;
242 		}
243 
244 
245 	nCount = pMgr->GetFormatCount(TYP_SEQFLD, sal_False);
246 	for ( i = 0; i < nCount; ++i )
247 	{
248         aFormatBox.InsertEntry( pMgr->GetFormatStr(TYP_SEQFLD, i) );
249 		sal_uInt16 nFmtId = pMgr->GetFormatId(TYP_SEQFLD, i);
250         aFormatBox.SetEntryData( i, reinterpret_cast<void*>( nFmtId ) );
251 		if( nFmtId == nSelFmt )
252 			aFormatBox.SelectEntryPos( i );
253 	}
254 
255 	// aPosBox
256 	switch (eType)
257 	{
258 		case nsSelectionType::SEL_GRF:
259 		case nsSelectionType::SEL_TBL:
260 		case nsSelectionType::SEL_TBL | nsSelectionType::SEL_NUM:
261 		case nsSelectionType::SEL_TBL | nsSelectionType::SEL_TXT:
262 		case nsSelectionType::SEL_TBL | nsSelectionType::SEL_NUM | nsSelectionType::SEL_TXT:
263 		case nsSelectionType::SEL_DRW:
264 		case nsSelectionType::SEL_DRW | nsSelectionType::SEL_BEZ:
265 			aPosBox.InsertEntry(SW_RESSTR(STR_ABOVE));
266 			aPosBox.InsertEntry(SW_RESSTR(STR_CP_BELOW));
267 			break;
268 		case nsSelectionType::SEL_FRM:
269 		case nsSelectionType::SEL_TXT:
270 			aPosBox.InsertEntry(SW_RESSTR(STR_BEGINNING));
271 			aPosBox.InsertEntry(SW_RESSTR(STR_END	  ));
272 			break;
273 	}
274 	aPosBox.SelectEntryPos(1);
275 	if (eType & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_DRW))
276     {
277         aPosText.Enable( sal_False );
278         aPosBox.Enable( sal_False );
279     }
280 
281 	aCategoryBox.GetModifyHdl().Call(&aCategoryBox);
282 
283 	FreeResource();
284 
285     CheckButtonWidth();
286 	aTextEdit.GrabFocus();
287 	DrawSample();
288 }
289 
Apply()290 void SwCaptionDialog::Apply()
291 {
292 	InsCaptionOpt aOpt;
293 	aOpt.UseCaption() = sal_True;
294     String aName( aCategoryBox.GetText() );
295     if ( aName == sNone )
296         aOpt.SetCategory( aEmptyStr );
297     else
298     {
299         aName.EraseLeadingChars( ' ' );
300         aName.EraseTrailingChars( ' ' );
301         aOpt.SetCategory( aName );
302     }
303     aOpt.SetNumType( (sal_uInt16)(sal_uIntPtr)aFormatBox.GetEntryData( aFormatBox.GetSelectEntryPos() ) );
304     aOpt.SetSeparator( aSepEdit.IsEnabled() ? aSepEdit.GetText() : String() );
305     aOpt.SetNumSeparator( aNumberingSeparatorED.GetText() );
306     aOpt.SetCaption( aTextEdit.GetText() );
307     aOpt.SetPos( aPosBox.GetSelectEntryPos() );
308 	aOpt.IgnoreSeqOpts() = sal_True;
309 	aOpt.CopyAttributes() = bCopyAttributes;
310     aOpt.SetCharacterStyle( sCharacterStyle );
311     rView.InsertCaption( &aOpt );
312 }
313 
IMPL_LINK_INLINE_START(SwCaptionDialog,OptionHdl,Button *,pButton)314 IMPL_LINK_INLINE_START( SwCaptionDialog, OptionHdl, Button*, pButton )
315 {
316     String sFldTypeName = aCategoryBox.GetText();
317     if(sFldTypeName == sNone)
318         sFldTypeName = aEmptyStr;
319     SwSequenceOptionDialog  aDlg( pButton, rView, sFldTypeName );
320     aDlg.SetApplyBorderAndShadow(bCopyAttributes);
321     aDlg.SetCharacterStyle( sCharacterStyle );
322     aDlg.SetOrderNumberingFirst( bOrderNumberingFirst );
323 	aDlg.Execute();
324     bCopyAttributes = aDlg.IsApplyBorderAndShadow();
325     sCharacterStyle = aDlg.GetCharacterStyle();
326     //#i61007# order of captions
327     if( bOrderNumberingFirst != aDlg.IsOrderNumberingFirst() )
328     {
329         bOrderNumberingFirst = aDlg.IsOrderNumberingFirst();
330         SW_MOD()->GetModuleConfig()->SetCaptionOrderNumberingFirst(bOrderNumberingFirst);
331         ApplyCaptionOrder();
332     }
333     DrawSample();
334 	return 0;
335 }
IMPL_LINK_INLINE_END(SwCaptionDialog,OptionHdl,Button *,EMPTYARG)336 IMPL_LINK_INLINE_END( SwCaptionDialog, OptionHdl, Button*, EMPTYARG )
337 
338 IMPL_LINK_INLINE_START( SwCaptionDialog, SelectHdl, ListBox *, EMPTYARG )
339 {
340 	DrawSample();
341 	return 0;
342 }
IMPL_LINK_INLINE_END(SwCaptionDialog,SelectHdl,ListBox *,EMPTYARG)343 IMPL_LINK_INLINE_END( SwCaptionDialog, SelectHdl, ListBox *, EMPTYARG )
344 
345 
346 
347 IMPL_LINK( SwCaptionDialog, ModifyHdl, Edit *, EMPTYARG )
348 {
349     SwWrtShell &rSh = rView.GetWrtShell();
350     String sFldTypeName = aCategoryBox.GetText();
351     sal_Bool bCorrectFldName = sFldTypeName.Len() > 0;
352     sal_Bool bNone = sFldTypeName == sNone;
353     SwFieldType* pType = (bCorrectFldName && !bNone)
354                     ? rSh.GetFldType( RES_SETEXPFLD, sFldTypeName )
355                     : 0;
356     aOKButton.Enable( bCorrectFldName &&
357                         (!pType ||
358                             ((SwSetExpFieldType*)pType)->GetType() == nsSwGetSetExpType::GSE_SEQ)
359                                 && 0 != sFldTypeName.Len() );
360     aOptionButton.Enable( aOKButton.IsEnabled() && !bNone );
361     aFormatText.Enable( !bNone );
362     aFormatBox.Enable( !bNone );
363     aSepText.Enable( !bNone );
364     aSepEdit.Enable( !bNone );
365     DrawSample();
366 	return 0;
367 }
368 
IMPL_LINK(SwCaptionDialog,CaptionHdl,PushButton *,EMPTYARG)369 IMPL_LINK(SwCaptionDialog, CaptionHdl, PushButton*, EMPTYARG)
370 {
371 	SfxItemSet	aSet( rView.GetDocShell()->GetDoc()->GetAttrPool() );
372 	SwCaptionOptDlg aDlg( this, aSet );
373 	aDlg.Execute();
374 
375 	return 0;
376 }
377 
DrawSample()378 void SwCaptionDialog::DrawSample()
379 {
380 	String aStr;
381 	String sCaption = aTextEdit.GetText();
382 
383 	// Nummer
384     String sFldTypeName = aCategoryBox.GetText();
385     sal_Bool bNone = sFldTypeName == sNone;
386     if( !bNone )
387     {
388         sal_uInt16 nNumFmt = (sal_uInt16)(sal_uIntPtr)aFormatBox.GetEntryData(
389                                         aFormatBox.GetSelectEntryPos() );
390         if( SVX_NUM_NUMBER_NONE != nNumFmt )
391         {
392             // Kategorie
393             //#i61007# order of captions
394             if( !bOrderNumberingFirst )
395             {
396                 aStr += sFldTypeName;
397                 if ( aStr.Len() > 0 )
398                     aStr += ' ';
399             }
400 
401             SwWrtShell &rSh = rView.GetWrtShell();
402             SwSetExpFieldType* pFldType = (SwSetExpFieldType*)rSh.GetFldType(
403                                             RES_SETEXPFLD, sFldTypeName );
404             if( pFldType && pFldType->GetOutlineLvl() < MAXLEVEL )
405             {
406                 sal_Int8 nLvl = pFldType->GetOutlineLvl();
407                 SwNumberTree::tNumberVector aNumVector;
408                 for( sal_Int8 i = 0; i <= nLvl; ++i )
409                     aNumVector.push_back(1);
410 
411                 String sNumber( rSh.GetOutlineNumRule()->
412                                 MakeNumString(aNumVector, sal_False ));
413                 if( sNumber.Len() )
414                     (aStr += sNumber) += pFldType->GetDelimiter();
415             }
416 
417             switch( nNumFmt )
418             {
419             case SVX_NUM_CHARS_UPPER_LETTER:    aStr += 'A'; break;
420             case SVX_NUM_CHARS_UPPER_LETTER_N:  aStr += 'A'; break;
421             case SVX_NUM_CHARS_LOWER_LETTER:    aStr += 'a'; break;
422             case SVX_NUM_CHARS_LOWER_LETTER_N:  aStr += 'a'; break;
423             case SVX_NUM_ROMAN_UPPER:           aStr += 'I'; break;
424             case SVX_NUM_ROMAN_LOWER:           aStr += 'i'; break;
425             //case ARABIC:
426             default:                    aStr += '1'; break;
427             }
428             //#i61007# order of captions
429             if( bOrderNumberingFirst )
430             {
431                 aStr += aNumberingSeparatorED.GetText();
432                 aStr += sFldTypeName;
433             }
434 
435         }
436         if( sCaption.Len() > 0 )
437 	{
438             aStr += aSepEdit.GetText();
439         }
440     }
441     aStr += sCaption;
442 	// do preview!
443 	aPrevWin.SetPreviewText( aStr );
444 }
445 
CheckButtonWidth()446 void SwCaptionDialog::CheckButtonWidth()
447 {
448     // check if the text of the AutoCaption button is to wide
449     const long nOffset = 10;
450     String sText = aAutoCaptionButton.GetText();
451     long nTxtW = aAutoCaptionButton.GetTextWidth( sText );
452     if ( sText.Search( '~' ) == STRING_NOTFOUND )
453         nTxtW += nOffset;
454     long nBtnW = aAutoCaptionButton.GetSizePixel().Width();
455     if ( nTxtW > nBtnW )
456     {
457         // then broaden all buttons
458         Size aNewSize;
459         long nDelta = Max( ( nTxtW - nBtnW ), nOffset );
460         Button* pBtns[] =
461         {
462             &aOKButton, &aCancelButton, &aHelpButton, &aAutoCaptionButton, &aOptionButton
463         };
464         Button** pCurrent = pBtns;
465         for ( sal_uInt32 i = 0; i < sizeof( pBtns ) / sizeof( pBtns[ 0 ] ); ++i, ++pCurrent )
466         {
467             aNewSize = (*pCurrent)->GetSizePixel();
468             aNewSize.Width() += nDelta;
469             (*pCurrent)->SetSizePixel( aNewSize );
470         }
471         // and the dialog
472         aNewSize = GetOutputSizePixel();
473         aNewSize.Width() += nDelta;
474         SetOutputSizePixel( aNewSize );
475     }
476 }
477 
~SwCaptionDialog()478 SwCaptionDialog::~SwCaptionDialog()
479 {
480 	delete pMgr;
481 }
482 /*  */
483 
484 
SwSequenceOptionDialog(Window * pParent,SwView & rV,const String & rSeqFldType)485 SwSequenceOptionDialog::SwSequenceOptionDialog( Window *pParent, SwView &rV,
486 											const String& rSeqFldType )
487 	: SvxStandardDialog( pParent, SW_RES(DLG_SEQUENCE_OPTION) ),
488     aFlHeader       (this, SW_RES(FL_HEADER    )),
489     aFtLevel        (this, SW_RES(FT_LEVEL     )),
490     aLbLevel        (this, SW_RES(LB_LEVEL     )),
491     aFtDelim        (this, SW_RES(FT_SEPARATOR )),
492     aEdDelim        (this, SW_RES(ED_SEPARATOR )),
493     aFlCatAndFrame  (this, SW_RES(FL_CATANDFRAME)),
494     aFtCharStyle    (this, SW_RES(FT_CHARSTYLE )),
495     aLbCharStyle    (this, SW_RES(LB_CHARSTYLE )),
496     aApplyBorderAndShadowCB(this, SW_RES(CB_APPLYBAS)),
497     aFlCaptionOrder(this, SW_RES( FL_ORDER )), //#i61007# order of captions
498     aFtCaptionOrder(this, SW_RES( FT_ORDER )),
499     aLbCaptionOrder(this, SW_RES( LB_ORDER )),
500 	aOKButton		(this, SW_RES(BTN_OK	   )),
501 	aCancelButton	(this, SW_RES(BTN_CANCEL   )),
502 	aHelpButton		(this, SW_RES(BTN_HELP     )),
503 
504     rView( rV ),
505     aFldTypeName( rSeqFldType )
506 {
507 	FreeResource();
508 	SwWrtShell &rSh = rView.GetWrtShell();
509 
510 	for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
511 		aLbLevel.InsertEntry( String::CreateFromInt32(n+1) );
512 
513 	SwSetExpFieldType* pFldType = (SwSetExpFieldType*)rSh.GetFldType(
514 										RES_SETEXPFLD, aFldTypeName );
515 
516 	sal_Unicode nLvl = MAXLEVEL;
517 	String sDelim( String::CreateFromAscii( ": " ) );
518 	if( pFldType )
519 	{
520 		sDelim = pFldType->GetDelimiter();
521 		nLvl = pFldType->GetOutlineLvl();
522 	}
523 
524 	aLbLevel.SelectEntryPos( nLvl < MAXLEVEL ? nLvl + 1 : 0 );
525 	aEdDelim.SetText( sDelim );
526 
527 	::FillCharStyleListBox( aLbCharStyle, rView.GetDocShell(), sal_True, sal_True );
528 	aLbCharStyle.SelectEntryPos( 0 );
529 }
530 
~SwSequenceOptionDialog()531 SwSequenceOptionDialog::~SwSequenceOptionDialog()
532 {
533 }
534 
Apply()535 void SwSequenceOptionDialog::Apply()
536 {
537 	SwWrtShell &rSh = rView.GetWrtShell();
538 	SwSetExpFieldType* pFldType = (SwSetExpFieldType*)rSh.GetFldType(
539 										RES_SETEXPFLD, aFldTypeName );
540 
541 	sal_Int8 nLvl = (sal_Int8)( aLbLevel.GetSelectEntryPos() - 1);
542 	sal_Unicode cDelim = aEdDelim.GetText().GetChar(0);
543 
544 	sal_Bool bUpdate = sal_True;
545 	if( pFldType )
546 	{
547 		pFldType->SetDelimiter( cDelim );
548 		pFldType->SetOutlineLvl( nLvl );
549 	}
550     else if( aFldTypeName.Len() && nLvl < MAXLEVEL )
551 	{
552 		// dann muessen wir das mal einfuegen
553 		SwSetExpFieldType aFldType( rSh.GetDoc(), aFldTypeName, nsSwGetSetExpType::GSE_SEQ );
554 		aFldType.SetDelimiter( cDelim );
555 		aFldType.SetOutlineLvl( nLvl );
556 		rSh.InsertFldType( aFldType );
557 	}
558 	else
559 		bUpdate = sal_False;
560 
561 	if( bUpdate )
562 		rSh.UpdateExpFlds();
563 }
564 
565 /*-- 24.08.2004 16:13:53---------------------------------------------------
566 
567   -----------------------------------------------------------------------*/
GetCharacterStyle() const568 String  SwSequenceOptionDialog::GetCharacterStyle() const
569 {
570     String sRet;
571     if(aLbCharStyle.GetSelectEntryPos())
572         sRet = aLbCharStyle.GetSelectEntry();
573     return sRet;
574 }
575 
576 /*-- 24.08.2004 16:14:00---------------------------------------------------
577 
578   -----------------------------------------------------------------------*/
SetCharacterStyle(const String & rStyle)579 void    SwSequenceOptionDialog::SetCharacterStyle(const String& rStyle)
580 {
581     aLbCharStyle.SelectEntryPos(0);
582     aLbCharStyle.SelectEntry(rStyle);
583 }
584 
PreNotify(NotifyEvent & rNEvt)585 long SwCaptionDialog::CategoryBox::PreNotify( NotifyEvent& rNEvt )
586 {
587 	long nHandled = 0;
588 	if( rNEvt.GetType() == EVENT_KEYINPUT &&
589 		rNEvt.GetKeyEvent()->GetCharCode() )
590 	{
591         const KeyEvent* pEvent = rNEvt.GetKeyEvent();
592         const KeyCode&  rKeyCode = pEvent->GetKeyCode();
593         sal_uInt16 nTmpCode = rKeyCode.GetFullCode() & ~KEY_ALLMODTYPE;
594 
595         if(nTmpCode != KEY_BACKSPACE && nTmpCode != KEY_RETURN
596                 && nTmpCode != KEY_TAB && nTmpCode != KEY_ESCAPE)
597         {
598             String sKey( pEvent->GetCharCode() ), sName( GetText() );
599             Selection aSel( GetSelection() );
600             aSel.Justify();
601             if( aSel.Len() )
602                 sName.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
603             sName.Insert( sKey, (xub_StrLen)aSel.Min() );
604             if( !SwCalc::IsValidVarName( sName ))
605                 nHandled = 1;
606         }
607 	}
608 	if(!nHandled)
609 		nHandled = ComboBox::PreNotify( rNEvt );
610 	return nHandled;
611 }
612 /*-- 01.11.2007 10:45:51---------------------------------------------------
613     //#i61007# order of captions
614   -----------------------------------------------------------------------*/
lcl_MoveH(Window & rWin,sal_Int32 nMove)615 void lcl_MoveH( Window& rWin, sal_Int32 nMove )
616 {
617     Point aPos( rWin.GetPosPixel() );
618     aPos.Y() += nMove;
619     rWin.SetPosPixel(aPos);
620 }
ApplyCaptionOrder()621 void SwCaptionDialog::ApplyCaptionOrder()
622 {
623     //have the settings changed?
624     bool bVisible = aNumberingSeparatorED.IsVisible() != 0;
625     if( bOrderNumberingFirst != bVisible )
626     {
627         sal_Int32 nDiff = aPosBox.GetPosPixel().Y() - aSepEdit.GetPosPixel().Y();
628 
629         aNumberingSeparatorFT.Show( bOrderNumberingFirst );
630         aNumberingSeparatorED.Show( bOrderNumberingFirst );
631         if( !bOrderNumberingFirst )
632         {
633             nDiff = -nDiff;
634         }
635         lcl_MoveH( aCategoryText, 2 * nDiff);
636         lcl_MoveH( aFormatText, -nDiff );
637         lcl_MoveH( aFormatBox, -nDiff );
638         lcl_MoveH( aCategoryBox, 2 * nDiff);
639         lcl_MoveH( aSepText, nDiff );
640         lcl_MoveH( aSepEdit, nDiff );
641         lcl_MoveH( aPosText, nDiff );
642         lcl_MoveH( aPosBox, nDiff );
643         lcl_MoveH( aPrevWin, nDiff );
644         Size aDlgSize( GetSizePixel() );
645         aDlgSize.Height() += nDiff;
646         SetSizePixel( aDlgSize );
647     }
648 }
649