merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / misc / pggrid.cxx
blob8b5e7ec7860975abcb35853f67b9e923543dbc9c
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: pggrid.cxx,v $
10 * $Revision: 1.19 $
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"
34 #ifdef SW_DLLIMPLEMENTATION
35 #undef SW_DLLIMPLEMENTATION
36 #endif
40 #include <sfx2/app.hxx>
42 #ifndef _CMDID_H
43 #include <cmdid.h>
44 #endif
45 #include <hintids.hxx>
46 #include <swtypes.hxx>
47 #ifndef _GLOBALS_HRC
48 #include <globals.hrc>
49 #endif
50 #include <svx/xtable.hxx>
51 #include <uitool.hxx>
52 #include <svx/sizeitem.hxx>
53 #include <svx/lrspitem.hxx>
54 #include <svx/ulspitem.hxx>
55 #include <svx/boxitem.hxx>
56 #include <svx/frmdiritem.hxx>
57 #include <svx/ruler.hxx>
58 #include <pggrid.hxx>
59 #include <tgrditem.hxx>
60 #include <pggrid.hrc>
62 #include "wrtsh.hxx"
63 #include "doc.hxx"
64 #include "uiitems.hxx"
65 #include "swmodule.hxx"
66 #include "view.hxx"
67 /*-- 06.02.2002 15:25:39---------------------------------------------------
69 -----------------------------------------------------------------------*/
70 SwTextGridPage::SwTextGridPage(Window *pParent, const SfxItemSet &rSet) :
71 SfxTabPage(pParent, SW_RES(TP_TEXTGRID_PAGE), rSet),
72 aGridTypeFL (this, SW_RES(FL_GRID_TYPE )),
73 aNoGridRB (this, SW_RES(RB_NOGRID )),
74 aLinesGridRB (this, SW_RES(RB_LINESGRID )),
75 aCharsGridRB (this, SW_RES(RB_CHARSGRID )),
76 aSnapToCharsCB (this, SW_RES(CB_SNAPTOCHARS )),
77 aExampleWN (this, SW_RES(WN_EXAMPLE )),
78 aLayoutFL (this, SW_RES(FL_LAYOUT )),
79 aLinesPerPageFT (this, SW_RES(FT_LINESPERPAGE )),
80 aLinesPerPageNF (this, SW_RES(NF_LINESPERPAGE )),
81 aLinesRangeFT (this, SW_RES(FT_LINERANGE )),
82 aTextSizeFT (this, SW_RES(FT_TEXTSIZE )),
83 aTextSizeMF (this, SW_RES(MF_TEXTSIZE )),
84 aCharsPerLineFT (this, SW_RES(FT_CHARSPERLINE )),
85 aCharsPerLineNF (this, SW_RES(NF_CHARSPERLINE )),
86 aCharsRangeFT (this, SW_RES(FT_CHARRANGE )),
87 aCharWidthFT (this, SW_RES(FT_CHARWIDTH )),
88 aCharWidthMF (this, SW_RES(MF_CHARWIDTH )),
89 aRubySizeFT (this, SW_RES(FT_RUBYSIZE )),
90 aRubySizeMF (this, SW_RES(MF_RUBYSIZE )),
91 aRubyBelowCB (this, SW_RES(CB_RUBYBELOW )),
92 aDisplayFL (this, SW_RES(FL_DISPLAY )),
93 aDisplayCB (this, SW_RES(CB_DISPLAY )),
94 aPrintCB (this, SW_RES(CB_PRINT )),
95 aColorFT (this, SW_RES(FT_COLOR )),
96 aColorLB (this, SW_RES(LB_COLOR )),
97 m_nRubyUserValue(0),
98 m_bRubyUserValue(sal_False),
99 m_aPageSize(MM50, MM50),
100 m_bVertical(sal_False),
101 m_bSquaredMode(sal_False),
102 m_bHRulerChanged( sal_False ),
103 m_bVRulerChanged( sal_False )
105 FreeResource();
107 aControls[0] =&aLayoutFL;
108 aControls[1] =&aLinesPerPageFT;
109 aControls[2] =&aLinesPerPageNF;
110 aControls[3] =&aTextSizeFT;
111 aControls[4] =&aTextSizeMF;
112 aControls[5] =&aCharsPerLineFT;
113 aControls[6] =&aCharsPerLineNF;
114 aControls[7] =&aCharWidthFT;
115 aControls[8] =&aCharWidthMF;
116 aControls[9] =&aRubySizeFT;
117 aControls[10] =&aRubySizeMF;
118 aControls[11] =&aRubyBelowCB;
119 aControls[12] =&aDisplayFL;
120 aControls[13] =&aDisplayCB;
121 aControls[14] =&aPrintCB;
122 aControls[15] =&aColorFT;
123 aControls[16] =&aColorLB;
124 aControls[17] =&aLinesRangeFT;
125 aControls[18] =&aCharsRangeFT;
126 aControls[19] =0;
128 Link aLink = LINK(this, SwTextGridPage, CharorLineChangedHdl);
129 aCharsPerLineNF.SetUpHdl(aLink);
130 aCharsPerLineNF.SetDownHdl(aLink);
131 aCharsPerLineNF.SetLoseFocusHdl(aLink);
132 aLinesPerPageNF.SetUpHdl(aLink);
133 aLinesPerPageNF.SetDownHdl(aLink);
134 aLinesPerPageNF.SetLoseFocusHdl(aLink);
136 Link aSizeLink = LINK(this, SwTextGridPage, TextSizeChangedHdl);
137 aTextSizeMF.SetUpHdl(aSizeLink);
138 aTextSizeMF.SetDownHdl(aSizeLink);
139 aTextSizeMF.SetLoseFocusHdl(aSizeLink);
140 aRubySizeMF.SetUpHdl(aSizeLink);
141 aRubySizeMF.SetDownHdl(aSizeLink);
142 aRubySizeMF.SetLoseFocusHdl(aSizeLink);
143 aCharWidthMF.SetUpHdl(aSizeLink);
144 aCharWidthMF.SetDownHdl(aSizeLink);
145 aCharWidthMF.SetLoseFocusHdl(aSizeLink);
147 Link aGridTypeHdl = LINK(this, SwTextGridPage, GridTypeHdl);
148 aNoGridRB .SetClickHdl(aGridTypeHdl);
149 aLinesGridRB.SetClickHdl(aGridTypeHdl);
150 aCharsGridRB.SetClickHdl(aGridTypeHdl);
152 Link aModifyLk = LINK(this, SwTextGridPage, GridModifyHdl);
153 aColorLB.SetSelectHdl(aModifyLk);
154 aPrintCB.SetClickHdl(aModifyLk);
155 aRubyBelowCB.SetClickHdl(aModifyLk);
158 aDisplayCB.SetClickHdl(LINK(this, SwTextGridPage, DisplayGridHdl));
160 XColorTable* pColorTbl = XColorTable::GetStdColorTable();
161 aColorLB.InsertAutomaticEntry();
162 for( USHORT i = 0; i < pColorTbl->Count(); ++i )
164 XColorEntry* pEntry = pColorTbl->GetColor( i );
165 Color aColor = pEntry->GetColor();
166 String sName = pEntry->GetName();
167 aColorLB.InsertEntry( aColor, sName );
169 aColorLB.SetUpdateMode( TRUE );
170 //Get the default paper mode
171 SwView *pView = ::GetActiveView();
172 if( pView )
174 SwWrtShell* pSh = pView->GetWrtShellPtr();
175 if( pSh )
177 m_bSquaredMode = pSh->GetDoc()->IsSquaredPageMode();
180 if( m_bSquaredMode )
182 aRubySizeFT.Show();
183 aRubySizeMF.Show();
184 aRubyBelowCB.Show();
185 aSnapToCharsCB.Hide();
186 aCharWidthFT.Hide();
187 aCharWidthMF.Hide();
189 else
191 aRubySizeFT.Hide();
192 aRubySizeMF.Hide();
193 aRubyBelowCB.Hide();
194 aSnapToCharsCB.Show();
195 aCharWidthFT.Show();
196 aCharWidthMF.Show();
199 /*-- 06.02.2002 15:25:40---------------------------------------------------
201 -----------------------------------------------------------------------*/
202 SwTextGridPage::~SwTextGridPage()
205 /*-- 06.02.2002 15:25:40---------------------------------------------------
207 -----------------------------------------------------------------------*/
208 SfxTabPage *SwTextGridPage::Create(Window *pParent, const SfxItemSet &rSet)
210 return new SwTextGridPage(pParent, rSet);
212 /*-- 06.02.2002 15:25:40---------------------------------------------------
214 -----------------------------------------------------------------------*/
215 BOOL SwTextGridPage::FillItemSet(SfxItemSet &rSet)
217 BOOL bRet = FALSE;
218 if(aNoGridRB.GetSavedValue() != aNoGridRB.IsChecked()||
219 aLinesGridRB.GetSavedValue() != aLinesGridRB.IsChecked()||
220 aLinesPerPageNF.GetSavedValue().ToInt32()
221 != aLinesPerPageNF.GetValue()||
222 aTextSizeMF.GetSavedValue().ToInt32() != aTextSizeMF.GetValue()||
223 aCharsPerLineNF.GetSavedValue().ToInt32()
224 != aCharsPerLineNF.GetValue()||
225 aSnapToCharsCB.GetSavedValue() != aSnapToCharsCB.IsChecked() ||
226 aRubySizeMF.GetSavedValue().ToInt32() != aRubySizeMF.GetValue()||
227 aCharWidthMF.GetSavedValue().ToInt32() != aCharWidthMF.GetValue()||
228 aRubyBelowCB.GetSavedValue() != aRubyBelowCB.IsChecked()||
229 aDisplayCB.GetSavedValue() != aDisplayCB.IsChecked()||
230 aPrintCB.GetSavedValue() != aPrintCB.IsChecked()||
231 aColorLB.GetSavedValue() != aColorLB.GetSelectEntryPos())
233 PutGridItem(rSet);
234 bRet = TRUE;
237 // draw ticks of ruler
238 SwView * pView = ::GetActiveView();
239 if ( m_bHRulerChanged )
240 pView->GetHLineal().DrawTicks();
241 if ( m_bVRulerChanged )
242 pView->GetVLineal().DrawTicks();
243 return bRet;
245 /*-- 06.02.2002 15:25:40---------------------------------------------------
247 -----------------------------------------------------------------------*/
248 void SwTextGridPage::Reset(const SfxItemSet &rSet)
250 if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(RES_TEXTGRID, TRUE))
252 const SwTextGridItem& rGridItem = (const SwTextGridItem&)rSet.Get(RES_TEXTGRID);
253 RadioButton* pButton = 0;
254 switch(rGridItem.GetGridType())
256 case GRID_NONE : pButton = &aNoGridRB; break;
257 case GRID_LINES_ONLY : pButton = &aLinesGridRB; break;
258 default: pButton = &aCharsGridRB;
260 pButton->Check();
261 aDisplayCB.Check(rGridItem.IsDisplayGrid());
262 GridTypeHdl(pButton);
263 aSnapToCharsCB.Check(rGridItem.IsSnapToChars());
264 aLinesPerPageNF.SetValue(rGridItem.GetLines());
265 SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
266 m_nRubyUserValue = rGridItem.GetBaseHeight();
267 m_bRubyUserValue = sal_True;
268 aTextSizeMF.SetValue(aTextSizeMF.Normalize(m_nRubyUserValue), FUNIT_TWIP);
269 aRubySizeMF.SetValue(aRubySizeMF.Normalize(rGridItem.GetRubyHeight()), FUNIT_TWIP);
270 aCharWidthMF.SetValue(aCharWidthMF.Normalize(rGridItem.GetBaseWidth()), FUNIT_TWIP);
271 aRubyBelowCB.Check(rGridItem.IsRubyTextBelow());
272 aPrintCB.Check(rGridItem.IsPrintGrid());
273 aColorLB.SelectEntry(rGridItem.GetColor());
275 UpdatePageSize(rSet);
277 aNoGridRB.SaveValue();
278 aLinesGridRB.SaveValue();
279 aSnapToCharsCB.SaveValue();
280 aLinesPerPageNF.SaveValue();
281 aTextSizeMF.SaveValue();
282 aCharsPerLineNF.SaveValue();
283 aRubySizeMF.SaveValue();
284 aCharWidthMF.SaveValue();
285 aRubyBelowCB.SaveValue();
286 aDisplayCB.SaveValue();
287 aPrintCB.SaveValue();
288 aColorLB.SaveValue();
290 /*-- 06.02.2002 15:25:41---------------------------------------------------
292 -----------------------------------------------------------------------*/
293 void SwTextGridPage::ActivatePage( const SfxItemSet& rSet )
295 aExampleWN.Hide();
296 aExampleWN.UpdateExample( rSet );
297 UpdatePageSize(rSet);
298 aExampleWN.Show();
299 aExampleWN.Invalidate();
301 /*-- 06.02.2002 15:25:41---------------------------------------------------
303 -----------------------------------------------------------------------*/
304 int SwTextGridPage::DeactivatePage( SfxItemSet* )
306 return LEAVE_PAGE;
308 /* -----------------------------08.02.2002 11:57------------------------------
310 ---------------------------------------------------------------------------*/
311 void SwTextGridPage::PutGridItem(SfxItemSet& rSet)
313 SwTextGridItem aGridItem;
314 aGridItem.SetGridType(aNoGridRB.IsChecked() ? GRID_NONE :
315 aLinesGridRB.IsChecked() ? GRID_LINES_ONLY : GRID_LINES_CHARS );
316 aGridItem.SetSnapToChars(aSnapToCharsCB.IsChecked());
317 aGridItem.SetLines( static_cast< sal_uInt16 >(aLinesPerPageNF.GetValue()) );
318 aGridItem.SetBaseHeight( static_cast< sal_uInt16 >(
319 m_bRubyUserValue ? m_nRubyUserValue :
320 aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP))) );
321 aGridItem.SetRubyHeight( static_cast< sal_uInt16 >(aRubySizeMF.Denormalize(aRubySizeMF.GetValue(FUNIT_TWIP))) );
322 aGridItem.SetBaseWidth( static_cast< sal_uInt16 >(aCharWidthMF.Denormalize(aCharWidthMF.GetValue(FUNIT_TWIP))) );
323 aGridItem.SetRubyTextBelow(aRubyBelowCB.IsChecked());
324 aGridItem.SetSquaredMode(m_bSquaredMode);
325 aGridItem.SetDisplayGrid(aDisplayCB.IsChecked());
326 aGridItem.SetPrintGrid(aPrintCB.IsChecked());
327 aGridItem.SetColor(aColorLB.GetSelectEntryColor());
328 rSet.Put(aGridItem);
329 /// Amelia
330 SwView * pView = ::GetActiveView();
331 if ( aGridItem.GetGridType() != GRID_NONE )
333 if ( aGridItem.GetGridType() == GRID_LINES_CHARS )
335 m_bHRulerChanged = sal_True;
337 m_bVRulerChanged = sal_True;
338 pView->GetHLineal().SetCharWidth((long)(aCharWidthMF.GetValue(FUNIT_TWIP)/56.7));
339 pView->GetVLineal().SetLineHeight((long)(aTextSizeMF.GetValue(FUNIT_TWIP)/56.7));
342 /* -----------------------------08.02.2002 10:54------------------------------
344 ---------------------------------------------------------------------------*/
345 void SwTextGridPage::UpdatePageSize(const SfxItemSet& rSet)
347 if( SFX_ITEM_UNKNOWN != rSet.GetItemState( RES_FRAMEDIR, TRUE ))
349 const SvxFrameDirectionItem& rDirItem =
350 (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR);
351 m_bVertical = rDirItem.GetValue() == FRMDIR_VERT_TOP_RIGHT||
352 rDirItem.GetValue() == FRMDIR_VERT_TOP_LEFT;
355 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_SIZE ))
357 const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(
358 SID_ATTR_PAGE_SIZE);
359 const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get(
360 RES_LR_SPACE );
361 const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)rSet.Get(
362 RES_UL_SPACE );
363 const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX);
364 sal_Int32 nDistanceLR = rLRSpace.GetLeft() + rLRSpace.GetRight();
365 sal_Int32 nDistanceUL = rULSpace.GetUpper() + rULSpace.GetLower();
367 sal_Int32 nValue1 = rSize.GetSize().Height() - nDistanceUL -
368 rBox.GetDistance(BOX_LINE_TOP) -
369 rBox.GetDistance(BOX_LINE_BOTTOM);
370 sal_Int32 nValue2 = rSize.GetSize().Width() - nDistanceLR -
371 rBox.GetDistance(BOX_LINE_LEFT) -
372 rBox.GetDistance(BOX_LINE_RIGHT);
373 if(m_bVertical)
375 m_aPageSize.Width() = nValue1;
376 m_aPageSize.Height() = nValue2;
378 else
380 m_aPageSize.Width() = nValue2;
381 m_aPageSize.Height() = nValue1;
384 sal_Int32 nTextSize = static_cast< sal_Int32 >(m_bRubyUserValue ?
385 m_nRubyUserValue :
386 aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)));
388 if ( m_bSquaredMode )
390 aCharsPerLineNF.SetValue(m_aPageSize.Width() / nTextSize);
391 aCharsPerLineNF.SetMax( aCharsPerLineNF.GetValue() );
392 aLinesPerPageNF.SetMax( m_aPageSize.Height() /
393 ( aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)) +
394 aRubySizeMF.Denormalize(aRubySizeMF.GetValue(FUNIT_TWIP))));
395 SetLinesOrCharsRanges( aCharsRangeFT , aCharsPerLineNF.GetMax() );
396 SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
398 else
400 sal_Int32 nTextWidth = static_cast< sal_Int32 >(aCharWidthMF.Denormalize(aCharWidthMF.GetValue(FUNIT_TWIP)));
401 aLinesPerPageNF.SetValue(m_aPageSize.Height() / nTextSize);
402 if (nTextWidth)
403 aCharsPerLineNF.SetValue(m_aPageSize.Width() / nTextWidth);
404 else
405 aCharsPerLineNF.SetValue( 45 );
406 SetLinesOrCharsRanges( aCharsRangeFT , aCharsPerLineNF.GetMax() );
407 SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
411 /* -----------------------------30.05.2008 14:12------------------------------
413 ---------------------------------------------------------------------------*/
414 void SwTextGridPage::SetLinesOrCharsRanges(FixedText & rField, const sal_Int32 nValue )
416 String aFieldStr = String::CreateFromAscii("( 1 -");
417 aFieldStr += String::CreateFromInt32( nValue );
418 aFieldStr += String::CreateFromAscii(" )");
419 rField.SetText( aFieldStr );
421 /* -----------------------------06.02.2002 15:24------------------------------
423 ---------------------------------------------------------------------------*/
424 USHORT* SwTextGridPage::GetRanges()
426 static USHORT __FAR_DATA aPageRg[] = {
427 RES_TEXTGRID, RES_TEXTGRID,
429 return aPageRg;
431 /* -----------------------------08.02.2002 10:56------------------------------
433 ---------------------------------------------------------------------------*/
434 IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, SpinField*, pField)
436 //if in squared mode
437 if ( m_bSquaredMode )
439 if(&aCharsPerLineNF == pField)
441 long nWidth = (long)(m_aPageSize.Width() / aCharsPerLineNF.GetValue());
442 aTextSizeMF.SetValue(aTextSizeMF.Normalize(nWidth), FUNIT_TWIP);
443 //prevent rounding errors in the MetricField by saving the used value
444 m_nRubyUserValue = nWidth;
445 m_bRubyUserValue = sal_True;
448 //set maximum line per page
450 sal_Int32 nMaxLines = static_cast< sal_Int32 >(m_aPageSize.Height() /
451 ( aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)) +
452 aRubySizeMF.Denormalize(aRubySizeMF.GetValue(FUNIT_TWIP))));
453 aLinesPerPageNF.SetMax(nMaxLines);
455 SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
456 SetLinesOrCharsRanges( aCharsRangeFT , aCharsPerLineNF.GetMax() );
458 else//in normal mode
460 if(&aLinesPerPageNF == pField)
462 long nHeight = static_cast< sal_Int32 >(m_aPageSize.Height() / aLinesPerPageNF.GetValue());
463 aTextSizeMF.SetValue(aTextSizeMF.Normalize(nHeight), FUNIT_TWIP);
464 aRubySizeMF.SetValue(0, FUNIT_TWIP);
465 SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
467 m_nRubyUserValue = nHeight;
468 m_bRubyUserValue = sal_True;
470 else if (&aCharsPerLineNF == pField)
472 long nWidth = static_cast< sal_Int32 >(m_aPageSize.Width() / aCharsPerLineNF.GetValue());
473 aCharWidthMF.SetValue(aCharWidthMF.Normalize(nWidth), FUNIT_TWIP);
474 SetLinesOrCharsRanges( aCharsRangeFT , aCharsPerLineNF.GetMax() );
477 GridModifyHdl(0);
478 return 0;
480 /* -----------------------------04.09.2006 15:46------------------------------
481 ---------------------------------------------------------------------------*/
482 IMPL_LINK(SwTextGridPage, TextSizeChangedHdl, SpinField*, pField)
484 //if in squared mode
485 if( m_bSquaredMode )
487 if (&aTextSizeMF == pField)
489 sal_Int32 nTextSize = static_cast< sal_Int32 >(aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)));
490 m_bRubyUserValue = sal_False;
492 //set maximum line per page
494 sal_Int32 nMaxLines = static_cast< sal_Int32 >(m_aPageSize.Height() /
495 ( aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)) +
496 aRubySizeMF.Denormalize(aRubySizeMF.GetValue(FUNIT_TWIP))));
497 aLinesPerPageNF.SetMax(nMaxLines);
498 SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
501 else
503 if (&aTextSizeMF == pField)
505 sal_Int32 nTextSize = static_cast< sal_Int32 >(aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)));
506 aLinesPerPageNF.SetValue(m_aPageSize.Height() / nTextSize);
507 m_bRubyUserValue = sal_False;
508 SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
510 else if (&aCharWidthMF == pField)
512 sal_Int32 nTextWidth = static_cast< sal_Int32 >(aCharWidthMF.Denormalize(aCharWidthMF.GetValue(FUNIT_TWIP)));
513 sal_Int32 nMaxChar = 45 ;
514 if (nTextWidth)
515 nMaxChar = m_aPageSize.Width() / nTextWidth;
516 aCharsPerLineNF.SetValue( nMaxChar );
517 SetLinesOrCharsRanges( aCharsRangeFT , aCharsPerLineNF.GetMax() );
519 //rubySize is disabled
521 GridModifyHdl(0);
522 return 0;
524 /* -----------------------------22.04.2002 14:53------------------------------
526 ---------------------------------------------------------------------------*/
527 IMPL_LINK(SwTextGridPage, GridTypeHdl, RadioButton*, pButton)
529 sal_Bool bEnable = &aNoGridRB != pButton;
530 sal_Int32 nIndex = 0;
531 while(aControls[nIndex])
532 aControls[nIndex++]->Enable(bEnable);
533 //one special case
534 if(bEnable)
535 DisplayGridHdl(&aDisplayCB);
537 bEnable = &aCharsGridRB == pButton;
538 aSnapToCharsCB.Enable(bEnable);
540 bEnable = &aLinesGridRB == pButton;
541 if(bEnable && !m_bSquaredMode )
543 aCharsPerLineFT.Enable(sal_False);
544 aCharsPerLineNF.Enable(sal_False);
545 aCharsRangeFT.Enable(sal_False);
546 aCharWidthFT.Enable(sal_False);
547 aCharWidthMF.Enable(sal_False);
550 GridModifyHdl(0);
551 return 0;
553 /* -----------------------------22.04.2002 15:46------------------------------
555 ---------------------------------------------------------------------------*/
556 IMPL_LINK(SwTextGridPage, DisplayGridHdl, CheckBox*, EMPTYARG)
558 aPrintCB.Enable(aDisplayCB.IsChecked());
559 return 0;
561 /* -----------------------------08.02.2002 11:54------------------------------
563 ---------------------------------------------------------------------------*/
564 IMPL_LINK(SwTextGridPage, GridModifyHdl, void*, EMPTYARG)
566 const SfxItemSet& rOldSet = GetItemSet();
567 SfxItemSet aSet(rOldSet);
568 const SfxItemSet* pExSet = GetTabDialog()->GetExampleSet();
569 if(pExSet)
570 aSet.Put(*pExSet);
571 PutGridItem(aSet);
572 aExampleWN.UpdateExample(aSet);
573 return 0;