Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <view.hxx>
21 : #include <wrtsh.hxx>
22 : #include <cption.hxx>
23 : #include <fldmgr.hxx>
24 : #include <expfld.hxx>
25 : #include <numrule.hxx>
26 : #include <poolfmt.hxx>
27 : #include <docsh.hxx>
28 : #include <frmfmt.hxx>
29 : #include <calc.hxx>
30 : #include <uitool.hxx>
31 : #include <doc.hxx>
32 : #include <modcfg.hxx>
33 : #include <swmodule.hxx>
34 : #include <com/sun/star/frame/XStorable.hpp>
35 : #include <com/sun/star/text/GraphicCrop.hpp>
36 : #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
37 : #include <com/sun/star/text/XTextTableCursor.hpp>
38 : #include <com/sun/star/text/XTextTablesSupplier.hpp>
39 : #include <com/sun/star/text/TableColumnSeparator.hpp>
40 : #include <com/sun/star/text/XTextTable.hpp>
41 : #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
42 : #include <com/sun/star/text/XTextFramesSupplier.hpp>
43 : #include <com/sun/star/text/XTextFrame.hpp>
44 : #include <comphelper/string.hxx>
45 : #include <frmui.hrc>
46 : #include <globals.hrc>
47 : #include <SwStyleNameMapper.hxx>
48 :
49 : using namespace ::com::sun::star;
50 :
51 : extern String* GetOldGrfCat();
52 : extern String* GetOldTabCat();
53 : extern String* GetOldFrmCat();
54 : extern String* GetOldDrwCat();
55 :
56 : class SwSequenceOptionDialog : public SvxStandardDialog
57 : {
58 : ListBox* m_pLbLevel;
59 : Edit* m_pEdDelim;
60 :
61 : ListBox* m_pLbCharStyle;
62 : CheckBox* m_pApplyBorderAndShadowCB;
63 :
64 : //#i61007# order of captions
65 : ListBox* m_pLbCaptionOrder;
66 :
67 : SwView& rView;
68 : String aFldTypeName;
69 :
70 : public:
71 : SwSequenceOptionDialog( Window *pParent, SwView &rV,
72 : const String& rSeqFldType );
73 : virtual ~SwSequenceOptionDialog();
74 : virtual void Apply();
75 :
76 0 : bool IsApplyBorderAndShadow( void ) { return m_pApplyBorderAndShadowCB->IsChecked(); }
77 0 : void SetApplyBorderAndShadow( bool bSet ) { m_pApplyBorderAndShadowCB->Check(bSet); }
78 :
79 : //#i61007# order of captions
80 0 : bool IsOrderNumberingFirst() const {return m_pLbCaptionOrder->GetSelectEntryPos() == 1;}
81 0 : void SetOrderNumberingFirst(bool bSet) { m_pLbCaptionOrder->SelectEntryPos( bSet ? 1 : 0 ); }
82 :
83 : void SetCharacterStyle(const String& rStyle);
84 : String GetCharacterStyle() const;
85 : };
86 :
87 0 : String SwCaptionDialog::our_aSepTextSave = OUString(": "); // Caption separator text
88 :
89 0 : SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) :
90 : SvxStandardDialog( pParent, "InsertCaptionDialog", "modules/swriter/ui/insertcaption.ui" ),
91 : m_sNone( SW_RESSTR(SW_STR_NONE) ),
92 : rView( rV ),
93 0 : pMgr( new SwFldMgr(rView.GetWrtShellPtr()) ),
94 : bCopyAttributes( sal_False ),
95 0 : bOrderNumberingFirst( SW_MOD()->GetModuleConfig()->IsCaptionOrderNumberingFirst() )
96 : {
97 0 : get(m_pTextEdit, "caption_edit");
98 0 : get(m_pCategoryBox, "category");
99 0 : get(m_pFormatText, "numbering_label");
100 0 : get(m_pFormatBox, "numbering");
101 0 : get(m_pNumberingSeparatorFT, "num_separator");
102 0 : get(m_pNumberingSeparatorED, "num_separator_edit");
103 0 : get(m_pSepText, "separator_label");
104 0 : get(m_pSepEdit, "separator_edit");
105 0 : get(m_pPosText, "position_label");
106 0 : get(m_pPosBox, "position");
107 0 : get(m_pPreview, "preview");
108 0 : get(m_pOKButton, "ok");
109 0 : get(m_pAutoCaptionButton, "auto");
110 0 : get(m_pOptionButton, "options");
111 :
112 : //#i61007# order of captions
113 0 : ApplyCaptionOrder();
114 0 : SwWrtShell &rSh = rView.GetWrtShell();
115 0 : uno::Reference< frame::XModel > xModel = rView.GetDocShell()->GetBaseModel();
116 :
117 0 : eType = rSh.GetSelectionType();
118 0 : if ( eType & nsSelectionType::SEL_OLE )
119 : {
120 0 : eType = nsSelectionType::SEL_GRF;
121 0 : uno::Reference< text::XTextEmbeddedObjectsSupplier > xObjs(xModel, uno::UNO_QUERY);
122 0 : xNameAccess = xObjs->getEmbeddedObjects();
123 : }
124 :
125 0 : Link aLk = LINK( this, SwCaptionDialog, ModifyHdl );
126 0 : m_pCategoryBox->SetModifyHdl( aLk );
127 0 : m_pTextEdit->SetModifyHdl( aLk );
128 0 : m_pNumberingSeparatorED->SetModifyHdl ( aLk );
129 0 : m_pSepEdit->SetModifyHdl( aLk );
130 :
131 0 : aLk = LINK(this, SwCaptionDialog, SelectHdl);
132 0 : m_pCategoryBox->SetSelectHdl( aLk );
133 0 : m_pFormatBox->SetSelectHdl( aLk );
134 0 : m_pOptionButton->SetClickHdl( LINK( this, SwCaptionDialog, OptionHdl ) );
135 0 : m_pAutoCaptionButton->SetClickHdl(LINK(this, SwCaptionDialog, CaptionHdl));
136 :
137 0 : m_pCategoryBox->InsertEntry( m_sNone );
138 0 : sal_uInt16 i, nCount = pMgr->GetFldTypeCount();
139 0 : for (i = 0; i < nCount; i++)
140 : {
141 0 : SwFieldType *pType = pMgr->GetFldType( USHRT_MAX, i );
142 0 : if( pType->Which() == RES_SETEXPFLD &&
143 0 : ((SwSetExpFieldType *) pType)->GetType() & nsSwGetSetExpType::GSE_SEQ )
144 0 : m_pCategoryBox->InsertEntry(pType->GetName());
145 : }
146 :
147 0 : String* pString = 0;
148 0 : sal_uInt16 nPoolId = 0;
149 0 : if (eType & nsSelectionType::SEL_GRF)
150 : {
151 0 : nPoolId = RES_POOLCOLL_LABEL_ABB;
152 0 : pString = ::GetOldGrfCat();
153 0 : bCopyAttributes = sal_True;
154 0 : sObjectName = rSh.GetFlyName();
155 : //if not OLE
156 0 : if(!xNameAccess.is())
157 : {
158 0 : uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(xModel, uno::UNO_QUERY);
159 0 : xNameAccess = xGraphics->getGraphicObjects();
160 : }
161 :
162 : }
163 0 : else if( eType & nsSelectionType::SEL_TBL )
164 : {
165 0 : nPoolId = RES_POOLCOLL_LABEL_TABLE;
166 0 : pString = ::GetOldTabCat();
167 0 : uno::Reference< text::XTextTablesSupplier > xTables(xModel, uno::UNO_QUERY);
168 0 : xNameAccess = xTables->getTextTables();
169 0 : sObjectName = rSh.GetTableFmt()->GetName();
170 : }
171 0 : else if( eType & nsSelectionType::SEL_FRM )
172 : {
173 0 : nPoolId = RES_POOLCOLL_LABEL_FRAME;
174 0 : pString = ::GetOldFrmCat();
175 0 : uno::Reference< text::XTextFramesSupplier > xFrms(xModel, uno::UNO_QUERY);
176 0 : xNameAccess = xFrms->getTextFrames();
177 0 : sObjectName = rSh.GetFlyName();
178 : }
179 0 : else if( eType == nsSelectionType::SEL_TXT )
180 : {
181 0 : nPoolId = RES_POOLCOLL_LABEL_FRAME;
182 0 : pString = ::GetOldFrmCat();
183 : }
184 0 : else if( eType & nsSelectionType::SEL_DRW )
185 : {
186 0 : nPoolId = RES_POOLCOLL_LABEL_DRAWING;
187 0 : pString = ::GetOldDrwCat();
188 : }
189 0 : if( nPoolId )
190 : {
191 0 : if( pString && pString->Len())
192 0 : m_pCategoryBox->SetText( *pString );
193 : else
194 : m_pCategoryBox->SetText(
195 0 : SwStyleNameMapper::GetUIName( nPoolId, aEmptyStr ));
196 : }
197 :
198 : // aFormatBox
199 0 : sal_uInt16 nSelFmt = SVX_NUM_ARABIC;
200 0 : nCount = pMgr->GetFldTypeCount();
201 : SwFieldType* pFldType;
202 0 : for ( i = nCount; i; )
203 : {
204 0 : pFldType = pMgr->GetFldType(USHRT_MAX, --i);
205 0 : if( pFldType->GetName().equals(m_pCategoryBox->GetText()) )
206 : {
207 0 : nSelFmt = (sal_uInt16)((SwSetExpFieldType*)pFldType)->GetSeqFormat();
208 0 : break;
209 : }
210 : }
211 :
212 0 : nCount = pMgr->GetFormatCount(TYP_SEQFLD, false);
213 0 : for ( i = 0; i < nCount; ++i )
214 : {
215 0 : m_pFormatBox->InsertEntry( pMgr->GetFormatStr(TYP_SEQFLD, i) );
216 0 : sal_uInt16 nFmtId = pMgr->GetFormatId(TYP_SEQFLD, i);
217 0 : m_pFormatBox->SetEntryData( i, reinterpret_cast<void*>( nFmtId ) );
218 0 : if( nFmtId == nSelFmt )
219 0 : m_pFormatBox->SelectEntryPos( i );
220 : }
221 :
222 : // aPosBox
223 0 : switch (eType)
224 : {
225 : case nsSelectionType::SEL_GRF:
226 : case nsSelectionType::SEL_TBL:
227 : case nsSelectionType::SEL_TBL | nsSelectionType::SEL_NUM:
228 : case nsSelectionType::SEL_TBL | nsSelectionType::SEL_TXT:
229 : case nsSelectionType::SEL_TBL | nsSelectionType::SEL_NUM | nsSelectionType::SEL_TXT:
230 : case nsSelectionType::SEL_DRW:
231 : case nsSelectionType::SEL_DRW | nsSelectionType::SEL_BEZ:
232 0 : m_pPosBox->InsertEntry(SW_RESSTR(STR_CAPTION_ABOVE));
233 0 : m_pPosBox->InsertEntry(SW_RESSTR(STR_CAPTION_BELOW));
234 0 : break;
235 : case nsSelectionType::SEL_FRM:
236 : case nsSelectionType::SEL_TXT:
237 0 : m_pPosBox->InsertEntry(SW_RESSTR(STR_CAPTION_BEGINNING));
238 0 : m_pPosBox->InsertEntry(SW_RESSTR(STR_CAPTION_END ));
239 0 : break;
240 : }
241 0 : m_pPosBox->SelectEntryPos(1);
242 :
243 0 : m_pCategoryBox->GetModifyHdl().Call(m_pCategoryBox);
244 :
245 0 : m_pSepEdit->SetText(our_aSepTextSave);
246 0 : m_pTextEdit->GrabFocus();
247 0 : DrawSample();
248 0 : }
249 :
250 0 : void SwCaptionDialog::Apply()
251 : {
252 0 : InsCaptionOpt aOpt;
253 0 : aOpt.UseCaption() = sal_True;
254 0 : OUString aName( m_pCategoryBox->GetText() );
255 0 : if ( aName == m_sNone )
256 : {
257 0 : aOpt.SetCategory( aEmptyStr );
258 0 : aOpt.SetNumSeparator( aEmptyStr );
259 : }
260 : else
261 : {
262 0 : aOpt.SetCategory(comphelper::string::strip(aName, ' '));
263 0 : aOpt.SetNumSeparator( m_pNumberingSeparatorED->GetText() );
264 : }
265 0 : aOpt.SetNumType( (sal_uInt16)(sal_uIntPtr)m_pFormatBox->GetEntryData( m_pFormatBox->GetSelectEntryPos() ) );
266 0 : aOpt.SetSeparator( m_pSepEdit->IsEnabled() ? m_pSepEdit->GetText() : OUString() );
267 0 : aOpt.SetCaption( m_pTextEdit->GetText() );
268 0 : aOpt.SetPos( m_pPosBox->GetSelectEntryPos() );
269 0 : aOpt.IgnoreSeqOpts() = true;
270 0 : aOpt.CopyAttributes() = bCopyAttributes;
271 0 : aOpt.SetCharacterStyle( sCharacterStyle );
272 0 : rView.InsertCaption( &aOpt );
273 0 : our_aSepTextSave = m_pSepEdit->GetText();
274 0 : }
275 :
276 0 : IMPL_LINK_INLINE_START( SwCaptionDialog, OptionHdl, Button*, pButton )
277 : {
278 0 : OUString sFldTypeName = m_pCategoryBox->GetText();
279 0 : if(sFldTypeName == m_sNone)
280 0 : sFldTypeName = aEmptyStr;
281 0 : SwSequenceOptionDialog aDlg( pButton, rView, sFldTypeName );
282 0 : aDlg.SetApplyBorderAndShadow(bCopyAttributes);
283 0 : aDlg.SetCharacterStyle( sCharacterStyle );
284 0 : aDlg.SetOrderNumberingFirst( bOrderNumberingFirst );
285 0 : aDlg.Execute();
286 0 : bCopyAttributes = aDlg.IsApplyBorderAndShadow();
287 0 : sCharacterStyle = aDlg.GetCharacterStyle();
288 : //#i61007# order of captions
289 0 : if( bOrderNumberingFirst != aDlg.IsOrderNumberingFirst() )
290 : {
291 0 : bOrderNumberingFirst = aDlg.IsOrderNumberingFirst();
292 0 : SW_MOD()->GetModuleConfig()->SetCaptionOrderNumberingFirst(bOrderNumberingFirst);
293 0 : ApplyCaptionOrder();
294 : }
295 0 : DrawSample();
296 0 : return 0;
297 : }
298 0 : IMPL_LINK_INLINE_END( SwCaptionDialog, OptionHdl, Button*, pButton )
299 :
300 0 : IMPL_LINK_NOARG_INLINE_START(SwCaptionDialog, SelectHdl)
301 : {
302 0 : DrawSample();
303 0 : return 0;
304 : }
305 0 : IMPL_LINK_NOARG_INLINE_END(SwCaptionDialog, SelectHdl)
306 :
307 0 : IMPL_LINK_NOARG(SwCaptionDialog, ModifyHdl)
308 : {
309 0 : SwWrtShell &rSh = rView.GetWrtShell();
310 0 : OUString sFldTypeName = m_pCategoryBox->GetText();
311 0 : bool bCorrectFldName = !sFldTypeName.isEmpty();
312 0 : bool bNone = sFldTypeName == m_sNone;
313 0 : SwFieldType* pType = (bCorrectFldName && !bNone)
314 0 : ? rSh.GetFldType( RES_SETEXPFLD, sFldTypeName )
315 0 : : 0;
316 0 : m_pOKButton->Enable( bCorrectFldName &&
317 0 : (!pType ||
318 0 : ((SwSetExpFieldType*)pType)->GetType() == nsSwGetSetExpType::GSE_SEQ) );
319 0 : m_pOptionButton->Enable( m_pOKButton->IsEnabled() && !bNone );
320 0 : m_pNumberingSeparatorFT->Enable( bOrderNumberingFirst && !bNone );
321 0 : m_pNumberingSeparatorED->Enable( bOrderNumberingFirst && !bNone );
322 0 : m_pFormatText->Enable( !bNone );
323 0 : m_pFormatBox->Enable( !bNone );
324 0 : m_pSepText->Enable( !bNone );
325 0 : m_pSepEdit->Enable( !bNone );
326 0 : DrawSample();
327 0 : return 0;
328 : }
329 :
330 0 : IMPL_LINK_NOARG(SwCaptionDialog, CaptionHdl)
331 : {
332 0 : SfxItemSet aSet( rView.GetDocShell()->GetDoc()->GetAttrPool() );
333 0 : SwCaptionOptDlg aDlg( this, aSet );
334 0 : aDlg.Execute();
335 :
336 0 : return 0;
337 : }
338 :
339 0 : void SwCaptionDialog::DrawSample()
340 : {
341 0 : String aStr;
342 0 : String sCaption = m_pTextEdit->GetText();
343 :
344 : // number
345 0 : OUString sFldTypeName = m_pCategoryBox->GetText();
346 0 : bool bNone = sFldTypeName == m_sNone;
347 0 : if( !bNone )
348 : {
349 : sal_uInt16 nNumFmt = (sal_uInt16)(sal_uIntPtr)m_pFormatBox->GetEntryData(
350 0 : m_pFormatBox->GetSelectEntryPos() );
351 0 : if( SVX_NUM_NUMBER_NONE != nNumFmt )
352 : {
353 : // category
354 : //#i61007# order of captions
355 0 : if( !bOrderNumberingFirst )
356 : {
357 0 : aStr += sFldTypeName;
358 0 : if ( aStr.Len() > 0 )
359 0 : aStr += ' ';
360 : }
361 :
362 0 : SwWrtShell &rSh = rView.GetWrtShell();
363 : SwSetExpFieldType* pFldType = (SwSetExpFieldType*)rSh.GetFldType(
364 0 : RES_SETEXPFLD, sFldTypeName );
365 0 : if( pFldType && pFldType->GetOutlineLvl() < MAXLEVEL )
366 : {
367 0 : sal_Int8 nLvl = pFldType->GetOutlineLvl();
368 0 : SwNumberTree::tNumberVector aNumVector;
369 0 : for( sal_Int8 i = 0; i <= nLvl; ++i )
370 0 : aNumVector.push_back(1);
371 :
372 : String sNumber( rSh.GetOutlineNumRule()->
373 0 : MakeNumString(aNumVector, sal_False ));
374 0 : if( sNumber.Len() )
375 0 : (aStr += sNumber) += pFldType->GetDelimiter();
376 : }
377 :
378 0 : switch( nNumFmt )
379 : {
380 0 : case SVX_NUM_CHARS_UPPER_LETTER: aStr += 'A'; break;
381 0 : case SVX_NUM_CHARS_UPPER_LETTER_N: aStr += 'A'; break;
382 0 : case SVX_NUM_CHARS_LOWER_LETTER: aStr += 'a'; break;
383 0 : case SVX_NUM_CHARS_LOWER_LETTER_N: aStr += 'a'; break;
384 0 : case SVX_NUM_ROMAN_UPPER: aStr += 'I'; break;
385 0 : case SVX_NUM_ROMAN_LOWER: aStr += 'i'; break;
386 0 : default: aStr += '1'; break;
387 : }
388 : //#i61007# order of captions
389 0 : if( bOrderNumberingFirst )
390 : {
391 0 : aStr += m_pNumberingSeparatorED->GetText();
392 0 : aStr += sFldTypeName;
393 : }
394 :
395 : }
396 0 : if( sCaption.Len() > 0 )
397 : {
398 0 : aStr += m_pSepEdit->GetText();
399 : }
400 : }
401 0 : aStr += sCaption;
402 : // do preview!
403 0 : m_pPreview->SetPreviewText( aStr );
404 0 : }
405 :
406 0 : SwCaptionDialog::~SwCaptionDialog()
407 : {
408 0 : delete pMgr;
409 0 : }
410 :
411 0 : SwSequenceOptionDialog::SwSequenceOptionDialog( Window *pParent, SwView &rV,
412 : const String& rSeqFldType )
413 : : SvxStandardDialog( pParent, "CaptionOptionsDialog", "modules/swriter/ui/captionoptions.ui" ),
414 : rView( rV ),
415 0 : aFldTypeName( rSeqFldType )
416 : {
417 0 : get(m_pLbLevel, "level");
418 0 : get(m_pEdDelim, "separator");
419 0 : get(m_pLbCharStyle, "style");
420 0 : get(m_pApplyBorderAndShadowCB, "border_and_shadow");
421 0 : get(m_pLbCaptionOrder, "caption_order");
422 :
423 0 : SwWrtShell &rSh = rView.GetWrtShell();
424 :
425 0 : OUString sNone(SW_RESSTR(SW_STR_NONE));
426 :
427 0 : m_pLbLevel->InsertEntry(sNone);
428 0 : for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
429 0 : m_pLbLevel->InsertEntry( OUString::number(n+1) );
430 :
431 : SwSetExpFieldType* pFldType = (SwSetExpFieldType*)rSh.GetFldType(
432 0 : RES_SETEXPFLD, aFldTypeName );
433 :
434 0 : sal_Unicode nLvl = MAXLEVEL;
435 0 : OUString sDelim(": ");
436 0 : if( pFldType )
437 : {
438 0 : sDelim = pFldType->GetDelimiter();
439 0 : nLvl = pFldType->GetOutlineLvl();
440 : }
441 :
442 0 : m_pLbLevel->SelectEntryPos( nLvl < MAXLEVEL ? nLvl + 1 : 0 );
443 0 : m_pEdDelim->SetText(sDelim);
444 :
445 0 : m_pLbCharStyle->InsertEntry(sNone);
446 0 : ::FillCharStyleListBox( *m_pLbCharStyle, rView.GetDocShell(), true, true );
447 0 : m_pLbCharStyle->SelectEntryPos( 0 );
448 0 : }
449 :
450 0 : SwSequenceOptionDialog::~SwSequenceOptionDialog()
451 : {
452 0 : }
453 :
454 0 : void SwSequenceOptionDialog::Apply()
455 : {
456 0 : SwWrtShell &rSh = rView.GetWrtShell();
457 : SwSetExpFieldType* pFldType = (SwSetExpFieldType*)rSh.GetFldType(
458 0 : RES_SETEXPFLD, aFldTypeName );
459 :
460 0 : sal_Int8 nLvl = (sal_Int8)( m_pLbLevel->GetSelectEntryPos() - 1);
461 0 : sal_Unicode cDelim = m_pEdDelim->GetText()[0];
462 :
463 0 : bool bUpdate = true;
464 0 : if( pFldType )
465 : {
466 0 : pFldType->SetDelimiter( OUString(cDelim) );
467 0 : pFldType->SetOutlineLvl( nLvl );
468 : }
469 0 : else if( aFldTypeName.Len() && nLvl < MAXLEVEL )
470 : {
471 : // then we have to insert that
472 0 : SwSetExpFieldType aFldType( rSh.GetDoc(), aFldTypeName, nsSwGetSetExpType::GSE_SEQ );
473 0 : aFldType.SetDelimiter( OUString(cDelim) );
474 0 : aFldType.SetOutlineLvl( nLvl );
475 0 : rSh.InsertFldType( aFldType );
476 : }
477 : else
478 0 : bUpdate = false;
479 :
480 0 : if( bUpdate )
481 0 : rSh.UpdateExpFlds();
482 0 : }
483 :
484 0 : String SwSequenceOptionDialog::GetCharacterStyle() const
485 : {
486 0 : String sRet;
487 0 : if(m_pLbCharStyle->GetSelectEntryPos())
488 0 : sRet = m_pLbCharStyle->GetSelectEntry();
489 0 : return sRet;
490 : }
491 :
492 0 : void SwSequenceOptionDialog::SetCharacterStyle(const String& rStyle)
493 : {
494 0 : m_pLbCharStyle->SelectEntryPos(0);
495 0 : m_pLbCharStyle->SelectEntry(rStyle);
496 0 : }
497 :
498 0 : long CategoryBox::PreNotify( NotifyEvent& rNEvt )
499 : {
500 0 : long nHandled = 0;
501 0 : if( rNEvt.GetType() == EVENT_KEYINPUT &&
502 0 : rNEvt.GetKeyEvent()->GetCharCode() )
503 : {
504 0 : const KeyEvent* pEvent = rNEvt.GetKeyEvent();
505 0 : const KeyCode& rKeyCode = pEvent->GetKeyCode();
506 0 : sal_uInt16 nTmpCode = rKeyCode.GetFullCode() & ~KEY_ALLMODTYPE;
507 :
508 0 : if(nTmpCode != KEY_BACKSPACE && nTmpCode != KEY_RETURN
509 0 : && nTmpCode != KEY_TAB && nTmpCode != KEY_ESCAPE)
510 : {
511 0 : OUString sKey( pEvent->GetCharCode() );
512 0 : String sName( GetText() );
513 0 : Selection aSel( GetSelection() );
514 0 : aSel.Justify();
515 0 : if( aSel.Len() )
516 0 : sName.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
517 0 : sName.Insert( sKey, (xub_StrLen)aSel.Min() );
518 0 : if( !SwCalc::IsValidVarName( sName ))
519 0 : nHandled = 1;
520 : }
521 : }
522 0 : if(!nHandled)
523 0 : nHandled = ComboBox::PreNotify( rNEvt );
524 0 : return nHandled;
525 : }
526 :
527 0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeCategoryBox(Window* pParent, VclBuilder::stringmap &)
528 : {
529 0 : CategoryBox* pCategoryBox = new CategoryBox(pParent, WB_LEFT | WB_DROPDOWN | WB_VCENTER | WB_3DLOOK | WB_SORT);
530 0 : pCategoryBox->EnableAutoSize(true);
531 0 : return pCategoryBox;
532 : }
533 :
534 : /*-------------------------------------------------------------------------
535 : //#i61007# order of captions
536 : -----------------------------------------------------------------------*/
537 0 : void SwCaptionDialog::ApplyCaptionOrder()
538 : {
539 0 : m_pNumberingSeparatorFT->Enable(bOrderNumberingFirst);
540 0 : m_pNumberingSeparatorED->Enable(bOrderNumberingFirst);
541 0 : }
542 :
543 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|