update credits
[LibreOffice.git] / sw / source / ui / config / optpage.cxx
blob79595b23fcf5ad952bdc82d37e02329096f8950a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <optpage.hxx>
21 #include <doc.hxx>
22 #include <hintids.hxx>
23 #include <cmdid.h>
24 #include <fmtcol.hxx>
25 #include <charatr.hxx>
26 #include <swtypes.hxx>
27 #include <view.hxx>
28 #include <docsh.hxx>
29 #include <IDocumentDeviceAccess.hxx>
30 #include <swmodule.hxx>
31 #include <wrtsh.hxx>
32 #include <uitool.hxx>
33 #include <cfgitems.hxx> //Items for Sw-pages
34 #include <poolfmt.hxx>
35 #include <uiitems.hxx>
36 #include <initui.hxx>
37 #include <printdata.hxx>
38 #include <modcfg.hxx>
39 #include <srcview.hxx>
40 #include <crstate.hxx>
41 #include <viewopt.hxx>
42 #include <globals.hrc>
43 #include <config.hrc>
44 #include <redlopt.hrc>
45 #include <optdlg.hrc>
46 #include <swwrtshitem.hxx>
47 #include <unomid.h>
49 #include <editeng/fhgtitem.hxx>
50 #include <editeng/fontitem.hxx>
51 #include <editeng/langitem.hxx>
52 #include <editeng/svxenum.hxx>
53 #include <sfx2/request.hxx>
54 #include <sfx2/printer.hxx>
55 #include <sfx2/bindings.hxx>
56 #include <svl/slstitm.hxx>
57 #include <svl/ctloptions.hxx>
58 #include <svl/eitem.hxx>
59 #include <svl/cjkoptions.hxx>
60 #include <svtools/ctrltool.hxx>
61 #include <sfx2/htmlmode.hxx>
62 #include <svx/xtable.hxx>
63 #include <svx/dlgutil.hxx>
64 #include <svx/strarray.hxx>
65 #include <vcl/svapp.hxx>
68 using namespace ::com::sun::star;
70 /*--------------------------------------------------------
71 Tools->Options->Writer->View
72 Tools->Options->Writer/Web->View
73 --------------------------------------------------------- */
74 SwContentOptPage::SwContentOptPage( Window* pParent,
75 const SfxItemSet& rCoreSet ) :
76 SfxTabPage(pParent, "ViewOptionsPage",
77 "modules/swriter/ui/viewoptionspage.ui", rCoreSet)
79 get (m_pCrossCB, "helplines");
81 get (m_pHScrollBox, "hscrollbar");
82 get (m_pVScrollBox, "vscrollbar");
83 get (m_pAnyRulerCB, "ruler");
84 get (m_pHRulerCBox, "hruler");
85 get (m_pHMetric, "hrulercombobox");
86 get (m_pVRulerCBox, "vruler");
87 get (m_pVRulerRightCBox, "vrulerright");
88 get (m_pVMetric, "vrulercombobox");
89 get (m_pSmoothCBox, "smoothscroll");
91 get (m_pGrfCB, "graphics");
92 get (m_pTblCB, "tables");
93 get (m_pDrwCB, "drawings");
94 get (m_pFldNameCB, "fieldcodes");
95 get (m_pPostItCB, "comments");
97 get (m_pSettingsFrame, "settingsframe");
98 get (m_pSettingsLabel, "settingslabel");
99 get (m_pMetricLabel, "measureunitlabel");
100 get (m_pMetricLB, "measureunit");
102 /* This part is visible only with Writer/Web->View dialogue. */
103 const SfxPoolItem* pItem;
104 if (! (SFX_ITEM_SET == rCoreSet.GetItemState(SID_HTML_MODE, sal_False, &pItem )
105 && ((SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON))
107 m_pSettingsFrame->Hide();
108 m_pSettingsLabel->Hide();
109 m_pMetricLabel->Hide();
110 m_pMetricLB->Hide();
113 SvtCJKOptions aCJKOptions;
114 if(!aCJKOptions.IsVerticalTextEnabled() )
115 m_pVRulerRightCBox->Hide();
116 m_pVRulerCBox->SetClickHdl(LINK(this, SwContentOptPage, VertRulerHdl ));
117 m_pAnyRulerCB->SetClickHdl(LINK(this, SwContentOptPage, AnyRulerHdl));
119 SvxStringArray aMetricArr( SW_RES( STR_ARR_METRIC ) );
120 for ( sal_uInt16 i = 0; i < aMetricArr.Count(); ++i )
122 String sMetric = aMetricArr.GetStringByPos( i );
123 FieldUnit eFUnit = (FieldUnit)aMetricArr.GetValue( i );
125 switch ( eFUnit )
127 case FUNIT_MM:
128 case FUNIT_CM:
129 case FUNIT_POINT:
130 case FUNIT_PICA:
131 case FUNIT_INCH:
132 case FUNIT_CHAR: // add two units , 'character' and 'line' , their ticks are not fixed
133 case FUNIT_LINE:
135 // only use these metrics
136 // a horizontal ruler has not the 'line' unit
137 // there isn't 'line' unit in HTML format
138 if ( eFUnit != FUNIT_LINE )
140 sal_uInt16 nPos = m_pMetricLB->InsertEntry( sMetric );
141 m_pMetricLB->SetEntryData( nPos, (void*)(long)eFUnit );
142 m_pHMetric->InsertEntry( sMetric );
143 m_pHMetric->SetEntryData( nPos, (void*)(long)eFUnit );
145 // a vertical ruler has not the 'character' unit
146 if ( eFUnit != FUNIT_CHAR )
148 sal_uInt16 nPos = m_pVMetric->InsertEntry( sMetric );
149 m_pVMetric->SetEntryData( nPos, (void*)(long)eFUnit );
152 default:;//prevent warning
157 SwContentOptPage::~SwContentOptPage()
161 SfxTabPage* SwContentOptPage::Create( Window* pParent,
162 const SfxItemSet& rAttrSet)
164 return new SwContentOptPage(pParent, rAttrSet);
167 static void lcl_SelectMetricLB(ListBox* rMetric, sal_uInt16 nSID, const SfxItemSet& rSet)
169 const SfxPoolItem* pItem;
170 if( rSet.GetItemState( nSID, sal_False, &pItem ) >= SFX_ITEM_AVAILABLE )
172 FieldUnit eFieldUnit = (FieldUnit)((SfxUInt16Item*)pItem)->GetValue();
173 for ( sal_uInt16 i = 0; i < rMetric->GetEntryCount(); ++i )
175 if ( (int)(sal_IntPtr)rMetric->GetEntryData( i ) == (int)eFieldUnit )
177 rMetric->SelectEntryPos( i );
178 break;
182 rMetric->SaveValue();
185 void SwContentOptPage::Reset(const SfxItemSet& rSet)
187 const SwElemItem* pElemAttr = 0;
189 rSet.GetItemState( FN_PARAM_ELEM , sal_False,
190 (const SfxPoolItem**)&pElemAttr );
191 if(pElemAttr)
193 m_pTblCB->Check (pElemAttr->bTable);
194 m_pGrfCB->Check (pElemAttr->bGraphic);
195 m_pDrwCB->Check (pElemAttr->bDrawing);
196 m_pFldNameCB->Check (pElemAttr->bFieldName);
197 m_pPostItCB->Check (pElemAttr->bNotes);
198 m_pCrossCB->Check (pElemAttr->bCrosshair);
199 m_pHScrollBox->Check (pElemAttr->bHorzScrollbar);
200 m_pVScrollBox->Check (pElemAttr->bVertScrollbar);
201 m_pAnyRulerCB->Check (pElemAttr->bAnyRuler);
202 m_pHRulerCBox->Check (pElemAttr->bHorzRuler);
203 m_pVRulerCBox->Check (pElemAttr->bVertRuler);
204 m_pVRulerRightCBox->Check (pElemAttr->bVertRulerRight);
205 m_pSmoothCBox->Check (pElemAttr->bSmoothScroll);
207 m_pMetricLB->SetNoSelection();
208 lcl_SelectMetricLB(m_pMetricLB, SID_ATTR_METRIC, rSet);
209 lcl_SelectMetricLB(m_pHMetric, FN_HSCROLL_METRIC, rSet);
210 lcl_SelectMetricLB(m_pVMetric, FN_VSCROLL_METRIC, rSet);
211 AnyRulerHdl(m_pAnyRulerCB);
214 sal_Bool SwContentOptPage::FillItemSet(SfxItemSet& rSet)
216 const SwElemItem* pOldAttr = (const SwElemItem*)
217 GetOldItem(GetItemSet(), FN_PARAM_ELEM);
219 SwElemItem aElem;
220 if(pOldAttr)
221 aElem = *pOldAttr;
222 aElem.bTable = m_pTblCB->IsChecked();
223 aElem.bGraphic = m_pGrfCB->IsChecked();
224 aElem.bDrawing = m_pDrwCB->IsChecked();
225 aElem.bFieldName = m_pFldNameCB->IsChecked();
226 aElem.bNotes = m_pPostItCB->IsChecked();
227 aElem.bCrosshair = m_pCrossCB->IsChecked();
228 aElem.bHorzScrollbar = m_pHScrollBox->IsChecked();
229 aElem.bVertScrollbar = m_pVScrollBox->IsChecked();
230 aElem.bAnyRuler = m_pAnyRulerCB->IsChecked();
231 aElem.bHorzRuler = m_pHRulerCBox->IsChecked();
232 aElem.bVertRuler = m_pVRulerCBox->IsChecked();
233 aElem.bVertRulerRight = m_pVRulerRightCBox->IsChecked();
234 aElem.bSmoothScroll = m_pSmoothCBox->IsChecked();
237 sal_Bool bRet = !pOldAttr || aElem != *pOldAttr;
238 if(bRet)
239 bRet = 0 != rSet.Put(aElem);
241 sal_uInt16 nMPos = m_pMetricLB->GetSelectEntryPos();
242 sal_uInt16 nGlobalMetricPos = nMPos;
243 if ( nMPos != m_pMetricLB->GetSavedValue() )
245 // Double-Cast for VA3.0
246 sal_uInt16 nFieldUnit = (sal_uInt16)(long)m_pMetricLB->GetEntryData( nMPos );
247 rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, (sal_uInt16)nFieldUnit ) );
248 bRet = sal_True;
251 nMPos = m_pHMetric->GetSelectEntryPos();
252 if ( nMPos != m_pHMetric->GetSavedValue() || nMPos != nGlobalMetricPos )
254 // Double-Cast for VA3.0
255 sal_uInt16 nFieldUnit = (sal_uInt16)(long)m_pHMetric->GetEntryData( nMPos );
256 rSet.Put( SfxUInt16Item( FN_HSCROLL_METRIC, (sal_uInt16)nFieldUnit ) );
257 bRet = sal_True;
259 nMPos = m_pVMetric->GetSelectEntryPos();
260 if ( nMPos != m_pVMetric->GetSavedValue() || nMPos != nGlobalMetricPos )
262 // Double-Cast for VA3.0
263 sal_uInt16 nFieldUnit = (sal_uInt16)(long)m_pVMetric->GetEntryData( nMPos );
264 rSet.Put( SfxUInt16Item( FN_VSCROLL_METRIC, (sal_uInt16)nFieldUnit ) );
265 bRet = sal_True;
267 return bRet;
270 IMPL_LINK(SwContentOptPage, VertRulerHdl, CheckBox*, pBox)
272 m_pVRulerRightCBox->Enable(pBox->IsEnabled() && pBox->IsChecked());
273 return 0;
276 IMPL_LINK( SwContentOptPage, AnyRulerHdl, CheckBox*, pBox)
278 sal_Bool bChecked = pBox->IsChecked();
279 m_pHRulerCBox->Enable(bChecked);
280 m_pHMetric->Enable(bChecked);
281 m_pVRulerCBox->Enable(bChecked);
282 m_pVMetric->Enable(bChecked);
283 VertRulerHdl(m_pVRulerCBox);
284 return 0;
286 /*------------------------------------------------------
287 TabPage Printer additional settings
288 -------------------------------------------------------*/
289 SwAddPrinterTabPage::SwAddPrinterTabPage(Window* pParent,
290 const SfxItemSet& rCoreSet)
291 : SfxTabPage(pParent, "PrintOptionsPage",
292 "modules/swriter/ui/printoptionspage.ui", rCoreSet)
293 , sNone(SW_RESSTR(SW_STR_NONE))
294 , bAttrModified(sal_False)
295 , bPreview(sal_False)
297 get(m_pGrfCB, "graphics");
298 get(m_pCtrlFldCB, "formcontrols");
299 get(m_pBackgroundCB, "background");
300 get(m_pBlackFontCB, "inblack");
301 get(m_pPrintHiddenTextCB, "hiddentext");
302 get(m_pPrintTextPlaceholderCB, "textplaceholder");
304 get(m_pPagesFrame, "pagesframe");
305 get(m_pLeftPageCB, "leftpages");
306 get(m_pRightPageCB, "rightpages");
307 get(m_pProspectCB, "brochure");
308 get(m_pProspectCB_RTL, "rtl");
310 get(m_pCommentsFrame, "commentsframe");
311 get(m_pNoRB, "none");
312 get(m_pOnlyRB, "only");
313 get(m_pEndRB, "end");
314 get(m_pEndPageRB, "endpage");
315 get(m_pPrintEmptyPagesCB, "blankpages");
316 get(m_pPaperFromSetupCB, "papertray");
317 get(m_pFaxLB, "fax");
319 Init();
321 Link aLk = LINK( this, SwAddPrinterTabPage, AutoClickHdl);
322 m_pGrfCB->SetClickHdl( aLk );
323 m_pRightPageCB->SetClickHdl( aLk );
324 m_pLeftPageCB->SetClickHdl( aLk );
325 m_pCtrlFldCB->SetClickHdl( aLk );
326 m_pBackgroundCB->SetClickHdl( aLk );
327 m_pBlackFontCB->SetClickHdl( aLk );
328 m_pPrintHiddenTextCB->SetClickHdl( aLk );
329 m_pPrintTextPlaceholderCB->SetClickHdl( aLk );
330 m_pProspectCB->SetClickHdl( aLk );
331 m_pProspectCB_RTL->SetClickHdl( aLk );
332 m_pPaperFromSetupCB->SetClickHdl( aLk );
333 m_pPrintEmptyPagesCB->SetClickHdl( aLk );
334 m_pEndPageRB->SetClickHdl( aLk );
335 m_pEndRB->SetClickHdl( aLk );
336 m_pOnlyRB->SetClickHdl( aLk );
337 m_pNoRB->SetClickHdl( aLk );
338 m_pFaxLB->SetSelectHdl( LINK( this, SwAddPrinterTabPage, SelectHdl ) );
340 const SfxPoolItem* pItem;
341 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_HTML_MODE, sal_False, &pItem )
342 && ((SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON)
344 m_pLeftPageCB->Hide();
345 m_pRightPageCB->Hide();
346 m_pPrintHiddenTextCB->Hide();
347 m_pPrintTextPlaceholderCB->Hide();
349 // hide m_pPrintEmptyPagesCB
350 m_pPrintEmptyPagesCB->Hide();
352 m_pProspectCB_RTL->Disable();
353 SvtCTLOptions aCTLOptions;
354 m_pProspectCB_RTL->Show(aCTLOptions.IsCTLFontEnabled());
357 void SwAddPrinterTabPage::SetPreview(sal_Bool bPrev)
359 bPreview = bPrev;
360 m_pCommentsFrame->Enable(!bPreview);
361 m_pPagesFrame->Enable(!bPreview);
364 SfxTabPage* SwAddPrinterTabPage::Create( Window* pParent,
365 const SfxItemSet& rAttrSet )
367 return ( new SwAddPrinterTabPage( pParent, rAttrSet ) );
370 sal_Bool SwAddPrinterTabPage::FillItemSet( SfxItemSet& rCoreSet )
372 if ( bAttrModified )
374 SwAddPrinterItem aAddPrinterAttr (FN_PARAM_ADDPRINTER);
375 aAddPrinterAttr.bPrintGraphic = m_pGrfCB->IsChecked();
376 aAddPrinterAttr.bPrintTable = sal_True; // always enabled since CWS printerpullgpages /*aTabCB.IsChecked();*/
377 aAddPrinterAttr.bPrintDraw = m_pGrfCB->IsChecked(); // UI merged with m_pGrfCB in CWS printerpullgpages
378 aAddPrinterAttr.bPrintControl = m_pCtrlFldCB->IsChecked();
379 aAddPrinterAttr.bPrintPageBackground = m_pBackgroundCB->IsChecked();
380 aAddPrinterAttr.bPrintBlackFont = m_pBlackFontCB->IsChecked();
381 aAddPrinterAttr.bPrintHiddenText = m_pPrintHiddenTextCB->IsChecked();
382 aAddPrinterAttr.bPrintTextPlaceholder = m_pPrintTextPlaceholderCB->IsChecked();
384 aAddPrinterAttr.bPrintLeftPages = m_pLeftPageCB->IsChecked();
385 aAddPrinterAttr.bPrintRightPages = m_pRightPageCB->IsChecked();
386 aAddPrinterAttr.bPrintReverse = sal_False; // handled by vcl itself since CWS printerpullpages /*aReverseCB.IsChecked()*/;
387 aAddPrinterAttr.bPrintProspect = m_pProspectCB->IsChecked();
388 aAddPrinterAttr.bPrintProspectRTL = m_pProspectCB_RTL->IsChecked();
389 aAddPrinterAttr.bPaperFromSetup = m_pPaperFromSetupCB->IsChecked();
390 aAddPrinterAttr.bPrintEmptyPages = m_pPrintEmptyPagesCB->IsChecked();
391 aAddPrinterAttr.bPrintSingleJobs = sal_True; // handled by vcl in new print dialog since CWS printerpullpages /*aSingleJobsCB.IsChecked()*/;
393 if (m_pNoRB->IsChecked()) aAddPrinterAttr.nPrintPostIts =
394 POSTITS_NONE;
395 if (m_pOnlyRB->IsChecked()) aAddPrinterAttr.nPrintPostIts =
396 POSTITS_ONLY;
397 if (m_pEndRB->IsChecked()) aAddPrinterAttr.nPrintPostIts =
398 POSTITS_ENDDOC;
399 if (m_pEndPageRB->IsChecked()) aAddPrinterAttr.nPrintPostIts =
400 POSTITS_ENDPAGE;
402 String sFax = m_pFaxLB->GetSelectEntry();
403 aAddPrinterAttr.sFaxName = sNone == sFax ? aEmptyStr : sFax;
404 rCoreSet.Put(aAddPrinterAttr);
406 return bAttrModified;
409 void SwAddPrinterTabPage::Reset( const SfxItemSet& )
411 const SfxItemSet& rSet = GetItemSet();
412 const SwAddPrinterItem* pAddPrinterAttr = 0;
414 if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_ADDPRINTER , sal_False,
415 (const SfxPoolItem**)&pAddPrinterAttr ))
417 m_pGrfCB->Check(pAddPrinterAttr->bPrintGraphic || pAddPrinterAttr->bPrintDraw);
418 m_pCtrlFldCB->Check( pAddPrinterAttr->bPrintControl);
419 m_pBackgroundCB->Check( pAddPrinterAttr->bPrintPageBackground);
420 m_pBlackFontCB->Check( pAddPrinterAttr->bPrintBlackFont);
421 m_pPrintHiddenTextCB->Check( pAddPrinterAttr->bPrintHiddenText);
422 m_pPrintTextPlaceholderCB->Check(pAddPrinterAttr->bPrintTextPlaceholder);
423 m_pLeftPageCB->Check( pAddPrinterAttr->bPrintLeftPages);
424 m_pRightPageCB->Check( pAddPrinterAttr->bPrintRightPages);
425 m_pPaperFromSetupCB->Check(pAddPrinterAttr->bPaperFromSetup);
426 m_pPrintEmptyPagesCB->Check(pAddPrinterAttr->bPrintEmptyPages);
427 m_pProspectCB->Check( pAddPrinterAttr->bPrintProspect);
428 m_pProspectCB_RTL->Check( pAddPrinterAttr->bPrintProspectRTL);
430 m_pNoRB->Check (pAddPrinterAttr->nPrintPostIts== POSTITS_NONE ) ;
431 m_pOnlyRB->Check (pAddPrinterAttr->nPrintPostIts== POSTITS_ONLY ) ;
432 m_pEndRB->Check (pAddPrinterAttr->nPrintPostIts== POSTITS_ENDDOC ) ;
433 m_pEndPageRB->Check (pAddPrinterAttr->nPrintPostIts== POSTITS_ENDPAGE ) ;
434 m_pFaxLB->SelectEntry( pAddPrinterAttr->sFaxName );
436 if (m_pProspectCB->IsChecked())
438 m_pProspectCB_RTL->Enable(sal_True);
439 m_pNoRB->Enable( sal_False );
440 m_pOnlyRB->Enable( sal_False );
441 m_pEndRB->Enable( sal_False );
442 m_pEndPageRB->Enable( sal_False );
444 else
445 m_pProspectCB_RTL->Enable( sal_False );
448 void SwAddPrinterTabPage::Init()
453 IMPL_LINK_NOARG_INLINE_START(SwAddPrinterTabPage, AutoClickHdl)
455 bAttrModified = sal_True;
456 bool bIsProspect = m_pProspectCB->IsChecked();
457 if (!bIsProspect)
458 m_pProspectCB_RTL->Check( sal_False );
459 m_pProspectCB_RTL->Enable( bIsProspect );
460 m_pNoRB->Enable( !bIsProspect );
461 m_pOnlyRB->Enable( !bIsProspect );
462 m_pEndRB->Enable( !bIsProspect );
463 m_pEndPageRB->Enable( !bIsProspect );
464 return 0;
466 IMPL_LINK_NOARG_INLINE_END(SwAddPrinterTabPage, AutoClickHdl)
468 void SwAddPrinterTabPage::SetFax( const std::vector<String>& rFaxLst )
470 m_pFaxLB->InsertEntry(sNone);
471 for(size_t i = 0; i < rFaxLst.size(); ++i)
473 m_pFaxLB->InsertEntry(rFaxLst[i]);
475 m_pFaxLB->SelectEntryPos(0);
478 IMPL_LINK_NOARG_INLINE_START(SwAddPrinterTabPage, SelectHdl)
480 bAttrModified=sal_True;
481 return 0;
483 IMPL_LINK_NOARG_INLINE_END(SwAddPrinterTabPage, SelectHdl)
485 void SwAddPrinterTabPage::PageCreated (SfxAllItemSet aSet)
487 SFX_ITEMSET_ARG (&aSet,pListItem,SfxBoolItem,SID_FAX_LIST,sal_False);
488 SFX_ITEMSET_ARG (&aSet,pPreviewItem,SfxBoolItem,SID_PREVIEWFLAG_TYPE,sal_False);
489 if (pPreviewItem)
491 SetPreview(pPreviewItem->GetValue());
492 Reset(aSet);
494 if (pListItem && pListItem->GetValue())
496 std::vector<String> aFaxList;
497 const std::vector<OUString>& rPrinters = Printer::GetPrinterQueues();
498 for (unsigned int i = 0; i < rPrinters.size(); ++i)
499 aFaxList.insert(aFaxList.begin(), rPrinters[i]);
500 SetFax( aFaxList );
504 /*--------------------------------------------------
505 Tabpage Standardfonts
506 --------------------------------------------------*/
507 SwStdFontTabPage::SwStdFontTabPage( Window* pParent,
508 const SfxItemSet& rSet ) :
509 SfxTabPage( pParent, SW_RES( TP_STD_FONT ), rSet),
510 aStdChrFL (this, SW_RES(FL_STDCHR )),
511 aTypeFT( this, SW_RES( FT_TYPE )),
513 aStandardLbl(this, SW_RES(FT_STANDARD)),
514 aStandardBox(this, SW_RES(LB_STANDARD)),
516 aHeightFT( this, SW_RES( FT_SIZE )),
517 aStandardHeightLB(this, SW_RES( LB_STANDARD_SIZE )),
519 aTitleLbl (this, SW_RES(FT_TITLE )),
520 aTitleBox (this, SW_RES(LB_TITLE )),
521 aTitleHeightLB( this, SW_RES( LB_TITLE_SIZE )),
523 aListLbl (this, SW_RES(FT_LIST )),
524 aListBox (this, SW_RES(LB_LIST )),
525 aListHeightLB( this, SW_RES( LB_LIST_SIZE )),
527 aLabelLbl (this, SW_RES(FT_LABEL )),
528 aLabelBox (this, SW_RES(LB_LABEL )),
529 aLabelHeightLB( this, SW_RES( LB_LABEL_SIZE )),
531 aIdxLbl (this, SW_RES(FT_IDX )),
532 aIdxBox (this, SW_RES(LB_IDX )),
533 aIndexHeightLB( this, SW_RES( LB_INDEX_SIZE )),
535 aDocOnlyCB (this, SW_RES(CB_DOCONLY )),
536 aStandardPB (this, SW_RES(PB_STANDARD)),
537 pPrt(0),
538 pFontList(0),
539 pFontConfig(0),
540 pWrtShell(0),
541 eLanguage( GetAppLanguage() ),
543 bListDefault(sal_False),
544 bSetListDefault(sal_True),
545 bLabelDefault(sal_False),
546 bSetLabelDefault(sal_True),
547 bIdxDefault(sal_False),
548 bSetIdxDefault(sal_True),
549 bDeletePrinter(sal_False),
551 bListHeightDefault (sal_False),
552 bSetListHeightDefault (sal_False),
553 bLabelHeightDefault (sal_False),
554 bSetLabelHeightDefault(sal_False),
555 bIndexHeightDefault (sal_False),
556 bSetIndexHeightDefault (sal_False),
558 nFontGroup(FONT_GROUP_DEFAULT),
560 sScriptWestern(SW_RES(ST_SCRIPT_WESTERN)),
561 sScriptAsian(SW_RES(ST_SCRIPT_ASIAN)),
562 sScriptComplex(SW_RES(ST_SCRIPT_CTL))
564 FreeResource();
565 aStandardPB.SetClickHdl(LINK(this, SwStdFontTabPage, StandardHdl));
566 aStandardBox.SetModifyHdl( LINK(this, SwStdFontTabPage, ModifyHdl));
567 aListBox .SetModifyHdl( LINK(this, SwStdFontTabPage, ModifyHdl));
568 aLabelBox .SetModifyHdl( LINK(this, SwStdFontTabPage, ModifyHdl));
569 aIdxBox .SetModifyHdl( LINK(this, SwStdFontTabPage, ModifyHdl));
570 Link aFocusLink = LINK( this, SwStdFontTabPage, LoseFocusHdl);
571 aStandardBox.SetLoseFocusHdl( aFocusLink );
572 aTitleBox .SetLoseFocusHdl( aFocusLink );
573 aListBox .SetLoseFocusHdl( aFocusLink );
574 aLabelBox .SetLoseFocusHdl( aFocusLink );
575 aIdxBox .SetLoseFocusHdl( aFocusLink );
577 Link aModifyHeightLink( LINK( this, SwStdFontTabPage, ModifyHeightHdl));
578 aStandardHeightLB.SetModifyHdl( aModifyHeightLink );
579 aTitleHeightLB. SetModifyHdl( aModifyHeightLink );
580 aListHeightLB. SetModifyHdl( aModifyHeightLink );
581 aLabelHeightLB. SetModifyHdl( aModifyHeightLink );
582 aIndexHeightLB. SetModifyHdl( aModifyHeightLink );
584 aDocOnlyCB.Check(SW_MOD()->GetModuleConfig()->IsDefaultFontInCurrDocOnly());
587 SwStdFontTabPage::~SwStdFontTabPage()
589 if(bDeletePrinter)
590 delete pPrt;
593 SfxTabPage* SwStdFontTabPage::Create( Window* pParent,
594 const SfxItemSet& rAttrSet )
596 return new SwStdFontTabPage(pParent, rAttrSet);
599 static void lcl_SetColl(SwWrtShell* pWrtShell, sal_uInt16 nType,
600 SfxPrinter* pPrt, const String& rStyle,
601 sal_uInt16 nFontWhich)
603 Font aFont( rStyle, Size( 0, 10 ) );
604 if( pPrt )
605 aFont = pPrt->GetFontMetric( aFont );
606 SwTxtFmtColl *pColl = pWrtShell->GetTxtCollFromPool(nType);
607 pColl->SetFmtAttr(SvxFontItem(aFont.GetFamily(), aFont.GetName(),
608 aEmptyStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich));
611 static void lcl_SetColl(SwWrtShell* pWrtShell, sal_uInt16 nType,
612 sal_Int32 nHeight, sal_uInt16 nFontHeightWhich)
614 float fSize = (float)nHeight / 10;
615 nHeight = CalcToUnit( fSize, SFX_MAPUNIT_TWIP );
616 SwTxtFmtColl *pColl = pWrtShell->GetTxtCollFromPool(nType);
617 pColl->SetFmtAttr(SvxFontHeightItem(nHeight, 100, nFontHeightWhich));
620 sal_Bool SwStdFontTabPage::FillItemSet( SfxItemSet& )
622 sal_Bool bNotDocOnly = !aDocOnlyCB.IsChecked();
623 SW_MOD()->GetModuleConfig()->SetDefaultFontInCurrDocOnly(!bNotDocOnly);
625 String sStandard = aStandardBox.GetText();
626 String sTitle = aTitleBox .GetText();
627 String sList = aListBox .GetText();
628 String sLabel = aLabelBox .GetText();
629 String sIdx = aIdxBox .GetText();
631 bool bStandardHeightChanged = aStandardHeightLB.GetSavedValue() != aStandardHeightLB.GetText();
632 bool bTitleHeightChanged = aTitleHeightLB.GetSavedValue() != aTitleHeightLB.GetText();
633 bool bListHeightChanged = aListHeightLB.GetSavedValue() != aListHeightLB.GetText() && (!bListHeightDefault || !bSetListHeightDefault );
634 bool bLabelHeightChanged = aLabelHeightLB.GetSavedValue() != aLabelHeightLB.GetText() && (!bLabelHeightDefault || !bSetLabelHeightDefault );
635 bool bIndexHeightChanged = aIndexHeightLB.GetSavedValue() != aIndexHeightLB.GetText() && (!bIndexHeightDefault || !bSetIndexHeightDefault );
636 if(bNotDocOnly)
638 pFontConfig->SetFontStandard(sStandard, nFontGroup);
639 pFontConfig->SetFontOutline(sTitle, nFontGroup);
640 pFontConfig->SetFontList(sList, nFontGroup);
641 pFontConfig->SetFontCaption(sLabel, nFontGroup);
642 pFontConfig->SetFontIndex(sIdx, nFontGroup);
643 if(bStandardHeightChanged)
645 float fSize = (float)aStandardHeightLB.GetValue() / 10;
646 pFontConfig->SetFontHeight( CalcToUnit( fSize, SFX_MAPUNIT_TWIP ), FONT_STANDARD, nFontGroup );
648 if(bTitleHeightChanged)
650 float fSize = (float)aTitleHeightLB.GetValue() / 10;
651 pFontConfig->SetFontHeight( CalcToUnit( fSize, SFX_MAPUNIT_TWIP ), FONT_OUTLINE, nFontGroup );
653 if(bListHeightChanged)
655 float fSize = (float)aListHeightLB.GetValue() / 10;
656 pFontConfig->SetFontHeight( CalcToUnit( fSize, SFX_MAPUNIT_TWIP ), FONT_LIST, nFontGroup );
658 if(bLabelHeightChanged)
660 float fSize = (float)aLabelHeightLB.GetValue() / 10;
661 pFontConfig->SetFontHeight( CalcToUnit( fSize, SFX_MAPUNIT_TWIP ), FONT_CAPTION, nFontGroup );
663 if(bIndexHeightChanged)
665 float fSize = (float)aIndexHeightLB.GetValue() / 10;
666 pFontConfig->SetFontHeight( CalcToUnit( fSize, SFX_MAPUNIT_TWIP ), FONT_INDEX, nFontGroup );
669 if(pWrtShell)
671 pWrtShell->StartAllAction();
672 SfxPrinter* pPrinter = pWrtShell->getIDocumentDeviceAccess()->getPrinter( false );
673 bool bMod = false;
674 sal_uInt16 nFontWhich = sal::static_int_cast< sal_uInt16, RES_CHRATR >(
675 nFontGroup == FONT_GROUP_DEFAULT ? RES_CHRATR_FONT :
676 FONT_GROUP_CJK == nFontGroup ? RES_CHRATR_CJK_FONT : RES_CHRATR_CTL_FONT);
677 sal_uInt16 nFontHeightWhich = sal::static_int_cast< sal_uInt16, RES_CHRATR >(
678 nFontGroup == FONT_GROUP_DEFAULT ? RES_CHRATR_FONTSIZE :
679 FONT_GROUP_CJK == nFontGroup ? RES_CHRATR_CJK_FONTSIZE : RES_CHRATR_CTL_FONTSIZE);
680 if(sStandard != sShellStd)
682 Font aFont( sStandard, Size( 0, 10 ) );
683 if( pPrinter )
684 aFont = pPrinter->GetFontMetric( aFont );
685 pWrtShell->SetDefault(SvxFontItem(aFont.GetFamily(), aFont.GetName(),
686 aEmptyStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich));
687 SwTxtFmtColl *pColl = pWrtShell->GetTxtCollFromPool(RES_POOLCOLL_STANDARD);
688 pColl->ResetFmtAttr(nFontWhich);
689 bMod = true;
691 if(bStandardHeightChanged)
693 float fSize = (float)aStandardHeightLB.GetValue() / 10;
694 pWrtShell->SetDefault(SvxFontHeightItem( CalcToUnit( fSize, SFX_MAPUNIT_TWIP ), 100, nFontHeightWhich ) );
695 SwTxtFmtColl *pColl = pWrtShell->GetTxtCollFromPool(RES_POOLCOLL_STANDARD);
696 pColl->ResetFmtAttr(nFontHeightWhich);
697 bMod = true;
700 if(sTitle != sShellTitle )
702 lcl_SetColl(pWrtShell, RES_POOLCOLL_HEADLINE_BASE, pPrinter, sTitle, nFontWhich);
703 bMod = true;
705 if(bTitleHeightChanged)
707 lcl_SetColl(pWrtShell, RES_POOLCOLL_HEADLINE_BASE,
708 sal::static_int_cast< sal_uInt16, sal_Int64 >(aTitleHeightLB.GetValue()), nFontHeightWhich);
709 bMod = true;
711 if(sList != sShellList && (!bListDefault || !bSetListDefault ))
713 lcl_SetColl(pWrtShell, RES_POOLCOLL_NUMBUL_BASE, pPrinter, sList, nFontWhich);
714 bMod = true;
716 if(bListHeightChanged)
718 lcl_SetColl(pWrtShell, RES_POOLCOLL_NUMBUL_BASE,
719 sal::static_int_cast< sal_uInt16, sal_Int64 >(aListHeightLB.GetValue()), nFontHeightWhich);
720 bMod = true;
722 if(sLabel != sShellLabel && (!bLabelDefault || !bSetLabelDefault))
724 lcl_SetColl(pWrtShell, RES_POOLCOLL_LABEL, pPrinter, sLabel, nFontWhich);
725 bMod = true;
727 if(bLabelHeightChanged)
729 lcl_SetColl(pWrtShell, RES_POOLCOLL_LABEL,
730 sal::static_int_cast< sal_uInt16, sal_Int64 >(aLabelHeightLB.GetValue()), nFontHeightWhich);
731 bMod = true;
733 if(sIdx != sShellIndex && (!bIdxDefault || !bSetIdxDefault))
735 lcl_SetColl(pWrtShell, RES_POOLCOLL_REGISTER_BASE, pPrinter, sIdx, nFontWhich);
736 bMod = true;
738 if(bIndexHeightChanged)
740 lcl_SetColl(pWrtShell, RES_POOLCOLL_REGISTER_BASE,
741 sal::static_int_cast< sal_uInt16, sal_Int64 >(aIndexHeightLB.GetValue()), nFontHeightWhich);
742 bMod = true;
744 if ( bMod )
745 pWrtShell->SetModified();
746 pWrtShell->EndAllAction();
749 return sal_False;
752 void SwStdFontTabPage::Reset( const SfxItemSet& rSet)
754 const SfxPoolItem* pLang;
755 sal_uInt16 nLangSlot = nFontGroup == FONT_GROUP_DEFAULT ? SID_ATTR_LANGUAGE :
756 FONT_GROUP_CJK == nFontGroup ? SID_ATTR_CHAR_CJK_LANGUAGE : SID_ATTR_CHAR_CTL_LANGUAGE;
759 if( SFX_ITEM_SET == rSet.GetItemState(nLangSlot, sal_False, &pLang))
760 eLanguage = ((const SvxLanguageItem*)pLang)->GetValue();
762 String sTmp(aStdChrFL.GetText());
763 String sToReplace = sScriptWestern;
764 if(FONT_GROUP_CJK == nFontGroup )
765 sToReplace = sScriptAsian;
766 else if(FONT_GROUP_CTL == nFontGroup )
767 sToReplace = sScriptComplex;
769 sTmp.SearchAndReplaceAscii("%1", sToReplace);
770 aStdChrFL.SetText(sTmp);
771 const SfxPoolItem* pItem;
773 if(SFX_ITEM_SET == rSet.GetItemState(FN_PARAM_PRINTER, sal_False, &pItem))
775 pPrt = (SfxPrinter*)((const SwPtrItem*)pItem)->GetValue();
777 else
779 SfxItemSet* pPrinterSet = new SfxItemSet( *rSet.GetPool(),
780 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
781 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
782 0 );
783 pPrt = new SfxPrinter(pPrinterSet);
784 bDeletePrinter = sal_True;
786 pFontList = new FontList( pPrt );
787 // #i94536# prevent duplication of font entries when 'reset' button is pressed
788 if( !aStandardBox.GetEntryCount() )
790 // get the set of disctinct available family names
791 std::set< String > aFontNames;
792 int nFontNames = pPrt->GetDevFontCount();
793 for( int i = 0; i < nFontNames; i++ )
795 FontInfo aInf( pPrt->GetDevFont( i ) );
796 aFontNames.insert( aInf.GetName() );
799 // insert to listboxes
800 for( std::set< String >::const_iterator it = aFontNames.begin();
801 it != aFontNames.end(); ++it )
803 aStandardBox.InsertEntry( *it );
804 aTitleBox .InsertEntry( *it );
805 aListBox .InsertEntry( *it );
806 aLabelBox .InsertEntry( *it );
807 aIdxBox .InsertEntry( *it );
810 if(SFX_ITEM_SET == rSet.GetItemState(FN_PARAM_STDFONTS, sal_False, &pItem))
812 pFontConfig = (SwStdFontConfig*)((const SwPtrItem*)pItem)->GetValue();
815 if(SFX_ITEM_SET == rSet.GetItemState(FN_PARAM_WRTSHELL, sal_False, &pItem))
817 pWrtShell = (SwWrtShell*)((const SwPtrItem*)pItem)->GetValue();
819 String sStdBackup;
820 String sOutBackup;
821 String sListBackup;
822 String sCapBackup;
823 String sIdxBackup;
824 sal_Int32 nStandardHeight = -1;
825 sal_Int32 nTitleHeight = -1;
826 sal_Int32 nListHeight = -1;
827 sal_Int32 nLabelHeight = -1;
828 sal_Int32 nIndexHeight = -1;
830 if(!pWrtShell)
832 sStdBackup = pFontConfig->GetFontStandard(nFontGroup);
833 sOutBackup = pFontConfig->GetFontOutline(nFontGroup);
834 sListBackup= pFontConfig->GetFontList(nFontGroup);
835 sCapBackup = pFontConfig->GetFontCaption(nFontGroup);
836 sIdxBackup = pFontConfig->GetFontIndex(nFontGroup);
837 nStandardHeight = pFontConfig->GetFontHeight( FONT_STANDARD, nFontGroup, eLanguage );
838 nTitleHeight = pFontConfig->GetFontHeight( FONT_OUTLINE , nFontGroup, eLanguage );
839 nListHeight = pFontConfig->GetFontHeight( FONT_LIST , nFontGroup, eLanguage );
840 nLabelHeight = pFontConfig->GetFontHeight( FONT_CAPTION , nFontGroup, eLanguage );
841 nIndexHeight = pFontConfig->GetFontHeight( FONT_INDEX , nFontGroup, eLanguage );
842 if( nStandardHeight <= 0)
843 nStandardHeight = pFontConfig->GetDefaultHeightFor( FONT_STANDARD + nFontGroup * FONT_PER_GROUP, eLanguage);
844 if( nTitleHeight <= 0)
845 nTitleHeight = pFontConfig->GetDefaultHeightFor( FONT_OUTLINE + nFontGroup * FONT_PER_GROUP, eLanguage);
846 if( nListHeight <= 0)
847 nListHeight = pFontConfig->GetDefaultHeightFor( FONT_LIST + nFontGroup * FONT_PER_GROUP, eLanguage);
848 if( nLabelHeight <= 0)
849 nLabelHeight = pFontConfig->GetDefaultHeightFor( FONT_CAPTION + nFontGroup * FONT_PER_GROUP, eLanguage);
850 if( nIndexHeight <= 0)
851 nIndexHeight = pFontConfig->GetDefaultHeightFor( FONT_INDEX + nFontGroup * FONT_PER_GROUP, eLanguage);
853 aDocOnlyCB.Enable(sal_False);
855 else
857 SwTxtFmtColl *pColl = pWrtShell->GetTxtCollFromPool(RES_POOLCOLL_STANDARD);
858 const SvxFontItem& rFont = !nFontGroup ? pColl->GetFont() :
859 FONT_GROUP_CJK == nFontGroup ? pColl->GetCJKFont() : pColl->GetCTLFont();
860 sShellStd = sStdBackup = rFont.GetFamilyName();
862 sal_uInt16 nFontHeightWhich = sal::static_int_cast< sal_uInt16, RES_CHRATR >(
863 nFontGroup == FONT_GROUP_DEFAULT ? RES_CHRATR_FONTSIZE :
864 FONT_GROUP_CJK == nFontGroup ? RES_CHRATR_CJK_FONTSIZE : RES_CHRATR_CTL_FONTSIZE );
865 const SvxFontHeightItem& rFontHeightStandard = (const SvxFontHeightItem& )pColl->GetFmtAttr(nFontHeightWhich);
866 nStandardHeight = (sal_Int32)rFontHeightStandard.GetHeight();
868 pColl = pWrtShell->GetTxtCollFromPool(RES_POOLCOLL_HEADLINE_BASE);
869 const SvxFontItem& rFontHL = !nFontGroup ? pColl->GetFont() :
870 FONT_GROUP_CJK == nFontGroup ? pColl->GetCJKFont() : pColl->GetCTLFont();
871 sShellTitle = sOutBackup = rFontHL.GetFamilyName();
873 const SvxFontHeightItem& rFontHeightTitle = (const SvxFontHeightItem&)pColl->GetFmtAttr( nFontHeightWhich, sal_True );
874 nTitleHeight = (sal_Int32)rFontHeightTitle.GetHeight();
876 sal_uInt16 nFontWhich = sal::static_int_cast< sal_uInt16, RES_CHRATR >(
877 nFontGroup == FONT_GROUP_DEFAULT ? RES_CHRATR_FONT :
878 FONT_GROUP_CJK == nFontGroup ? RES_CHRATR_CJK_FONT : RES_CHRATR_CTL_FONT);
879 pColl = pWrtShell->GetTxtCollFromPool(RES_POOLCOLL_NUMBUL_BASE);
880 const SvxFontItem& rFontLS = !nFontGroup ? pColl->GetFont() :
881 FONT_GROUP_CJK == nFontGroup ? pColl->GetCJKFont() : pColl->GetCTLFont();
882 bListDefault = SFX_ITEM_DEFAULT == pColl->GetAttrSet().GetItemState(nFontWhich, sal_False);
883 sShellList = sListBackup = rFontLS.GetFamilyName();
885 const SvxFontHeightItem& rFontHeightList = (const SvxFontHeightItem&)pColl->GetFmtAttr(nFontHeightWhich, sal_True);
886 nListHeight = (sal_Int32)rFontHeightList.GetHeight();
887 bListHeightDefault = SFX_ITEM_DEFAULT == pColl->GetAttrSet().GetItemState(nFontWhich, sal_False);
890 pColl = pWrtShell->GetTxtCollFromPool(RES_POOLCOLL_LABEL);
891 bLabelDefault = SFX_ITEM_DEFAULT == pColl->GetAttrSet().GetItemState(nFontWhich, sal_False);
892 const SvxFontItem& rFontCP = !nFontGroup ? pColl->GetFont() :
893 FONT_GROUP_CJK == nFontGroup ? pColl->GetCJKFont() : pColl->GetCTLFont();
894 sShellLabel = sCapBackup = rFontCP.GetFamilyName();
895 const SvxFontHeightItem& rFontHeightLabel = (const SvxFontHeightItem&)pColl->GetFmtAttr(nFontHeightWhich, sal_True);
896 nLabelHeight = (sal_Int32)rFontHeightLabel.GetHeight();
897 bLabelHeightDefault = SFX_ITEM_DEFAULT == pColl->GetAttrSet().GetItemState(nFontWhich, sal_False);
899 pColl = pWrtShell->GetTxtCollFromPool(RES_POOLCOLL_REGISTER_BASE);
900 bIdxDefault = SFX_ITEM_DEFAULT == pColl->GetAttrSet().GetItemState(nFontWhich, sal_False);
901 const SvxFontItem& rFontIDX = !nFontGroup ? pColl->GetFont() :
902 FONT_GROUP_CJK == nFontGroup ? pColl->GetCJKFont() : pColl->GetCTLFont();
903 sShellIndex = sIdxBackup = rFontIDX.GetFamilyName();
904 const SvxFontHeightItem& rFontHeightIndex = (const SvxFontHeightItem&)pColl->GetFmtAttr(nFontHeightWhich, sal_True);
905 nIndexHeight = (sal_Int32)rFontHeightIndex.GetHeight();
906 bIndexHeightDefault = SFX_ITEM_DEFAULT == pColl->GetAttrSet().GetItemState(nFontWhich, sal_False);
908 aStandardBox.SetText(sStdBackup );
909 aTitleBox .SetText(sOutBackup );
910 aListBox .SetText(sListBackup);
911 aLabelBox .SetText(sCapBackup );
912 aIdxBox .SetText(sIdxBackup );
914 FontInfo aFontInfo( pFontList->Get(sStdBackup, sStdBackup) );
915 aStandardHeightLB.Fill( &aFontInfo, pFontList );
916 aFontInfo = pFontList->Get(sOutBackup, sOutBackup );
917 aTitleHeightLB.Fill( &aFontInfo, pFontList );
918 aFontInfo = pFontList->Get(sListBackup,sListBackup);
919 aListHeightLB.Fill( &aFontInfo, pFontList );
920 aFontInfo = pFontList->Get(sCapBackup, sCapBackup );
921 aLabelHeightLB.Fill( &aFontInfo, pFontList );
922 aFontInfo = pFontList->Get(sIdxBackup, sIdxBackup );
923 aIndexHeightLB.Fill( &aFontInfo, pFontList );
925 aStandardHeightLB.SetValue( CalcToPoint( nStandardHeight, SFX_MAPUNIT_TWIP, 10 ) );
926 aTitleHeightLB. SetValue( CalcToPoint( nTitleHeight , SFX_MAPUNIT_TWIP, 10 ) );
927 aListHeightLB. SetValue( CalcToPoint( nListHeight , SFX_MAPUNIT_TWIP, 10 ) );
928 aLabelHeightLB. SetValue( CalcToPoint( nLabelHeight , SFX_MAPUNIT_TWIP, 10 ));
929 aIndexHeightLB. SetValue( CalcToPoint( nIndexHeight , SFX_MAPUNIT_TWIP, 10 ));
931 aStandardBox.SaveValue();
932 aTitleBox .SaveValue();
933 aListBox .SaveValue();
934 aLabelBox .SaveValue();
935 aIdxBox .SaveValue();
937 aStandardHeightLB.SaveValue();
938 aTitleHeightLB. SaveValue();
939 aListHeightLB. SaveValue();
940 aLabelHeightLB. SaveValue();
941 aIndexHeightLB. SaveValue();
944 IMPL_LINK_NOARG(SwStdFontTabPage, StandardHdl)
946 sal_uInt8 nFontOffset = nFontGroup * FONT_PER_GROUP;
947 aStandardBox.SetText(SwStdFontConfig::GetDefaultFor(FONT_STANDARD + nFontOffset, eLanguage));
948 aTitleBox .SetText(SwStdFontConfig::GetDefaultFor(FONT_OUTLINE + nFontOffset, eLanguage));
949 aListBox .SetText(SwStdFontConfig::GetDefaultFor(FONT_LIST + nFontOffset, eLanguage));
950 aLabelBox .SetText(SwStdFontConfig::GetDefaultFor(FONT_CAPTION + nFontOffset, eLanguage));
951 aIdxBox .SetText(SwStdFontConfig::GetDefaultFor(FONT_INDEX + nFontOffset, eLanguage));
953 aStandardBox.SaveValue();
954 aTitleBox .SaveValue();
955 aListBox .SaveValue();
956 aLabelBox .SaveValue();
957 aIdxBox .SaveValue();
959 aStandardHeightLB.SetValue( CalcToPoint(
960 SwStdFontConfig::GetDefaultHeightFor(FONT_STANDARD + nFontOffset, eLanguage),
961 SFX_MAPUNIT_TWIP, 10 ) );
962 aTitleHeightLB .SetValue(CalcToPoint(
963 SwStdFontConfig::GetDefaultHeightFor(FONT_OUTLINE +
964 nFontOffset, eLanguage), SFX_MAPUNIT_TWIP, 10 ));
965 aListHeightLB .SetValue(CalcToPoint(
966 SwStdFontConfig::GetDefaultHeightFor(FONT_LIST + nFontOffset, eLanguage),
967 SFX_MAPUNIT_TWIP, 10 ));
968 aLabelHeightLB .SetValue(CalcToPoint(
969 SwStdFontConfig::GetDefaultHeightFor(FONT_CAPTION + nFontOffset, eLanguage),
970 SFX_MAPUNIT_TWIP, 10 ));
971 aIndexHeightLB .SetValue(CalcToPoint(
972 SwStdFontConfig::GetDefaultHeightFor(FONT_INDEX + nFontOffset, eLanguage),
973 SFX_MAPUNIT_TWIP, 10 ));
975 return 0;
978 IMPL_LINK( SwStdFontTabPage, ModifyHdl, ComboBox*, pBox )
980 if(pBox == &aStandardBox)
982 String sEntry = pBox->GetText();
983 if(bSetListDefault && bListDefault)
984 aListBox.SetText(sEntry);
985 if(bSetLabelDefault && bLabelDefault)
986 aLabelBox.SetText(sEntry);
987 if(bSetIdxDefault && bIdxDefault)
988 aIdxBox.SetText(sEntry);
990 else if(pBox == &aListBox)
992 bSetListDefault = sal_False;
994 else if(pBox == &aLabelBox)
996 bSetLabelDefault = sal_False;
998 else if(pBox == &aIdxBox)
1000 bSetIdxDefault = sal_False;
1002 return 0;
1005 IMPL_LINK( SwStdFontTabPage, ModifyHeightHdl, FontSizeBox*, pBox )
1007 if(pBox == &aStandardHeightLB)
1009 sal_Int64 nValue = pBox->GetValue(FUNIT_TWIP);
1010 if(bSetListHeightDefault && bListHeightDefault)
1011 aListHeightLB.SetValue(nValue, FUNIT_TWIP);
1012 if(bSetLabelHeightDefault && bLabelHeightDefault)
1013 aLabelHeightLB.SetValue(nValue, FUNIT_TWIP);
1014 if(bSetIndexHeightDefault && bIndexHeightDefault)
1015 aIndexHeightLB.SetValue(nValue, FUNIT_TWIP);
1017 else if(pBox == &aListHeightLB)
1019 bSetListHeightDefault = sal_False;
1021 else if(pBox == &aLabelHeightLB)
1023 bSetLabelHeightDefault = sal_False;
1025 else if(pBox == &aIndexHeightLB)
1027 bSetIndexHeightDefault = sal_False;
1029 return 0;
1032 IMPL_LINK( SwStdFontTabPage, LoseFocusHdl, ComboBox*, pBox )
1034 FontSizeBox* pHeightLB = 0;
1035 String sEntry = pBox->GetText();
1036 if(pBox == &aStandardBox)
1038 pHeightLB = &aStandardHeightLB;
1040 else if(pBox == &aTitleBox)
1042 pHeightLB = &aTitleHeightLB;
1044 else if(pBox == &aListBox)
1046 pHeightLB = &aListHeightLB;
1048 else if(pBox == &aLabelBox)
1050 pHeightLB = &aLabelHeightLB;
1052 else /*if(pBox == &aIdxBox)*/
1054 pHeightLB = &aIndexHeightLB;
1056 FontInfo aFontInfo( pFontList->Get(sEntry, sEntry) );
1057 pHeightLB->Fill( &aFontInfo, pFontList );
1059 return 0;
1063 void SwStdFontTabPage::PageCreated (SfxAllItemSet aSet)
1065 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt16Item, SID_FONTMODE_TYPE, sal_False);
1066 if (pFlagItem)
1067 SetFontMode(sal::static_int_cast< sal_uInt8, sal_uInt16>( pFlagItem->GetValue()));
1070 SwTableOptionsTabPage::SwTableOptionsTabPage( Window* pParent, const SfxItemSet& rSet ) :
1071 SfxTabPage(pParent, SW_RES(TP_OPTTABLE_PAGE), rSet),
1072 aTableFL (this, SW_RES(FL_TABLE )),
1073 aHeaderCB (this, SW_RES(CB_HEADER )),
1074 aRepeatHeaderCB (this, SW_RES(CB_REPEAT_HEADER )),
1075 aDontSplitCB (this, SW_RES(CB_DONT_SPLIT )),
1076 aBorderCB (this, SW_RES(CB_BORDER )),
1078 aSeparatorFL (this, SW_RES(FL_TABLE_SEPARATOR)),
1080 aTableInsertFL (this, SW_RES(FL_TABLE_INSERT )),
1081 aNumFormattingCB(this, SW_RES(CB_NUMFORMATTING )),
1082 aNumFmtFormattingCB(this, SW_RES(CB_NUMFMT_FORMATTING )),
1083 aNumAlignmentCB (this, SW_RES(CB_NUMALIGNMENT )),
1085 aMoveFL( this, SW_RES(FL_MOVE )),
1086 aMoveFT( this, SW_RES(FT_MOVE )),
1087 aRowMoveFT( this, SW_RES(FT_ROWMOVE )),
1088 aRowMoveMF( this, SW_RES(MF_ROWMOVE )),
1089 aColMoveFT( this, SW_RES(FT_COLMOVE )),
1090 aColMoveMF( this, SW_RES(MF_COLMOVE )),
1092 aInsertFT( this, SW_RES(FT_INSERT )),
1093 aRowInsertFT( this, SW_RES(FT_ROWINSERT)),
1094 aRowInsertMF( this, SW_RES(MF_ROWINSERT)),
1095 aColInsertFT( this, SW_RES(FT_COLINSERT)),
1096 aColInsertMF( this, SW_RES(MF_COLINSERT)),
1098 aHandlingFT( this, SW_RES(FT_HANDLING )),
1099 aFixRB( this, SW_RES(RB_FIX )),
1100 aFixPropRB( this, SW_RES(RB_FIXPROP )),
1101 aVarRB( this, SW_RES(RB_VAR )),
1102 aFixFT( this, SW_RES(FT_FIX )),
1103 aFixPropFT( this, SW_RES(FT_FIXPROP )),
1104 aVarFT( this, SW_RES(FT_VAR )),
1105 pWrtShell(0),
1106 bHTMLMode(sal_False)
1108 FreeResource();
1110 Link aLnk(LINK(this, SwTableOptionsTabPage, CheckBoxHdl));
1111 aNumFormattingCB.SetClickHdl(aLnk);
1112 aNumFmtFormattingCB.SetClickHdl(aLnk);
1113 aHeaderCB.SetClickHdl(aLnk);
1116 SwTableOptionsTabPage::~SwTableOptionsTabPage()
1120 SfxTabPage* SwTableOptionsTabPage::Create( Window* pParent,
1121 const SfxItemSet& rAttrSet )
1123 return new SwTableOptionsTabPage(pParent, rAttrSet );
1126 sal_Bool SwTableOptionsTabPage::FillItemSet( SfxItemSet& )
1128 sal_Bool bRet = sal_False;
1129 SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
1131 if(aRowMoveMF.IsModified())
1132 pModOpt->SetTblHMove( (sal_uInt16)aRowMoveMF.Denormalize( aRowMoveMF.GetValue(FUNIT_TWIP)));
1134 if(aColMoveMF.IsModified())
1135 pModOpt->SetTblVMove( (sal_uInt16)aColMoveMF.Denormalize( aColMoveMF.GetValue(FUNIT_TWIP)));
1137 if(aRowInsertMF.IsModified())
1138 pModOpt->SetTblHInsert((sal_uInt16)aRowInsertMF.Denormalize( aRowInsertMF.GetValue(FUNIT_TWIP)));
1140 if(aColInsertMF.IsModified())
1141 pModOpt->SetTblVInsert((sal_uInt16)aColInsertMF.Denormalize( aColInsertMF.GetValue(FUNIT_TWIP)));
1143 TblChgMode eMode;
1144 if(aFixRB.IsChecked())
1145 eMode = TBLFIX_CHGABS;
1146 else if(aFixPropRB.IsChecked())
1147 eMode = TBLFIX_CHGPROP;
1148 else
1149 eMode = TBLVAR_CHGABS;
1150 if(eMode != pModOpt->GetTblMode())
1152 pModOpt->SetTblMode(eMode);
1153 // the table-keyboard-mode has changed, now the current
1154 // table should know about that too.
1155 if(pWrtShell && nsSelectionType::SEL_TBL & pWrtShell->GetSelectionType())
1157 pWrtShell->SetTblChgMode(eMode);
1158 static sal_uInt16 aInva[] =
1159 { FN_TABLE_MODE_FIX,
1160 FN_TABLE_MODE_FIX_PROP,
1161 FN_TABLE_MODE_VARIABLE,
1164 pWrtShell->GetView().GetViewFrame()->GetBindings().Invalidate( aInva );
1167 bRet = sal_True;
1170 SwInsertTableOptions aInsOpts( 0, 0 );
1172 if (aHeaderCB.IsChecked())
1173 aInsOpts.mnInsMode |= tabopts::HEADLINE;
1175 if (aRepeatHeaderCB.IsEnabled() )
1176 aInsOpts.mnRowsToRepeat = aRepeatHeaderCB.IsChecked()? 1 : 0;
1178 if (!aDontSplitCB.IsChecked())
1179 aInsOpts.mnInsMode |= tabopts::SPLIT_LAYOUT;
1181 if (aBorderCB.IsChecked())
1182 aInsOpts.mnInsMode |= tabopts::DEFAULT_BORDER;
1184 if (aHeaderCB.GetSavedValue() != aHeaderCB.GetState() ||
1185 aRepeatHeaderCB.GetSavedValue() != aRepeatHeaderCB.GetState() ||
1186 aDontSplitCB.GetSavedValue() != aDontSplitCB.GetState() ||
1187 aBorderCB.GetSavedValue() != aBorderCB.GetState())
1189 pModOpt->SetInsTblFlags(bHTMLMode, aInsOpts);
1192 if (aNumFormattingCB.GetSavedValue() != aNumFormattingCB.GetState())
1194 pModOpt->SetInsTblFormatNum(bHTMLMode, aNumFormattingCB.IsChecked());
1195 bRet = sal_True;
1198 if (aNumFmtFormattingCB.GetSavedValue() != aNumFmtFormattingCB.GetState())
1200 pModOpt->SetInsTblChangeNumFormat(bHTMLMode, aNumFmtFormattingCB.IsChecked());
1201 bRet = sal_True;
1204 if (aNumAlignmentCB.GetSavedValue() != aNumAlignmentCB.GetState())
1206 pModOpt->SetInsTblAlignNum(bHTMLMode, aNumAlignmentCB.IsChecked());
1207 bRet = sal_True;
1210 return bRet;
1213 void SwTableOptionsTabPage::Reset( const SfxItemSet& rSet)
1215 const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
1216 if ( rSet.GetItemState( SID_ATTR_METRIC ) >= SFX_ITEM_AVAILABLE )
1218 const SfxUInt16Item& rItem = (SfxUInt16Item&)rSet.Get( SID_ATTR_METRIC );
1219 FieldUnit eFieldUnit = (FieldUnit)rItem.GetValue();
1220 ::SetFieldUnit( aRowMoveMF, eFieldUnit );
1221 ::SetFieldUnit( aColMoveMF, eFieldUnit );
1222 ::SetFieldUnit( aRowInsertMF, eFieldUnit );
1223 ::SetFieldUnit( aColInsertMF, eFieldUnit );
1226 aRowMoveMF .SetValue(aRowMoveMF.Normalize(pModOpt->GetTblHMove()), FUNIT_TWIP);
1227 aColMoveMF .SetValue(aColMoveMF.Normalize(pModOpt->GetTblVMove()), FUNIT_TWIP);
1228 aRowInsertMF.SetValue(aRowInsertMF.Normalize(pModOpt->GetTblHInsert()), FUNIT_TWIP);
1229 aColInsertMF.SetValue(aColInsertMF.Normalize(pModOpt->GetTblVInsert()), FUNIT_TWIP);
1231 switch(pModOpt->GetTblMode())
1233 case TBLFIX_CHGABS: aFixRB.Check(); break;
1234 case TBLFIX_CHGPROP: aFixPropRB.Check(); break;
1235 case TBLVAR_CHGABS: aVarRB.Check(); break;
1237 const SfxPoolItem* pItem;
1238 if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem))
1240 bHTMLMode = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON);
1243 // hide certain controls for html
1244 if(bHTMLMode)
1246 aRepeatHeaderCB.Hide();
1247 aDontSplitCB.Hide();
1249 long nMoveUpBy =
1250 aRepeatHeaderCB.LogicToPixel( Size( 13, 13 ), MAP_APPFONT ).Height();
1252 Point aPos = aRepeatHeaderCB.GetPosPixel();
1253 aRepeatHeaderCB.SetPosPixel( Point( aPos.X(), aPos.Y() - nMoveUpBy ) );
1255 nMoveUpBy +=
1256 aDontSplitCB.LogicToPixel( Size( 13, 13 ), MAP_APPFONT ).Height();
1258 aPos = aBorderCB.GetPosPixel();
1259 aBorderCB.SetPosPixel( Point( aPos.X(), aPos.Y() - nMoveUpBy ) );
1262 SwInsertTableOptions aInsOpts = pModOpt->GetInsTblFlags(bHTMLMode);
1263 sal_uInt16 nInsTblFlags = aInsOpts.mnInsMode;
1265 aHeaderCB.Check(0 != (nInsTblFlags & tabopts::HEADLINE));
1266 aRepeatHeaderCB.Check((!bHTMLMode) && (aInsOpts.mnRowsToRepeat > 0));
1267 aDontSplitCB.Check(!(nInsTblFlags & tabopts::SPLIT_LAYOUT));
1268 aBorderCB.Check(0 != (nInsTblFlags & tabopts::DEFAULT_BORDER));
1270 aNumFormattingCB.Check(pModOpt->IsInsTblFormatNum(bHTMLMode));
1271 aNumFmtFormattingCB.Check(pModOpt->IsInsTblChangeNumFormat(bHTMLMode));
1272 aNumAlignmentCB.Check(pModOpt->IsInsTblAlignNum(bHTMLMode));
1274 aHeaderCB.SaveValue();
1275 aRepeatHeaderCB.SaveValue();
1276 aDontSplitCB.SaveValue();
1277 aBorderCB.SaveValue();
1278 aNumFormattingCB.SaveValue();
1279 aNumFmtFormattingCB.SaveValue();
1280 aNumAlignmentCB.SaveValue();
1282 CheckBoxHdl(0);
1285 IMPL_LINK_NOARG(SwTableOptionsTabPage, CheckBoxHdl)
1287 aNumFmtFormattingCB.Enable(aNumFormattingCB.IsChecked());
1288 aNumAlignmentCB.Enable(aNumFormattingCB.IsChecked());
1289 aRepeatHeaderCB.Enable(aHeaderCB.IsChecked());
1290 return 0;
1293 void SwTableOptionsTabPage::PageCreated (SfxAllItemSet aSet)
1295 SFX_ITEMSET_ARG (&aSet,pWrtSh,SwWrtShellItem,SID_WRT_SHELL,sal_False);
1296 if (pWrtSh)
1297 SetWrtShell(pWrtSh->GetValue());
1300 SwShdwCrsrOptionsTabPage::SwShdwCrsrOptionsTabPage( Window* pParent,
1301 const SfxItemSet& rSet )
1302 : SfxTabPage(pParent, SW_RES(TP_OPTSHDWCRSR), rSet),
1303 aUnprintFL ( this, SW_RES( FL_NOPRINT ) ),
1304 aParaCB ( this, SW_RES( CB_PARA ) ),
1305 aSHyphCB ( this, SW_RES( CB_SHYPH ) ),
1306 aSpacesCB ( this, SW_RES( CB_SPACE ) ),
1307 aHSpacesCB ( this, SW_RES( CB_HSPACE ) ),
1308 aTabCB ( this, SW_RES( CB_TAB ) ),
1309 aBreakCB ( this, SW_RES( CB_BREAK ) ),
1310 aCharHiddenCB ( this, SW_RES( CB_CHAR_HIDDEN ) ),
1311 aFldHiddenCB ( this, SW_RES( CB_FLD_HIDDEN ) ),
1312 aFldHiddenParaCB ( this, SW_RES( CB_FLD_HIDDEN_PARA ) ),
1314 aSeparatorFL( this, SW_RES( FL_SEPARATOR_SHDW)),
1316 aFlagFL( this, SW_RES( FL_SHDWCRSFLAG )),
1317 aOnOffCB( this, SW_RES( CB_SHDWCRSONOFF )),
1319 aFillModeFT( this, SW_RES( FT_SHDWCRSFILLMODE )),
1320 aFillMarginRB( this, SW_RES( RB_SHDWCRSFILLMARGIN )),
1321 aFillIndentRB( this, SW_RES( RB_SHDWCRSFILLINDENT )),
1322 aFillTabRB( this, SW_RES( RB_SHDWCRSFILLTAB )),
1323 aFillSpaceRB( this, SW_RES( RB_SHDWCRSFILLSPACE )),
1324 aCrsrOptFL ( this, SW_RES( FL_CRSR_OPT)),
1325 aCrsrInProtCB( this, SW_RES( CB_ALLOW_IN_PROT )),
1326 m_aLayoutOptionsFL( this, SW_RES( FL_LAYOUT_OPTIONS ) ),
1327 m_aMathBaselineAlignmentCB( this, SW_RES( CB_MATH_BASELINE_ALIGNMENT ) ),
1328 m_pWrtShell( NULL )
1330 FreeResource();
1331 const SfxPoolItem* pItem = 0;
1333 SwShadowCursorItem aOpt;
1334 if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_SHADOWCURSOR, sal_False, &pItem ))
1335 aOpt = *(SwShadowCursorItem*)pItem;
1336 aOnOffCB.Check( aOpt.IsOn() );
1338 sal_uInt8 eMode = aOpt.GetMode();
1339 aFillIndentRB.Check( FILL_INDENT == eMode );
1340 aFillMarginRB.Check( FILL_MARGIN == eMode );
1341 aFillTabRB.Check( FILL_TAB == eMode );
1342 aFillSpaceRB.Check( FILL_SPACE == eMode );
1344 if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem )
1345 && ((SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON)
1347 aTabCB .Hide();
1348 aCharHiddenCB.Hide();
1349 aFldHiddenCB .Hide();
1350 aFldHiddenParaCB.Hide();
1351 aBreakCB.SetPosPixel(aTabCB.GetPosPixel());
1352 aFlagFL .Hide();
1353 aOnOffCB .Hide();
1354 aFillModeFT .Hide();
1355 aFillMarginRB .Hide();
1356 aFillIndentRB .Hide();
1357 aFillTabRB .Hide();
1358 aFillSpaceRB .Hide();
1359 aCrsrOptFL .Hide();
1360 aCrsrInProtCB .Hide();
1361 aSeparatorFL.Hide();
1362 long nWidth = aFlagFL.GetSizePixel().Width() + aFlagFL.GetPosPixel().X()
1363 - aUnprintFL.GetPosPixel().X();
1364 Size aSize(aUnprintFL.GetSizePixel());
1365 aSize.Width() = nWidth;
1366 aUnprintFL.SetSizePixel(aSize);
1370 SwShdwCrsrOptionsTabPage::~SwShdwCrsrOptionsTabPage()
1374 SfxTabPage* SwShdwCrsrOptionsTabPage::Create( Window* pParent, const SfxItemSet& rSet )
1376 return new SwShdwCrsrOptionsTabPage( pParent, rSet );
1380 void SwShdwCrsrOptionsTabPage::PageCreated( SfxAllItemSet aSet )
1382 SFX_ITEMSET_ARG (&aSet,pWrtSh,SwWrtShellItem,SID_WRT_SHELL,sal_False);
1383 if (pWrtSh)
1384 SetWrtShell(pWrtSh->GetValue());
1388 sal_Bool SwShdwCrsrOptionsTabPage::FillItemSet( SfxItemSet& rSet )
1390 SwShadowCursorItem aOpt;
1391 aOpt.SetOn( aOnOffCB.IsChecked() );
1393 sal_uInt8 eMode;
1394 if( aFillIndentRB.IsChecked() )
1395 eMode= FILL_INDENT;
1396 else if( aFillMarginRB.IsChecked() )
1397 eMode = FILL_MARGIN;
1398 else if( aFillTabRB.IsChecked() )
1399 eMode = FILL_TAB;
1400 else
1401 eMode = FILL_SPACE;
1402 aOpt.SetMode( eMode );
1404 sal_Bool bRet = sal_False;
1405 const SfxPoolItem* pItem = 0;
1406 if( SFX_ITEM_SET != rSet.GetItemState( FN_PARAM_SHADOWCURSOR, sal_False, &pItem )
1407 || ((SwShadowCursorItem&)*pItem) != aOpt )
1409 rSet.Put( aOpt );
1410 bRet = sal_True;
1413 if (m_pWrtShell) {
1414 m_pWrtShell->GetDoc()->set( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT,
1415 m_aMathBaselineAlignmentCB.IsChecked() );
1416 bRet |= m_aMathBaselineAlignmentCB.IsChecked() != m_aMathBaselineAlignmentCB.GetSavedValue();
1419 if( aCrsrInProtCB.IsChecked() != aCrsrInProtCB.GetSavedValue())
1421 rSet.Put(SfxBoolItem(FN_PARAM_CRSR_IN_PROTECTED, aCrsrInProtCB.IsChecked()));
1422 bRet |= sal_True;
1425 const SwDocDisplayItem* pOldAttr = (const SwDocDisplayItem*)
1426 GetOldItem(GetItemSet(), FN_PARAM_DOCDISP);
1428 SwDocDisplayItem aDisp;
1429 if(pOldAttr)
1430 aDisp = *pOldAttr;
1432 aDisp.bParagraphEnd = aParaCB .IsChecked();
1433 aDisp.bTab = aTabCB .IsChecked();
1434 aDisp.bSpace = aSpacesCB .IsChecked();
1435 aDisp.bNonbreakingSpace = aHSpacesCB .IsChecked();
1436 aDisp.bSoftHyphen = aSHyphCB .IsChecked();
1437 aDisp.bFldHiddenText = aFldHiddenCB .IsChecked();
1438 aDisp.bCharHiddenText = aCharHiddenCB.IsChecked();
1439 aDisp.bShowHiddenPara = aFldHiddenParaCB .IsChecked();
1440 aDisp.bManualBreak = aBreakCB .IsChecked();
1442 bRet |= (!pOldAttr || aDisp != *pOldAttr);
1443 if(bRet)
1444 bRet = 0 != rSet.Put(aDisp);
1446 return bRet;
1449 void SwShdwCrsrOptionsTabPage::Reset( const SfxItemSet& rSet )
1451 const SfxPoolItem* pItem = 0;
1453 SwShadowCursorItem aOpt;
1454 if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_SHADOWCURSOR, sal_False, &pItem ))
1455 aOpt = *(SwShadowCursorItem*)pItem;
1456 aOnOffCB.Check( aOpt.IsOn() );
1458 sal_uInt8 eMode = aOpt.GetMode();
1459 aFillIndentRB.Check( FILL_INDENT == eMode );
1460 aFillMarginRB.Check( FILL_MARGIN == eMode );
1461 aFillTabRB.Check( FILL_TAB == eMode );
1462 aFillSpaceRB.Check( FILL_SPACE == eMode );
1464 if (m_pWrtShell) {
1465 m_aMathBaselineAlignmentCB.Check( m_pWrtShell->GetDoc()->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT ) );
1466 m_aMathBaselineAlignmentCB.SaveValue();
1467 } else {
1468 m_aMathBaselineAlignmentCB.Hide();
1471 if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_CRSR_IN_PROTECTED, sal_False, &pItem ))
1472 aCrsrInProtCB.Check(((const SfxBoolItem*)pItem)->GetValue());
1473 aCrsrInProtCB.SaveValue();
1475 const SwDocDisplayItem* pDocDisplayAttr = 0;
1477 rSet.GetItemState( FN_PARAM_DOCDISP, sal_False,
1478 (const SfxPoolItem**)&pDocDisplayAttr );
1479 if(pDocDisplayAttr)
1481 aParaCB .Check (pDocDisplayAttr->bParagraphEnd );
1482 aTabCB .Check (pDocDisplayAttr->bTab );
1483 aSpacesCB .Check (pDocDisplayAttr->bSpace );
1484 aHSpacesCB .Check (pDocDisplayAttr->bNonbreakingSpace );
1485 aSHyphCB .Check (pDocDisplayAttr->bSoftHyphen );
1486 aCharHiddenCB.Check (pDocDisplayAttr->bCharHiddenText );
1487 aFldHiddenCB .Check (pDocDisplayAttr->bFldHiddenText );
1488 aFldHiddenParaCB.Check (pDocDisplayAttr->bShowHiddenPara );
1489 aBreakCB .Check (pDocDisplayAttr->bManualBreak );
1493 /*--------------------------------------------------
1494 TabPage for Redlining
1495 --------------------------------------------------*/
1496 struct CharAttr
1498 sal_uInt16 nItemId;
1499 sal_uInt16 nAttr;
1502 // Edit corresponds to Paste-attributes
1503 static CharAttr aRedlineAttr[] =
1505 { SID_ATTR_CHAR_CASEMAP, SVX_CASEMAP_NOT_MAPPED },
1506 { SID_ATTR_CHAR_WEIGHT, WEIGHT_BOLD },
1507 { SID_ATTR_CHAR_POSTURE, ITALIC_NORMAL },
1508 { SID_ATTR_CHAR_UNDERLINE, UNDERLINE_SINGLE },
1509 { SID_ATTR_CHAR_UNDERLINE, UNDERLINE_DOUBLE },
1510 { SID_ATTR_CHAR_STRIKEOUT, STRIKEOUT_SINGLE },
1511 { SID_ATTR_CHAR_CASEMAP, SVX_CASEMAP_VERSALIEN },
1512 { SID_ATTR_CHAR_CASEMAP, SVX_CASEMAP_GEMEINE },
1513 { SID_ATTR_CHAR_CASEMAP, SVX_CASEMAP_KAPITAELCHEN },
1514 { SID_ATTR_CHAR_CASEMAP, SVX_CASEMAP_TITEL },
1515 { SID_ATTR_BRUSH, 0 }
1517 // Items from aRedlineAttr relevant for InsertAttr: strikethrough is
1518 // not used
1519 static sal_uInt16 aInsertAttrMap[] = { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10 };
1521 // Items from aRedlineAttr relevant for DeleteAttr: underline and
1522 // double underline is not used
1523 static sal_uInt16 aDeletedAttrMap[] = { 0, 1, 2, 5, 6, 7, 8, 9, 10 };
1525 // Items from aRedlineAttr relevant for ChangeAttr: strikethrough is
1526 // not used
1527 static sal_uInt16 aChangedAttrMap[] = { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10 };
1529 /*-----------------------------------------------------------------------
1530 Description: Preview of selection
1531 -----------------------------------------------------------------------*/
1532 SwMarkPreview::SwMarkPreview( Window *pParent, const ResId& rResID ) :
1534 Window(pParent, rResID),
1535 m_aTransCol( COL_TRANSPARENT ),
1536 m_aMarkCol( COL_LIGHTRED ),
1537 nMarkPos(0)
1540 InitColors();
1541 SetMapMode(MAP_PIXEL);
1543 const Size aSz(GetOutputSizePixel());
1545 // Page
1546 aPage.SetSize(Size(aSz.Width() - 3, aSz.Height() - 3));
1548 sal_uLong nOutWPix = aPage.GetWidth();
1549 sal_uLong nOutHPix = aPage.GetHeight();
1551 // PrintArea
1552 sal_uLong nLBorder = 8;
1553 sal_uLong nRBorder = 8;
1554 sal_uLong nTBorder = 4;
1555 sal_uLong nBBorder = 4;
1557 aLeftPagePrtArea = Rectangle(Point(nLBorder, nTBorder), Point((nOutWPix - 1) - nRBorder, (nOutHPix - 1) - nBBorder));
1558 sal_uInt16 nWidth = (sal_uInt16)aLeftPagePrtArea.GetWidth();
1559 sal_uInt16 nKorr = (nWidth & 1) != 0 ? 0 : 1;
1560 aLeftPagePrtArea.SetSize(Size(nWidth / 2 - (nLBorder + nRBorder) / 2 + nKorr, aLeftPagePrtArea.GetHeight()));
1562 aRightPagePrtArea = aLeftPagePrtArea;
1563 aRightPagePrtArea.Move(aLeftPagePrtArea.GetWidth() + nLBorder + nRBorder + 1, 0);
1566 SwMarkPreview::~SwMarkPreview()
1570 void SwMarkPreview::InitColors( void )
1572 // m_aTransCol and m_aMarkCol are _not_ changed because they are set from outside!
1574 const StyleSettings& rSettings = GetSettings().GetStyleSettings();
1575 m_aBgCol = Color( rSettings.GetWindowColor() );
1577 sal_Bool bHC = rSettings.GetHighContrastMode();
1578 m_aLineCol = bHC? SwViewOption::GetFontColor() : Color( COL_BLACK );
1579 m_aShadowCol = bHC? m_aBgCol : rSettings.GetShadowColor();
1580 m_aTxtCol = bHC? SwViewOption::GetFontColor() : Color( COL_GRAY );
1581 m_aPrintAreaCol = m_aTxtCol;
1584 void SwMarkPreview::DataChanged( const DataChangedEvent& rDCEvt )
1586 Window::DataChanged( rDCEvt );
1588 if( rDCEvt.GetType() == DATACHANGED_SETTINGS && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
1589 InitColors();
1592 void SwMarkPreview::Paint(const Rectangle &/*rRect*/)
1594 // draw shadow
1595 Rectangle aShadow(aPage);
1596 aShadow += Point(3, 3);
1597 DrawRect( aShadow, m_aShadowCol, m_aTransCol );
1599 // draw page
1600 DrawRect( aPage, m_aBgCol, m_aLineCol );
1602 // draw separator
1603 Rectangle aPageSeparator(aPage);
1604 aPageSeparator.SetSize(Size(2, aPageSeparator.GetHeight()));
1605 aPageSeparator.Move(aPage.GetWidth() / 2 - 1, 0);
1606 DrawRect( aPageSeparator, m_aLineCol, m_aTransCol );
1608 PaintPage(aLeftPagePrtArea);
1609 PaintPage(aRightPagePrtArea);
1611 Rectangle aLeftMark(Point(aPage.Left() + 2, aLeftPagePrtArea.Top() + 4), Size(aLeftPagePrtArea.Left() - 4, 2));
1612 Rectangle aRightMark(Point(aRightPagePrtArea.Right() + 2, aRightPagePrtArea.Bottom() - 6), Size(aLeftPagePrtArea.Left() - 4, 2));
1614 switch (nMarkPos)
1616 case 1: // left
1617 aRightMark.SetPos(Point(aRightPagePrtArea.Left() - 2 - aRightMark.GetWidth(), aRightMark.Top()));
1618 break;
1620 case 2: // right
1621 aLeftMark.SetPos(Point(aLeftPagePrtArea.Right() + 2, aLeftMark.Top()));
1622 break;
1624 case 3: // outside
1625 break;
1627 case 4: // inside
1628 aLeftMark.SetPos(Point(aLeftPagePrtArea.Right() + 2, aLeftMark.Top()));
1629 aRightMark.SetPos(Point(aRightPagePrtArea.Left() - 2 - aRightMark.GetWidth(), aRightMark.Top()));
1630 break;
1632 case 0: // none
1633 default:
1634 return;
1636 DrawRect( aLeftMark, m_aMarkCol, m_aTransCol );
1637 DrawRect( aRightMark, m_aMarkCol, m_aTransCol );
1640 void SwMarkPreview::PaintPage(const Rectangle &rRect)
1642 // draw PrintArea
1643 DrawRect(rRect, m_aTransCol, m_aPrintAreaCol );
1645 // draw Testparagraph
1646 sal_uLong nLTxtBorder = 4;
1647 sal_uLong nRTxtBorder = 4;
1648 sal_uLong nTTxtBorder = 4;
1650 Rectangle aTextLine = rRect;
1651 aTextLine.SetSize(Size(aTextLine.GetWidth(), 2));
1652 aTextLine.Left() += nLTxtBorder;
1653 aTextLine.Right() -= nRTxtBorder;
1654 aTextLine.Move(0, nTTxtBorder);
1656 sal_Int32 nStep;
1657 sal_uInt16 nLines;
1659 nStep = aTextLine.GetHeight() + 2;
1660 nLines = (sal_uInt16)(rRect.GetHeight() / (aTextLine.GetHeight() + 2)) - 1;
1662 // simulate text
1663 for (sal_uInt16 i = 0; i < nLines; ++i)
1665 if (i == (nLines - 1))
1666 aTextLine.SetSize(Size(aTextLine.GetWidth() / 2, aTextLine.GetHeight()));
1668 if (aPage.IsInside(aTextLine))
1669 DrawRect(aTextLine, m_aTxtCol, m_aTransCol );
1671 aTextLine.Move(0, nStep);
1673 aTextLine.Move(0, -nStep);
1676 void SwMarkPreview::DrawRect(const Rectangle &rRect, const Color &rFillColor, const Color &rLineColor)
1678 SetFillColor(rFillColor);
1679 SetLineColor(rLineColor);
1680 Window::DrawRect(rRect);
1683 namespace
1685 void lcl_FillRedlineAttrListBox(
1686 ListBox& rLB, const AuthorCharAttr& rAttrToSelect,
1687 const sal_uInt16* pAttrMap, const sal_uInt16 nAttrMapSize)
1689 for (sal_uInt16 i = 0; i != nAttrMapSize; ++i)
1691 CharAttr& rAttr(aRedlineAttr[pAttrMap[i]]);
1692 rLB.SetEntryData(i, &rAttr);
1693 if (rAttr.nItemId == rAttrToSelect.nItemId &&
1694 rAttr.nAttr == rAttrToSelect.nAttr)
1695 rLB.SelectEntryPos(i);
1700 SwRedlineOptionsTabPage::SwRedlineOptionsTabPage( Window* pParent,
1701 const SfxItemSet& rSet )
1702 : SfxTabPage(pParent, SW_RES(TP_REDLINE_OPT), rSet),
1704 aInsertFL( this, SW_RES( FL_TE )),
1706 aInsertFT( this, SW_RES( FT_CHG_INSERT )),
1707 aInsertAttrFT( this, SW_RES( FT_INS_ATTR )),
1708 aInsertLB( this, SW_RES( LB_INS_ATTR )),
1709 aInsertColorFT( this, SW_RES( FT_INS_COL )),
1710 aInsertColorLB( this, SW_RES( LB_INS_COL )),
1711 aInsertedPreviewWN( this, SW_RES( WIN_INS )),
1713 aDeletedFT( this, SW_RES( FT_CHG_DELETE )),
1714 aDeletedAttrFT( this, SW_RES( FT_DEL_ATTR )),
1715 aDeletedLB( this, SW_RES( LB_DEL_ATTR )),
1716 aDeletedColorFT( this, SW_RES( FT_DEL_COL )),
1717 aDeletedColorLB( this, SW_RES( LB_DEL_COL )),
1718 aDeletedPreviewWN( this, SW_RES( WIN_DEL )),
1720 aChangedFT( this, SW_RES( FT_CHG_CHANGE )),
1721 aChangedAttrFT( this, SW_RES( FT_CHG_ATTR )),
1722 aChangedLB( this, SW_RES( LB_CHG_ATTR )),
1723 aChangedColorFT( this, SW_RES( FT_CHG_COL )),
1724 aChangedColorLB( this, SW_RES( LB_CHG_COL )),
1725 aChangedPreviewWN( this, SW_RES( WIN_CHG )),
1727 aChangedFL ( this, SW_RES( FL_LC )),
1729 aMarkPosFT ( this, SW_RES( FT_MARKPOS )),
1730 aMarkPosLB ( this, SW_RES( LB_MARKPOS )),
1731 aMarkColorFT ( this, SW_RES( FT_LC_COL )),
1732 aMarkColorLB ( this, SW_RES( LB_LC_COL )),
1733 aMarkPreviewWN ( this, SW_RES( WIN_MARK )),
1735 sAuthor ( SW_RES( STR_AUTHOR )),
1736 sNone ( SW_RES( STR_NOTHING ))
1739 FreeResource();
1741 for(sal_uInt16 i = 0; i < aInsertLB.GetEntryCount(); i++)
1743 String sEntry(aInsertLB.GetEntry(i));
1744 aDeletedLB.InsertEntry(sEntry);
1745 aChangedLB.InsertEntry(sEntry);
1748 // remove strikethrough from insert and change and underline + double
1749 // underline from delete
1750 aInsertLB.RemoveEntry(5);
1751 aChangedLB.RemoveEntry(5);
1752 aDeletedLB.RemoveEntry(4);
1753 aDeletedLB.RemoveEntry(3);
1755 Link aLk = LINK(this, SwRedlineOptionsTabPage, AttribHdl);
1756 aInsertLB.SetSelectHdl( aLk );
1757 aDeletedLB.SetSelectHdl( aLk );
1758 aChangedLB.SetSelectHdl( aLk );
1760 aLk = LINK(this, SwRedlineOptionsTabPage, ColorHdl);
1761 aInsertColorLB.SetSelectHdl( aLk );
1762 aDeletedColorLB.SetSelectHdl( aLk );
1763 aChangedColorLB.SetSelectHdl( aLk );
1765 aLk = LINK(this, SwRedlineOptionsTabPage, ChangedMaskPrevHdl);
1766 aMarkPosLB.SetSelectHdl( aLk );
1767 aMarkColorLB.SetSelectHdl( aLk );
1769 //solution: set different accessible name of four color box
1770 aInsertColorLB.SetAccessibleName(OUString( aInsertFT.GetDisplayText()) + OUString(aInsertColorFT.GetDisplayText()));
1771 aDeletedColorLB.SetAccessibleName(OUString( aDeletedFT.GetDisplayText()) + OUString( aDeletedColorFT.GetDisplayText()));
1772 aChangedColorLB.SetAccessibleName(OUString( aChangedFT.GetDisplayText()) + OUString( aChangedColorFT.GetDisplayText()));
1773 aMarkColorLB.SetAccessibleName(OUString( aMarkPosFT.GetDisplayText()) + OUString( aMarkColorFT.GetDisplayText()));
1776 SwRedlineOptionsTabPage::~SwRedlineOptionsTabPage()
1780 SfxTabPage* SwRedlineOptionsTabPage::Create( Window* pParent, const SfxItemSet& rSet)
1782 return new SwRedlineOptionsTabPage( pParent, rSet );
1785 sal_Bool SwRedlineOptionsTabPage::FillItemSet( SfxItemSet& )
1787 CharAttr *pAttr;
1788 SwModuleOptions *pOpt = SW_MOD()->GetModuleConfig();
1790 AuthorCharAttr aInsertedAttr;
1791 AuthorCharAttr aDeletedAttr;
1792 AuthorCharAttr aChangedAttr;
1794 AuthorCharAttr aOldInsertAttr(pOpt->GetInsertAuthorAttr());
1795 AuthorCharAttr aOldDeletedAttr(pOpt->GetDeletedAuthorAttr());
1796 AuthorCharAttr aOldChangedAttr(pOpt->GetFormatAuthorAttr());
1798 ColorData nOldMarkColor = pOpt->GetMarkAlignColor().GetColor();
1799 sal_uInt16 nOldMarkMode = pOpt->GetMarkAlignMode();
1801 sal_uInt16 nPos = aInsertLB.GetSelectEntryPos();
1802 if (nPos != LISTBOX_ENTRY_NOTFOUND)
1804 pAttr = (CharAttr *)aInsertLB.GetEntryData(nPos);
1805 aInsertedAttr.nItemId = pAttr->nItemId;
1806 aInsertedAttr.nAttr = pAttr->nAttr;
1808 nPos = aInsertColorLB.GetSelectEntryPos();
1810 switch (nPos)
1812 case 0:
1813 aInsertedAttr.nColor = COL_NONE;
1814 break;
1815 case 1:
1816 case LISTBOX_ENTRY_NOTFOUND:
1817 aInsertedAttr.nColor = COL_TRANSPARENT;
1818 break;
1819 default:
1820 aInsertedAttr.nColor = aInsertColorLB.GetEntryColor(nPos).GetColor();
1821 break;
1824 pOpt->SetInsertAuthorAttr(aInsertedAttr);
1827 nPos = aDeletedLB.GetSelectEntryPos();
1828 if (nPos != LISTBOX_ENTRY_NOTFOUND)
1830 pAttr = (CharAttr *)aDeletedLB.GetEntryData(nPos);
1831 aDeletedAttr.nItemId = pAttr->nItemId;
1832 aDeletedAttr.nAttr = pAttr->nAttr;
1834 nPos = aDeletedColorLB.GetSelectEntryPos();
1836 switch (nPos)
1838 case 0:
1839 aDeletedAttr.nColor = COL_NONE;
1840 break;
1841 case 1:
1842 case LISTBOX_ENTRY_NOTFOUND:
1843 aDeletedAttr.nColor = COL_TRANSPARENT;
1844 break;
1845 default:
1846 aDeletedAttr.nColor = aDeletedColorLB.GetEntryColor(nPos).GetColor();
1847 break;
1850 pOpt->SetDeletedAuthorAttr(aDeletedAttr);
1853 nPos = aChangedLB.GetSelectEntryPos();
1854 if (nPos != LISTBOX_ENTRY_NOTFOUND)
1856 pAttr = (CharAttr *)aChangedLB.GetEntryData(nPos);
1857 aChangedAttr.nItemId = pAttr->nItemId;
1858 aChangedAttr.nAttr = pAttr->nAttr;
1860 nPos = aChangedColorLB.GetSelectEntryPos();
1862 switch (nPos)
1864 case 0:
1865 aChangedAttr.nColor = COL_NONE;
1866 break;
1867 case 1:
1868 case LISTBOX_ENTRY_NOTFOUND:
1869 aChangedAttr.nColor = COL_TRANSPARENT;
1870 break;
1871 default:
1872 aChangedAttr.nColor = aChangedColorLB.GetEntryColor(nPos).GetColor();
1873 break;
1876 pOpt->SetFormatAuthorAttr(aChangedAttr);
1879 nPos = 0;
1880 switch (aMarkPosLB.GetSelectEntryPos())
1882 case 0: nPos = text::HoriOrientation::NONE; break;
1883 case 1: nPos = text::HoriOrientation::LEFT; break;
1884 case 2: nPos = text::HoriOrientation::RIGHT; break;
1885 case 3: nPos = text::HoriOrientation::OUTSIDE; break;
1886 case 4: nPos = text::HoriOrientation::INSIDE; break;
1888 pOpt->SetMarkAlignMode(nPos);
1890 pOpt->SetMarkAlignColor(aMarkColorLB.GetSelectEntryColor());
1892 if (!(aInsertedAttr == aOldInsertAttr) ||
1893 !(aDeletedAttr == aOldDeletedAttr) ||
1894 !(aChangedAttr == aOldChangedAttr) ||
1895 nOldMarkColor != pOpt->GetMarkAlignColor().GetColor() ||
1896 nOldMarkMode != pOpt->GetMarkAlignMode())
1898 // update all documents
1899 TypeId aType(TYPE(SwDocShell));
1900 SwDocShell* pDocShell = (SwDocShell*)SfxObjectShell::GetFirst(&aType);
1902 while( pDocShell )
1904 pDocShell->GetWrtShell()->UpdateRedlineAttr();
1905 pDocShell = (SwDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
1909 return sal_False;
1912 void SwRedlineOptionsTabPage::Reset( const SfxItemSet& )
1914 const SwModuleOptions *pOpt = SW_MOD()->GetModuleConfig();
1916 const AuthorCharAttr &rInsertAttr = pOpt->GetInsertAuthorAttr();
1917 const AuthorCharAttr &rDeletedAttr = pOpt->GetDeletedAuthorAttr();
1918 const AuthorCharAttr &rChangedAttr = pOpt->GetFormatAuthorAttr();
1920 // initialise preview
1921 InitFontStyle(aInsertedPreviewWN);
1922 InitFontStyle(aDeletedPreviewWN);
1923 InitFontStyle(aChangedPreviewWN);
1925 // initialise colour list box
1926 aInsertColorLB.SetUpdateMode(sal_False);
1927 aDeletedColorLB.SetUpdateMode(sal_False);
1928 aChangedColorLB.SetUpdateMode(sal_False);
1929 aMarkColorLB.SetUpdateMode(sal_False);
1931 aInsertColorLB.InsertEntry(sNone);
1932 aDeletedColorLB.InsertEntry(sNone);
1933 aChangedColorLB.InsertEntry(sNone);
1935 aInsertColorLB.InsertEntry(sAuthor);
1936 aDeletedColorLB.InsertEntry(sAuthor);
1937 aChangedColorLB.InsertEntry(sAuthor);
1939 XColorListRef pColorLst = XColorList::GetStdColorList();
1940 sal_uInt16 i;
1941 for( i = 0; i < pColorLst->Count(); ++i )
1943 XColorEntry* pEntry = pColorLst->GetColor( i );
1944 Color aColor = pEntry->GetColor();
1945 String sName = pEntry->GetName();
1947 aInsertColorLB.InsertEntry( aColor, sName );
1948 aDeletedColorLB.InsertEntry( aColor, sName );
1949 aChangedColorLB.InsertEntry( aColor, sName );
1950 aMarkColorLB.InsertEntry( aColor, sName );
1952 aInsertColorLB.SetUpdateMode( sal_True );
1953 aDeletedColorLB.SetUpdateMode( sal_True );
1954 aChangedColorLB.SetUpdateMode( sal_True );
1955 aMarkColorLB.SetUpdateMode( sal_True );
1957 ColorData nColor = rInsertAttr.nColor;
1959 switch (nColor)
1961 case COL_TRANSPARENT:
1962 aInsertColorLB.SelectEntryPos(1);
1963 break;
1964 case COL_NONE:
1965 aInsertColorLB.SelectEntryPos(0);
1966 break;
1967 default:
1968 aInsertColorLB.SelectEntry(Color(nColor));
1971 nColor = rDeletedAttr.nColor;
1973 switch (nColor)
1975 case COL_TRANSPARENT:
1976 aDeletedColorLB.SelectEntryPos(1);
1977 break;
1978 case COL_NONE:
1979 aDeletedColorLB.SelectEntryPos(0);
1980 break;
1981 default:
1982 aDeletedColorLB.SelectEntry(Color(nColor));
1985 nColor = rChangedAttr.nColor;
1987 switch (nColor)
1989 case COL_TRANSPARENT:
1990 aChangedColorLB.SelectEntryPos(1);
1991 break;
1992 case COL_NONE:
1993 aChangedColorLB.SelectEntryPos(0);
1994 break;
1995 default:
1996 aChangedColorLB.SelectEntry(Color(nColor));
1999 aMarkColorLB.SelectEntry(pOpt->GetMarkAlignColor());
2001 aInsertLB.SelectEntryPos(0);
2002 aDeletedLB.SelectEntryPos(0);
2003 aChangedLB.SelectEntryPos(0);
2005 lcl_FillRedlineAttrListBox(aInsertLB, rInsertAttr, aInsertAttrMap,
2006 sizeof(aInsertAttrMap) / sizeof(sal_uInt16));
2007 lcl_FillRedlineAttrListBox(aDeletedLB, rDeletedAttr, aDeletedAttrMap,
2008 sizeof(aDeletedAttrMap) / sizeof(sal_uInt16));
2009 lcl_FillRedlineAttrListBox(aChangedLB, rChangedAttr, aChangedAttrMap,
2010 sizeof(aChangedAttrMap) / sizeof(sal_uInt16));
2012 sal_uInt16 nPos = 0;
2013 switch (pOpt->GetMarkAlignMode())
2015 case text::HoriOrientation::NONE: nPos = 0; break;
2016 case text::HoriOrientation::LEFT: nPos = 1; break;
2017 case text::HoriOrientation::RIGHT: nPos = 2; break;
2018 case text::HoriOrientation::OUTSIDE: nPos = 3; break;
2019 case text::HoriOrientation::INSIDE: nPos = 4; break;
2021 aMarkPosLB.SelectEntryPos(nPos);
2023 // show settings in preview
2024 AttribHdl(&aInsertLB);
2025 ColorHdl(&aInsertColorLB);
2026 AttribHdl(&aDeletedLB);
2027 ColorHdl(&aInsertColorLB);
2028 AttribHdl(&aChangedLB);
2029 ColorHdl(&aChangedColorLB);
2031 ChangedMaskPrevHdl();
2034 IMPL_LINK( SwRedlineOptionsTabPage, AttribHdl, ListBox *, pLB )
2036 SvxFontPrevWindow *pPrev = 0;
2037 ColorListBox *pColorLB;
2039 if (pLB == &aInsertLB)
2041 pColorLB = &aInsertColorLB;
2042 pPrev = &aInsertedPreviewWN;
2044 else if (pLB == &aDeletedLB)
2046 pColorLB = &aDeletedColorLB;
2047 pPrev = &aDeletedPreviewWN;
2049 else
2051 pColorLB = &aChangedColorLB;
2052 pPrev = &aChangedPreviewWN;
2055 SvxFont& rFont = pPrev->GetFont();
2056 SvxFont& rCJKFont = pPrev->GetCJKFont();
2058 rFont.SetWeight(WEIGHT_NORMAL);
2059 rCJKFont.SetWeight(WEIGHT_NORMAL);
2060 rFont.SetItalic(ITALIC_NONE);
2061 rCJKFont.SetItalic(ITALIC_NONE);
2062 rFont.SetUnderline(UNDERLINE_NONE);
2063 rCJKFont.SetUnderline(UNDERLINE_NONE);
2064 rFont.SetStrikeout(STRIKEOUT_NONE);
2065 rCJKFont.SetStrikeout(STRIKEOUT_NONE);
2066 rFont.SetCaseMap(SVX_CASEMAP_NOT_MAPPED);
2067 rCJKFont.SetCaseMap(SVX_CASEMAP_NOT_MAPPED);
2069 sal_uInt16 nPos = pColorLB->GetSelectEntryPos();
2071 switch( nPos )
2073 case 0:
2074 rFont.SetColor( Color( COL_BLACK ) );
2075 rCJKFont.SetColor( Color( COL_BLACK ) );
2076 break;
2077 case 1:
2078 case LISTBOX_ENTRY_NOTFOUND:
2079 rFont.SetColor( Color( COL_RED ) );
2080 rCJKFont.SetColor( Color( COL_RED ) );
2081 break;
2082 default:
2083 rFont.SetColor( pColorLB->GetEntryColor( nPos ) );
2084 rCJKFont.SetColor( pColorLB->GetEntryColor( nPos ) );
2085 break;
2088 nPos = pLB->GetSelectEntryPos();
2089 if( nPos == LISTBOX_ENTRY_NOTFOUND )
2090 nPos = 0;
2092 CharAttr* pAttr = ( CharAttr* ) pLB->GetEntryData( nPos );
2093 //switch off preview background color
2094 pPrev->ResetColor();
2095 switch (pAttr->nItemId)
2097 case SID_ATTR_CHAR_WEIGHT:
2098 rFont.SetWeight( ( FontWeight ) pAttr->nAttr );
2099 rCJKFont.SetWeight( ( FontWeight ) pAttr->nAttr );
2100 break;
2102 case SID_ATTR_CHAR_POSTURE:
2103 rFont.SetItalic( ( FontItalic ) pAttr->nAttr );
2104 rCJKFont.SetItalic( ( FontItalic ) pAttr->nAttr );
2105 break;
2107 case SID_ATTR_CHAR_UNDERLINE:
2108 rFont.SetUnderline( ( FontUnderline ) pAttr->nAttr );
2109 rCJKFont.SetUnderline( ( FontUnderline ) pAttr->nAttr );
2110 break;
2112 case SID_ATTR_CHAR_STRIKEOUT:
2113 rFont.SetStrikeout( ( FontStrikeout ) pAttr->nAttr );
2114 rCJKFont.SetStrikeout( ( FontStrikeout ) pAttr->nAttr );
2115 break;
2117 case SID_ATTR_CHAR_CASEMAP:
2118 rFont.SetCaseMap( ( SvxCaseMap ) pAttr->nAttr );
2119 rCJKFont.SetCaseMap( ( SvxCaseMap ) pAttr->nAttr );
2120 break;
2122 case SID_ATTR_BRUSH:
2124 nPos = pColorLB->GetSelectEntryPos();
2125 if( nPos )
2126 pPrev->SetColor( pColorLB->GetSelectEntryColor() );
2127 else
2128 pPrev->SetColor( Color( COL_LIGHTGRAY ) );
2130 rFont.SetColor( Color( COL_BLACK ) );
2131 rCJKFont.SetColor( Color( COL_BLACK ) );
2133 break;
2136 pPrev->Invalidate();
2138 return 0;
2141 IMPL_LINK( SwRedlineOptionsTabPage, ColorHdl, ColorListBox *, pColorLB )
2143 SvxFontPrevWindow *pPrev = 0;
2144 ListBox* pLB;
2146 if (pColorLB == &aInsertColorLB)
2148 pLB = &aInsertLB;
2149 pPrev = &aInsertedPreviewWN;
2151 else if (pColorLB == &aDeletedColorLB)
2153 pLB = &aDeletedLB;
2154 pPrev = &aDeletedPreviewWN;
2156 else
2158 pLB = &aChangedLB;
2159 pPrev = &aChangedPreviewWN;
2162 SvxFont& rFont = pPrev->GetFont();
2163 SvxFont& rCJKFont = pPrev->GetCJKFont();
2164 sal_uInt16 nPos = pLB->GetSelectEntryPos();
2165 if( nPos == LISTBOX_ENTRY_NOTFOUND )
2166 nPos = 0;
2168 CharAttr* pAttr = ( CharAttr* ) pLB->GetEntryData( nPos );
2170 if( pAttr->nItemId == SID_ATTR_BRUSH )
2172 rFont.SetColor( Color( COL_BLACK ) );
2173 rCJKFont.SetColor( Color( COL_BLACK ) );
2174 nPos = pColorLB->GetSelectEntryPos();
2175 if( nPos && nPos != LISTBOX_ENTRY_NOTFOUND )
2176 pPrev->SetColor( pColorLB->GetSelectEntryColor() );
2177 else
2178 pPrev->SetColor( Color( COL_LIGHTGRAY ) );
2180 else
2182 nPos = pColorLB->GetSelectEntryPos();
2184 switch( nPos )
2186 case 0:
2187 rFont.SetColor( Color( COL_BLACK ) );
2188 rCJKFont.SetColor( Color( COL_BLACK ) );
2189 break;
2190 case 1:
2191 case LISTBOX_ENTRY_NOTFOUND:
2192 rFont.SetColor( Color( COL_RED ) );
2193 rCJKFont.SetColor( Color( COL_RED ) );
2194 break;
2195 default:
2196 rFont.SetColor( pColorLB->GetEntryColor( nPos ) );
2197 rCJKFont.SetColor( pColorLB->GetEntryColor( nPos ) );
2198 break;
2202 pPrev->Invalidate();
2204 return 0;
2207 IMPL_LINK_NOARG(SwRedlineOptionsTabPage, ChangedMaskPrevHdl)
2209 aMarkPreviewWN.SetMarkPos(aMarkPosLB.GetSelectEntryPos());
2210 aMarkPreviewWN.SetColor(aMarkColorLB.GetSelectEntryColor().GetColor());
2212 aMarkPreviewWN.Invalidate();
2214 return 0;
2217 void SwRedlineOptionsTabPage::InitFontStyle(SvxFontPrevWindow& rExampleWin)
2219 const AllSettings& rAllSettings = Application::GetSettings();
2220 LanguageType eLangType = rAllSettings.GetUILanguageTag().getLanguageType();
2221 Color aBackCol( rAllSettings.GetStyleSettings().GetWindowColor() );
2222 SvxFont& rFont = rExampleWin.GetFont();
2223 SvxFont& rCJKFont = rExampleWin.GetCJKFont();
2224 SvxFont& rCTLFont = rExampleWin.GetCTLFont();
2226 Font aFont( OutputDevice::GetDefaultFont( DEFAULTFONT_SERIF, eLangType,
2227 DEFAULTFONT_FLAGS_ONLYONE, &rExampleWin ) );
2228 Font aCJKFont( OutputDevice::GetDefaultFont( DEFAULTFONT_CJK_TEXT, eLangType,
2229 DEFAULTFONT_FLAGS_ONLYONE, &rExampleWin ) );
2230 Font aCTLFont( OutputDevice::GetDefaultFont( DEFAULTFONT_CTL_TEXT, eLangType,
2231 DEFAULTFONT_FLAGS_ONLYONE, &rExampleWin ) );
2232 const Size aDefSize( 0, 12 );
2233 aFont.SetSize( aDefSize );
2234 aCJKFont.SetSize( aDefSize );
2235 aCTLFont.SetSize( aDefSize );
2237 aFont.SetFillColor( aBackCol );
2238 aCJKFont.SetFillColor( aBackCol );
2239 aCTLFont.SetFillColor( aBackCol );
2241 aFont.SetWeight( WEIGHT_NORMAL );
2242 aCJKFont.SetWeight( WEIGHT_NORMAL );
2243 aCTLFont.SetWeight( WEIGHT_NORMAL );
2245 rFont = aFont;
2246 rCJKFont = aCJKFont;
2247 rCTLFont = aCTLFont;
2249 const Size aNewSize( 0, rExampleWin.GetOutputSize().Height() * 2 / 3 );
2250 rFont.SetSize( aNewSize );
2251 rCJKFont.SetSize( aNewSize );
2253 rExampleWin.SetFont( rFont, rCJKFont,rCTLFont );
2255 rExampleWin.UseResourceText();
2257 Wallpaper aWall( aBackCol );
2258 rExampleWin.SetBackground( aWall );
2259 rExampleWin.Invalidate();
2263 //----------------------------------------------------------
2264 SwCompareOptionsTabPage::SwCompareOptionsTabPage( Window* pParent, const SfxItemSet& rSet )
2265 : SfxTabPage( pParent,"OptComparison","modules/swriter/ui/optcomparison.ui", rSet )
2267 get(m_pAutoRB,"auto");
2268 get(m_pWordRB, "byword");
2269 get(m_pCharRB, "bycharacter");
2271 get(m_pRsidCB, "useRSID");
2272 get(m_pIgnoreCB, "ignore");
2273 get(m_pLenNF, "ignorelen");
2275 Link aLnk( LINK( this, SwCompareOptionsTabPage, ComparisonHdl ) );
2276 m_pAutoRB->SetClickHdl( aLnk );
2277 m_pWordRB->SetClickHdl( aLnk );
2278 m_pCharRB->SetClickHdl( aLnk );
2280 m_pIgnoreCB->SetClickHdl( LINK( this, SwCompareOptionsTabPage, IgnoreHdl) );
2283 SwCompareOptionsTabPage::~SwCompareOptionsTabPage()
2287 SfxTabPage* SwCompareOptionsTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
2289 return new SwCompareOptionsTabPage( pParent, rAttrSet );
2292 sal_Bool SwCompareOptionsTabPage::FillItemSet( SfxItemSet& )
2294 sal_Bool bRet = sal_False;
2295 SwModuleOptions *pOpt = SW_MOD()->GetModuleConfig();
2297 if( m_pAutoRB->IsChecked() != m_pAutoRB->GetSavedValue() ||
2298 m_pWordRB->IsChecked() != m_pWordRB->GetSavedValue() ||
2299 m_pCharRB->IsChecked() != m_pCharRB->GetSavedValue() )
2301 SvxCompareMode eCmpMode = SVX_CMP_AUTO;
2303 if ( m_pAutoRB->IsChecked() ) eCmpMode = SVX_CMP_AUTO;
2304 if ( m_pWordRB->IsChecked() ) eCmpMode = SVX_CMP_BY_WORD;
2305 if ( m_pCharRB->IsChecked() ) eCmpMode = SVX_CMP_BY_CHAR;
2307 pOpt->SetCompareMode( eCmpMode );
2308 bRet = sal_True;
2311 if( m_pRsidCB->IsChecked() != m_pRsidCB->GetSavedValue() )
2313 pOpt->SetUseRsid( m_pRsidCB->IsChecked() );
2314 bRet = sal_True;
2317 if( m_pIgnoreCB->IsChecked() != m_pIgnoreCB->GetSavedValue() )
2319 pOpt->SetIgnorePieces( m_pIgnoreCB->IsChecked() );
2320 bRet = sal_True;
2323 if( m_pLenNF->IsModified() )
2325 pOpt->SetPieceLen( m_pLenNF->GetValue() );
2326 bRet = sal_True;
2329 return bRet;
2332 void SwCompareOptionsTabPage::Reset( const SfxItemSet& )
2334 SwModuleOptions *pOpt = SW_MOD()->GetModuleConfig();
2336 SvxCompareMode eCmpMode = pOpt->GetCompareMode();
2337 if( eCmpMode == SVX_CMP_AUTO )
2339 m_pAutoRB->Check();
2340 m_pRsidCB->Disable();
2341 m_pIgnoreCB->Disable();
2342 m_pLenNF->Disable();
2344 else if( eCmpMode == SVX_CMP_BY_WORD )
2346 m_pWordRB->Check();
2347 m_pRsidCB->Enable();
2348 m_pIgnoreCB->Enable();
2349 m_pLenNF->Enable();
2351 else if( eCmpMode == SVX_CMP_BY_CHAR)
2353 m_pCharRB->Check();
2354 m_pRsidCB->Enable();
2355 m_pIgnoreCB->Enable();
2356 m_pLenNF->Enable();
2358 m_pAutoRB->SaveValue();
2359 m_pWordRB->SaveValue();
2360 m_pCharRB->SaveValue();
2362 m_pRsidCB->Check( pOpt->IsUseRsid() );
2363 m_pRsidCB->SaveValue();
2365 m_pIgnoreCB->Check( pOpt->IsIgnorePieces() );
2366 m_pIgnoreCB->SaveValue();
2368 m_pLenNF->Enable( m_pIgnoreCB->IsChecked() && eCmpMode );
2370 m_pLenNF->SetValue( pOpt->GetPieceLen() );
2371 m_pLenNF->SaveValue();
2374 IMPL_LINK_NOARG(SwCompareOptionsTabPage, ComparisonHdl)
2376 bool bChecked = !m_pAutoRB->IsChecked();
2377 m_pRsidCB->Enable( bChecked );
2378 m_pIgnoreCB->Enable( bChecked );
2379 m_pLenNF->Enable( bChecked && m_pIgnoreCB->IsChecked() );
2381 return 0;
2384 IMPL_LINK_NOARG(SwCompareOptionsTabPage, IgnoreHdl)
2386 m_pLenNF->Enable( m_pIgnoreCB->IsChecked() );
2387 return 0;
2390 #ifdef DBG_UTIL
2392 SwTestTabPage::SwTestTabPage(Window* pParent, const SfxItemSet& rCoreSet)
2393 : SfxTabPage( pParent, "OptTestPage", "modules/swriter/ui/opttestpage.ui", rCoreSet)
2394 , bAttrModified( sal_False )
2396 get(m_pTest1CBox, "unused");
2397 get(m_pTest2CBox, "dynamic");
2398 get(m_pTest3CBox, "nocalm");
2399 get(m_pTest4CBox, "wysiwygdbg");
2400 get(m_pTest5CBox, "noidle");
2401 get(m_pTest6CBox, "noscreenadj");
2402 get(m_pTest7CBox, "winformat");
2403 get(m_pTest8CBox, "noscroll");
2404 get(m_pTest9CBox, "DrawingLayerNotLoading");
2405 get(m_pTest10CBox, "AutoFormatByInput");
2407 Init();
2411 SfxTabPage* SwTestTabPage::Create( Window* pParent,
2412 const SfxItemSet& rAttrSet )
2414 return new SwTestTabPage(pParent, rAttrSet);
2417 sal_Bool SwTestTabPage::FillItemSet( SfxItemSet& rCoreSet )
2420 if ( bAttrModified )
2422 SwTestItem aTestItem(FN_PARAM_SWTEST);
2423 aTestItem.bTest1=m_pTest1CBox->IsChecked();
2424 aTestItem.bTest2=m_pTest2CBox->IsChecked();
2425 aTestItem.bTest3=m_pTest3CBox->IsChecked();
2426 aTestItem.bTest4=m_pTest4CBox->IsChecked();
2427 aTestItem.bTest5=m_pTest5CBox->IsChecked();
2428 aTestItem.bTest6=m_pTest6CBox->IsChecked();
2429 aTestItem.bTest7=m_pTest7CBox->IsChecked();
2430 aTestItem.bTest8=m_pTest8CBox->IsChecked();
2431 aTestItem.bTest9=m_pTest9CBox->IsChecked();
2432 aTestItem.bTest10=m_pTest10CBox->IsChecked();
2433 rCoreSet.Put(aTestItem);
2435 return bAttrModified;
2438 void SwTestTabPage::Reset( const SfxItemSet& )
2440 const SfxItemSet& rSet = GetItemSet();
2441 const SwTestItem* pTestAttr = 0;
2443 if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_SWTEST , sal_False,
2444 (const SfxPoolItem**)&pTestAttr ))
2446 m_pTest1CBox->Check(pTestAttr->bTest1);
2447 m_pTest2CBox->Check(pTestAttr->bTest2);
2448 m_pTest3CBox->Check(pTestAttr->bTest3);
2449 m_pTest4CBox->Check(pTestAttr->bTest4);
2450 m_pTest5CBox->Check(pTestAttr->bTest5);
2451 m_pTest6CBox->Check(pTestAttr->bTest6);
2452 m_pTest7CBox->Check(pTestAttr->bTest7);
2453 m_pTest8CBox->Check(pTestAttr->bTest8);
2454 m_pTest9CBox->Check(pTestAttr->bTest9);
2455 m_pTest10CBox->Check(pTestAttr->bTest10);
2459 void SwTestTabPage::Init()
2461 // handler
2462 Link aLk = LINK( this, SwTestTabPage, AutoClickHdl );
2463 m_pTest1CBox->SetClickHdl( aLk );
2464 m_pTest2CBox->SetClickHdl( aLk );
2465 m_pTest3CBox->SetClickHdl( aLk );
2466 m_pTest4CBox->SetClickHdl( aLk );
2467 m_pTest5CBox->SetClickHdl( aLk );
2468 m_pTest6CBox->SetClickHdl( aLk );
2469 m_pTest7CBox->SetClickHdl( aLk );
2470 m_pTest8CBox->SetClickHdl( aLk );
2471 m_pTest9CBox->SetClickHdl( aLk );
2472 m_pTest10CBox->SetClickHdl( aLk );
2475 IMPL_LINK_NOARG_INLINE_START(SwTestTabPage, AutoClickHdl)
2477 bAttrModified = sal_True;
2478 return 0;
2480 IMPL_LINK_NOARG_INLINE_END(SwTestTabPage, AutoClickHdl)
2483 #endif
2487 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */