Update ooo320-m1
[ooovba.git] / sw / source / ui / config / optload.cxx
blob040ed1714416f8b5c3012b7789463032dd3bf1cc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: optload.cxx,v $
10 * $Revision: 1.34 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #ifdef SW_DLLIMPLEMENTATION
34 #undef SW_DLLIMPLEMENTATION
35 #endif
38 #include <tools/shl.hxx>
39 #include <swtypes.hxx>
40 #ifndef _HELPID_H
41 #include <helpid.h>
42 #endif
43 #include <uiitems.hxx>
44 #ifndef _MODCFG_HXX
45 #include <modcfg.hxx>
46 #endif
47 #include "swmodule.hxx"
48 #include "usrpref.hxx"
49 #include "wrtsh.hxx"
50 #include "linkenum.hxx"
51 #include <uitool.hxx>
52 #include <view.hxx>
54 #include "globals.hrc"
55 #include "cmdid.h"
57 #include "optload.hrc"
58 #include "optload.hxx"
59 #include <svx/dlgutil.hxx>
60 #include <svx/htmlmode.hxx>
61 #include <fldmgr.hxx>
62 #include <poolfmt.hxx>
63 #include <expfld.hxx>
64 #include <caption.hxx>
65 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
67 #include <svtools/insdlg.hxx>
68 #include <sot/clsids.hxx>
69 #include <unotools/configmgr.hxx>
70 #include <docsh.hxx>
71 #ifndef _CONFIG_HRC
72 #include <config.hrc>
73 #endif
74 #include <SwStyleNameMapper.hxx>
75 #include <numrule.hxx>
76 #include <SwNodeNum.hxx>
78 #include <doc.hxx>
79 #include <svtools/cjkoptions.hxx>
81 using namespace ::com::sun::star;
83 #ifndef _SFXENUMITEM_HXX //autogen
84 #include <svtools/eitem.hxx>
85 #endif
87 /* -----------------22.10.98 15:12-------------------
89 * --------------------------------------------------*/
90 SwLoadOptPage::SwLoadOptPage( Window* pParent, const SfxItemSet& rSet ) :
92 SfxTabPage( pParent, SW_RES( TP_OPTLOAD_PAGE ), rSet ),
94 aUpdateFL ( this, SW_RES( FL_UPDATE ) ),
95 aLinkFT ( this, SW_RES( FT_LINK ) ),
96 aAlwaysRB ( this, SW_RES( RB_ALWAYS ) ),
97 aRequestRB ( this, SW_RES( RB_REQUEST ) ),
98 aNeverRB ( this, SW_RES( RB_NEVER ) ),
100 aFieldFT ( this, SW_RES( FT_FIELD ) ),
101 aAutoUpdateFields ( this, SW_RES( CB_AUTO_UPDATE_FIELDS ) ),
102 aAutoUpdateCharts ( this, SW_RES( CB_AUTO_UPDATE_CHARTS ) ),
104 aSettingsFL ( this, SW_RES( FL_SETTINGS ) ),
105 aMetricFT ( this, SW_RES( FT_METRIC ) ),
106 aMetricLB ( this, SW_RES( LB_METRIC ) ),
107 aTabFT ( this, SW_RES( FT_TAB ) ),
108 aTabMF ( this, SW_RES( MF_TAB ) ),
109 aUseSquaredPageMode ( this, SW_RES( CB_USE_SQUARE_PAGE_MODE ) ),
110 aUseCharUnit ( this , SW_RES( CB_USE_CHAR_UNIT ) ),
112 pWrtShell ( NULL ),
113 bHTMLMode ( FALSE ),
114 nLastTab ( 0 ),
115 nOldLinkMode( MANUAL )
118 FreeResource();
120 SvxStringArray aMetricArr( SW_RES( STR_ARR_METRIC ) );
121 for ( USHORT i = 0; i < aMetricArr.Count(); ++i )
123 String sMetric = aMetricArr.GetStringByPos( i );
124 FieldUnit eFUnit = (FieldUnit)aMetricArr.GetValue( i );
126 switch ( eFUnit )
128 case FUNIT_MM:
129 case FUNIT_CM:
130 case FUNIT_POINT:
131 case FUNIT_PICA:
132 case FUNIT_INCH:
134 // nur diese Metriken benutzen
135 USHORT nPos = aMetricLB.InsertEntry( sMetric );
136 aMetricLB.SetEntryData( nPos, (void*)(long)eFUnit );
138 default:; //prevent warning
141 aMetricLB.SetSelectHdl(LINK(this, SwLoadOptPage, MetricHdl));
143 const SfxPoolItem* pItem;
144 if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, FALSE, &pItem )
145 && ((SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON)
147 aTabFT.Hide();
148 aTabMF.Hide();
151 SvtCJKOptions aCJKOptions;
152 if(!aCJKOptions.IsAsianTypographyEnabled())
154 aUseSquaredPageMode.Hide();
155 aUseCharUnit.Hide();
159 /*-----------------18.01.97 12.43-------------------
161 --------------------------------------------------*/
163 SwLoadOptPage::~SwLoadOptPage()
167 /*-----------------18.01.97 12.43-------------------
169 --------------------------------------------------*/
171 SfxTabPage* __EXPORT SwLoadOptPage::Create( Window* pParent,
172 const SfxItemSet& rAttrSet )
174 return new SwLoadOptPage(pParent, rAttrSet );
177 /*-----------------18.01.97 12.42-------------------
179 --------------------------------------------------*/
181 BOOL __EXPORT SwLoadOptPage::FillItemSet( SfxItemSet& rSet )
183 BOOL bRet = FALSE;
184 SwModule* pMod = SW_MOD();
186 USHORT nNewLinkMode = AUTOMATIC;
187 if (aNeverRB.IsChecked())
188 nNewLinkMode = NEVER;
189 else if (aRequestRB.IsChecked())
190 nNewLinkMode = MANUAL;
192 SwFldUpdateFlags eFldFlags = aAutoUpdateFields.IsChecked() ?
193 aAutoUpdateCharts.IsChecked() ? AUTOUPD_FIELD_AND_CHARTS : AUTOUPD_FIELD_ONLY : AUTOUPD_OFF;
195 if(aAutoUpdateFields.IsChecked() != aAutoUpdateFields.GetSavedValue() ||
196 aAutoUpdateCharts.IsChecked() != aAutoUpdateCharts.GetSavedValue())
198 pMod->ApplyFldUpdateFlags(eFldFlags);
199 if(pWrtShell)
201 pWrtShell->SetFldUpdateFlags(eFldFlags);
202 pWrtShell->SetModified();
206 if (nNewLinkMode != nOldLinkMode)
208 pMod->ApplyLinkMode(nNewLinkMode);
209 if (pWrtShell)
211 pWrtShell->SetLinkUpdMode( nNewLinkMode );
212 pWrtShell->SetModified();
215 bRet = TRUE;
218 const USHORT nMPos = aMetricLB.GetSelectEntryPos();
219 if ( nMPos != aMetricLB.GetSavedValue() )
221 // Doppel-Cast fuer VA3.0
222 USHORT nFieldUnit = (USHORT)(long)aMetricLB.GetEntryData( nMPos );
223 rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, (UINT16)nFieldUnit ) );
224 bRet = TRUE;
227 if(aTabMF.IsVisible() && aTabMF.GetText() != aTabMF.GetSavedValue())
229 rSet.Put(SfxUInt16Item(SID_ATTR_DEFTABSTOP,
230 (USHORT)aTabMF.Denormalize(aTabMF.GetValue(FUNIT_TWIP))));
231 bRet = TRUE;
234 sal_Bool bIsUseCharUnitFlag = aUseCharUnit.IsChecked();
235 SvtCJKOptions aCJKOptions;
236 bIsUseCharUnitFlag = bIsUseCharUnitFlag && aCJKOptions.IsAsianTypographyEnabled();
237 if( bIsUseCharUnitFlag != aUseCharUnit.GetSavedValue())
239 rSet.Put(SfxBoolItem(SID_ATTR_APPLYCHARUNIT, bIsUseCharUnitFlag ));
240 bRet = TRUE;
243 sal_Bool bIsSquaredPageModeFlag = aUseSquaredPageMode.IsChecked();
244 if ( bIsSquaredPageModeFlag != aUseSquaredPageMode.GetSavedValue() )
246 pMod->ApplyDefaultPageMode( bIsSquaredPageModeFlag );
247 if ( pWrtShell )
249 SwDoc* pDoc = pWrtShell->GetDoc();
250 pDoc->SetDefaultPageMode( bIsSquaredPageModeFlag );
251 pWrtShell->SetModified();
253 bRet = TRUE;
256 return bRet;
258 /*-----------------18.01.97 12.42-------------------
260 --------------------------------------------------*/
261 void __EXPORT SwLoadOptPage::Reset( const SfxItemSet& rSet)
263 const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref(FALSE);
264 const SfxPoolItem* pItem;
266 if(SFX_ITEM_SET == rSet.GetItemState(FN_PARAM_WRTSHELL, FALSE, &pItem))
267 pWrtShell = (SwWrtShell*)((const SwPtrItem*)pItem)->GetValue();
269 SwFldUpdateFlags eFldFlags = AUTOUPD_GLOBALSETTING;
270 nOldLinkMode = GLOBALSETTING;
271 if (pWrtShell)
273 eFldFlags = pWrtShell->GetFldUpdateFlags(TRUE);
274 nOldLinkMode = pWrtShell->GetLinkUpdMode(TRUE);
276 if(GLOBALSETTING == nOldLinkMode)
277 nOldLinkMode = pUsrPref->GetUpdateLinkMode();
278 if(AUTOUPD_GLOBALSETTING == eFldFlags)
279 eFldFlags = pUsrPref->GetFldUpdateFlags();
281 aAutoUpdateFields.Check(eFldFlags != AUTOUPD_OFF);
282 aAutoUpdateCharts.Check(eFldFlags == AUTOUPD_FIELD_AND_CHARTS);
284 switch (nOldLinkMode)
286 case NEVER: aNeverRB.Check(); break;
287 case MANUAL: aRequestRB.Check(); break;
288 case AUTOMATIC: aAlwaysRB.Check(); break;
291 aAutoUpdateFields.SaveValue();
292 aAutoUpdateCharts.SaveValue();
293 aMetricLB.SetNoSelection();
294 if ( rSet.GetItemState( SID_ATTR_METRIC ) >= SFX_ITEM_AVAILABLE )
296 const SfxUInt16Item& rItem = (SfxUInt16Item&)rSet.Get( SID_ATTR_METRIC );
297 FieldUnit eFieldUnit = (FieldUnit)rItem.GetValue();
299 for ( USHORT i = 0; i < aMetricLB.GetEntryCount(); ++i )
301 if ( (int)(sal_IntPtr)aMetricLB.GetEntryData( i ) == (int)eFieldUnit )
303 aMetricLB.SelectEntryPos( i );
304 break;
307 ::SetFieldUnit(aTabMF, eFieldUnit);
309 aMetricLB.SaveValue();
310 if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_DEFTABSTOP, FALSE, &pItem))
312 nLastTab = ((SfxUInt16Item*)pItem)->GetValue();
313 aTabMF.SetValue(aTabMF.Normalize(nLastTab), FUNIT_TWIP);
315 aTabMF.SaveValue();
317 if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, FALSE, &pItem))
319 bHTMLMode = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON);
322 //default page mode loading
323 if(pWrtShell)
325 sal_Bool bSquaredPageMode = pWrtShell->GetDoc()->IsSquaredPageMode();
326 aUseSquaredPageMode.Check( bSquaredPageMode );
327 aUseSquaredPageMode.SaveValue();
330 if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_APPLYCHARUNIT, FALSE, &pItem))
332 BOOL bUseCharUnit = ((const SfxBoolItem*)pItem)->GetValue();
333 aUseCharUnit.Check(bUseCharUnit);
335 else
337 aUseCharUnit.Check(pUsrPref->IsApplyCharUnit());
339 aUseCharUnit.SaveValue();
341 /*-----------------13.01.97 14.44-------------------
342 Metric des Deftabstops umschalten
343 --------------------------------------------------*/
345 IMPL_LINK(SwLoadOptPage, MetricHdl, ListBox*, EMPTYARG)
347 const USHORT nMPos = aMetricLB.GetSelectEntryPos();
348 if(nMPos != USHRT_MAX)
350 // Doppel-Cast fuer VA3.0
351 FieldUnit eFieldUnit = (FieldUnit)(long)aMetricLB.GetEntryData( nMPos );
352 BOOL bModified = aTabMF.IsModified();
353 long nVal = bModified ?
354 sal::static_int_cast<sal_Int32, sal_Int64 >( aTabMF.Denormalize( aTabMF.GetValue( FUNIT_TWIP ) )) :
355 nLastTab;
356 ::SetFieldUnit( aTabMF, eFieldUnit );
357 aTabMF.SetValue( aTabMF.Normalize( nVal ), FUNIT_TWIP );
358 if(!bModified)
359 aTabMF.ClearModifyFlag();
362 return 0;
364 /*********************************************************************/
365 /* */
366 /*********************************************************************/
368 IMPL_LINK(SwLoadOptPage, CaptionHdl, PushButton*, EMPTYARG)
370 SwCaptionOptDlg aDlg(this, GetItemSet());
371 aDlg.Execute();
373 return 0;
376 /*--------------------------------------------------------------------
377 Beschreibung:
378 --------------------------------------------------------------------*/
380 SwCaptionOptDlg::SwCaptionOptDlg(Window* pParent, const SfxItemSet& rSet) :
381 SfxSingleTabDialog(pParent, rSet, 0)
383 // TabPage erzeugen
384 SetTabPage((SwCaptionOptPage*) SwCaptionOptPage::Create(this, rSet));
387 /*--------------------------------------------------------------------
388 Beschreibung:
389 --------------------------------------------------------------------*/
391 SwCaptionOptDlg::~SwCaptionOptDlg()
395 /* -----------------22.10.98 15:12-------------------
397 * --------------------------------------------------*/
399 SwCaptionPreview::SwCaptionPreview( Window* pParent, const ResId& rResId )
400 : Window( pParent, rResId )
402 maDrawPos = Point( 4, 6 );
404 Wallpaper aBack( GetSettings().GetStyleSettings().GetWindowColor() );
405 SetBackground( aBack );
406 SetFillColor( aBack.GetColor() );
407 SetLineColor( aBack.GetColor() );
408 SetBorderStyle( WINDOW_BORDER_MONO );
409 Font aFont(GetFont());
410 aFont.SetHeight(aFont.GetHeight() * 120 / 100 );
411 SetFont(aFont);
414 void SwCaptionPreview::SetPreviewText( const String& rText )
416 if( rText != maText )
418 maText = rText;
419 Invalidate();
423 void SwCaptionPreview::Paint( const Rectangle& rRect )
425 Window::Paint( rRect );
427 DrawRect( Rectangle( Point( 0, 0 ), GetSizePixel() ) );
428 DrawText( Point( 4, 6 ), maText );
432 SwCaptionOptPage::SwCaptionOptPage( Window* pParent, const SfxItemSet& rSet )
433 : SfxTabPage(pParent, SW_RES(TP_OPTCAPTION_PAGE), rSet),
434 aCheckFT (this, SW_RES(FT_OBJECTS )),
435 aCheckLB (this, SW_RES(CLB_OBJECTS )),
436 aFtCaptionOrder(this, SW_RES( FT_ORDER )),
437 aLbCaptionOrder(this, SW_RES( LB_ORDER )),
438 aPreview (this, SW_RES(WIN_PREVIEW )),
439 aSettingsGroupFL(this, SW_RES(FL_SETTINGS_2 )),
440 aCategoryText (this, SW_RES(TXT_CATEGORY )),
441 aCategoryBox (this, SW_RES(BOX_CATEGORY )),
442 aFormatText (this, SW_RES(TXT_FORMAT )),
443 aFormatBox (this, SW_RES(BOX_FORMAT )),
444 aNumberingSeparatorFT(this, SW_RES(FT_NUM_SEP )),
445 aNumberingSeparatorED(this, SW_RES(ED_NUM_SEP )),
446 aTextText (this, SW_RES(TXT_TEXT )),
447 aTextEdit (this, SW_RES(EDT_TEXT )),
448 aPosText (this, SW_RES(TXT_POS )),
449 aPosBox (this, SW_RES(BOX_POS )),
450 aNumCaptFL (this, SW_RES(FL_NUMCAPT )),
451 aFtLevel (this, SW_RES(FT_LEVEL )),
452 aLbLevel (this, SW_RES(LB_LEVEL )),
453 aFtDelim (this, SW_RES(FT_SEPARATOR )),
454 aEdDelim (this, SW_RES(ED_SEPARATOR )),
455 aCategoryFL (this, SW_RES(FL_CATEGORY )),
456 aCharStyleFT (this, SW_RES(FT_CHARSTYLE )),
457 aCharStyleLB (this, SW_RES(LB_CHARSTYLE )),
458 aApplyBorderCB (this, SW_RES(CB_APPLYBORDER)),
460 sSWTable (SW_RES(STR_TABLE )),
461 sSWFrame (SW_RES(STR_FRAME )),
462 sSWGraphic (SW_RES(STR_GRAPHIC )),
463 sOLE (SW_RES(STR_OLE )),
465 sBegin (SW_RESSTR(STR_BEGINNING )),
466 sEnd (SW_RESSTR(STR_END )),
467 sAbove (SW_RESSTR(STR_ABOVE )),
468 sBelow (SW_RESSTR(STR_CP_BELOW )),
469 sNone (SW_RESSTR( STR_CATEGORY_NONE )),
471 pMgr (new SwFldMgr()),
472 bHTMLMode(FALSE)
474 Wallpaper aBack( GetSettings().GetStyleSettings().GetWindowColor() );
475 aPreview.SetBackground( aBack );
477 SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_ABB, sIllustration );
478 SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_TABLE, sTable );
479 SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_FRAME, sText );
480 SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_DRAWING, sDrawing );
482 USHORT i, nCount;
483 SwWrtShell *pSh = ::GetActiveWrtShell();
485 // aFormatBox
486 USHORT nSelFmt = SVX_NUM_ARABIC;
487 if (pSh)
489 nCount = pMgr->GetFldTypeCount();
490 SwFieldType* pFldType;
491 for ( i = nCount; i; )
492 if( ( pFldType = pMgr->GetFldType(USHRT_MAX, --i))->GetName() ==
493 aCategoryBox.GetText() )
495 nSelFmt = (USHORT)((SwSetExpFieldType*)pFldType)->GetSeqFormat();
496 break;
499 ::FillCharStyleListBox( aCharStyleLB, pSh->GetView().GetDocShell(), TRUE, TRUE );
503 nCount = pMgr->GetFormatCount(TYP_SEQFLD, FALSE);
504 for ( i = 0; i < nCount; ++i )
506 aFormatBox.InsertEntry( pMgr->GetFormatStr(TYP_SEQFLD, i) );
507 USHORT nFmtId = pMgr->GetFormatId(TYP_SEQFLD, i);
508 aFormatBox.SetEntryData( i, reinterpret_cast<void*>(nFmtId) );
509 if( nFmtId == nSelFmt )
510 aFormatBox.SelectEntryPos( i );
513 for (i = 0; i < MAXLEVEL; i++)
514 aLbLevel.InsertEntry(String::CreateFromInt32(i + 1));
516 sal_Unicode nLvl = MAXLEVEL;
517 String sDelim( String::CreateFromAscii( ": " ) );
519 if (pSh)
521 SwSetExpFieldType* pFldType = (SwSetExpFieldType*)pMgr->GetFldType(
522 RES_SETEXPFLD, aCategoryBox.GetText() );
523 if( pFldType )
525 sDelim = pFldType->GetDelimiter();
526 nLvl = pFldType->GetOutlineLvl();
530 aLbLevel.SelectEntryPos( nLvl < MAXLEVEL ? nLvl + 1 : 0 );
531 aEdDelim.SetText( sDelim );
533 aCheckLB.SetHelpId(HID_OPTCAPTION_CLB);
535 FreeResource();
537 Link aLk = LINK( this, SwCaptionOptPage, ModifyHdl );
538 aCategoryBox.SetModifyHdl( aLk );
539 aNumberingSeparatorED.SetModifyHdl( aLk );
540 aTextEdit .SetModifyHdl( aLk );
542 aLk = LINK(this, SwCaptionOptPage, SelectHdl);
543 aCategoryBox.SetSelectHdl( aLk );
544 aFormatBox .SetSelectHdl( aLk );
546 aLbCaptionOrder.SetSelectHdl( LINK(this, SwCaptionOptPage, OrderHdl));
548 aCheckLB.SetSelectHdl( LINK(this, SwCaptionOptPage, ShowEntryHdl) );
549 aCheckLB.SetCheckButtonHdl( LINK(this, SwCaptionOptPage, ShowEntryHdl) );
550 aCheckLB.SetDeselectHdl( LINK(this, SwCaptionOptPage, SaveEntryHdl) );
553 /*-----------------18.01.97 12.43-------------------
555 --------------------------------------------------*/
557 SwCaptionOptPage::~SwCaptionOptPage()
559 DelUserData();
560 delete pMgr;
563 /*-----------------18.01.97 12.43-------------------
565 --------------------------------------------------*/
567 SfxTabPage* SwCaptionOptPage::Create( Window* pParent,
568 const SfxItemSet& rAttrSet )
570 return new SwCaptionOptPage(pParent, rAttrSet );
573 /*-----------------18.01.97 12.42-------------------
575 --------------------------------------------------*/
577 BOOL SwCaptionOptPage::FillItemSet( SfxItemSet& )
579 BOOL bRet = FALSE;
580 SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
582 SaveEntry(aCheckLB.FirstSelected()); // Aktuellen Eintrag uebernehmen
584 SvLBoxEntry* pEntry = aCheckLB.First();
586 while (pEntry)
588 InsCaptionOpt* pData = (InsCaptionOpt*)pEntry->GetUserData();
589 bRet |= pModOpt->SetCapOption(bHTMLMode, pData);
590 pEntry = aCheckLB.Next(pEntry);
593 USHORT nCheckCount = aCheckLB.GetCheckedEntryCount();
594 pModOpt->SetInsWithCaption( bHTMLMode, nCheckCount > 0 );
596 sal_Int32 nPos = aLbCaptionOrder.GetSelectEntryPos();
597 pModOpt->SetCaptionOrderNumberingFirst(nPos == 1 ? sal_True : sal_False );
599 return bRet;
602 /*-----------------18.01.97 12.42-------------------
604 --------------------------------------------------*/
606 void SwCaptionOptPage::Reset( const SfxItemSet& rSet)
608 const SfxPoolItem* pItem;
609 if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, FALSE, &pItem))
611 bHTMLMode = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON);
614 DelUserData();
615 aCheckLB.GetModel()->Clear(); // remove all entries
617 // Writer objects
618 USHORT nPos = 0;
619 aCheckLB.InsertEntry(sSWTable);
620 SetOptions(nPos++, TABLE_CAP);
621 aCheckLB.InsertEntry(sSWFrame);
622 SetOptions(nPos++, FRAME_CAP);
623 aCheckLB.InsertEntry(sSWGraphic);
624 SetOptions(nPos++, GRAPHIC_CAP);
626 // get Productname and -version
627 String sComplete, sWithoutVersion;
628 ::rtl::OUString sTemp;
629 uno::Any aAny =
630 ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME );
631 if ( aAny >>= sTemp )
633 sComplete = sTemp;
634 sWithoutVersion = sTemp;
635 aAny = ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTVERSION );
636 if ( !( aAny >>= sTemp ) )
638 DBG_ERRORFILE( "Couldn't get PRODUCTVERSION variable" );
640 else
642 sComplete += ' ';
643 sComplete += String( sTemp );
646 else
648 DBG_ERRORFILE( "Couldn't get PRODUCTNAME variable" );
651 SvObjectServerList aObjS;
652 aObjS.FillInsertObjects();
653 aObjS.Remove( SvGlobalName( SO3_SW_CLASSID ) ); // remove Writer-ID
655 for ( ULONG i = 0; i < aObjS.Count(); ++i )
657 const SvGlobalName &rOleId = aObjS[i].GetClassName();
658 const String* pClassName = &aObjS[i].GetHumanName();
659 if ( rOleId == SvGlobalName( SO3_OUT_CLASSID ) )
660 pClassName = &sOLE;
661 String sClass( *pClassName );
662 // don't show product version
663 sClass.SearchAndReplace( sComplete, sWithoutVersion );
664 aCheckLB.InsertEntry( sClass );
665 SetOptions( nPos++, OLE_CAP, &rOleId );
667 aLbCaptionOrder.SelectEntryPos(
668 SW_MOD()->GetModuleConfig()->IsCaptionOrderNumberingFirst() ? 1 : 0);
669 ModifyHdl();
672 /*-----------------18.01.97 12.42-------------------
674 --------------------------------------------------*/
676 void SwCaptionOptPage::SetOptions(const USHORT nPos,
677 const SwCapObjType eObjType, const SvGlobalName *pOleId)
679 SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
680 const InsCaptionOpt* pOpt = pModOpt->GetCapOption(bHTMLMode, eObjType, pOleId);
682 if (pOpt)
684 aCheckLB.SetEntryData(nPos, new InsCaptionOpt(*pOpt));
685 aCheckLB.CheckEntryPos(nPos, pOpt->UseCaption());
687 else
688 aCheckLB.SetEntryData(nPos, new InsCaptionOpt(eObjType, pOleId));
691 /*-----------------18.01.97 12.42-------------------
693 --------------------------------------------------*/
695 void SwCaptionOptPage::DelUserData()
697 SvLBoxEntry* pEntry = aCheckLB.First();
699 while (pEntry)
701 delete (InsCaptionOpt*)pEntry->GetUserData();
702 pEntry->SetUserData(0);
703 pEntry = aCheckLB.Next(pEntry);
707 /* -----------------26.10.98 11:06-------------------
709 * --------------------------------------------------*/
711 IMPL_LINK( SwCaptionOptPage, ShowEntryHdl, SvxCheckListBox *, EMPTYARG )
713 SvLBoxEntry* pSelEntry = aCheckLB.FirstSelected();
715 if (pSelEntry)
717 sal_Bool bChecked = aCheckLB.IsChecked((USHORT)aCheckLB.GetModel()->GetAbsPos(pSelEntry));
719 aSettingsGroupFL.Enable( bChecked );
720 aCategoryText.Enable( bChecked );
721 aCategoryBox.Enable( bChecked );
722 aFormatText.Enable( bChecked );
723 aFormatBox.Enable( bChecked );
724 sal_Bool bNumSep = bChecked && aLbCaptionOrder.GetSelectEntryPos() == 1;
725 aNumberingSeparatorED.Enable( bNumSep );
726 aNumberingSeparatorFT.Enable( bNumSep );
727 aTextText.Enable( bChecked );
728 aTextEdit.Enable( bChecked );
729 aPosText.Enable( bChecked );
730 aPosBox.Enable( bChecked );
731 aNumCaptFL.Enable( bChecked );
732 aFtLevel.Enable( bChecked );
733 aLbLevel.Enable( bChecked );
734 aFtDelim.Enable( bChecked );
735 aEdDelim.Enable( bChecked );
736 aCategoryFL.Enable( bChecked );
737 aCharStyleFT.Enable( bChecked );
738 aCharStyleLB.Enable( bChecked );
739 aApplyBorderCB.Enable( bChecked );
740 aPreview.Enable( bChecked );
742 SwWrtShell *pSh = ::GetActiveWrtShell();
744 InsCaptionOpt* pOpt = (InsCaptionOpt*)pSelEntry->GetUserData();
746 aCategoryBox.Clear();
747 aCategoryBox.InsertEntry( sNone );
748 if (pSh)
750 USHORT nCount = pMgr->GetFldTypeCount();
752 for (USHORT i = 0; i < nCount; i++)
754 SwFieldType *pType = pMgr->GetFldType( USHRT_MAX, i );
755 if( pType->Which() == RES_SETEXPFLD &&
756 ((SwSetExpFieldType *) pType)->GetType() & nsSwGetSetExpType::GSE_SEQ )
757 aCategoryBox.InsertEntry(SwBoxEntry(pType->GetName()));
760 else
762 aCategoryBox.InsertEntry(SwBoxEntry(sIllustration));
763 aCategoryBox.InsertEntry(SwBoxEntry(sTable));
764 aCategoryBox.InsertEntry(SwBoxEntry(sText));
765 aCategoryBox.InsertEntry(SwBoxEntry(sDrawing));
768 if(pOpt->GetCategory().Len())
769 aCategoryBox.SetText(pOpt->GetCategory());
770 else
771 aCategoryBox.SetText( sNone );
772 if (pOpt->GetCategory().Len() &&
773 aCategoryBox.GetEntryPos(pOpt->GetCategory()) == COMBOBOX_ENTRY_NOTFOUND)
774 aCategoryBox.InsertEntry(pOpt->GetCategory());
775 if (!aCategoryBox.GetText().Len())
777 USHORT nPos = 0;
778 switch(pOpt->GetObjType())
780 case OLE_CAP:
781 case GRAPHIC_CAP: nPos = 1; break;
782 case TABLE_CAP: nPos = 2; break;
783 case FRAME_CAP: nPos = 3; break;
785 aCategoryBox.SetText(aCategoryBox.GetEntry(nPos).GetName());
788 for (USHORT i = 0; i < aFormatBox.GetEntryCount(); i++)
790 if (pOpt->GetNumType() == (USHORT)(ULONG)aFormatBox.GetEntryData(i))
792 aFormatBox.SelectEntryPos(i);
793 break;
796 aTextEdit.SetText(pOpt->GetCaption());
798 aPosBox.Clear();
799 switch (pOpt->GetObjType())
801 case GRAPHIC_CAP:
802 case TABLE_CAP:
803 case OLE_CAP:
804 aPosBox.InsertEntry(sAbove);
805 aPosBox.InsertEntry(sBelow);
806 break;
807 case FRAME_CAP:
808 aPosBox.InsertEntry(sBegin);
809 aPosBox.InsertEntry(sEnd);
810 break;
812 aPosBox.SelectEntryPos(pOpt->GetPos());
813 aPosBox.Enable( pOpt->GetObjType() != GRAPHIC_CAP &&
814 pOpt->GetObjType() != OLE_CAP &&
815 aPosText.IsEnabled() );
816 aPosBox.SelectEntryPos(pOpt->GetPos());
818 USHORT nLevelPos = ( pOpt->GetLevel() < MAXLEVEL ) ? pOpt->GetLevel() + 1 : 0;
819 aLbLevel.SelectEntryPos( nLevelPos );
820 aEdDelim.SetText(pOpt->GetSeparator());
821 aNumberingSeparatorED.SetText( pOpt->GetNumSeparator() );
822 if(pOpt->GetCharacterStyle().Len())
823 aCharStyleLB.SelectEntry( pOpt->GetCharacterStyle() );
824 else
825 aCharStyleLB.SelectEntryPos( 0 );
826 aApplyBorderCB.Enable( aCategoryBox.IsEnabled() &&
827 pOpt->GetObjType() != TABLE_CAP && pOpt->GetObjType() != FRAME_CAP );
828 aApplyBorderCB.Check( pOpt->CopyAttributes() );
831 ModifyHdl();
833 return 0;
836 /* -----------------26.10.98 11:06-------------------
838 * --------------------------------------------------*/
840 IMPL_LINK( SwCaptionOptPage, SaveEntryHdl, SvxCheckListBox *, EMPTYARG )
842 SvLBoxEntry* pEntry = aCheckLB.GetHdlEntry();
844 if (pEntry) // Alles speichern
845 SaveEntry(pEntry);
847 return 0;
850 /* -----------------05.11.98 16:23-------------------
852 * --------------------------------------------------*/
854 void SwCaptionOptPage::SaveEntry(SvLBoxEntry* pEntry)
856 if (pEntry)
858 InsCaptionOpt* pOpt = (InsCaptionOpt*)pEntry->GetUserData();
860 pOpt->UseCaption() = aCheckLB.IsChecked((USHORT)aCheckLB.GetModel()->GetAbsPos(pEntry));
861 String aName( aCategoryBox.GetText() );
862 if(aName == sNone)
863 pOpt->SetCategory(aEmptyStr);
864 else
866 aName.EraseLeadingChars (' ');
867 aName.EraseTrailingChars(' ');
868 pOpt->SetCategory(aName);
870 pOpt->SetNumType((USHORT)(ULONG)aFormatBox.GetEntryData(aFormatBox.GetSelectEntryPos()));
871 pOpt->SetCaption(aTextEdit.IsEnabled() ? aTextEdit.GetText() : aEmptyStr );
872 pOpt->SetPos(aPosBox.GetSelectEntryPos());
873 USHORT nPos = aLbLevel.GetSelectEntryPos();
874 USHORT nLevel = ( nPos > 0 && nPos != LISTBOX_ENTRY_NOTFOUND ) ? nPos - 1 : MAXLEVEL;
875 pOpt->SetLevel(nLevel);
876 pOpt->SetSeparator(aEdDelim.GetText());
877 pOpt->SetNumSeparator( aNumberingSeparatorED.GetText());
878 if(!aCharStyleLB.GetSelectEntryPos())
879 pOpt->SetCharacterStyle(aEmptyStr);
880 else
881 pOpt->SetCharacterStyle(aCharStyleLB.GetSelectEntry());
882 pOpt->CopyAttributes() = aApplyBorderCB.IsChecked();
886 /* -----------------26.10.98 11:06-------------------
888 * --------------------------------------------------*/
890 IMPL_LINK( SwCaptionOptPage, ModifyHdl, Edit *, EMPTYARG )
892 String sFldTypeName = aCategoryBox.GetText();
894 SwFieldType* pType = sFldTypeName.Len() ? pMgr->GetFldType(RES_SETEXPFLD, sFldTypeName) : 0;
896 ((SfxSingleTabDialog*)GetParent())->GetOKButton()->Enable( (!pType || ((SwSetExpFieldType*)pType)->GetType() == GSE_SEQ)
897 && sFldTypeName.Len() != 0 );
899 SfxSingleTabDialog *pDlg = (SfxSingleTabDialog *)GetParent();
900 PushButton *pBtn = pDlg->GetOKButton();
901 if (pBtn)
902 pBtn->Enable(sFldTypeName.Len() != 0);
903 sal_Bool bEnable = aCategoryBox.IsEnabled() && sFldTypeName != sNone;
905 aFormatText.Enable(bEnable);
906 aFormatBox.Enable(bEnable);
907 aTextText.Enable(bEnable);
908 aTextEdit.Enable(bEnable);
910 DrawSample();
911 return 0;
914 /* -----------------26.10.98 10:58-------------------
916 * --------------------------------------------------*/
918 IMPL_LINK_INLINE_START( SwCaptionOptPage, SelectHdl, ListBox *, EMPTYARG )
920 DrawSample();
921 return 0;
923 IMPL_LINK_INLINE_END( SwCaptionOptPage, SelectHdl, ListBox *, EMPTYARG )
924 /*-- 02.11.2007 10:00:36---------------------------------------------------
926 -----------------------------------------------------------------------*/
927 IMPL_LINK( SwCaptionOptPage, OrderHdl, ListBox*, pBox )
929 DrawSample();
930 sal_Int32 nPos = pBox->GetSelectEntryPos();
931 aNumberingSeparatorFT.Enable( nPos == 1 );
932 aNumberingSeparatorED.Enable( nPos == 1 );
933 return 0;
935 /* -----------------26.10.98 10:58-------------------
937 * --------------------------------------------------*/
939 void SwCaptionOptPage::DrawSample()
941 String aStr;
943 if( aCategoryBox.GetText() != sNone)
945 //#i61007# order of captions
946 bool bOrderNumberingFirst = aLbCaptionOrder.GetSelectEntryPos() == 1;
947 // Nummer
948 USHORT nNumFmt = (USHORT)(ULONG)aFormatBox.GetEntryData(
949 aFormatBox.GetSelectEntryPos() );
950 if( SVX_NUM_NUMBER_NONE != nNumFmt )
952 //#i61007# order of captions
953 if( !bOrderNumberingFirst )
955 // Kategorie
956 aStr += aCategoryBox.GetText();
957 aStr += ' ';
960 SwWrtShell *pSh = ::GetActiveWrtShell();
961 String sFldTypeName( aCategoryBox.GetText() );
962 if (pSh)
964 SwSetExpFieldType* pFldType = (SwSetExpFieldType*)pMgr->GetFldType(
965 RES_SETEXPFLD, sFldTypeName );
966 if( pFldType && pFldType->GetOutlineLvl() < MAXLEVEL )
968 BYTE nLvl = pFldType->GetOutlineLvl();
969 SwNumberTree::tNumberVector aNumVector;
970 for( BYTE i = 0; i <= nLvl; ++i )
971 aNumVector.push_back(1);
973 String sNumber( pSh->GetOutlineNumRule()->MakeNumString(
974 aNumVector, FALSE ));
975 if( sNumber.Len() )
976 (aStr += sNumber) += pFldType->GetDelimiter();
980 switch( nNumFmt )
982 case SVX_NUM_CHARS_UPPER_LETTER: aStr += 'A'; break;
983 case SVX_NUM_CHARS_UPPER_LETTER_N: aStr += 'A'; break;
984 case SVX_NUM_CHARS_LOWER_LETTER: aStr += 'a'; break;
985 case SVX_NUM_CHARS_LOWER_LETTER_N: aStr += 'a'; break;
986 case SVX_NUM_ROMAN_UPPER: aStr += 'I'; break;
987 case SVX_NUM_ROMAN_LOWER: aStr += 'i'; break;
988 //case ARABIC:
989 default: aStr += '1'; break;
992 //#i61007# order of captions
993 if( bOrderNumberingFirst )
995 aStr += aNumberingSeparatorED.GetText();
996 aStr += aCategoryBox.GetText();
998 aStr += aTextEdit.GetText();
1000 aPreview.SetPreviewText( aStr );
1003 /*------------------------------------------------------------------------
1004 Beschreibung: ComboBox ohne Spaces
1005 ------------------------------------------------------------------------*/
1007 void CaptionComboBox::KeyInput(const KeyEvent& rEvt)
1009 if( rEvt.GetKeyCode().GetCode() != KEY_SPACE )
1010 SwComboBox::KeyInput(rEvt);