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