Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <sfx2/app.hxx>
30 : :
31 : : #include <cmdid.h>
32 : : #include <hintids.hxx>
33 : : #include <swtypes.hxx>
34 : : #include <globals.hrc>
35 : : #include <svx/xtable.hxx>
36 : : #include <uitool.hxx>
37 : : #include <editeng/sizeitem.hxx>
38 : : #include <editeng/lrspitem.hxx>
39 : : #include <editeng/ulspitem.hxx>
40 : : #include <editeng/boxitem.hxx>
41 : : #include <editeng/frmdiritem.hxx>
42 : : #include <svx/ruler.hxx>
43 : : #include <pggrid.hxx>
44 : : #include <tgrditem.hxx>
45 : : #include <pggrid.hrc>
46 : :
47 : : #include "wrtsh.hxx"
48 : : #include "doc.hxx"
49 : : #include "uiitems.hxx"
50 : : #include "swmodule.hxx"
51 : : #include "view.hxx"
52 : :
53 : 0 : SwTextGridPage::SwTextGridPage(Window *pParent, const SfxItemSet &rSet) :
54 : : SfxTabPage(pParent, SW_RES(TP_TEXTGRID_PAGE), rSet),
55 : : aGridTypeFL (this, SW_RES(FL_GRID_TYPE )),
56 : : aNoGridRB (this, SW_RES(RB_NOGRID )),
57 : : aLinesGridRB (this, SW_RES(RB_LINESGRID )),
58 : : aCharsGridRB (this, SW_RES(RB_CHARSGRID )),
59 : : aSnapToCharsCB (this, SW_RES(CB_SNAPTOCHARS )),
60 : : aExampleWN (this, SW_RES(WN_EXAMPLE )),
61 : : aLayoutFL (this, SW_RES(FL_LAYOUT )),
62 : : aLinesPerPageFT (this, SW_RES(FT_LINESPERPAGE )),
63 : : aLinesPerPageNF (this, SW_RES(NF_LINESPERPAGE )),
64 : : aLinesRangeFT (this, SW_RES(FT_LINERANGE )),
65 : : aTextSizeFT (this, SW_RES(FT_TEXTSIZE )),
66 : : aTextSizeMF (this, SW_RES(MF_TEXTSIZE )),
67 : : aCharsPerLineFT (this, SW_RES(FT_CHARSPERLINE )),
68 : : aCharsPerLineNF (this, SW_RES(NF_CHARSPERLINE )),
69 : : aCharsRangeFT (this, SW_RES(FT_CHARRANGE )),
70 : : aCharWidthFT (this, SW_RES(FT_CHARWIDTH )),
71 : : aCharWidthMF (this, SW_RES(MF_CHARWIDTH )),
72 : : aRubySizeFT (this, SW_RES(FT_RUBYSIZE )),
73 : : aRubySizeMF (this, SW_RES(MF_RUBYSIZE )),
74 : : aRubyBelowCB (this, SW_RES(CB_RUBYBELOW )),
75 : : aDisplayFL (this, SW_RES(FL_DISPLAY )),
76 : : aDisplayCB (this, SW_RES(CB_DISPLAY )),
77 : : aPrintCB (this, SW_RES(CB_PRINT )),
78 : : aColorFT (this, SW_RES(FT_COLOR )),
79 : : aColorLB (this, SW_RES(LB_COLOR )),
80 : : m_nRubyUserValue(0),
81 : : m_bRubyUserValue(sal_False),
82 : : m_aPageSize(MM50, MM50),
83 : : m_bVertical(sal_False),
84 : : m_bSquaredMode(sal_False),
85 : : m_bHRulerChanged( sal_False ),
86 : 0 : m_bVRulerChanged( sal_False )
87 : : {
88 : 0 : FreeResource();
89 : :
90 : 0 : aControls[0] =&aLayoutFL;
91 : 0 : aControls[1] =&aLinesPerPageFT;
92 : 0 : aControls[2] =&aLinesPerPageNF;
93 : 0 : aControls[3] =&aTextSizeFT;
94 : 0 : aControls[4] =&aTextSizeMF;
95 : 0 : aControls[5] =&aCharsPerLineFT;
96 : 0 : aControls[6] =&aCharsPerLineNF;
97 : 0 : aControls[7] =&aCharWidthFT;
98 : 0 : aControls[8] =&aCharWidthMF;
99 : 0 : aControls[9] =&aRubySizeFT;
100 : 0 : aControls[10] =&aRubySizeMF;
101 : 0 : aControls[11] =&aRubyBelowCB;
102 : 0 : aControls[12] =&aDisplayFL;
103 : 0 : aControls[13] =&aDisplayCB;
104 : 0 : aControls[14] =&aPrintCB;
105 : 0 : aControls[15] =&aColorFT;
106 : 0 : aControls[16] =&aColorLB;
107 : 0 : aControls[17] =&aLinesRangeFT;
108 : 0 : aControls[18] =&aCharsRangeFT;
109 : 0 : aControls[19] =0;
110 : :
111 : 0 : Link aLink = LINK(this, SwTextGridPage, CharorLineChangedHdl);
112 : 0 : aCharsPerLineNF.SetUpHdl(aLink);
113 : 0 : aCharsPerLineNF.SetDownHdl(aLink);
114 : 0 : aCharsPerLineNF.SetLoseFocusHdl(aLink);
115 : 0 : aLinesPerPageNF.SetUpHdl(aLink);
116 : 0 : aLinesPerPageNF.SetDownHdl(aLink);
117 : 0 : aLinesPerPageNF.SetLoseFocusHdl(aLink);
118 : :
119 : 0 : Link aSizeLink = LINK(this, SwTextGridPage, TextSizeChangedHdl);
120 : 0 : aTextSizeMF.SetUpHdl(aSizeLink);
121 : 0 : aTextSizeMF.SetDownHdl(aSizeLink);
122 : 0 : aTextSizeMF.SetLoseFocusHdl(aSizeLink);
123 : 0 : aRubySizeMF.SetUpHdl(aSizeLink);
124 : 0 : aRubySizeMF.SetDownHdl(aSizeLink);
125 : 0 : aRubySizeMF.SetLoseFocusHdl(aSizeLink);
126 : 0 : aCharWidthMF.SetUpHdl(aSizeLink);
127 : 0 : aCharWidthMF.SetDownHdl(aSizeLink);
128 : 0 : aCharWidthMF.SetLoseFocusHdl(aSizeLink);
129 : :
130 : 0 : Link aGridTypeHdl = LINK(this, SwTextGridPage, GridTypeHdl);
131 : 0 : aNoGridRB .SetClickHdl(aGridTypeHdl);
132 : 0 : aLinesGridRB.SetClickHdl(aGridTypeHdl);
133 : 0 : aCharsGridRB.SetClickHdl(aGridTypeHdl);
134 : :
135 : 0 : Link aModifyLk = LINK(this, SwTextGridPage, GridModifyHdl);
136 : 0 : aColorLB.SetSelectHdl(aModifyLk);
137 : 0 : aPrintCB.SetClickHdl(aModifyLk);
138 : 0 : aRubyBelowCB.SetClickHdl(aModifyLk);
139 : :
140 : 0 : aDisplayCB.SetClickHdl(LINK(this, SwTextGridPage, DisplayGridHdl));
141 : :
142 : 0 : XColorListRef pColorLst = XColorList::GetStdColorList();
143 : 0 : aColorLB.InsertAutomaticEntryColor( Color( COL_AUTO ) );
144 : 0 : for( sal_uInt16 i = 0; i < pColorLst->Count(); ++i )
145 : : {
146 : 0 : XColorEntry* pEntry = pColorLst->GetColor( i );
147 : 0 : Color aColor = pEntry->GetColor();
148 : 0 : String sName = pEntry->GetName();
149 : 0 : aColorLB.InsertEntry( aColor, sName );
150 : 0 : }
151 : 0 : aColorLB.SetUpdateMode( sal_True );
152 : : //Get the default paper mode
153 : 0 : SwView *pView = ::GetActiveView();
154 : 0 : if( pView )
155 : : {
156 : 0 : SwWrtShell* pSh = pView->GetWrtShellPtr();
157 : 0 : if( pSh )
158 : : {
159 : 0 : m_bSquaredMode = pSh->GetDoc()->IsSquaredPageMode();
160 : : }
161 : : }
162 : 0 : if( m_bSquaredMode )
163 : : {
164 : 0 : aRubySizeFT.Show();
165 : 0 : aRubySizeMF.Show();
166 : 0 : aRubyBelowCB.Show();
167 : 0 : aSnapToCharsCB.Hide();
168 : 0 : aCharWidthFT.Hide();
169 : 0 : aCharWidthMF.Hide();
170 : : }
171 : : else
172 : : {
173 : 0 : aRubySizeFT.Hide();
174 : 0 : aRubySizeMF.Hide();
175 : 0 : aRubyBelowCB.Hide();
176 : 0 : aSnapToCharsCB.Show();
177 : 0 : aCharWidthFT.Show();
178 : 0 : aCharWidthMF.Show();
179 : 0 : }
180 : 0 : }
181 : :
182 : 0 : SwTextGridPage::~SwTextGridPage()
183 : : {
184 : 0 : }
185 : :
186 : 0 : SfxTabPage *SwTextGridPage::Create(Window *pParent, const SfxItemSet &rSet)
187 : : {
188 : 0 : return new SwTextGridPage(pParent, rSet);
189 : : }
190 : :
191 : 0 : sal_Bool SwTextGridPage::FillItemSet(SfxItemSet &rSet)
192 : : {
193 : 0 : sal_Bool bRet = sal_False;
194 : 0 : if(aNoGridRB.GetSavedValue() != aNoGridRB.IsChecked()||
195 : 0 : aLinesGridRB.GetSavedValue() != aLinesGridRB.IsChecked()||
196 : 0 : aLinesPerPageNF.GetSavedValue().ToInt32()
197 : 0 : != aLinesPerPageNF.GetValue()||
198 : 0 : aTextSizeMF.GetSavedValue().ToInt32() != aTextSizeMF.GetValue()||
199 : 0 : aCharsPerLineNF.GetSavedValue().ToInt32()
200 : 0 : != aCharsPerLineNF.GetValue()||
201 : 0 : aSnapToCharsCB.GetSavedValue() != aSnapToCharsCB.IsChecked() ||
202 : 0 : aRubySizeMF.GetSavedValue().ToInt32() != aRubySizeMF.GetValue()||
203 : 0 : aCharWidthMF.GetSavedValue().ToInt32() != aCharWidthMF.GetValue()||
204 : 0 : aRubyBelowCB.GetSavedValue() != aRubyBelowCB.IsChecked()||
205 : 0 : aDisplayCB.GetSavedValue() != aDisplayCB.IsChecked()||
206 : 0 : aPrintCB.GetSavedValue() != aPrintCB.IsChecked()||
207 : 0 : aColorLB.GetSavedValue() != aColorLB.GetSelectEntryPos())
208 : : {
209 : 0 : PutGridItem(rSet);
210 : 0 : bRet = sal_True;
211 : : }
212 : :
213 : : // draw ticks of ruler
214 : 0 : SwView * pView = ::GetActiveView();
215 : 0 : if ( m_bHRulerChanged )
216 : 0 : pView->GetHLineal().DrawTicks();
217 : 0 : if ( m_bVRulerChanged )
218 : 0 : pView->GetVLineal().DrawTicks();
219 : 0 : return bRet;
220 : : }
221 : :
222 : 0 : void SwTextGridPage::Reset(const SfxItemSet &rSet)
223 : : {
224 : 0 : if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(RES_TEXTGRID, sal_True))
225 : : {
226 : 0 : const SwTextGridItem& rGridItem = (const SwTextGridItem&)rSet.Get(RES_TEXTGRID);
227 : 0 : RadioButton* pButton = 0;
228 : 0 : switch(rGridItem.GetGridType())
229 : : {
230 : 0 : case GRID_NONE : pButton = &aNoGridRB; break;
231 : 0 : case GRID_LINES_ONLY : pButton = &aLinesGridRB; break;
232 : 0 : default: pButton = &aCharsGridRB;
233 : : }
234 : 0 : pButton->Check();
235 : 0 : aDisplayCB.Check(rGridItem.IsDisplayGrid());
236 : 0 : GridTypeHdl(pButton);
237 : 0 : aSnapToCharsCB.Check(rGridItem.IsSnapToChars());
238 : 0 : aLinesPerPageNF.SetValue(rGridItem.GetLines());
239 : 0 : SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
240 : 0 : m_nRubyUserValue = rGridItem.GetBaseHeight();
241 : 0 : m_bRubyUserValue = sal_True;
242 : 0 : aTextSizeMF.SetValue(aTextSizeMF.Normalize(m_nRubyUserValue), FUNIT_TWIP);
243 : 0 : aRubySizeMF.SetValue(aRubySizeMF.Normalize(rGridItem.GetRubyHeight()), FUNIT_TWIP);
244 : 0 : aCharWidthMF.SetValue(aCharWidthMF.Normalize(rGridItem.GetBaseWidth()), FUNIT_TWIP);
245 : 0 : aRubyBelowCB.Check(rGridItem.IsRubyTextBelow());
246 : 0 : aPrintCB.Check(rGridItem.IsPrintGrid());
247 : 0 : aColorLB.SelectEntry(rGridItem.GetColor());
248 : : }
249 : 0 : UpdatePageSize(rSet);
250 : :
251 : 0 : aNoGridRB.SaveValue();
252 : 0 : aLinesGridRB.SaveValue();
253 : 0 : aSnapToCharsCB.SaveValue();
254 : 0 : aLinesPerPageNF.SaveValue();
255 : 0 : aTextSizeMF.SaveValue();
256 : 0 : aCharsPerLineNF.SaveValue();
257 : 0 : aRubySizeMF.SaveValue();
258 : 0 : aCharWidthMF.SaveValue();
259 : 0 : aRubyBelowCB.SaveValue();
260 : 0 : aDisplayCB.SaveValue();
261 : 0 : aPrintCB.SaveValue();
262 : 0 : aColorLB.SaveValue();
263 : 0 : }
264 : :
265 : 0 : void SwTextGridPage::ActivatePage( const SfxItemSet& rSet )
266 : : {
267 : 0 : aExampleWN.Hide();
268 : 0 : aExampleWN.UpdateExample( rSet );
269 : 0 : UpdatePageSize(rSet);
270 : 0 : aExampleWN.Show();
271 : 0 : aExampleWN.Invalidate();
272 : 0 : }
273 : :
274 : 0 : int SwTextGridPage::DeactivatePage( SfxItemSet* )
275 : : {
276 : 0 : return LEAVE_PAGE;
277 : : }
278 : :
279 : 0 : void SwTextGridPage::PutGridItem(SfxItemSet& rSet)
280 : : {
281 : 0 : SwTextGridItem aGridItem;
282 : 0 : aGridItem.SetGridType(aNoGridRB.IsChecked() ? GRID_NONE :
283 : 0 : aLinesGridRB.IsChecked() ? GRID_LINES_ONLY : GRID_LINES_CHARS );
284 : 0 : aGridItem.SetSnapToChars(aSnapToCharsCB.IsChecked());
285 : 0 : aGridItem.SetLines( static_cast< sal_uInt16 >(aLinesPerPageNF.GetValue()) );
286 : : aGridItem.SetBaseHeight( static_cast< sal_uInt16 >(
287 : : m_bRubyUserValue ? m_nRubyUserValue :
288 : 0 : aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP))) );
289 : 0 : aGridItem.SetRubyHeight( static_cast< sal_uInt16 >(aRubySizeMF.Denormalize(aRubySizeMF.GetValue(FUNIT_TWIP))) );
290 : 0 : aGridItem.SetBaseWidth( static_cast< sal_uInt16 >(aCharWidthMF.Denormalize(aCharWidthMF.GetValue(FUNIT_TWIP))) );
291 : 0 : aGridItem.SetRubyTextBelow(aRubyBelowCB.IsChecked());
292 : 0 : aGridItem.SetSquaredMode(m_bSquaredMode);
293 : 0 : aGridItem.SetDisplayGrid(aDisplayCB.IsChecked());
294 : 0 : aGridItem.SetPrintGrid(aPrintCB.IsChecked());
295 : 0 : aGridItem.SetColor(aColorLB.GetSelectEntryColor());
296 : 0 : rSet.Put(aGridItem);
297 : :
298 : 0 : SwView * pView = ::GetActiveView();
299 : 0 : if ( aGridItem.GetGridType() != GRID_NONE )
300 : : {
301 : 0 : if ( aGridItem.GetGridType() == GRID_LINES_CHARS )
302 : : {
303 : 0 : m_bHRulerChanged = sal_True;
304 : : }
305 : 0 : m_bVRulerChanged = sal_True;
306 : 0 : pView->GetHLineal().SetCharWidth((long)(aCharWidthMF.GetValue(FUNIT_TWIP)/56.7));
307 : 0 : pView->GetVLineal().SetLineHeight((long)(aTextSizeMF.GetValue(FUNIT_TWIP)/56.7));
308 : 0 : }
309 : 0 : }
310 : :
311 : 0 : void SwTextGridPage::UpdatePageSize(const SfxItemSet& rSet)
312 : : {
313 : 0 : if( SFX_ITEM_UNKNOWN != rSet.GetItemState( RES_FRAMEDIR, sal_True ))
314 : : {
315 : : const SvxFrameDirectionItem& rDirItem =
316 : 0 : (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR);
317 : 0 : m_bVertical = rDirItem.GetValue() == FRMDIR_VERT_TOP_RIGHT||
318 : 0 : rDirItem.GetValue() == FRMDIR_VERT_TOP_LEFT;
319 : : }
320 : :
321 : 0 : if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_SIZE ))
322 : : {
323 : : const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(
324 : 0 : SID_ATTR_PAGE_SIZE);
325 : : const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get(
326 : 0 : RES_LR_SPACE );
327 : : const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)rSet.Get(
328 : 0 : RES_UL_SPACE );
329 : 0 : const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX);
330 : 0 : sal_Int32 nDistanceLR = rLRSpace.GetLeft() + rLRSpace.GetRight();
331 : 0 : sal_Int32 nDistanceUL = rULSpace.GetUpper() + rULSpace.GetLower();
332 : :
333 : 0 : sal_Int32 nValue1 = rSize.GetSize().Height() - nDistanceUL -
334 : 0 : rBox.GetDistance(BOX_LINE_TOP) -
335 : 0 : rBox.GetDistance(BOX_LINE_BOTTOM);
336 : 0 : sal_Int32 nValue2 = rSize.GetSize().Width() - nDistanceLR -
337 : 0 : rBox.GetDistance(BOX_LINE_LEFT) -
338 : 0 : rBox.GetDistance(BOX_LINE_RIGHT);
339 : 0 : if(m_bVertical)
340 : : {
341 : 0 : m_aPageSize.Width() = nValue1;
342 : 0 : m_aPageSize.Height() = nValue2;
343 : : }
344 : : else
345 : : {
346 : 0 : m_aPageSize.Width() = nValue2;
347 : 0 : m_aPageSize.Height() = nValue1;
348 : : }
349 : :
350 : : sal_Int32 nTextSize = static_cast< sal_Int32 >(m_bRubyUserValue ?
351 : : m_nRubyUserValue :
352 : 0 : aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)));
353 : :
354 : 0 : if ( m_bSquaredMode )
355 : : {
356 : 0 : aCharsPerLineNF.SetValue(m_aPageSize.Width() / nTextSize);
357 : 0 : aCharsPerLineNF.SetMax( aCharsPerLineNF.GetValue() );
358 : 0 : aLinesPerPageNF.SetMax( m_aPageSize.Height() /
359 : 0 : ( aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)) +
360 : 0 : aRubySizeMF.Denormalize(aRubySizeMF.GetValue(FUNIT_TWIP))));
361 : 0 : SetLinesOrCharsRanges( aCharsRangeFT , aCharsPerLineNF.GetMax() );
362 : 0 : SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
363 : : }
364 : : else
365 : : {
366 : 0 : sal_Int32 nTextWidth = static_cast< sal_Int32 >(aCharWidthMF.Denormalize(aCharWidthMF.GetValue(FUNIT_TWIP)));
367 : 0 : aLinesPerPageNF.SetValue(m_aPageSize.Height() / nTextSize);
368 : 0 : if (nTextWidth)
369 : 0 : aCharsPerLineNF.SetValue(m_aPageSize.Width() / nTextWidth);
370 : : else
371 : 0 : aCharsPerLineNF.SetValue( 45 );
372 : 0 : SetLinesOrCharsRanges( aCharsRangeFT , aCharsPerLineNF.GetMax() );
373 : 0 : SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
374 : : }
375 : : }
376 : 0 : }
377 : :
378 : 0 : void SwTextGridPage::SetLinesOrCharsRanges(FixedText & rField, const sal_Int32 nValue )
379 : : {
380 : 0 : String aFieldStr = rtl::OUString("( 1 -");
381 : 0 : aFieldStr += rtl::OUString::valueOf(nValue);
382 : 0 : aFieldStr += rtl::OUString(" )");
383 : 0 : rField.SetText( aFieldStr );
384 : 0 : }
385 : :
386 : 0 : sal_uInt16* SwTextGridPage::GetRanges()
387 : : {
388 : : static sal_uInt16 aPageRg[] = {
389 : : RES_TEXTGRID, RES_TEXTGRID,
390 : : 0};
391 : 0 : return aPageRg;
392 : : }
393 : :
394 : 0 : IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, SpinField*, pField)
395 : : {
396 : : //if in squared mode
397 : 0 : if ( m_bSquaredMode )
398 : : {
399 : 0 : if(&aCharsPerLineNF == pField)
400 : : {
401 : 0 : long nWidth = (long)(m_aPageSize.Width() / aCharsPerLineNF.GetValue());
402 : 0 : aTextSizeMF.SetValue(aTextSizeMF.Normalize(nWidth), FUNIT_TWIP);
403 : : //prevent rounding errors in the MetricField by saving the used value
404 : 0 : m_nRubyUserValue = nWidth;
405 : 0 : m_bRubyUserValue = sal_True;
406 : :
407 : : }
408 : : //set maximum line per page
409 : : {
410 : 0 : sal_Int32 nMaxLines = static_cast< sal_Int32 >(m_aPageSize.Height() /
411 : 0 : ( aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)) +
412 : 0 : aRubySizeMF.Denormalize(aRubySizeMF.GetValue(FUNIT_TWIP))));
413 : 0 : aLinesPerPageNF.SetMax(nMaxLines);
414 : : }
415 : 0 : SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
416 : 0 : SetLinesOrCharsRanges( aCharsRangeFT , aCharsPerLineNF.GetMax() );
417 : : }
418 : : else//in normal mode
419 : : {
420 : 0 : if(&aLinesPerPageNF == pField)
421 : : {
422 : 0 : long nHeight = static_cast< sal_Int32 >(m_aPageSize.Height() / aLinesPerPageNF.GetValue());
423 : 0 : aTextSizeMF.SetValue(aTextSizeMF.Normalize(nHeight), FUNIT_TWIP);
424 : 0 : aRubySizeMF.SetValue(0, FUNIT_TWIP);
425 : 0 : SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
426 : :
427 : 0 : m_nRubyUserValue = nHeight;
428 : 0 : m_bRubyUserValue = sal_True;
429 : : }
430 : 0 : else if (&aCharsPerLineNF == pField)
431 : : {
432 : 0 : long nWidth = static_cast< sal_Int32 >(m_aPageSize.Width() / aCharsPerLineNF.GetValue());
433 : 0 : aCharWidthMF.SetValue(aCharWidthMF.Normalize(nWidth), FUNIT_TWIP);
434 : 0 : SetLinesOrCharsRanges( aCharsRangeFT , aCharsPerLineNF.GetMax() );
435 : : }
436 : : }
437 : 0 : GridModifyHdl(0);
438 : 0 : return 0;
439 : : }
440 : :
441 : 0 : IMPL_LINK(SwTextGridPage, TextSizeChangedHdl, SpinField*, pField)
442 : : {
443 : : //if in squared mode
444 : 0 : if( m_bSquaredMode )
445 : : {
446 : 0 : if (&aTextSizeMF == pField)
447 : : {
448 : 0 : m_bRubyUserValue = sal_False;
449 : :
450 : : // fdo#50941: set maximum characters per line
451 : 0 : sal_Int32 nTextSize = static_cast< sal_Int32 >(aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)));
452 : 0 : if (nTextSize > 0)
453 : : {
454 : 0 : sal_Int32 nMaxChars = m_aPageSize.Width() / nTextSize;
455 : 0 : aCharsPerLineNF.SetValue(nMaxChars);
456 : 0 : aCharsPerLineNF.SetMax(nMaxChars);
457 : 0 : SetLinesOrCharsRanges( aCharsRangeFT , aCharsPerLineNF.GetMax() );
458 : : }
459 : : }
460 : : //set maximum line per page
461 : : {
462 : 0 : sal_Int32 nMaxLines = static_cast< sal_Int32 >(m_aPageSize.Height() /
463 : 0 : ( aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)) +
464 : 0 : aRubySizeMF.Denormalize(aRubySizeMF.GetValue(FUNIT_TWIP))));
465 : 0 : aLinesPerPageNF.SetMax(nMaxLines);
466 : 0 : SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
467 : : }
468 : : }
469 : : else
470 : : {
471 : 0 : if (&aTextSizeMF == pField)
472 : : {
473 : 0 : sal_Int32 nTextSize = static_cast< sal_Int32 >(aTextSizeMF.Denormalize(aTextSizeMF.GetValue(FUNIT_TWIP)));
474 : 0 : aLinesPerPageNF.SetValue(m_aPageSize.Height() / nTextSize);
475 : 0 : m_bRubyUserValue = sal_False;
476 : 0 : SetLinesOrCharsRanges( aLinesRangeFT , aLinesPerPageNF.GetMax() );
477 : : }
478 : 0 : else if (&aCharWidthMF == pField)
479 : : {
480 : 0 : sal_Int32 nTextWidth = static_cast< sal_Int32 >(aCharWidthMF.Denormalize(aCharWidthMF.GetValue(FUNIT_TWIP)));
481 : 0 : sal_Int32 nMaxChar = 45 ;
482 : 0 : if (nTextWidth)
483 : 0 : nMaxChar = m_aPageSize.Width() / nTextWidth;
484 : 0 : aCharsPerLineNF.SetValue( nMaxChar );
485 : 0 : SetLinesOrCharsRanges( aCharsRangeFT , aCharsPerLineNF.GetMax() );
486 : : }
487 : : //rubySize is disabled
488 : : }
489 : 0 : GridModifyHdl(0);
490 : 0 : return 0;
491 : : }
492 : :
493 : 0 : IMPL_LINK(SwTextGridPage, GridTypeHdl, RadioButton*, pButton)
494 : : {
495 : 0 : sal_Bool bEnable = &aNoGridRB != pButton;
496 : 0 : sal_Int32 nIndex = 0;
497 : 0 : while(aControls[nIndex])
498 : 0 : aControls[nIndex++]->Enable(bEnable);
499 : : //one special case
500 : 0 : if(bEnable)
501 : 0 : DisplayGridHdl(&aDisplayCB);
502 : :
503 : 0 : bEnable = &aCharsGridRB == pButton;
504 : 0 : aSnapToCharsCB.Enable(bEnable);
505 : :
506 : 0 : bEnable = &aLinesGridRB == pButton;
507 : 0 : if(bEnable && !m_bSquaredMode )
508 : : {
509 : 0 : aCharsPerLineFT.Enable(sal_False);
510 : 0 : aCharsPerLineNF.Enable(sal_False);
511 : 0 : aCharsRangeFT.Enable(sal_False);
512 : 0 : aCharWidthFT.Enable(sal_False);
513 : 0 : aCharWidthMF.Enable(sal_False);
514 : : }
515 : :
516 : 0 : GridModifyHdl(0);
517 : 0 : return 0;
518 : : }
519 : :
520 : 0 : IMPL_LINK_NOARG(SwTextGridPage, DisplayGridHdl)
521 : : {
522 : 0 : sal_Bool bChecked = aDisplayCB.IsChecked();
523 : 0 : aPrintCB.Enable(bChecked);
524 : 0 : aPrintCB.Check(bChecked);
525 : 0 : return 0;
526 : : }
527 : :
528 : 0 : IMPL_LINK_NOARG(SwTextGridPage, GridModifyHdl)
529 : : {
530 : 0 : const SfxItemSet& rOldSet = GetItemSet();
531 : 0 : SfxItemSet aSet(rOldSet);
532 : 0 : const SfxItemSet* pExSet = GetTabDialog()->GetExampleSet();
533 : 0 : if(pExSet)
534 : 0 : aSet.Put(*pExSet);
535 : 0 : PutGridItem(aSet);
536 : 0 : aExampleWN.UpdateExample(aSet);
537 : 0 : return 0;
538 : : }
539 : :
540 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|