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 <hintids.hxx>
30 : : #include <comphelper/string.hxx>
31 : : #include <vcl/msgbox.hxx>
32 : : #include <svl/stritem.hxx>
33 : : #include <svl/intitem.hxx>
34 : : #include <editeng/keepitem.hxx>
35 : : #include <editeng/brkitem.hxx>
36 : : #include <editeng/ulspitem.hxx>
37 : : #include <editeng/frmdiritem.hxx>
38 : : #include <svl/ctloptions.hxx>
39 : : #include <swmodule.hxx>
40 : : #include <fmtornt.hxx>
41 : : #include <fmtpdsc.hxx>
42 : : #include <fmtlsplt.hxx>
43 : :
44 : : #include <svtools/htmlcfg.hxx>
45 : : #include <fmtrowsplt.hxx>
46 : : #include <svx/htmlmode.hxx>
47 : :
48 : : #include "access.hrc"
49 : :
50 : : #include <docsh.hxx>
51 : : #include <wrtsh.hxx>
52 : : #include <view.hxx>
53 : : #include <viewopt.hxx>
54 : : #include <uitool.hxx>
55 : : #include <frmatr.hxx>
56 : : #include <tabledlg.hxx>
57 : : #include <tablepg.hxx>
58 : : #include <tablemgr.hxx>
59 : : #include <pagedesc.hxx>
60 : : #include <uiitems.hxx>
61 : : #include <poolfmt.hxx>
62 : : #include <SwStyleNameMapper.hxx>
63 : :
64 : : #include <cmdid.h>
65 : : #include <tabledlg.hrc>
66 : : #include <table.hrc>
67 : : #include <svx/svxids.hrc>
68 : : #include <svx/dialogs.hrc>
69 : : #include <svx/flagsdef.hxx>
70 : : #include <svx/svxdlg.hxx>
71 : :
72 : : using namespace ::com::sun::star;
73 : :
74 : :
75 : 0 : SwFormatTablePage::SwFormatTablePage( Window* pParent, const SfxItemSet& rSet ) :
76 : : SfxTabPage(pParent, SW_RES( TP_FORMAT_TABLE ), rSet ),
77 : : aOptionsFL(this, SW_RES( FL_OPTIONS )),
78 : : aNameFT(this, SW_RES( FT_NAME )),
79 : : aNameED(this, SW_RES( ED_NAME )),
80 : : aWidthFT(this, SW_RES( FT_WIDTH )),
81 : : aWidthMF(this, SW_RES( ED_WIDTH )),
82 : : aRelWidthCB(this, SW_RES( CB_REL_WIDTH )),
83 : :
84 : : aPosFL(this, SW_RES( FL_POS )),
85 : : aFullBtn(this, SW_RES( RB_FULL )),
86 : : aLeftBtn(this, SW_RES( RB_LEFT )),
87 : : aFromLeftBtn(this, SW_RES( RB_FROM_LEFT )),
88 : : aRightBtn(this, SW_RES( RB_RIGHT )),
89 : : aCenterBtn(this, SW_RES( RB_CENTER )),
90 : : aFreeBtn(this, SW_RES( RB_FREE )),
91 : :
92 : : aDistFL(this, SW_RES( FL_DIST )),
93 : : aLeftFT(this, SW_RES( FT_LEFT_DIST )),
94 : : aLeftMF(this, SW_RES( ED_LEFT_DIST )),
95 : : aRightFT(this, SW_RES( FT_RIGHT_DIST )),
96 : : aRightMF(this, SW_RES( ED_RIGHT_DIST )),
97 : : aTopFT (this, SW_RES( FT_TOP_DIST )),
98 : : aTopMF(this, SW_RES( ED_TOP_DIST )),
99 : : aBottomFT(this, SW_RES( FT_BOTTOM_DIST )),
100 : : aBottomMF(this, SW_RES( ED_BOTTOM_DIST )),
101 : :
102 : : aPropertiesFL(this, SW_RES( FL_PROPERTIES )),
103 : : aTextDirectionFT(this, SW_RES( FT_TEXTORIENTATION )),
104 : : aTextDirectionLB(this, SW_RES( LB_TEXTORIENTATION )),
105 : :
106 : : pTblData(0),
107 : : nSaveWidth(0),
108 : : nMinTableWidth(MINLAY),
109 : : bModified(sal_False),
110 : : bFull(0),
111 : 0 : bHtmlMode(sal_False)
112 : : {
113 : 0 : FreeResource();
114 : 0 : SetExchangeSupport();
115 : :
116 : : const SfxPoolItem* pItem;
117 : 0 : if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem))
118 : 0 : bHtmlMode = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON);
119 : :
120 : 0 : sal_Bool bCTL = SW_MOD()->GetCTLOptions().IsCTLFontEnabled();
121 : 0 : if( !bHtmlMode && bCTL )
122 : : {
123 : 0 : aPropertiesFL.Show();
124 : 0 : aTextDirectionFT.Show();
125 : 0 : aTextDirectionLB.Show();
126 : : }
127 : :
128 : 0 : Init();
129 : 0 : }
130 : :
131 : :
132 : 0 : void SwFormatTablePage::Init()
133 : : {
134 : 0 : aLeftMF.MetricField::SetMin(-999999);
135 : 0 : aRightMF.MetricField::SetMin(-999999);
136 : :
137 : : // handler
138 : 0 : Link aLk = LINK( this, SwFormatTablePage, AutoClickHdl );
139 : 0 : aFullBtn.SetClickHdl( aLk );
140 : 0 : aFreeBtn.SetClickHdl( aLk );
141 : 0 : aLeftBtn.SetClickHdl( aLk );
142 : 0 : aFromLeftBtn.SetClickHdl( aLk );
143 : 0 : aRightBtn.SetClickHdl( aLk );
144 : 0 : aCenterBtn.SetClickHdl( aLk );
145 : :
146 : 0 : aLk = LINK( this, SwFormatTablePage, UpDownLoseFocusHdl );
147 : 0 : aTopMF.SetUpHdl( aLk );
148 : 0 : aBottomMF.SetUpHdl( aLk );
149 : 0 : aRightMF.SetUpHdl( aLk );
150 : 0 : aLeftMF.SetUpHdl( aLk );
151 : 0 : aWidthMF.SetUpHdl( aLk );
152 : :
153 : 0 : aTopMF.SetDownHdl( aLk );
154 : 0 : aBottomMF.SetDownHdl( aLk );
155 : 0 : aRightMF.SetDownHdl( aLk );
156 : 0 : aLeftMF.SetDownHdl( aLk );
157 : 0 : aWidthMF.SetDownHdl( aLk );
158 : :
159 : 0 : aTopMF.SetLoseFocusHdl( aLk );
160 : 0 : aBottomMF.SetLoseFocusHdl( aLk );
161 : 0 : aRightMF.SetLoseFocusHdl( aLk );
162 : 0 : aLeftMF.SetLoseFocusHdl( aLk );
163 : 0 : aWidthMF.SetLoseFocusHdl( aLk );
164 : :
165 : 0 : aRelWidthCB.SetClickHdl(LINK( this, SwFormatTablePage, RelWidthClickHdl ));
166 : 0 : }
167 : :
168 : : /*------------------------------------------------------------------------*/
169 : :
170 : 0 : IMPL_LINK( SwFormatTablePage, RelWidthClickHdl, CheckBox *, pBtn )
171 : : {
172 : : OSL_ENSURE(pTblData, "table data not available?");
173 : 0 : sal_Bool bIsChecked = pBtn->IsChecked();
174 : 0 : sal_Int64 nLeft = aLeftMF.DenormalizePercent(aLeftMF.GetValue(FUNIT_TWIP ));
175 : 0 : sal_Int64 nRight = aRightMF.DenormalizePercent(aRightMF.GetValue(FUNIT_TWIP ));
176 : 0 : aWidthMF.ShowPercent(bIsChecked);
177 : 0 : aLeftMF.ShowPercent(bIsChecked);
178 : 0 : aRightMF.ShowPercent(bIsChecked);
179 : :
180 : 0 : if (bIsChecked)
181 : : {
182 : 0 : aWidthMF.SetRefValue(pTblData->GetSpace());
183 : 0 : aLeftMF.SetRefValue(pTblData->GetSpace());
184 : 0 : aRightMF.SetRefValue(pTblData->GetSpace());
185 : 0 : aLeftMF.MetricField::SetMin(0); // wird vom Percentfield ueberschrieben
186 : 0 : aRightMF.MetricField::SetMin(0);// -""-
187 : 0 : aLeftMF.MetricField::SetMax(99); //
188 : 0 : aRightMF.MetricField::SetMax(99);//
189 : 0 : aLeftMF.SetPrcntValue(aLeftMF.NormalizePercent(nLeft ), FUNIT_TWIP );
190 : 0 : aRightMF.SetPrcntValue(aRightMF.NormalizePercent(nRight ), FUNIT_TWIP );
191 : : }
192 : : else
193 : 0 : ModifyHdl(&aLeftMF); // Werte wieder korrigieren
194 : :
195 : 0 : if(aFreeBtn.IsChecked())
196 : : {
197 : 0 : sal_Bool bEnable = !pBtn->IsChecked();
198 : 0 : aRightMF.Enable(bEnable);
199 : 0 : aRightFT.Enable(bEnable);
200 : : }
201 : 0 : bModified = sal_True;
202 : :
203 : 0 : return 0;
204 : : }
205 : :
206 : :
207 : 0 : IMPL_LINK( SwFormatTablePage, AutoClickHdl, CheckBox *, pBox )
208 : : {
209 : 0 : sal_Bool bRestore = sal_True,
210 : 0 : bLeftEnable = sal_False,
211 : 0 : bRightEnable= sal_False,
212 : 0 : bWidthEnable= sal_False,
213 : 0 : bOthers = sal_True;
214 : 0 : if( (RadioButton *) pBox == &aFullBtn )
215 : : {
216 : 0 : aLeftMF.SetPrcntValue(0);
217 : 0 : aRightMF.SetPrcntValue(0);
218 : 0 : nSaveWidth = static_cast< SwTwips >(aWidthMF.DenormalizePercent(aWidthMF.GetValue(FUNIT_TWIP )));
219 : 0 : aWidthMF.SetPrcntValue(aWidthMF.NormalizePercent(pTblData->GetSpace() ), FUNIT_TWIP );
220 : 0 : bFull = sal_True;
221 : 0 : bRestore = sal_False;
222 : : }
223 : 0 : else if( (RadioButton *) pBox == &aLeftBtn )
224 : : {
225 : 0 : bRightEnable = bWidthEnable = sal_True;
226 : 0 : aLeftMF.SetPrcntValue(0);
227 : : }
228 : 0 : else if( (RadioButton *) pBox == &aFromLeftBtn )
229 : : {
230 : 0 : bLeftEnable = bWidthEnable = sal_True;
231 : 0 : aRightMF.SetPrcntValue(0);
232 : : }
233 : 0 : else if( (RadioButton *) pBox == &aRightBtn )
234 : : {
235 : 0 : bLeftEnable = bWidthEnable = sal_True;
236 : 0 : aRightMF.SetPrcntValue(0);
237 : : }
238 : 0 : else if( ( RadioButton * ) pBox == &aCenterBtn )
239 : : {
240 : 0 : bLeftEnable = bWidthEnable = sal_True;
241 : : }
242 : 0 : else if( ( RadioButton * ) pBox == &aFreeBtn )
243 : : {
244 : 0 : RightModify();
245 : 0 : bLeftEnable = sal_True;
246 : 0 : bWidthEnable = sal_True;
247 : 0 : bOthers = sal_False;
248 : : }
249 : 0 : aLeftMF.Enable(bLeftEnable);
250 : 0 : aLeftFT.Enable(bLeftEnable);
251 : 0 : aWidthMF.Enable(bWidthEnable);
252 : 0 : aWidthFT.Enable(bWidthEnable);
253 : 0 : if ( bOthers )
254 : : {
255 : 0 : aRightMF.Enable(bRightEnable);
256 : 0 : aRightFT.Enable(bRightEnable);
257 : 0 : aRelWidthCB.Enable(bWidthEnable);
258 : : }
259 : :
260 : 0 : if(bFull && bRestore)
261 : : {
262 : : // nachdem auf autom. geschaltet wurde, wurde die Breite gemerkt,
263 : : // um sie beim Zurueckschalten restaurieren zu koennen
264 : 0 : bFull = sal_False;
265 : 0 : aWidthMF.SetPrcntValue(aWidthMF.NormalizePercent(nSaveWidth ), FUNIT_TWIP );
266 : : }
267 : 0 : ModifyHdl(&aWidthMF);
268 : 0 : bModified = sal_True;
269 : 0 : return 0;
270 : : }
271 : :
272 : : /*----------------------------------------------------------------------*/
273 : 0 : void SwFormatTablePage::RightModify()
274 : : {
275 : 0 : if(aFreeBtn.IsChecked())
276 : : {
277 : 0 : sal_Bool bEnable = aRightMF.GetValue() == 0;
278 : 0 : aRelWidthCB.Enable(bEnable);
279 : 0 : if ( !bEnable )
280 : : {
281 : 0 : aRelWidthCB.Check(sal_False);
282 : 0 : RelWidthClickHdl(&aRelWidthCB);
283 : : }
284 : 0 : bEnable = aRelWidthCB.IsChecked();
285 : 0 : aRightMF.Enable(!bEnable);
286 : 0 : aRightFT.Enable(!bEnable);
287 : : }
288 : 0 : }
289 : :
290 : :
291 : 0 : IMPL_LINK_INLINE_START( SwFormatTablePage, UpDownLoseFocusHdl, MetricField *, pEdit )
292 : : {
293 : 0 : if( &aRightMF == pEdit)
294 : 0 : RightModify();
295 : 0 : ModifyHdl( pEdit );
296 : 0 : return 0;
297 : : }
298 : 0 : IMPL_LINK_INLINE_END( SwFormatTablePage, UpDownLoseFocusHdl, MetricField *, pEdit )
299 : :
300 : 0 : void SwFormatTablePage::ModifyHdl( Edit* pEdit )
301 : : {
302 : :
303 : 0 : SwTwips nCurWidth = static_cast< SwTwips >(aWidthMF.DenormalizePercent(aWidthMF.GetValue( FUNIT_TWIP )));
304 : 0 : SwTwips nPrevWidth = nCurWidth;
305 : 0 : SwTwips nRight = static_cast< SwTwips >(aRightMF.DenormalizePercent(aRightMF.GetValue( FUNIT_TWIP )));
306 : 0 : SwTwips nLeft = static_cast< SwTwips >(aLeftMF.DenormalizePercent(aLeftMF.GetValue( FUNIT_TWIP )));
307 : : SwTwips nDiff;
308 : :
309 : 0 : if( pEdit == &aWidthMF )
310 : : {
311 : 0 : if( nCurWidth < MINLAY )
312 : 0 : nCurWidth = MINLAY;
313 : 0 : nDiff = nRight + nLeft + nCurWidth - pTblData->GetSpace() ;
314 : : //rechtsbuendig nur linken Rand veraendern
315 : 0 : if(aRightBtn.IsChecked())
316 : 0 : nLeft -= nDiff;
317 : : //linksbuendig nur rechten Rand veraendern
318 : 0 : else if(aLeftBtn.IsChecked())
319 : 0 : nRight -= nDiff;
320 : : //linker Rand und Breite erlaubt - erst rechts - dann links
321 : 0 : else if(aFromLeftBtn.IsChecked())
322 : : {
323 : 0 : if( nRight >= nDiff )
324 : 0 : nRight -= nDiff;
325 : : else
326 : : {
327 : 0 : nDiff -= nRight;
328 : 0 : nRight = 0;
329 : 0 : if(nLeft >= nDiff)
330 : 0 : nLeft -= nDiff;
331 : : else
332 : : {
333 : 0 : nRight += nLeft - nDiff;
334 : 0 : nLeft = 0;
335 : 0 : nCurWidth = pTblData->GetSpace();
336 : : }
337 : :
338 : : }
339 : : }
340 : : //zentriert beide Seiten gleichmaessig veraendern
341 : 0 : else if(aCenterBtn.IsChecked())
342 : : {
343 : 0 : if((nLeft != nRight))
344 : : {
345 : 0 : nDiff += nLeft + nRight;
346 : 0 : nLeft = nDiff/2;
347 : 0 : nRight = nDiff/2;
348 : : }
349 : : else
350 : : {
351 : 0 : nLeft -= nDiff/2;
352 : 0 : nRight -= nDiff/2;
353 : : }
354 : : }
355 : : //freie Ausrichtung: beide Raender verkleinern
356 : 0 : else if(aFreeBtn.IsChecked())
357 : : {
358 : 0 : nLeft -= nDiff/2;
359 : 0 : nRight -= nDiff/2;
360 : : }
361 : : }
362 : 0 : if( pEdit == &aRightMF )
363 : : {
364 : :
365 : 0 : if( nRight + nLeft > pTblData->GetSpace() - MINLAY )
366 : 0 : nRight = pTblData->GetSpace() -nLeft - MINLAY;
367 : :
368 : 0 : nCurWidth = pTblData->GetSpace() - nLeft - nRight;
369 : : }
370 : 0 : if( pEdit == &aLeftMF )
371 : : {
372 : 0 : if(!aFromLeftBtn.IsChecked())
373 : : {
374 : 0 : sal_Bool bCenter = aCenterBtn.IsChecked();
375 : 0 : if( bCenter )
376 : 0 : nRight = nLeft;
377 : 0 : if(nRight + nLeft > pTblData->GetSpace() - MINLAY )
378 : : {
379 : 0 : nLeft = bCenter ? (pTblData->GetSpace() - MINLAY) /2 :
380 : 0 : (pTblData->GetSpace() - MINLAY) - nRight;
381 : 0 : nRight = bCenter ? (pTblData->GetSpace() - MINLAY) /2 : nRight;
382 : : }
383 : 0 : nCurWidth = pTblData->GetSpace() - nLeft - nRight;
384 : : }
385 : : else
386 : : {
387 : : //hier wird bei Aenderung an der linken Seite zuerst der
388 : : //rechte Rand veraendert, dann die Breite
389 : 0 : nDiff = nRight + nLeft + nCurWidth - pTblData->GetSpace() ;
390 : :
391 : 0 : nRight -= nDiff;
392 : 0 : nCurWidth = pTblData->GetSpace() - nLeft - nRight;
393 : : }
394 : : }
395 : 0 : if (nCurWidth != nPrevWidth )
396 : 0 : aWidthMF.SetPrcntValue( aWidthMF.NormalizePercent( nCurWidth ), FUNIT_TWIP );
397 : 0 : aRightMF.SetPrcntValue( aRightMF.NormalizePercent( nRight ), FUNIT_TWIP );
398 : 0 : aLeftMF.SetPrcntValue( aLeftMF.NormalizePercent( nLeft ), FUNIT_TWIP );
399 : 0 : bModified = sal_True;
400 : 0 : }
401 : :
402 : :
403 : 0 : SfxTabPage* SwFormatTablePage::Create( Window* pParent,
404 : : const SfxItemSet& rAttrSet)
405 : : {
406 : 0 : return new SwFormatTablePage( pParent, rAttrSet );
407 : : }
408 : :
409 : :
410 : 0 : sal_Bool SwFormatTablePage::FillItemSet( SfxItemSet& rCoreSet )
411 : : {
412 : : // Testen, ob eins der Control noch den Focus hat
413 : 0 : if(aWidthMF.HasFocus())
414 : 0 : ModifyHdl(&aWidthMF);
415 : 0 : else if(aLeftMF.HasFocus())
416 : 0 : ModifyHdl(&aLeftMF);
417 : 0 : else if(aRightMF.HasFocus())
418 : 0 : ModifyHdl(&aRightMF);
419 : 0 : else if(aTopMF.HasFocus())
420 : 0 : ModifyHdl(&aTopMF);
421 : 0 : else if(aBottomMF.HasFocus())
422 : 0 : ModifyHdl(&aBottomMF);
423 : :
424 : 0 : if(bModified)
425 : : {
426 : 0 : if( aBottomMF.GetText() != aBottomMF.GetSavedValue() ||
427 : 0 : aTopMF.GetText() != aTopMF.GetSavedValue() )
428 : : {
429 : 0 : SvxULSpaceItem aULSpace(RES_UL_SPACE);
430 : : aULSpace.SetUpper( (sal_uInt16) aTopMF.Denormalize(
431 : 0 : aTopMF.GetValue( FUNIT_TWIP )));
432 : : aULSpace.SetLower( (sal_uInt16) aBottomMF.Denormalize(
433 : 0 : aBottomMF.GetValue( FUNIT_TWIP )));
434 : 0 : rCoreSet.Put(aULSpace);
435 : : }
436 : :
437 : : }
438 : 0 : if(aNameED.GetText() != aNameED.GetSavedValue())
439 : : {
440 : 0 : rCoreSet.Put(SfxStringItem( FN_PARAM_TABLE_NAME, aNameED.GetText()));
441 : 0 : bModified = sal_True;
442 : : }
443 : :
444 : : sal_uInt16 nPos;
445 : 0 : if( aTextDirectionLB.IsVisible() &&
446 : 0 : ( nPos = aTextDirectionLB.GetSelectEntryPos() ) !=
447 : 0 : aTextDirectionLB.GetSavedValue() )
448 : : {
449 : 0 : sal_uInt32 nDirection = (sal_uInt32)(sal_uIntPtr)aTextDirectionLB.GetEntryData( nPos );
450 : 0 : rCoreSet.Put( SvxFrameDirectionItem( (SvxFrameDirection)nDirection, RES_FRAMEDIR));
451 : 0 : bModified = sal_True;
452 : : }
453 : :
454 : 0 : return bModified;
455 : : }
456 : :
457 : :
458 : 0 : void SwFormatTablePage::Reset( const SfxItemSet& )
459 : : {
460 : 0 : const SfxItemSet& rSet = GetItemSet();
461 : : const SfxPoolItem* pItem;
462 : :
463 : 0 : if(bHtmlMode)
464 : : {
465 : 0 : aNameED .Disable();
466 : 0 : aTopFT .Hide();
467 : 0 : aTopMF .Hide();
468 : 0 : aBottomFT.Hide();
469 : 0 : aBottomMF.Hide();
470 : 0 : aFreeBtn.Enable(sal_False);
471 : : }
472 : 0 : FieldUnit aMetric = ::GetDfltMetric(bHtmlMode);
473 : 0 : SetMetric( aWidthMF, aMetric );
474 : 0 : SetMetric( aRightMF, aMetric );
475 : 0 : SetMetric( aLeftMF, aMetric );
476 : 0 : SetMetric( aTopMF, aMetric );
477 : 0 : SetMetric( aBottomMF, aMetric );
478 : :
479 : : //Name
480 : 0 : if(SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_NAME, sal_False, &pItem ))
481 : : {
482 : 0 : aNameED.SetText(((const SfxStringItem*)pItem)->GetValue());
483 : 0 : aNameED.SaveValue();
484 : : }
485 : :
486 : 0 : if(SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_REP, sal_False, &pItem ))
487 : : {
488 : 0 : pTblData = (SwTableRep*)((const SwPtrItem*) pItem)->GetValue();
489 : 0 : nMinTableWidth = pTblData->GetColCount() * MINLAY;
490 : :
491 : 0 : if(pTblData->GetWidthPercent())
492 : : {
493 : 0 : aRelWidthCB.Check(sal_True);
494 : 0 : RelWidthClickHdl(&aRelWidthCB);
495 : 0 : aWidthMF.SetPrcntValue(pTblData->GetWidthPercent(), FUNIT_CUSTOM);
496 : :
497 : 0 : aWidthMF.SaveValue();
498 : 0 : nSaveWidth = static_cast< SwTwips >(aWidthMF.GetValue(FUNIT_CUSTOM));
499 : : }
500 : : else
501 : : {
502 : : aWidthMF.SetPrcntValue(aWidthMF.NormalizePercent(
503 : 0 : pTblData->GetWidth()), FUNIT_TWIP);
504 : 0 : aWidthMF.SaveValue();
505 : 0 : nSaveWidth = pTblData->GetWidth();
506 : 0 : nMinTableWidth = Min( nSaveWidth, nMinTableWidth );
507 : : }
508 : :
509 : 0 : aWidthMF.SetRefValue(pTblData->GetSpace());
510 : 0 : aWidthMF.SetLast(aWidthMF.NormalizePercent( pTblData->GetSpace() ));
511 : 0 : aLeftMF.SetLast(aLeftMF.NormalizePercent( pTblData->GetSpace() ));
512 : 0 : aRightMF.SetLast(aRightMF.NormalizePercent( pTblData->GetSpace() ));
513 : :
514 : : aLeftMF.SetPrcntValue(aLeftMF.NormalizePercent(
515 : 0 : pTblData->GetLeftSpace()), FUNIT_TWIP);
516 : : aRightMF.SetPrcntValue(aRightMF.NormalizePercent(
517 : 0 : pTblData->GetRightSpace()), FUNIT_TWIP);
518 : 0 : aLeftMF.SaveValue();
519 : 0 : aRightMF.SaveValue();
520 : :
521 : 0 : nOldAlign = pTblData->GetAlign();
522 : :
523 : 0 : sal_Bool bSetRight = sal_False, bRightEnable = sal_False,
524 : 0 : bSetLeft = sal_False, bLeftEnable = sal_False;
525 : 0 : switch( nOldAlign )
526 : : {
527 : : case text::HoriOrientation::NONE:
528 : 0 : aFreeBtn.Check();
529 : 0 : if(aRelWidthCB.IsChecked())
530 : 0 : bSetRight = sal_True;
531 : 0 : break;
532 : : case text::HoriOrientation::FULL:
533 : : {
534 : 0 : bSetRight = bSetLeft = sal_True;
535 : 0 : aFullBtn.Check();
536 : 0 : aWidthMF.Enable(sal_False);
537 : 0 : aRelWidthCB.Enable(sal_False);
538 : 0 : aWidthFT.Enable(sal_False);
539 : : }
540 : 0 : break;
541 : : case text::HoriOrientation::LEFT:
542 : : {
543 : 0 : bSetLeft = sal_True;
544 : 0 : aLeftBtn.Check();
545 : : }
546 : 0 : break;
547 : : case text::HoriOrientation::LEFT_AND_WIDTH :
548 : : {
549 : 0 : bSetRight = sal_True;
550 : 0 : aFromLeftBtn.Check();
551 : : }
552 : 0 : break;
553 : : case text::HoriOrientation::RIGHT:
554 : : {
555 : 0 : bSetRight = sal_True;
556 : 0 : aRightBtn.Check();
557 : : }
558 : 0 : break;
559 : : case text::HoriOrientation::CENTER:
560 : : {
561 : 0 : bSetRight = sal_True;
562 : 0 : aCenterBtn.Check();
563 : : }
564 : 0 : break;
565 : : }
566 : 0 : if ( bSetRight )
567 : : {
568 : 0 : aRightMF.Enable(bRightEnable);
569 : 0 : aRightFT.Enable(bRightEnable);
570 : : }
571 : 0 : if ( bSetLeft )
572 : : {
573 : 0 : aLeftMF.Enable(bLeftEnable);
574 : 0 : aLeftFT.Enable(bLeftEnable);
575 : : }
576 : :
577 : : }
578 : :
579 : : //Raender
580 : 0 : if(SFX_ITEM_SET == rSet.GetItemState( RES_UL_SPACE, sal_False,&pItem ))
581 : : {
582 : : aTopMF.SetValue(aTopMF.Normalize(
583 : 0 : ((const SvxULSpaceItem*)pItem)->GetUpper()), FUNIT_TWIP);
584 : : aBottomMF.SetValue(aBottomMF.Normalize(
585 : 0 : ((const SvxULSpaceItem*)pItem)->GetLower()), FUNIT_TWIP);
586 : 0 : aTopMF.SaveValue();
587 : 0 : aBottomMF.SaveValue();
588 : : }
589 : :
590 : : //text direction
591 : 0 : if( SFX_ITEM_SET == rSet.GetItemState( RES_FRAMEDIR, sal_True, &pItem ) )
592 : : {
593 : 0 : sal_uIntPtr nVal = ((SvxFrameDirectionItem*)pItem)->GetValue();
594 : 0 : sal_uInt16 nPos = aTextDirectionLB.GetEntryPos( (void*) nVal );
595 : 0 : aTextDirectionLB.SelectEntryPos( nPos );
596 : 0 : aTextDirectionLB.SaveValue();
597 : : }
598 : :
599 : 0 : aWidthMF.SetMax( 2*aWidthMF.NormalizePercent( pTblData->GetSpace() ), FUNIT_TWIP );
600 : 0 : aRightMF.SetMax( aRightMF.NormalizePercent( pTblData->GetSpace() ), FUNIT_TWIP );
601 : 0 : aLeftMF.SetMax( aLeftMF.NormalizePercent( pTblData->GetSpace() ), FUNIT_TWIP );
602 : 0 : aWidthMF.SetMin( aWidthMF.NormalizePercent( nMinTableWidth ), FUNIT_TWIP );
603 : :
604 : 0 : }
605 : :
606 : :
607 : 0 : void SwFormatTablePage::ActivatePage( const SfxItemSet& rSet )
608 : : {
609 : : OSL_ENSURE(pTblData, "table data not available?");
610 : 0 : if(SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_REP ))
611 : : {
612 : 0 : SwTwips nCurWidth = text::HoriOrientation::FULL != pTblData->GetAlign() ?
613 : 0 : pTblData->GetWidth() :
614 : 0 : pTblData->GetSpace();
615 : 0 : if(pTblData->GetWidthPercent() == 0 &&
616 : 0 : nCurWidth != aWidthMF.DenormalizePercent(aWidthMF.GetValue(FUNIT_TWIP )))
617 : : {
618 : : aWidthMF.SetPrcntValue(aWidthMF.NormalizePercent(
619 : 0 : nCurWidth), FUNIT_TWIP);
620 : 0 : aWidthMF.SaveValue();
621 : 0 : nSaveWidth = nCurWidth;
622 : : aLeftMF.SetPrcntValue(aLeftMF.NormalizePercent(
623 : 0 : pTblData->GetLeftSpace()), FUNIT_TWIP);
624 : 0 : aLeftMF.SaveValue();
625 : : aRightMF.SetPrcntValue(aRightMF.NormalizePercent(
626 : 0 : pTblData->GetRightSpace()), FUNIT_TWIP);
627 : 0 : aRightMF.SaveValue();
628 : : }
629 : : }
630 : :
631 : 0 : }
632 : :
633 : 0 : int SwFormatTablePage::DeactivatePage( SfxItemSet* _pSet )
634 : : {
635 : : // os: VCL sorgt nicht dafuer, dass das aktive Control im
636 : : // dialog bei OK den focus verliert
637 : 0 : aNameED.GrabFocus();
638 : : // Test des Tabellennamens auf Leerzeichen
639 : 0 : String sTblName = aNameED.GetText();
640 : 0 : if(sTblName.Search(' ') != STRING_NOTFOUND)
641 : : {
642 : 0 : InfoBox(this, SW_RES(MSG_WRONG_TABLENAME)).Execute();
643 : 0 : aNameED.GrabFocus();
644 : 0 : return KEEP_PAGE;
645 : : }
646 : 0 : if(_pSet)
647 : : {
648 : 0 : FillItemSet(*_pSet);
649 : 0 : if(bModified)
650 : : {
651 : 0 : SwTwips lLeft = static_cast< SwTwips >(aLeftMF.DenormalizePercent(aLeftMF.GetValue( FUNIT_TWIP )));
652 : 0 : SwTwips lRight = static_cast< SwTwips >(aRightMF.DenormalizePercent(aRightMF.GetValue( FUNIT_TWIP )));
653 : :
654 : :
655 : 0 : if( aLeftMF.GetText() != aLeftMF.GetSavedValue() ||
656 : 0 : aRightMF.GetText() != aRightMF.GetSavedValue() )
657 : : {
658 : 0 : pTblData->SetWidthChanged();
659 : 0 : pTblData->SetLeftSpace( lLeft);
660 : 0 : pTblData->SetRightSpace( lRight);
661 : : }
662 : :
663 : : SwTwips lWidth;
664 : 0 : if (aRelWidthCB.IsChecked() && aRelWidthCB.IsEnabled())
665 : : {
666 : 0 : lWidth = pTblData->GetSpace() - lRight - lLeft;
667 : 0 : sal_uInt16 nPercentWidth = (sal_uInt16)aWidthMF.GetValue(FUNIT_CUSTOM);
668 : 0 : if(pTblData->GetWidthPercent() != nPercentWidth)
669 : : {
670 : 0 : pTblData->SetWidthPercent(nPercentWidth);
671 : 0 : pTblData->SetWidthChanged();
672 : : }
673 : : }
674 : : else
675 : : {
676 : 0 : pTblData->SetWidthPercent(0);
677 : 0 : lWidth = static_cast< SwTwips >(aWidthMF.DenormalizePercent(aWidthMF.GetValue( FUNIT_TWIP )));
678 : : }
679 : 0 : pTblData->SetWidth(lWidth);
680 : :
681 : 0 : SwTwips nColSum = 0;
682 : : sal_uInt16 i;
683 : :
684 : 0 : for( i = 0; i < pTblData->GetColCount(); i++)
685 : : {
686 : 0 : nColSum += pTblData->GetColumns()[i].nWidth;
687 : : }
688 : 0 : if(nColSum != pTblData->GetWidth())
689 : : {
690 : : SwTwips nMinWidth = Min( (long)MINLAY,
691 : 0 : (long) (pTblData->GetWidth() /
692 : 0 : pTblData->GetColCount() - 1));
693 : 0 : SwTwips nDiff = nColSum - pTblData->GetWidth();
694 : 0 : while ( Abs(nDiff) > pTblData->GetColCount() + 1 )
695 : : {
696 : 0 : SwTwips nSub = nDiff / pTblData->GetColCount();
697 : 0 : for( i = 0; i < pTblData->GetColCount(); i++)
698 : : {
699 : 0 : if(pTblData->GetColumns()[i].nWidth - nMinWidth > nSub)
700 : : {
701 : 0 : pTblData->GetColumns()[i].nWidth -= nSub;
702 : 0 : nDiff -= nSub;
703 : : }
704 : : else
705 : : {
706 : 0 : nDiff -= pTblData->GetColumns()[i].nWidth - nMinWidth;
707 : 0 : pTblData->GetColumns()[i].nWidth = nMinWidth;
708 : : }
709 : :
710 : : }
711 : : }
712 : : }
713 : :
714 : 0 : sal_Int16 nAlign = 0;
715 : 0 : if(aRightBtn.IsChecked())
716 : 0 : nAlign = text::HoriOrientation::RIGHT;
717 : 0 : else if(aLeftBtn.IsChecked())
718 : 0 : nAlign = text::HoriOrientation::LEFT;
719 : 0 : else if(aFromLeftBtn.IsChecked())
720 : 0 : nAlign = text::HoriOrientation::LEFT_AND_WIDTH;
721 : 0 : else if(aCenterBtn.IsChecked())
722 : 0 : nAlign = text::HoriOrientation::CENTER;
723 : 0 : else if(aFreeBtn.IsChecked())
724 : 0 : nAlign = text::HoriOrientation::NONE;
725 : 0 : else if(aFullBtn.IsChecked())
726 : : {
727 : 0 : nAlign = text::HoriOrientation::FULL;
728 : 0 : lWidth = lAutoWidth;
729 : : }
730 : 0 : if(nAlign != pTblData->GetAlign())
731 : : {
732 : 0 : pTblData->SetWidthChanged();
733 : 0 : pTblData->SetAlign(nAlign);
734 : : }
735 : :
736 : 0 : if(pTblData->GetWidth() != lWidth )
737 : : {
738 : 0 : pTblData->SetWidthChanged();
739 : : pTblData->SetWidth(
740 : 0 : nAlign == text::HoriOrientation::FULL ? pTblData->GetSpace() : lWidth );
741 : : }
742 : 0 : if(pTblData->HasWidthChanged())
743 : 0 : _pSet->Put(SwPtrItem(FN_TABLE_REP, pTblData));
744 : : }
745 : : }
746 : 0 : return sal_True;
747 : : }
748 : : /*------------------------------------------------------------------------
749 : : Beschreibung: Seite Spaltenkonfiguration
750 : : ------------------------------------------------------------------------*/
751 : 0 : SwTableColumnPage::SwTableColumnPage( Window* pParent,
752 : : const SfxItemSet& rSet ) :
753 : : SfxTabPage(pParent, SW_RES( TP_TABLE_COLUMN ), rSet ),
754 : : aModifyTableCB(this, SW_RES(CB_MOD_TBL)),
755 : : aProportionalCB(this, SW_RES(CB_PROP)),
756 : : aSpaceFT(this, SW_RES(FT_SPACE)),
757 : : aSpaceED(this, SW_RES(ED_SPACE)),
758 : :
759 : : aColFL(this, SW_RES(COL_FL_LAYOUT)),
760 : : aUpBtn(this, SW_RES(COL_BTN_UP)),
761 : : aFT1(this, SW_RES(COL_FT_1)),
762 : : aMF1(this, SW_RES(COL_MF_1)),
763 : : aFT2(this, SW_RES(COL_FT_2)),
764 : : aMF2(this, SW_RES(COL_MF_2)),
765 : : aFT3(this, SW_RES(COL_FT_3)),
766 : : aMF3(this, SW_RES(COL_MF_3)),
767 : : aFT4(this, SW_RES(COL_FT_4)),
768 : : aMF4(this, SW_RES(COL_MF_4)),
769 : : aFT5(this, SW_RES(COL_FT_5)),
770 : : aMF5(this, SW_RES(COL_MF_5)),
771 : : aFT6(this, SW_RES(COL_FT_6)),
772 : : aMF6(this, SW_RES(COL_MF_6)),
773 : : aDownBtn(this, SW_RES(COL_BTN_DOWN)),
774 : :
775 : : nTableWidth(0),
776 : : nMinWidth( MINLAY ),
777 : : nNoOfCols( 0 ),
778 : : nNoOfVisibleCols( 0 ),
779 : : bModified(sal_False),
780 : : bModifyTbl(sal_False),
781 : 0 : bPercentMode(sal_False)
782 : : {
783 : 0 : FreeResource();
784 : 0 : SetExchangeSupport();
785 : :
786 : 0 : aDownBtn.SetAccessibleRelationMemberOf(&aColFL);
787 : 0 : aUpBtn.SetAccessibleRelationMemberOf(&aColFL);
788 : :
789 : 0 : pFieldArr[0] = &aMF1;
790 : 0 : pFieldArr[1] = &aMF2;
791 : 0 : pFieldArr[2] = &aMF3;
792 : 0 : pFieldArr[3] = &aMF4;
793 : 0 : pFieldArr[4] = &aMF5;
794 : 0 : pFieldArr[5] = &aMF6;
795 : :
796 : 0 : pTextArr[0] = &aFT1;
797 : 0 : pTextArr[1] = &aFT2;
798 : 0 : pTextArr[2] = &aFT3;
799 : 0 : pTextArr[3] = &aFT4;
800 : 0 : pTextArr[4] = &aFT5;
801 : 0 : pTextArr[5] = &aFT6;
802 : :
803 : : const SfxPoolItem* pItem;
804 : 0 : Init((SFX_ITEM_SET == rSet.GetItemState( SID_HTML_MODE, sal_False,&pItem )
805 : 0 : && ((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON));
806 : :
807 : 0 : };
808 : : /*------------------------------------------------------------------------
809 : : Beschreibung: Seite Spaltenkonfiguration
810 : : ------------------------------------------------------------------------*/
811 : 0 : SwTableColumnPage::~SwTableColumnPage()
812 : : {
813 : 0 : };
814 : :
815 : :
816 : 0 : SfxTabPage* SwTableColumnPage::Create( Window* pParent,
817 : : const SfxItemSet& rAttrSet)
818 : : {
819 : 0 : return new SwTableColumnPage( pParent, rAttrSet );
820 : : };
821 : :
822 : :
823 : 0 : void SwTableColumnPage::Reset( const SfxItemSet& )
824 : : {
825 : 0 : const SfxItemSet& rSet = GetItemSet();
826 : :
827 : : const SfxPoolItem* pItem;
828 : 0 : if(SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_REP, sal_False, &pItem ))
829 : : {
830 : 0 : pTblData = (SwTableRep*)((const SwPtrItem*) pItem)->GetValue();
831 : 0 : nNoOfVisibleCols = pTblData->GetColCount();
832 : 0 : nNoOfCols = pTblData->GetAllColCount();
833 : 0 : nTableWidth = pTblData->GetAlign() != text::HoriOrientation::FULL &&
834 : 0 : pTblData->GetAlign() != text::HoriOrientation::LEFT_AND_WIDTH?
835 : 0 : pTblData->GetWidth() : pTblData->GetSpace();
836 : :
837 : : sal_uInt16 i;
838 : 0 : for( i = 0; i < nNoOfCols; i++ )
839 : : {
840 : 0 : if( pTblData->GetColumns()[i].nWidth < nMinWidth )
841 : 0 : nMinWidth = pTblData->GetColumns()[i].nWidth;
842 : : }
843 : 0 : sal_Int64 nMinTwips = pFieldArr[0]->NormalizePercent( nMinWidth );
844 : 0 : sal_Int64 nMaxTwips = pFieldArr[0]->NormalizePercent( nTableWidth );
845 : 0 : for( i = 0; (i < MET_FIELDS) && (i < nNoOfVisibleCols); i++ )
846 : : {
847 : 0 : pFieldArr[i]->SetPrcntValue( pFieldArr[i]->NormalizePercent(
848 : 0 : GetVisibleWidth(i) ), FUNIT_TWIP );
849 : 0 : pFieldArr[i]->SetMin( nMinTwips , FUNIT_TWIP );
850 : 0 : pFieldArr[i]->SetMax( nMaxTwips , FUNIT_TWIP );
851 : 0 : pFieldArr[i]->Enable();
852 : 0 : pTextArr[i]->Enable();
853 : : }
854 : :
855 : 0 : if( nNoOfVisibleCols > MET_FIELDS )
856 : 0 : aUpBtn.Enable();
857 : 0 : i = nNoOfVisibleCols;
858 : 0 : while( i < MET_FIELDS )
859 : : {
860 : 0 : pFieldArr[i]->SetText( aEmptyStr );
861 : 0 : pTextArr[i]->Hide();
862 : 0 : i++;
863 : : }
864 : : }
865 : 0 : ActivatePage(rSet);
866 : :
867 : 0 : };
868 : :
869 : :
870 : 0 : void SwTableColumnPage::Init(sal_Bool bWeb)
871 : : {
872 : 0 : FieldUnit aMetric = ::GetDfltMetric(bWeb);
873 : 0 : Link aLkUp = LINK( this, SwTableColumnPage, UpHdl );
874 : 0 : Link aLkDown = LINK( this, SwTableColumnPage, DownHdl );
875 : 0 : Link aLkLF = LINK( this, SwTableColumnPage, LoseFocusHdl );
876 : 0 : for( sal_uInt16 i = 0; i < MET_FIELDS; i++ )
877 : : {
878 : 0 : aValueTbl[i] = i;
879 : 0 : SetMetric(*pFieldArr[i], aMetric);
880 : 0 : pFieldArr[i]->SetUpHdl( aLkUp );
881 : 0 : pFieldArr[i]->SetDownHdl( aLkDown );
882 : 0 : pFieldArr[i]->SetLoseFocusHdl( aLkLF );
883 : :
884 : : }
885 : 0 : SetMetric(aSpaceED, aMetric);
886 : :
887 : 0 : Link aLk = LINK( this, SwTableColumnPage, AutoClickHdl );
888 : 0 : aUpBtn.SetClickHdl( aLk );
889 : 0 : aDownBtn.SetClickHdl( aLk );
890 : :
891 : 0 : aLk = LINK( this, SwTableColumnPage, ModeHdl );
892 : 0 : aModifyTableCB .SetClickHdl( aLk );
893 : 0 : aProportionalCB.SetClickHdl( aLk );
894 : 0 : };
895 : :
896 : :
897 : 0 : IMPL_LINK( SwTableColumnPage, AutoClickHdl, CheckBox *, pBox )
898 : : {
899 : : //Anzeigefenster verschieben
900 : 0 : if(pBox == (CheckBox *)&aDownBtn)
901 : : {
902 : 0 : if(aValueTbl[0] > 0)
903 : : {
904 : 0 : for( sal_uInt16 i=0; i < MET_FIELDS; i++ )
905 : 0 : aValueTbl[i] -= 1;
906 : : }
907 : : }
908 : 0 : if(pBox == (CheckBox *)&aUpBtn)
909 : : {
910 : 0 : if( aValueTbl[ MET_FIELDS -1 ] < nNoOfVisibleCols -1 )
911 : : {
912 : 0 : for(sal_uInt16 i=0;i < MET_FIELDS;i++)
913 : 0 : aValueTbl[i] += 1;
914 : : }
915 : : }
916 : 0 : for( sal_uInt16 i = 0; (i < nNoOfVisibleCols ) && ( i < MET_FIELDS); i++ )
917 : : {
918 : 0 : String sEntry = rtl::OUString('~');
919 : 0 : String sIndex = String::CreateFromInt32( aValueTbl[i] + 1 );
920 : 0 : sEntry += sIndex;
921 : 0 : pTextArr[i]->SetText( sEntry );
922 : :
923 : : //added by menghu for SODC_5143,12/12/2006
924 : 0 : String sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH);
925 : 0 : sColumnWidth.SearchAndReplace( DEFINE_CONST_UNICODE("%1"), sIndex );
926 : 0 : pFieldArr[i]->SetAccessibleName( sColumnWidth );
927 : 0 : }
928 : :
929 : 0 : aDownBtn.Enable(aValueTbl[0] > 0);
930 : 0 : aUpBtn.Enable(aValueTbl[ MET_FIELDS -1 ] < nNoOfVisibleCols -1 );
931 : 0 : UpdateCols(0);
932 : 0 : return 0;
933 : : };
934 : :
935 : :
936 : 0 : IMPL_LINK_INLINE_START( SwTableColumnPage, UpHdl, PercentField *, pEdit )
937 : : {
938 : 0 : bModified = sal_True;
939 : 0 : ModifyHdl( pEdit );
940 : 0 : return 0;
941 : : };
942 : 0 : IMPL_LINK_INLINE_END( SwTableColumnPage, UpHdl, PercentField *, pEdit )
943 : :
944 : :
945 : 0 : IMPL_LINK_INLINE_START( SwTableColumnPage, DownHdl, PercentField *, pEdit )
946 : : {
947 : 0 : bModified = sal_True;
948 : 0 : ModifyHdl( pEdit );
949 : 0 : return 0;
950 : : };
951 : 0 : IMPL_LINK_INLINE_END( SwTableColumnPage, DownHdl, PercentField *, pEdit )
952 : :
953 : :
954 : 0 : IMPL_LINK_INLINE_START( SwTableColumnPage, LoseFocusHdl, PercentField *, pEdit )
955 : : {
956 : 0 : if(pEdit->IsModified())
957 : : {
958 : 0 : bModified = sal_True;
959 : 0 : ModifyHdl( pEdit );
960 : : }
961 : 0 : return 0;
962 : : };
963 : 0 : IMPL_LINK_INLINE_END( SwTableColumnPage, LoseFocusHdl, PercentField *, pEdit )
964 : :
965 : :
966 : 0 : IMPL_LINK( SwTableColumnPage, ModeHdl, CheckBox*, pBox )
967 : : {
968 : 0 : sal_Bool bCheck = pBox->IsChecked();
969 : 0 : if(pBox == &aProportionalCB)
970 : : {
971 : 0 : if(bCheck)
972 : 0 : aModifyTableCB.Check();
973 : 0 : aModifyTableCB.Enable(!bCheck && bModifyTbl);
974 : : }
975 : 0 : return 0;
976 : : };
977 : :
978 : :
979 : 0 : sal_Bool SwTableColumnPage::FillItemSet( SfxItemSet& )
980 : : {
981 : 0 : for( sal_uInt16 i = 0; i < MET_FIELDS; i++ )
982 : : {
983 : 0 : if(pFieldArr[i]->HasFocus())
984 : : {
985 : 0 : LoseFocusHdl(pFieldArr[i]);
986 : 0 : break;
987 : : }
988 : : }
989 : :
990 : 0 : if(bModified)
991 : : {
992 : 0 : pTblData->SetColsChanged();
993 : : }
994 : 0 : return bModified;
995 : : };
996 : :
997 : :
998 : 0 : void SwTableColumnPage::ModifyHdl( PercentField* pEdit )
999 : : {
1000 : : sal_uInt16 nAktPos;
1001 : : sal_uInt16 i;
1002 : :
1003 : 0 : for( i = 0; i < MET_FIELDS; i++)
1004 : 0 : if(pEdit == pFieldArr[i])
1005 : 0 : break;
1006 : :
1007 : 0 : if (MET_FIELDS <= i)
1008 : : {
1009 : : OSL_ENSURE(false, "cannot happen.");
1010 : 0 : return;
1011 : : }
1012 : :
1013 : 0 : SetVisibleWidth(aValueTbl[i], static_cast< SwTwips >(pEdit->DenormalizePercent(pEdit->GetValue( FUNIT_TWIP ))) );
1014 : 0 : nAktPos = aValueTbl[i];
1015 : :
1016 : 0 : UpdateCols( nAktPos );
1017 : : };
1018 : :
1019 : :
1020 : 0 : void SwTableColumnPage::UpdateCols( sal_uInt16 nAktPos )
1021 : : {
1022 : 0 : SwTwips nSum = 0;
1023 : : sal_uInt16 i;
1024 : :
1025 : 0 : for( i = 0; i < nNoOfCols; i++ )
1026 : : {
1027 : 0 : nSum += (pTblData->GetColumns())[i].nWidth;
1028 : : }
1029 : 0 : SwTwips nDiff = nSum - nTableWidth;
1030 : :
1031 : 0 : sal_Bool bModifyTable = aModifyTableCB.IsChecked();
1032 : 0 : sal_Bool bProp = aProportionalCB.IsChecked();
1033 : :
1034 : 0 : if(!bModifyTable && !bProp )
1035 : : {
1036 : : // the table width is constant, the difference is balanced with the other columns
1037 : 0 : sal_uInt16 nLoopCount = 0;
1038 : 0 : while( nDiff )
1039 : : {
1040 : 0 : if( ++nAktPos == nNoOfVisibleCols)
1041 : : {
1042 : 0 : nAktPos = 0;
1043 : 0 : ++nLoopCount;
1044 : : //#i101353# in small tables it might not be possible to balance column width
1045 : 0 : if( nLoopCount > 1 )
1046 : 0 : break;
1047 : : }
1048 : 0 : if( nDiff < 0 )
1049 : : {
1050 : 0 : SetVisibleWidth(nAktPos, GetVisibleWidth(nAktPos) -nDiff);
1051 : 0 : nDiff = 0;
1052 : : }
1053 : 0 : else if( GetVisibleWidth(nAktPos) >= nDiff + nMinWidth )
1054 : : {
1055 : 0 : SetVisibleWidth(nAktPos, GetVisibleWidth(nAktPos) -nDiff);
1056 : 0 : nDiff = 0;
1057 : : }
1058 : 0 : if( nDiff > 0 && GetVisibleWidth(nAktPos) > nMinWidth )
1059 : : {
1060 : 0 : if( nDiff >= (GetVisibleWidth(nAktPos) - nMinWidth) )
1061 : : {
1062 : 0 : nDiff -= (GetVisibleWidth(nAktPos) - nMinWidth);
1063 : 0 : SetVisibleWidth(nAktPos, nMinWidth);
1064 : : }
1065 : : else
1066 : : {
1067 : 0 : nDiff = 0;
1068 : 0 : SetVisibleWidth(nAktPos, GetVisibleWidth(nAktPos) -nDiff);
1069 : : }
1070 : : OSL_ENSURE(nDiff >= 0, "nDiff < 0 cannot be here!");
1071 : : }
1072 : 0 : }
1073 : : }
1074 : 0 : else if(bModifyTable && !bProp)
1075 : : {
1076 : : // Differenz wird ueber die Tabellenbreite ausgeglichen,
1077 : : // andere Spalten bleiben unveraendert
1078 : : OSL_ENSURE(nDiff <= pTblData->GetSpace() - nTableWidth, "wrong maximum" );
1079 : 0 : SwTwips nActSpace = pTblData->GetSpace() - nTableWidth;
1080 : 0 : if(nDiff > nActSpace)
1081 : : {
1082 : 0 : nTableWidth = pTblData->GetSpace();
1083 : 0 : SetVisibleWidth(nAktPos, GetVisibleWidth(nAktPos) - nDiff + nActSpace );
1084 : : }
1085 : : else
1086 : : {
1087 : 0 : nTableWidth += nDiff;
1088 : 0 : }
1089 : : }
1090 : 0 : else if(bModifyTable & bProp)
1091 : : {
1092 : : // Alle Spalten werden proportional mitveraendert, die Tabellenbreite wird
1093 : : // entsprechend angepasst
1094 : : OSL_ENSURE(nDiff * nNoOfVisibleCols <= pTblData->GetSpace() - nTableWidth, "wrong maximum" );
1095 : 0 : long nAdd = nDiff;
1096 : 0 : if(nDiff * nNoOfVisibleCols > pTblData->GetSpace() - nTableWidth)
1097 : : {
1098 : 0 : nAdd = (pTblData->GetSpace() - nTableWidth) / nNoOfVisibleCols;
1099 : 0 : SetVisibleWidth(nAktPos, GetVisibleWidth(nAktPos) - nDiff + nAdd );
1100 : 0 : nDiff = nAdd;
1101 : : }
1102 : 0 : if(nAdd)
1103 : 0 : for(i = 0; i < nNoOfVisibleCols; i++ )
1104 : : {
1105 : 0 : if(i == nAktPos)
1106 : 0 : continue;
1107 : : SwTwips nVisWidth;
1108 : 0 : if((nVisWidth = GetVisibleWidth(i)) + nDiff < MINLAY)
1109 : : {
1110 : 0 : nAdd += nVisWidth - MINLAY;
1111 : 0 : SetVisibleWidth(i, MINLAY);
1112 : : }
1113 : : else
1114 : : {
1115 : 0 : SetVisibleWidth(i, nVisWidth + nDiff);
1116 : 0 : nAdd += nDiff;
1117 : : }
1118 : :
1119 : : }
1120 : 0 : nTableWidth += nAdd;
1121 : : }
1122 : :
1123 : 0 : if(!bPercentMode)
1124 : 0 : aSpaceED.SetValue(aSpaceED.Normalize( pTblData->GetSpace() - nTableWidth) , FUNIT_TWIP);
1125 : :
1126 : 0 : for( i = 0; ( i < nNoOfVisibleCols ) && ( i < MET_FIELDS ); i++)
1127 : : {
1128 : 0 : pFieldArr[i]->SetPrcntValue(pFieldArr[i]->NormalizePercent(
1129 : 0 : GetVisibleWidth(aValueTbl[i]) ), FUNIT_TWIP);
1130 : 0 : pFieldArr[i]->ClearModifyFlag();
1131 : : }
1132 : :
1133 : 0 : }
1134 : :
1135 : :
1136 : 0 : void SwTableColumnPage::ActivatePage( const SfxItemSet& )
1137 : : {
1138 : 0 : bPercentMode = pTblData->GetWidthPercent() != 0;
1139 : 0 : for( sal_uInt16 i = 0; (i < MET_FIELDS) && (i < nNoOfVisibleCols); i++ )
1140 : : {
1141 : 0 : pFieldArr[i]->SetRefValue(pTblData->GetWidth());
1142 : 0 : pFieldArr[i]->ShowPercent( bPercentMode );
1143 : : }
1144 : :
1145 : 0 : sal_uInt16 nTblAlign = pTblData->GetAlign();
1146 : 0 : if((text::HoriOrientation::FULL != nTblAlign && nTableWidth != pTblData->GetWidth()) ||
1147 : 0 : (text::HoriOrientation::FULL == nTblAlign && nTableWidth != pTblData->GetSpace()))
1148 : : {
1149 : : nTableWidth = text::HoriOrientation::FULL == nTblAlign ?
1150 : 0 : pTblData->GetSpace() :
1151 : 0 : pTblData->GetWidth();
1152 : 0 : UpdateCols(0);
1153 : : }
1154 : 0 : bModifyTbl = sal_True;
1155 : 0 : if(pTblData->GetWidthPercent() ||
1156 : : text::HoriOrientation::FULL == nTblAlign ||
1157 : 0 : pTblData->IsLineSelected() )
1158 : 0 : bModifyTbl = sal_False;
1159 : 0 : if(bPercentMode)
1160 : : {
1161 : 0 : aModifyTableCB .Check(sal_False);
1162 : 0 : aProportionalCB .Check(sal_False);
1163 : : }
1164 : 0 : else if( !bModifyTbl )
1165 : : {
1166 : 0 : aProportionalCB.Check(sal_False);
1167 : 0 : aModifyTableCB.Check(sal_False);
1168 : : }
1169 : 0 : aSpaceFT.Enable(!bPercentMode);
1170 : 0 : aSpaceED.Enable(!bPercentMode);
1171 : 0 : aModifyTableCB.Enable( !bPercentMode && bModifyTbl );
1172 : 0 : aProportionalCB.Enable(!bPercentMode && bModifyTbl );
1173 : :
1174 : : aSpaceED.SetValue(aSpaceED.Normalize(
1175 : 0 : pTblData->GetSpace() - nTableWidth) , FUNIT_TWIP);
1176 : :
1177 : 0 : }
1178 : :
1179 : :
1180 : 0 : int SwTableColumnPage::DeactivatePage( SfxItemSet* _pSet )
1181 : : {
1182 : 0 : if(_pSet)
1183 : : {
1184 : 0 : FillItemSet(*_pSet);
1185 : 0 : if(text::HoriOrientation::FULL != pTblData->GetAlign() && pTblData->GetWidth() != nTableWidth)
1186 : : {
1187 : 0 : pTblData->SetWidth(nTableWidth);
1188 : 0 : SwTwips nDiff = pTblData->GetSpace() - pTblData->GetWidth() -
1189 : 0 : pTblData->GetLeftSpace() - pTblData->GetRightSpace();
1190 : 0 : switch( pTblData->GetAlign() )
1191 : : {
1192 : : case text::HoriOrientation::RIGHT:
1193 : 0 : pTblData->SetLeftSpace(pTblData->GetLeftSpace() + nDiff);
1194 : 0 : break;
1195 : : case text::HoriOrientation::LEFT:
1196 : 0 : pTblData->SetRightSpace(pTblData->GetRightSpace() + nDiff);
1197 : 0 : break;
1198 : : case text::HoriOrientation::NONE:
1199 : : {
1200 : 0 : SwTwips nDiff2 = nDiff/2;
1201 : 0 : if( nDiff > 0 ||
1202 : 0 : (-nDiff2 < pTblData->GetRightSpace() && - nDiff2 < pTblData->GetLeftSpace()))
1203 : : {
1204 : 0 : pTblData->SetRightSpace(pTblData->GetRightSpace() + nDiff2);
1205 : 0 : pTblData->SetLeftSpace(pTblData->GetLeftSpace() + nDiff2);
1206 : : }
1207 : : else
1208 : : {
1209 : 0 : if(pTblData->GetRightSpace() > pTblData->GetLeftSpace())
1210 : : {
1211 : 0 : pTblData->SetLeftSpace(0);
1212 : 0 : pTblData->SetRightSpace(pTblData->GetSpace() - pTblData->GetWidth());
1213 : : }
1214 : : else
1215 : : {
1216 : 0 : pTblData->SetRightSpace(0);
1217 : 0 : pTblData->SetLeftSpace(pTblData->GetSpace() - pTblData->GetWidth());
1218 : : }
1219 : : }
1220 : : }
1221 : 0 : break;
1222 : : case text::HoriOrientation::CENTER:
1223 : 0 : pTblData->SetRightSpace(pTblData->GetRightSpace() + nDiff/2);
1224 : 0 : pTblData->SetLeftSpace(pTblData->GetLeftSpace() + nDiff/2);
1225 : 0 : break;
1226 : : case text::HoriOrientation::LEFT_AND_WIDTH :
1227 : 0 : if(nDiff > pTblData->GetRightSpace())
1228 : : {
1229 : 0 : pTblData->SetLeftSpace(pTblData->GetSpace() - pTblData->GetWidth());
1230 : : }
1231 : : pTblData->SetRightSpace(
1232 : 0 : pTblData->GetSpace() - pTblData->GetWidth() - pTblData->GetLeftSpace());
1233 : 0 : break;
1234 : : }
1235 : 0 : pTblData->SetWidthChanged();
1236 : : }
1237 : 0 : _pSet->Put(SwPtrItem( FN_TABLE_REP, pTblData ));
1238 : : }
1239 : 0 : return sal_True;
1240 : : }
1241 : :
1242 : :
1243 : 0 : SwTwips SwTableColumnPage::GetVisibleWidth(sal_uInt16 nPos)
1244 : : {
1245 : 0 : sal_uInt16 i=0;
1246 : :
1247 : 0 : while( nPos )
1248 : : {
1249 : 0 : if(pTblData->GetColumns()[i].bVisible && nPos)
1250 : 0 : nPos--;
1251 : 0 : i++;
1252 : : }
1253 : 0 : SwTwips nReturn = pTblData->GetColumns()[i].nWidth;
1254 : : OSL_ENSURE(i < nNoOfCols, "Array index out of range");
1255 : 0 : while(!pTblData->GetColumns()[i].bVisible && (i + 1) < nNoOfCols)
1256 : 0 : nReturn += pTblData->GetColumns()[++i].nWidth;
1257 : :
1258 : 0 : return nReturn;
1259 : : }
1260 : :
1261 : :
1262 : 0 : void SwTableColumnPage::SetVisibleWidth(sal_uInt16 nPos, SwTwips nNewWidth)
1263 : : {
1264 : 0 : sal_uInt16 i=0;
1265 : 0 : while( nPos )
1266 : : {
1267 : 0 : if(pTblData->GetColumns()[i].bVisible && nPos)
1268 : 0 : nPos--;
1269 : 0 : i++;
1270 : : }
1271 : : OSL_ENSURE(i < nNoOfCols, "Array index out of range");
1272 : 0 : pTblData->GetColumns()[i].nWidth = nNewWidth;
1273 : 0 : while(!pTblData->GetColumns()[i].bVisible && (i + 1) < nNoOfCols)
1274 : 0 : pTblData->GetColumns()[++i].nWidth = 0;
1275 : :
1276 : 0 : }
1277 : :
1278 : :
1279 : 0 : SwTableTabDlg::SwTableTabDlg(Window* pParent, SfxItemPool& ,
1280 : : const SfxItemSet* pItemSet, SwWrtShell* pSh ) :
1281 : : SfxTabDialog(pParent, SW_RES(DLG_FORMAT_TABLE), pItemSet,0),
1282 : : pShell(pSh),
1283 : 0 : nHtmlMode(::GetHtmlMode(pSh->GetView().GetDocShell()))
1284 : : {
1285 : 0 : FreeResource();
1286 : 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1287 : : OSL_ENSURE(pFact, "Dialogdiet fail!");
1288 : 0 : AddTabPage(TP_FORMAT_TABLE, &SwFormatTablePage::Create, 0 );
1289 : 0 : AddTabPage(TP_TABLE_TEXTFLOW, &SwTextFlowPage::Create, 0 );
1290 : 0 : AddTabPage(TP_TABLE_COLUMN, &SwTableColumnPage::Create, 0 );
1291 : 0 : AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 );
1292 : 0 : AddTabPage(TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), 0 );
1293 : 0 : }
1294 : :
1295 : :
1296 : 0 : void SwTableTabDlg::PageCreated(sal_uInt16 nId, SfxTabPage& rPage)
1297 : : {
1298 : 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1299 : 0 : if( TP_BACKGROUND == nId )
1300 : : {
1301 : 0 : sal_Int32 nFlagType = SVX_SHOW_TBLCTL;
1302 : 0 : if(!( nHtmlMode & HTMLMODE_ON ) ||
1303 : : nHtmlMode & HTMLMODE_SOME_STYLES)
1304 : 0 : nFlagType |= SVX_SHOW_SELECTOR;
1305 : 0 : aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, nFlagType));
1306 : 0 : rPage.PageCreated(aSet);
1307 : : }
1308 : 0 : else if(TP_BORDER == nId)
1309 : : {
1310 : 0 : aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_TABLE));
1311 : 0 : rPage.PageCreated(aSet);
1312 : : }
1313 : 0 : else if(TP_TABLE_TEXTFLOW == nId)
1314 : : {
1315 : 0 : ((SwTextFlowPage&)rPage).SetShell(pShell);
1316 : 0 : const sal_uInt16 eType = pShell->GetFrmType(0,sal_True);
1317 : 0 : if( !(FRMTYPE_BODY & eType) )
1318 : 0 : ((SwTextFlowPage&)rPage).DisablePageBreak();
1319 : 0 : }
1320 : 0 : }
1321 : :
1322 : 0 : SwTextFlowPage::SwTextFlowPage( Window* pParent,
1323 : : const SfxItemSet& rSet ) :
1324 : : SfxTabPage(pParent, SW_RES( TP_TABLE_TEXTFLOW ), rSet ),
1325 : : aFlowFL (this, SW_RES(FL_FLOW )),
1326 : : aPgBrkCB (this, SW_RES(CB_PAGEBREAK )),
1327 : : aPgBrkRB (this, SW_RES(RB_BREAKPAGE )),
1328 : : aColBrkRB (this, SW_RES(RB_BREAKCOLUMN )),
1329 : : aPgBrkBeforeRB (this, SW_RES(RB_PAGEBREAKBEFORE)),
1330 : : aPgBrkAfterRB (this, SW_RES(RB_PAGEBREAKAFTER )),
1331 : : aPageCollCB (this, SW_RES(CB_PAGECOLL )),
1332 : : aPageCollLB (this, SW_RES(LB_PAGECOLL )),
1333 : : aPageNoFT (this, SW_RES(FT_PAGENUM )),
1334 : : aPageNoNF (this, SW_RES(NF_PAGENUM )),
1335 : : aSplitCB (this, SW_RES(CB_SPLIT )),
1336 : : aSplitRowCB (this, SW_RES(CB_SPLIT_ROW )),
1337 : : aKeepCB (this, SW_RES(CB_KEEP )),
1338 : : aHeadLineCB (this, SW_RES(CB_HEADLINE )),
1339 : : aRepeatHeaderFT (this, SW_RES(FT_REPEAT_HEADER )),
1340 : : aRepeatHeaderBeforeFT (this),
1341 : : aRepeatHeaderNF (this, SW_RES(NF_REPEAT_HEADER )),
1342 : : aRepeatHeaderAfterFT (this),
1343 : : aRepeatHeaderCombo (this, SW_RES(WIN_REPEAT_HEADER), aRepeatHeaderNF, aRepeatHeaderBeforeFT, aRepeatHeaderAfterFT),
1344 : : aTextDirectionFT(this, SW_RES(FT_TEXTORIENTATION )),
1345 : : aTextDirectionLB(this, SW_RES(LB_TEXTORIENTATION )),
1346 : :
1347 : : aVertOrientFL (this, SW_RES(FL_VERT_ORIENT )),
1348 : : aVertOrientFT(this, SW_RES(FT_VERTORIENT )),
1349 : : aVertOrientLB(this, SW_RES(LB_VERTORIENT )),
1350 : :
1351 : : pShell(0),
1352 : :
1353 : : bPageBreak(sal_True),
1354 : 0 : bHtmlMode(sal_False)
1355 : : {
1356 : 0 : FreeResource();
1357 : :
1358 : 0 : aPgBrkRB.SetAccessibleRelationMemberOf(&aPgBrkCB);
1359 : 0 : aColBrkRB.SetAccessibleRelationMemberOf(&aPgBrkCB);
1360 : 0 : aPgBrkBeforeRB.SetAccessibleRelationMemberOf(&aPgBrkCB);
1361 : 0 : aPgBrkAfterRB.SetAccessibleRelationMemberOf(&aPgBrkCB);
1362 : 0 : aPageCollLB.SetAccessibleRelationLabeledBy(&aPageCollCB);
1363 : 0 : aPageCollLB.SetAccessibleName(aPageCollCB.GetText());
1364 : :
1365 : 0 : aPgBrkCB.SetClickHdl(LINK(this, SwTextFlowPage, PageBreakHdl_Impl));
1366 : : aPgBrkBeforeRB.SetClickHdl(
1367 : 0 : LINK( this, SwTextFlowPage, PageBreakPosHdl_Impl ) );
1368 : : aPgBrkAfterRB.SetClickHdl(
1369 : 0 : LINK( this, SwTextFlowPage, PageBreakPosHdl_Impl ) );
1370 : : aPageCollCB.SetClickHdl(
1371 : 0 : LINK( this, SwTextFlowPage, ApplyCollClickHdl_Impl ) );
1372 : : aColBrkRB.SetClickHdl(
1373 : 0 : LINK( this, SwTextFlowPage, PageBreakTypeHdl_Impl ) );
1374 : : aPgBrkRB.SetClickHdl(
1375 : 0 : LINK( this, SwTextFlowPage, PageBreakTypeHdl_Impl ) );
1376 : : aSplitCB.SetClickHdl(
1377 : 0 : LINK( this, SwTextFlowPage, SplitHdl_Impl));
1378 : : aSplitRowCB.SetClickHdl(
1379 : 0 : LINK( this, SwTextFlowPage, SplitRowHdl_Impl));
1380 : 0 : aHeadLineCB.SetClickHdl( LINK( this, SwTextFlowPage, HeadLineCBClickHdl ) );
1381 : :
1382 : : #ifndef SW_FILEFORMAT_40
1383 : : const SfxPoolItem *pItem;
1384 : 0 : if(SFX_ITEM_SET == rSet.GetItemState( SID_HTML_MODE, sal_False,&pItem )
1385 : 0 : && ((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON)
1386 : : #endif
1387 : : {
1388 : 0 : aKeepCB.Hide();
1389 : 0 : aSplitCB.Hide();
1390 : 0 : aSplitRowCB.Hide();
1391 : : }
1392 : :
1393 : 0 : aRepeatHeaderCombo.Arrange( aRepeatHeaderFT );
1394 : :
1395 : 0 : HeadLineCBClickHdl();
1396 : 0 : }
1397 : :
1398 : 0 : SwTextFlowPage::~SwTextFlowPage()
1399 : : {
1400 : 0 : }
1401 : :
1402 : 0 : SfxTabPage* SwTextFlowPage::Create( Window* pParent,
1403 : : const SfxItemSet& rAttrSet)
1404 : : {
1405 : 0 : return new SwTextFlowPage(pParent, rAttrSet);
1406 : : }
1407 : :
1408 : 0 : sal_Bool SwTextFlowPage::FillItemSet( SfxItemSet& rSet )
1409 : : {
1410 : 0 : sal_Bool bModified = sal_False;
1411 : :
1412 : : // Repeat Heading
1413 : 0 : if(aHeadLineCB.IsChecked() != aHeadLineCB.GetSavedValue() ||
1414 : 0 : String::CreateFromInt32( static_cast< sal_Int32 >(aRepeatHeaderNF.GetValue()) ) != aRepeatHeaderNF.GetSavedValue() )
1415 : : {
1416 : : bModified |= 0 != rSet.Put(
1417 : 0 : SfxUInt16Item(FN_PARAM_TABLE_HEADLINE, aHeadLineCB.IsChecked()? sal_uInt16(aRepeatHeaderNF.GetValue()) : 0 ));
1418 : : }
1419 : 0 : if(aKeepCB.IsChecked() != aKeepCB.GetSavedValue())
1420 : 0 : bModified |= 0 != rSet.Put( SvxFmtKeepItem( aKeepCB.IsChecked(), RES_KEEP));
1421 : :
1422 : 0 : if(aSplitCB.IsChecked() != aSplitCB.GetSavedValue())
1423 : 0 : bModified |= 0 != rSet.Put( SwFmtLayoutSplit( aSplitCB.IsChecked()));
1424 : :
1425 : 0 : if(aSplitRowCB.IsChecked() != aSplitRowCB.GetSavedValue())
1426 : 0 : bModified |= 0 != rSet.Put( SwFmtRowSplit( aSplitRowCB.IsChecked()));
1427 : :
1428 : :
1429 : 0 : const SvxFmtBreakItem* pBreak = (const SvxFmtBreakItem*)GetOldItem( rSet, RES_BREAK );
1430 : 0 : const SwFmtPageDesc* pDesc = (const SwFmtPageDesc*) GetOldItem( rSet, RES_PAGEDESC );
1431 : :
1432 : :
1433 : 0 : sal_Bool bState = aPageCollCB.IsChecked();
1434 : :
1435 : : // If we have a page style, then there's no break
1436 : 0 : sal_Bool bPageItemPut = sal_False;
1437 : 0 : if ( bState != aPageCollCB.GetSavedValue() ||
1438 : : ( bState &&
1439 : 0 : aPageCollLB.GetSelectEntryPos() != aPageCollLB.GetSavedValue() )
1440 : 0 : || (aPageNoNF.IsEnabled() && aPageNoNF.IsValueModified()) )
1441 : : {
1442 : 0 : String sPage;
1443 : :
1444 : 0 : if ( bState )
1445 : : {
1446 : 0 : sPage = aPageCollLB.GetSelectEntry();
1447 : : }
1448 : 0 : sal_uInt16 nPgNum = static_cast< sal_uInt16 >(aPageNoNF.GetValue());
1449 : 0 : if ( !pDesc || !pDesc->GetPageDesc() ||
1450 : 0 : ( pDesc->GetPageDesc() && ((pDesc->GetPageDesc()->GetName() != sPage) ||
1451 : 0 : !comphelper::string::equals(aPageNoNF.GetSavedValue(), nPgNum))))
1452 : : {
1453 : 0 : SwFmtPageDesc aFmt( pShell->FindPageDescByName( sPage, sal_True ) );
1454 : 0 : aFmt.SetNumOffset(bState ? nPgNum : 0);
1455 : 0 : bModified |= 0 != rSet.Put( aFmt );
1456 : 0 : bPageItemPut = bState;
1457 : 0 : }
1458 : : }
1459 : 0 : sal_Bool bIsChecked = aPgBrkCB.IsChecked();
1460 : 0 : if ( !bPageItemPut &&
1461 : 0 : ( bState != aPageCollCB.GetSavedValue() ||
1462 : 0 : bIsChecked != aPgBrkCB.GetSavedValue() ||
1463 : 0 : aPgBrkBeforeRB.IsChecked() != aPgBrkBeforeRB.GetSavedValue() ||
1464 : 0 : aPgBrkRB.IsChecked() != aPgBrkRB.GetSavedValue() ))
1465 : : {
1466 : : SvxFmtBreakItem aBreak(
1467 : 0 : (const SvxFmtBreakItem&)GetItemSet().Get( RES_BREAK ) );
1468 : :
1469 : 0 : if(bIsChecked)
1470 : : {
1471 : 0 : sal_Bool bBefore = aPgBrkBeforeRB.IsChecked();
1472 : :
1473 : 0 : if ( aPgBrkRB.IsChecked() )
1474 : : {
1475 : 0 : if ( bBefore )
1476 : 0 : aBreak.SetValue( SVX_BREAK_PAGE_BEFORE );
1477 : : else
1478 : 0 : aBreak.SetValue( SVX_BREAK_PAGE_AFTER );
1479 : : }
1480 : : else
1481 : : {
1482 : 0 : if ( bBefore )
1483 : 0 : aBreak.SetValue( SVX_BREAK_COLUMN_BEFORE );
1484 : : else
1485 : 0 : aBreak.SetValue( SVX_BREAK_COLUMN_AFTER );
1486 : : }
1487 : : }
1488 : : else
1489 : : {
1490 : 0 : aBreak.SetValue( SVX_BREAK_NONE );
1491 : : }
1492 : :
1493 : 0 : if ( !pBreak || !( *(const SvxFmtBreakItem*)pBreak == aBreak ) )
1494 : : {
1495 : 0 : bModified |= 0 != rSet.Put( aBreak );
1496 : 0 : }
1497 : : }
1498 : :
1499 : 0 : if(aTextDirectionLB.GetSelectEntryPos() != aTextDirectionLB.GetSavedValue())
1500 : : {
1501 : : bModified |= 0 != rSet.Put(
1502 : : SvxFrameDirectionItem(
1503 : 0 : (SvxFrameDirection)(sal_uLong)aTextDirectionLB.GetEntryData(aTextDirectionLB.GetSelectEntryPos())
1504 : 0 : , FN_TABLE_BOX_TEXTORIENTATION));
1505 : : }
1506 : :
1507 : 0 : if(aVertOrientLB.GetSelectEntryPos() != aVertOrientLB.GetSavedValue())
1508 : : {
1509 : 0 : sal_uInt16 nOrient = USHRT_MAX;
1510 : 0 : switch(aVertOrientLB.GetSelectEntryPos())
1511 : : {
1512 : 0 : case 0 : nOrient = text::VertOrientation::NONE; break;
1513 : 0 : case 1 : nOrient = text::VertOrientation::CENTER; break;
1514 : 0 : case 2 : nOrient = text::VertOrientation::BOTTOM; break;
1515 : : }
1516 : 0 : if(nOrient != USHRT_MAX)
1517 : 0 : bModified |= 0 != rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, nOrient));
1518 : : }
1519 : :
1520 : 0 : return bModified;
1521 : :
1522 : : }
1523 : :
1524 : 0 : void SwTextFlowPage::Reset( const SfxItemSet& rSet )
1525 : : {
1526 : : const SfxPoolItem* pItem;
1527 : 0 : SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
1528 : 0 : sal_Bool bFlowAllowed = !bHtmlMode || rHtmlOpt.IsPrintLayoutExtension();
1529 : 0 : if(bFlowAllowed)
1530 : : {
1531 : : // Einfuegen der vorhandenen Seitenvorlagen in die Listbox
1532 : 0 : const sal_uInt16 nCount = pShell->GetPageDescCnt();
1533 : : sal_uInt16 i;
1534 : :
1535 : 0 : for( i = 0; i < nCount; ++i)
1536 : : {
1537 : 0 : const SwPageDesc &rPageDesc = pShell->GetPageDesc(i);
1538 : 0 : aPageCollLB.InsertEntry(rPageDesc.GetName());
1539 : : }
1540 : :
1541 : 0 : String aFmtName;
1542 : 0 : for(i = RES_POOLPAGE_BEGIN; i < RES_POOLPAGE_END; ++i)
1543 : 0 : if( LISTBOX_ENTRY_NOTFOUND == aPageCollLB.GetEntryPos(
1544 : 0 : aFmtName = SwStyleNameMapper::GetUIName( i, aFmtName ) ))
1545 : 0 : aPageCollLB.InsertEntry( aFmtName );
1546 : :
1547 : 0 : if(SFX_ITEM_SET == rSet.GetItemState( RES_KEEP, sal_False, &pItem ))
1548 : : {
1549 : 0 : aKeepCB.Check( ((const SvxFmtKeepItem*)pItem)->GetValue() );
1550 : 0 : aKeepCB.SaveValue();
1551 : : }
1552 : 0 : if(SFX_ITEM_SET == rSet.GetItemState( RES_LAYOUT_SPLIT, sal_False, &pItem ))
1553 : : {
1554 : 0 : aSplitCB.Check( ((const SwFmtLayoutSplit*)pItem)->GetValue() );
1555 : : }
1556 : : else
1557 : 0 : aSplitCB.Check();
1558 : :
1559 : 0 : aSplitCB.SaveValue();
1560 : 0 : SplitHdl_Impl(&aSplitCB);
1561 : :
1562 : 0 : if(SFX_ITEM_SET == rSet.GetItemState( RES_ROW_SPLIT, sal_False, &pItem ))
1563 : : {
1564 : 0 : aSplitRowCB.Check( ((const SwFmtRowSplit*)pItem)->GetValue() );
1565 : : }
1566 : : else
1567 : 0 : aSplitRowCB.SetState(STATE_DONTKNOW);
1568 : 0 : aSplitRowCB.SaveValue();
1569 : :
1570 : 0 : if(bPageBreak)
1571 : : {
1572 : 0 : if(SFX_ITEM_SET == rSet.GetItemState( RES_PAGEDESC, sal_False, &pItem ))
1573 : : {
1574 : 0 : String sPageDesc;
1575 : 0 : const SwPageDesc* pDesc = ((const SwFmtPageDesc*)pItem)->GetPageDesc();
1576 : 0 : aPageNoNF.SetValue(((const SwFmtPageDesc*)pItem)->GetNumOffset());
1577 : 0 : if(pDesc)
1578 : 0 : sPageDesc = pDesc->GetName();
1579 : 0 : if ( sPageDesc.Len() &&
1580 : 0 : aPageCollLB.GetEntryPos( sPageDesc ) != LISTBOX_ENTRY_NOTFOUND )
1581 : : {
1582 : 0 : aPageCollLB.SelectEntry( sPageDesc );
1583 : 0 : aPageCollCB.Check();
1584 : :
1585 : 0 : aPgBrkCB.Enable();
1586 : 0 : aPgBrkRB.Enable();
1587 : 0 : aColBrkRB.Enable();
1588 : 0 : aPgBrkBeforeRB.Enable();
1589 : 0 : aPgBrkAfterRB.Enable();
1590 : 0 : aPageCollCB.Enable();
1591 : 0 : aPgBrkCB.Check();
1592 : :
1593 : 0 : aPgBrkCB.Check( sal_True );
1594 : 0 : aColBrkRB.Check( sal_False );
1595 : 0 : aPgBrkBeforeRB.Check( sal_True );
1596 : 0 : aPgBrkAfterRB.Check( sal_False );
1597 : : }
1598 : : else
1599 : : {
1600 : 0 : aPageCollLB.SetNoSelection();
1601 : 0 : aPageCollCB.Check(sal_False);
1602 : 0 : }
1603 : : }
1604 : :
1605 : 0 : if(SFX_ITEM_SET == rSet.GetItemState( RES_BREAK, sal_False, &pItem ))
1606 : : {
1607 : 0 : const SvxFmtBreakItem* pPageBreak = (const SvxFmtBreakItem*)pItem;
1608 : 0 : SvxBreak eBreak = (SvxBreak)pPageBreak->GetValue();
1609 : :
1610 : 0 : if ( eBreak != SVX_BREAK_NONE )
1611 : : {
1612 : 0 : aPgBrkCB.Check();
1613 : 0 : aPageCollCB.Enable(sal_False);
1614 : 0 : aPageCollLB.Enable(sal_False);
1615 : 0 : aPageNoFT.Enable(sal_False);
1616 : 0 : aPageNoNF.Enable(sal_False);
1617 : : }
1618 : 0 : switch ( eBreak )
1619 : : {
1620 : : case SVX_BREAK_PAGE_BEFORE:
1621 : 0 : aPgBrkRB.Check( sal_True );
1622 : 0 : aColBrkRB.Check( sal_False );
1623 : 0 : aPgBrkBeforeRB.Check( sal_True );
1624 : 0 : aPgBrkAfterRB.Check( sal_False );
1625 : 0 : break;
1626 : : case SVX_BREAK_PAGE_AFTER:
1627 : 0 : aPgBrkRB.Check( sal_True );
1628 : 0 : aColBrkRB.Check( sal_False );
1629 : 0 : aPgBrkBeforeRB.Check( sal_False );
1630 : 0 : aPgBrkAfterRB.Check( sal_True );
1631 : 0 : break;
1632 : : case SVX_BREAK_COLUMN_BEFORE:
1633 : 0 : aPgBrkRB.Check( sal_False );
1634 : 0 : aColBrkRB.Check( sal_True );
1635 : 0 : aPgBrkBeforeRB.Check( sal_True );
1636 : 0 : aPgBrkAfterRB.Check( sal_False );
1637 : 0 : break;
1638 : : case SVX_BREAK_COLUMN_AFTER:
1639 : 0 : aPgBrkRB.Check( sal_False );
1640 : 0 : aColBrkRB.Check( sal_True );
1641 : 0 : aPgBrkBeforeRB.Check( sal_False );
1642 : 0 : aPgBrkAfterRB.Check( sal_True );
1643 : 0 : break;
1644 : : default:; //prevent warning
1645 : : }
1646 : :
1647 : : }
1648 : 0 : if ( aPgBrkBeforeRB.IsChecked() )
1649 : 0 : PageBreakPosHdl_Impl( &aPgBrkBeforeRB );
1650 : 0 : else if ( aPgBrkAfterRB.IsChecked() )
1651 : 0 : PageBreakPosHdl_Impl( &aPgBrkAfterRB );
1652 : 0 : PageBreakHdl_Impl( &aPgBrkCB );
1653 : 0 : }
1654 : : }
1655 : : else
1656 : : {
1657 : 0 : aPgBrkRB.Enable(sal_False);
1658 : 0 : aColBrkRB.Enable(sal_False);
1659 : 0 : aPgBrkBeforeRB.Enable(sal_False);
1660 : 0 : aPgBrkAfterRB.Enable(sal_False);
1661 : 0 : aKeepCB .Enable(sal_False);
1662 : 0 : aSplitCB.Enable(sal_False);
1663 : 0 : aPgBrkCB.Enable(sal_False);
1664 : 0 : aPageCollCB.Enable(sal_False);
1665 : 0 : aPageCollLB.Enable(sal_False);
1666 : : }
1667 : :
1668 : 0 : if(SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_HEADLINE, sal_False, &pItem ))
1669 : : {
1670 : 0 : sal_uInt16 nRep = ((const SfxUInt16Item*)pItem)->GetValue();
1671 : 0 : aHeadLineCB.Check( nRep > 0 );
1672 : 0 : aHeadLineCB.SaveValue();
1673 : 0 : aRepeatHeaderNF.SetValue( nRep );
1674 : 0 : aRepeatHeaderNF.SaveValue();
1675 : : }
1676 : 0 : if ( rSet.GetItemState(FN_TABLE_BOX_TEXTORIENTATION) > SFX_ITEM_AVAILABLE )
1677 : : {
1678 : 0 : sal_uLong nDirection = ((const SvxFrameDirectionItem&)rSet.Get(FN_TABLE_BOX_TEXTORIENTATION)).GetValue();
1679 : 0 : aTextDirectionLB.SelectEntryPos(aTextDirectionLB.GetEntryPos( (const void*)nDirection ));
1680 : : }
1681 : :
1682 : 0 : if ( rSet.GetItemState(FN_TABLE_SET_VERT_ALIGN) > SFX_ITEM_AVAILABLE )
1683 : : {
1684 : 0 : sal_uInt16 nVert = ((const SfxUInt16Item&)rSet.Get(FN_TABLE_SET_VERT_ALIGN)).GetValue();
1685 : 0 : sal_uInt16 nPos = 0;
1686 : 0 : switch(nVert)
1687 : : {
1688 : 0 : case text::VertOrientation::NONE: nPos = 0; break;
1689 : 0 : case text::VertOrientation::CENTER: nPos = 1; break;
1690 : 0 : case text::VertOrientation::BOTTOM: nPos = 2; break;
1691 : : }
1692 : 0 : aVertOrientLB.SelectEntryPos(nPos);
1693 : : }
1694 : :
1695 : 0 : aPageCollCB.SaveValue();
1696 : 0 : aPageCollLB.SaveValue();
1697 : 0 : aPgBrkCB.SaveValue();
1698 : 0 : aPgBrkRB.SaveValue();
1699 : 0 : aColBrkRB.SaveValue();
1700 : 0 : aPgBrkBeforeRB.SaveValue();
1701 : 0 : aPgBrkAfterRB.SaveValue();
1702 : 0 : aPageNoNF.SaveValue();
1703 : 0 : aTextDirectionLB.SaveValue();
1704 : 0 : aVertOrientLB.SaveValue();
1705 : :
1706 : 0 : HeadLineCBClickHdl();
1707 : 0 : }
1708 : :
1709 : 0 : void SwTextFlowPage::SetShell(SwWrtShell* pSh)
1710 : : {
1711 : 0 : pShell = pSh;
1712 : 0 : bHtmlMode = 0 != (::GetHtmlMode(pShell->GetView().GetDocShell()) & HTMLMODE_ON);
1713 : 0 : if(bHtmlMode)
1714 : : {
1715 : 0 : aPageNoNF.Enable(sal_False);
1716 : 0 : aPageNoFT.Enable(sal_False);
1717 : : }
1718 : 0 : }
1719 : :
1720 : 0 : IMPL_LINK_NOARG(SwTextFlowPage, PageBreakHdl_Impl)
1721 : : {
1722 : 0 : if( aPgBrkCB.IsChecked() )
1723 : : {
1724 : 0 : aPgBrkRB. Enable();
1725 : 0 : aColBrkRB. Enable();
1726 : 0 : aPgBrkBeforeRB. Enable();
1727 : 0 : aPgBrkAfterRB. Enable();
1728 : :
1729 : 0 : if ( aPgBrkRB.IsChecked() && aPgBrkBeforeRB.IsChecked() )
1730 : : {
1731 : 0 : aPageCollCB.Enable();
1732 : :
1733 : 0 : sal_Bool bEnable = aPageCollCB.IsChecked() &&
1734 : 0 : aPageCollLB.GetEntryCount();
1735 : 0 : aPageCollLB.Enable(bEnable);
1736 : 0 : if(!bHtmlMode)
1737 : : {
1738 : 0 : aPageNoFT.Enable(bEnable);
1739 : 0 : aPageNoNF.Enable(bEnable);
1740 : : }
1741 : : }
1742 : : }
1743 : : else
1744 : : {
1745 : 0 : aPageCollCB.Check( sal_False );
1746 : 0 : aPageCollCB.Enable(sal_False);
1747 : 0 : aPageCollLB.Enable(sal_False);
1748 : 0 : aPageNoFT.Enable(sal_False);
1749 : 0 : aPageNoNF.Enable(sal_False);
1750 : 0 : aPgBrkRB. Enable(sal_False);
1751 : 0 : aColBrkRB. Enable(sal_False);
1752 : 0 : aPgBrkBeforeRB. Enable(sal_False);
1753 : 0 : aPgBrkAfterRB. Enable(sal_False);
1754 : : }
1755 : 0 : return 0;
1756 : : }
1757 : :
1758 : 0 : IMPL_LINK_NOARG(SwTextFlowPage, ApplyCollClickHdl_Impl)
1759 : : {
1760 : 0 : sal_Bool bEnable = sal_False;
1761 : 0 : if ( aPageCollCB.IsChecked() &&
1762 : 0 : aPageCollLB.GetEntryCount() )
1763 : : {
1764 : 0 : bEnable = sal_True;
1765 : 0 : aPageCollLB.SelectEntryPos( 0 );
1766 : : }
1767 : : else
1768 : : {
1769 : 0 : aPageCollLB.SetNoSelection();
1770 : : }
1771 : 0 : aPageCollLB.Enable(bEnable);
1772 : 0 : if(!bHtmlMode)
1773 : : {
1774 : 0 : aPageNoFT.Enable(bEnable);
1775 : 0 : aPageNoNF.Enable(bEnable);
1776 : : }
1777 : 0 : return 0;
1778 : : }
1779 : :
1780 : 0 : IMPL_LINK( SwTextFlowPage, PageBreakPosHdl_Impl, RadioButton*, pBtn )
1781 : : {
1782 : 0 : if ( aPgBrkCB.IsChecked() )
1783 : : {
1784 : 0 : if ( pBtn == &aPgBrkBeforeRB && aPgBrkRB.IsChecked() )
1785 : : {
1786 : 0 : aPageCollCB.Enable();
1787 : :
1788 : 0 : sal_Bool bEnable = aPageCollCB.IsChecked() &&
1789 : 0 : aPageCollLB.GetEntryCount();
1790 : :
1791 : 0 : aPageCollLB.Enable(bEnable);
1792 : 0 : if(!bHtmlMode)
1793 : : {
1794 : 0 : aPageNoFT.Enable(bEnable);
1795 : 0 : aPageNoNF.Enable(bEnable);
1796 : : }
1797 : : }
1798 : 0 : else if ( pBtn == &aPgBrkAfterRB )
1799 : : {
1800 : 0 : aPageCollCB .Check( sal_False );
1801 : 0 : aPageCollCB .Enable(sal_False);
1802 : 0 : aPageCollLB .Enable(sal_False);
1803 : 0 : aPageNoFT .Enable(sal_False);
1804 : 0 : aPageNoNF .Enable(sal_False);
1805 : : }
1806 : : }
1807 : 0 : return 0;
1808 : : }
1809 : :
1810 : 0 : IMPL_LINK( SwTextFlowPage, PageBreakTypeHdl_Impl, RadioButton*, pBtn )
1811 : : {
1812 : 0 : if ( pBtn == &aColBrkRB || aPgBrkAfterRB.IsChecked() )
1813 : : {
1814 : 0 : aPageCollCB .Check(sal_False);
1815 : 0 : aPageCollCB .Enable(sal_False);
1816 : 0 : aPageCollLB .Enable(sal_False);
1817 : 0 : aPageNoFT .Enable(sal_False);
1818 : 0 : aPageNoNF .Enable(sal_False);
1819 : : }
1820 : 0 : else if ( aPgBrkBeforeRB.IsChecked() )
1821 : 0 : PageBreakPosHdl_Impl( &aPgBrkBeforeRB );
1822 : 0 : return 0;
1823 : : }
1824 : :
1825 : 0 : IMPL_LINK( SwTextFlowPage, SplitHdl_Impl, CheckBox*, pBox )
1826 : : {
1827 : 0 : aSplitRowCB.Enable(pBox->IsChecked());
1828 : 0 : return 0;
1829 : : }
1830 : :
1831 : 0 : IMPL_LINK( SwTextFlowPage, SplitRowHdl_Impl, TriStateBox*, pBox )
1832 : : {
1833 : 0 : pBox->EnableTriState(sal_False);
1834 : 0 : return 0;
1835 : : }
1836 : :
1837 : 0 : IMPL_LINK_NOARG(SwTextFlowPage, HeadLineCBClickHdl)
1838 : : {
1839 : 0 : aRepeatHeaderCombo.Enable(aHeadLineCB.IsChecked());
1840 : :
1841 : 0 : return 0;
1842 : : }
1843 : :
1844 : 0 : void SwTextFlowPage::DisablePageBreak()
1845 : : {
1846 : 0 : bPageBreak = sal_False;
1847 : 0 : aPgBrkCB .Disable();
1848 : 0 : aPgBrkRB .Disable();
1849 : 0 : aColBrkRB .Disable();
1850 : 0 : aPgBrkBeforeRB .Disable();
1851 : 0 : aPgBrkAfterRB .Disable();
1852 : 0 : aPageCollCB .Disable();
1853 : 0 : aPageCollLB .Disable();
1854 : 0 : aPageNoFT .Disable();
1855 : 0 : aPageNoNF .Disable();
1856 : 0 : }
1857 : :
1858 : :
1859 : :
1860 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|