update dev300-m58
[ooovba.git] / sw / source / ui / frmdlg / wrap.cxx
bloba971b012ca0b467b55c6ecfd4aecfc72fa6df6fd
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: wrap.cxx,v $
10 * $Revision: 1.17 $
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 "hintids.hxx"
41 #include <vcl/graph.hxx>
42 #include <svx/htmlmode.hxx>
43 #include <sfx2/objsh.hxx>
44 #include <svtools/intitem.hxx>
45 #include <svx/opaqitem.hxx>
46 #include <svx/ulspitem.hxx>
47 #include <svx/lrspitem.hxx>
48 // OD 18.09.2003 #i18732#
49 #include <fmtfollowtextflow.hxx>
50 #include <svx/swframevalidation.hxx>
53 #include "cmdid.h"
54 #include "uitool.hxx"
55 #include "wrtsh.hxx"
56 #include "swmodule.hxx"
57 #include "viewopt.hxx"
58 #include "frmatr.hxx"
59 #include "frmmgr.hxx"
60 #include "globals.hrc"
61 #include "frmui.hrc"
62 #include "wrap.hrc"
63 #include "wrap.hxx"
65 using namespace ::com::sun::star;
68 /*--------------------------------------------------------------------
69 Beschreibung:
70 --------------------------------------------------------------------*/
72 static USHORT __FAR_DATA aWrapPageRg[] = {
73 RES_LR_SPACE, RES_UL_SPACE,
74 RES_PROTECT, RES_SURROUND,
75 RES_PRINT, RES_PRINT,
80 /*--------------------------------------------------------------------
81 Beschreibung:
82 --------------------------------------------------------------------*/
86 SwWrapDlg::SwWrapDlg(Window* pParent, SfxItemSet& rSet, SwWrtShell* pSh, BOOL bDrawMode) :
87 SfxSingleTabDialog(pParent, rSet, 0),
88 pWrtShell(pSh)
91 // TabPage erzeugen
92 SwWrapTabPage* pNewPage = (SwWrapTabPage*) SwWrapTabPage::Create(this, rSet);
93 pNewPage->SetFormatUsed(FALSE, bDrawMode);
94 pNewPage->SetShell(pWrtShell);
95 SetTabPage(pNewPage);
97 String sTitle(SW_RES(STR_FRMUI_WRAP));
98 SetText(sTitle);
103 SwWrapDlg::~SwWrapDlg()
107 /*--------------------------------------------------------------------
108 Beschreibung:
109 --------------------------------------------------------------------*/
113 SwWrapTabPage::SwWrapTabPage(Window *pParent, const SfxItemSet &rSet) :
114 SfxTabPage(pParent, SW_RES(TP_FRM_WRAP), rSet),
116 aWrapFLC (this, SW_RES(C_WRAP_FL)),
117 aNoWrapRB (this, SW_RES(RB_NO_WRAP)),
118 aWrapLeftRB (this, SW_RES(RB_WRAP_LEFT)),
119 aWrapRightRB (this, SW_RES(RB_WRAP_RIGHT)),
120 aWrapParallelRB (this, SW_RES(RB_WRAP_PARALLEL)),
121 aWrapThroughRB (this, SW_RES(RB_WRAP_THROUGH)),
122 aIdealWrapRB (this, SW_RES(RB_WRAP_IDEAL)),
124 aMarginFL (this, SW_RES(FL_MARGIN)),
125 aLeftMarginFT (this, SW_RES(FT_LEFT_MARGIN)),
126 aLeftMarginED (this, SW_RES(ED_LEFT_MARGIN)),
127 aRightMarginFT (this, SW_RES(FT_RIGHT_MARGIN)),
128 aRightMarginED (this, SW_RES(ED_RIGHT_MARGIN)),
129 aTopMarginFT (this, SW_RES(FT_TOP_MARGIN)),
130 aTopMarginED (this, SW_RES(ED_TOP_MARGIN)),
131 aBottomMarginFT (this, SW_RES(FT_BOTTOM_MARGIN)),
132 aBottomMarginED (this, SW_RES(ED_BOTTOM_MARGIN)),
134 aOptionsSepFL (this, SW_RES(FL_OPTION_SEP)),
135 aOptionsFL (this, SW_RES(FL_OPTION)),
136 aWrapAnchorOnlyCB (this, SW_RES(CB_ANCHOR_ONLY)),
137 aWrapTransparentCB (this, SW_RES(CB_TRANSPARENT)),
138 aWrapOutlineCB (this, SW_RES(CB_OUTLINE)),
139 aWrapOutsideCB (this, SW_RES(CB_ONLYOUTSIDE)),
141 aWrapIL (SW_RES(IL_WRAP)),
142 aWrapILH (SW_RES(ILH_WRAP)),
144 nAnchorId(FLY_AT_CNTNT),
145 nHtmlMode(0),
147 pWrtSh(0),
149 bFormat(FALSE),
150 bNew(TRUE),
151 bHtmlMode(FALSE),
152 bContourImage(FALSE)
155 FreeResource();
156 SetExchangeSupport();
158 Link aLk = LINK(this, SwWrapTabPage, RangeModifyHdl);
159 aLeftMarginED.SetUpHdl(aLk);
160 aLeftMarginED.SetDownHdl(aLk);
161 aLeftMarginED.SetFirstHdl(aLk);
162 aLeftMarginED.SetLastHdl(aLk);
163 aLeftMarginED.SetLoseFocusHdl(aLk);
165 aRightMarginED.SetUpHdl(aLk);
166 aRightMarginED.SetDownHdl(aLk);
167 aRightMarginED.SetFirstHdl(aLk);
168 aRightMarginED.SetLastHdl(aLk);
169 aRightMarginED.SetLoseFocusHdl(aLk);
171 aTopMarginED.SetUpHdl(aLk);
172 aTopMarginED.SetDownHdl(aLk);
173 aTopMarginED.SetFirstHdl(aLk);
174 aTopMarginED.SetLastHdl(aLk);
175 aTopMarginED.SetLoseFocusHdl(aLk);
177 aBottomMarginED.SetUpHdl(aLk);
178 aBottomMarginED.SetDownHdl(aLk);
179 aBottomMarginED.SetFirstHdl(aLk);
180 aBottomMarginED.SetLastHdl(aLk);
181 aBottomMarginED.SetLoseFocusHdl(aLk);
183 aLk = LINK(this, SwWrapTabPage, WrapTypeHdl);
184 aNoWrapRB.SetClickHdl(aLk);
185 aWrapLeftRB.SetClickHdl(aLk);
186 aWrapRightRB.SetClickHdl(aLk);
187 aWrapParallelRB.SetClickHdl(aLk);
188 aWrapThroughRB.SetClickHdl(aLk);
189 aIdealWrapRB.SetClickHdl(aLk);
190 ApplyImageList();
191 aWrapOutlineCB.SetClickHdl(LINK(this, SwWrapTabPage, ContourHdl));
196 SwWrapTabPage::~SwWrapTabPage()
202 SfxTabPage* SwWrapTabPage::Create(Window *pParent, const SfxItemSet &rSet)
204 return new SwWrapTabPage(pParent, rSet);
206 /*--------------------------------------------------------------------
207 Beschreibung:
208 --------------------------------------------------------------------*/
212 void SwWrapTabPage::Reset(const SfxItemSet &rSet)
214 //Contour fuer Draw, Grafik und OLE (Einfuegen/Grafik/Eigenschaften fehlt noch!)
215 if( bDrawMode )
217 aWrapOutlineCB.Show();
218 aWrapOutsideCB.Show();
220 aWrapTransparentCB.Check( 0 == ((const SfxInt16Item&)rSet.Get(
221 FN_DRAW_WRAP_DLG)).GetValue() );
222 aWrapTransparentCB.SaveValue();
224 else
226 BOOL bShowCB = bFormat;
227 if( !bFormat )
229 int nSelType = pWrtSh->GetSelectionType();
230 if( ( nSelType & nsSelectionType::SEL_GRF ) ||
231 ( nSelType & nsSelectionType::SEL_OLE && GRAPHIC_NONE !=
232 pWrtSh->GetIMapGraphic().GetType() ))
233 bShowCB = TRUE;
235 if( bShowCB )
237 aWrapOutlineCB.Show();
238 aWrapOutsideCB.Show();
242 nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
243 bHtmlMode = nHtmlMode & HTMLMODE_ON ? TRUE : FALSE;
245 FieldUnit aMetric = ::GetDfltMetric(bHtmlMode);
246 SetMetric( aLeftMarginED , aMetric );
247 SetMetric( aRightMarginED , aMetric );
248 SetMetric( aTopMarginED , aMetric );
249 SetMetric( aBottomMarginED, aMetric );
251 const SwFmtSurround& rSurround = (const SwFmtSurround&)rSet.Get(RES_SURROUND);
253 SwSurround nSur = rSurround.GetSurround();
254 const SwFmtAnchor &rAnch = (const SwFmtAnchor&)rSet.Get(RES_ANCHOR);
255 nAnchorId = rAnch.GetAnchorId();
257 if ( (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) && nSur != SURROUND_NONE )
258 aWrapAnchorOnlyCB.Check( rSurround.IsAnchorOnly() );
259 else
260 aWrapAnchorOnlyCB.Enable( FALSE );
262 BOOL bContour = rSurround.IsContour();
263 aWrapOutlineCB.Check( bContour );
264 aWrapOutsideCB.Check( rSurround.IsOutside() );
265 aWrapThroughRB.Enable(!aWrapOutlineCB.IsChecked());
266 bContourImage = !bContour;
268 ImageRadioButton* pBtn = NULL;
270 switch (nSur)
272 case SURROUND_NONE:
274 pBtn = &aNoWrapRB;
275 break;
278 case SURROUND_THROUGHT:
280 // transparent ?
281 pBtn = &aWrapThroughRB;
283 if (!bDrawMode)
285 const SvxOpaqueItem& rOpaque = (const SvxOpaqueItem&)rSet.Get(RES_OPAQUE);
286 aWrapTransparentCB.Check(!rOpaque.GetValue());
288 break;
291 case SURROUND_PARALLEL:
293 pBtn = &aWrapParallelRB;
294 break;
297 case SURROUND_IDEAL:
299 pBtn = &aIdealWrapRB;
300 break;
303 default:
305 if (nSur == SURROUND_LEFT)
306 pBtn = &aWrapLeftRB;
307 else if (nSur == SURROUND_RIGHT)
308 pBtn = &aWrapRightRB;
311 if (pBtn)
313 pBtn->Check();
314 WrapTypeHdl(pBtn);
315 // Hier wird fuer Zeichenobjekte, die im Moment auf Durchlauf stehen,
316 // schon mal der Default "Kontur an" vorbereitet, falls man spaeter auf
317 // irgendeinen Umlauf umschaltet.
318 if (bDrawMode && !aWrapOutlineCB.IsEnabled())
319 aWrapOutlineCB.Check();
321 aWrapTransparentCB.Enable( pBtn == &aWrapThroughRB && !bHtmlMode );
323 const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rSet.Get(RES_UL_SPACE);
324 const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rSet.Get(RES_LR_SPACE);
326 // Abstand zum Text
327 aLeftMarginED.SetValue(aLeftMarginED.Normalize(rLR.GetLeft()), FUNIT_TWIP);
328 aRightMarginED.SetValue(aRightMarginED.Normalize(rLR.GetRight()), FUNIT_TWIP);
329 aTopMarginED.SetValue(aTopMarginED.Normalize(rUL.GetUpper()), FUNIT_TWIP);
330 aBottomMarginED.SetValue(aBottomMarginED.Normalize(rUL.GetLower()), FUNIT_TWIP);
332 ContourHdl(0);
333 ActivatePage( rSet );
336 /*--------------------------------------------------------------------
337 Beschreibung: Attribute in den Set stopfen bei OK
338 --------------------------------------------------------------------*/
342 BOOL SwWrapTabPage::FillItemSet(SfxItemSet &rSet)
344 BOOL bModified = FALSE;
345 const SfxPoolItem* pOldItem;
347 const SwFmtSurround& rOldSur = (const SwFmtSurround&)GetItemSet().Get(RES_SURROUND);
348 SwFmtSurround aSur( rOldSur );
350 SvxOpaqueItem aOp( RES_OPAQUE);
352 if (!bDrawMode)
354 const SvxOpaqueItem& rOpaque = (const SvxOpaqueItem&)GetItemSet().Get(RES_OPAQUE);
355 aOp = rOpaque;
356 aOp.SetValue(TRUE);
359 if (aNoWrapRB.IsChecked())
360 aSur.SetSurround(SURROUND_NONE);
361 else if (aWrapLeftRB.IsChecked())
362 aSur.SetSurround(SURROUND_LEFT);
363 else if (aWrapRightRB.IsChecked())
364 aSur.SetSurround(SURROUND_RIGHT);
365 else if (aWrapParallelRB.IsChecked())
366 aSur.SetSurround(SURROUND_PARALLEL);
367 else if (aWrapThroughRB.IsChecked())
369 aSur.SetSurround(SURROUND_THROUGHT);
370 if (aWrapTransparentCB.IsChecked() && !bDrawMode)
371 aOp.SetValue(FALSE);
373 else if (aIdealWrapRB.IsChecked())
374 aSur.SetSurround(SURROUND_IDEAL);
376 aSur.SetAnchorOnly( aWrapAnchorOnlyCB.IsChecked() );
377 BOOL bContour = aWrapOutlineCB.IsChecked() && aWrapOutlineCB.IsEnabled();
378 aSur.SetContour( bContour );
380 if ( bContour )
381 aSur.SetOutside(aWrapOutsideCB.IsChecked());
383 if(0 == (pOldItem = GetOldItem( rSet, RES_SURROUND )) ||
384 aSur != *pOldItem )
386 rSet.Put(aSur);
387 bModified = TRUE;
390 if (!bDrawMode)
392 if(0 == (pOldItem = GetOldItem( rSet, FN_OPAQUE )) ||
393 aOp != *pOldItem )
395 rSet.Put(aOp);
396 bModified = TRUE;
400 BOOL bTopMod = aTopMarginED.IsValueModified();
401 BOOL bBottomMod = aBottomMarginED.IsValueModified();
403 SvxULSpaceItem aUL( RES_UL_SPACE );
404 aUL.SetUpper((USHORT)aTopMarginED.Denormalize(aTopMarginED.GetValue(FUNIT_TWIP)));
405 aUL.SetLower((USHORT)aBottomMarginED.Denormalize(aBottomMarginED.GetValue(FUNIT_TWIP)));
407 if ( bTopMod || bBottomMod )
409 if(0 == (pOldItem = GetOldItem(rSet, RES_UL_SPACE)) ||
410 aUL != *pOldItem )
412 rSet.Put( aUL, RES_UL_SPACE );
413 bModified = TRUE;
417 BOOL bLeftMod = aLeftMarginED.IsValueModified();
418 BOOL bRightMod = aRightMarginED.IsValueModified();
420 SvxLRSpaceItem aLR( RES_LR_SPACE );
421 aLR.SetLeft((USHORT)aLeftMarginED.Denormalize(aLeftMarginED.GetValue(FUNIT_TWIP)));
422 aLR.SetRight((USHORT)aRightMarginED.Denormalize(aRightMarginED.GetValue(FUNIT_TWIP)));
424 if ( bLeftMod || bRightMod )
426 if( 0 == (pOldItem = GetOldItem(rSet, RES_LR_SPACE)) ||
427 aLR != *pOldItem )
429 rSet.Put(aLR, RES_LR_SPACE);
430 bModified = TRUE;
434 if ( bDrawMode )
436 BOOL bChecked = aWrapTransparentCB.IsChecked() & aWrapTransparentCB.IsEnabled();
437 if (aWrapTransparentCB.GetSavedValue() != bChecked)
438 bModified |= 0 != rSet.Put(SfxInt16Item(FN_DRAW_WRAP_DLG, bChecked ? 0 : 1));
441 return bModified;
444 /*--------------------------------------------------------------------
445 Beschreibung: Bsp - Update
446 --------------------------------------------------------------------*/
450 void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet)
452 // Anchor
453 const SwFmtAnchor &rAnch = (const SwFmtAnchor&)rSet.Get(RES_ANCHOR);
454 nAnchorId = rAnch.GetAnchorId();
455 BOOL bEnable = nAnchorId != FLY_IN_CNTNT;
457 if (!bDrawMode)
459 SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell() : pWrtSh;
460 SwFlyFrmAttrMgr aMgr( bNew, pSh, (const SwAttrSet&)GetItemSet() );
461 SvxSwFrameValidation aVal;
463 // Size
464 const SwFmtFrmSize& rFrmSize = (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE);
465 Size aSize = rFrmSize.GetSize();
467 // Rand
468 const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rSet.Get(RES_UL_SPACE);
469 const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rSet.Get(RES_LR_SPACE);
470 nOldLeftMargin = static_cast< USHORT >(rLR.GetLeft());
471 nOldRightMargin = static_cast< USHORT >(rLR.GetRight());
472 nOldUpperMargin = static_cast< USHORT >(rUL.GetUpper());
473 nOldLowerMargin = static_cast< USHORT >(rUL.GetLower());
475 // Position
476 const SwFmtHoriOrient& rHori = (const SwFmtHoriOrient&)rSet.Get(RES_HORI_ORIENT);
477 const SwFmtVertOrient& rVert = (const SwFmtVertOrient&)rSet.Get(RES_VERT_ORIENT);
479 aVal.nAnchorType = static_cast< sal_Int16 >(nAnchorId);
480 aVal.bAutoHeight = rFrmSize.GetHeightSizeType() == ATT_MIN_SIZE;
481 aVal.bAutoWidth = rFrmSize.GetWidthSizeType() == ATT_MIN_SIZE;
482 aVal.bMirror = rHori.IsPosToggle();
483 // OD 18.09.2003 #i18732#
484 aVal.bFollowTextFlow =
485 static_cast<const SwFmtFollowTextFlow&>(rSet.Get(RES_FOLLOW_TEXT_FLOW)).GetValue();
487 aVal.nHoriOrient = (short)rHori.GetHoriOrient();
488 aVal.nVertOrient = (short)rVert.GetVertOrient();
490 aVal.nHPos = rHori.GetPos();
491 aVal.nHRelOrient = rHori.GetRelationOrient();
492 aVal.nVPos = rVert.GetPos();
493 aVal.nVRelOrient = rVert.GetRelationOrient();
495 if (rFrmSize.GetWidthPercent() && rFrmSize.GetWidthPercent() != 0xff)
496 aSize.Width() = aSize.Width() * rFrmSize.GetWidthPercent() / 100;
498 if (rFrmSize.GetHeightPercent() && rFrmSize.GetHeightPercent() != 0xff)
499 aSize.Height() = aSize.Height() * rFrmSize.GetHeightPercent() / 100;
501 aVal.nWidth = aSize.Width();
502 aVal.nHeight = aSize.Height();
503 aFrmSize = aSize;
505 aMgr.ValidateMetrics(aVal, 0);
507 SwTwips nLeft;
508 SwTwips nRight;
509 SwTwips nTop;
510 SwTwips nBottom;
512 nLeft = aVal.nHPos - aVal.nMinHPos;
513 nRight = aVal.nMaxWidth - aVal.nWidth;
514 nTop = aVal.nVPos - aVal.nMinVPos;
515 nBottom = aVal.nMaxHeight - aVal.nHeight;
517 if (bHtmlMode && 0 == (nHtmlMode & HTMLMODE_FULL_ABS_POS))
519 nLeft = nRight = ( nLeft + nRight ) / 2;
520 nTop = nBottom = ( nTop + nBottom ) / 2;
522 else
524 if (aVal.nAnchorType == FLY_IN_CNTNT)
526 nLeft = nRight;
528 if (aVal.nVPos < 0)
530 if (aVal.nVPos <= aVal.nMaxHeight)
531 nTop = aVal.nMaxVPos - aVal.nHeight;
532 else
533 nTop = nBottom = 0; // Kein Umlauf
535 else
536 nTop = aVal.nMaxVPos - aVal.nHeight - aVal.nVPos;
538 else
540 nLeft += nRight;
541 nTop += nBottom;
544 nBottom = nTop;
545 nRight = nLeft;
548 aLeftMarginED.SetMax(aLeftMarginED.Normalize(nLeft), FUNIT_TWIP);
549 aRightMarginED.SetMax(aRightMarginED.Normalize(nRight), FUNIT_TWIP);
551 aTopMarginED.SetMax(aTopMarginED.Normalize(nTop), FUNIT_TWIP);
552 aBottomMarginED.SetMax(aBottomMarginED.Normalize(nBottom), FUNIT_TWIP);
554 RangeModifyHdl(&aLeftMarginED);
555 RangeModifyHdl(&aTopMarginED);
558 const SwFmtSurround& rSurround = (const SwFmtSurround&)rSet.Get(RES_SURROUND);
559 SwSurround nSur = rSurround.GetSurround();
561 aWrapTransparentCB.Enable( bEnable && !bHtmlMode && nSur == SURROUND_THROUGHT );
562 if(bHtmlMode)
564 BOOL bSomeAbsPos = 0 != (nHtmlMode & HTMLMODE_SOME_ABS_POS);
565 const SwFmtHoriOrient& rHori = (const SwFmtHoriOrient&)rSet.Get(RES_HORI_ORIENT);
566 sal_Int16 eHOrient = rHori.GetHoriOrient();
567 sal_Int16 eHRelOrient = rHori.GetRelationOrient();
568 aWrapOutlineCB.Hide();
569 BOOL bAllHtmlModes = (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) &&
570 (eHOrient == text::HoriOrientation::RIGHT || eHOrient == text::HoriOrientation::LEFT);
571 aWrapAnchorOnlyCB.Enable( bAllHtmlModes && nSur != SURROUND_NONE );
572 aWrapOutsideCB.Hide();
573 aIdealWrapRB.Enable( FALSE );
576 aWrapTransparentCB.Enable( FALSE );
577 aNoWrapRB.Enable( FLY_AT_CNTNT == nAnchorId );
578 aWrapParallelRB.Enable( FALSE );
579 aWrapLeftRB .Enable( FLY_AT_CNTNT == nAnchorId ||
580 (FLY_AUTO_CNTNT == nAnchorId && eHOrient == text::HoriOrientation::RIGHT && eHRelOrient == text::RelOrientation::PRINT_AREA));
581 aWrapRightRB .Enable( FLY_AT_CNTNT == nAnchorId ||
582 ( FLY_AUTO_CNTNT == nAnchorId && eHOrient == text::HoriOrientation::LEFT && eHRelOrient == text::RelOrientation::PRINT_AREA));
584 aWrapThroughRB.Enable( (FLY_PAGE == nAnchorId ||
585 (FLY_AUTO_CNTNT == nAnchorId && eHRelOrient != text::RelOrientation::PRINT_AREA) || FLY_AT_CNTNT == nAnchorId )
586 && bSomeAbsPos &&
587 eHOrient != text::HoriOrientation::RIGHT);
588 if(aNoWrapRB.IsChecked() && !aNoWrapRB.IsEnabled())
590 if(aWrapThroughRB.IsEnabled())
591 aWrapThroughRB.Check(TRUE);
592 else if(aWrapLeftRB.IsEnabled())
593 aWrapLeftRB.Check();
594 else if(aWrapRightRB.IsEnabled())
595 aWrapRightRB.Check();
598 if(aWrapLeftRB.IsChecked() && !aWrapLeftRB.IsEnabled())
600 if(aWrapRightRB.IsEnabled())
601 aWrapRightRB.Check();
602 else if(aWrapThroughRB.IsEnabled())
603 aWrapThroughRB.Check();
605 if(aWrapRightRB.IsChecked() && !aWrapRightRB.IsEnabled())
607 if(aWrapLeftRB.IsEnabled())
608 aWrapLeftRB.Check();
609 else if(aWrapThroughRB.IsEnabled())
610 aWrapThroughRB.Check();
612 if(aWrapThroughRB.IsChecked() && !aWrapThroughRB.IsEnabled())
613 if(aNoWrapRB.IsEnabled())
614 aNoWrapRB.Check();
616 if(aWrapParallelRB.IsChecked() && !aWrapParallelRB.IsEnabled())
617 aWrapThroughRB.Check();
619 else
621 aNoWrapRB.Enable( bEnable );
622 aWrapLeftRB.Enable( bEnable );
623 aWrapRightRB.Enable( bEnable );
624 aIdealWrapRB.Enable( bEnable );
625 aWrapThroughRB.Enable( bEnable );
626 aWrapParallelRB.Enable( bEnable );
627 aWrapAnchorOnlyCB.Enable( (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT)
628 && nSur != SURROUND_NONE );
630 ContourHdl(0);
635 int SwWrapTabPage::DeactivatePage(SfxItemSet* _pSet)
637 if(_pSet)
638 FillItemSet(*_pSet);
640 return TRUE;
643 /*--------------------------------------------------------------------
644 Beschreibung: Bereichspruefung
645 --------------------------------------------------------------------*/
649 IMPL_LINK( SwWrapTabPage, RangeModifyHdl, MetricField *, pEdit )
651 if(bHtmlMode && 0 == (nHtmlMode & HTMLMODE_FULL_ABS_POS))
653 sal_Int64 nValue = pEdit->GetValue();
654 if (pEdit == &aLeftMarginED)
655 aRightMarginED.SetUserValue(nValue, FUNIT_NONE);
656 else if (pEdit == &aRightMarginED)
657 aLeftMarginED.SetUserValue(nValue, FUNIT_NONE);
658 else if (pEdit == &aTopMarginED)
659 aBottomMarginED.SetUserValue(nValue, FUNIT_NONE);
660 else if (pEdit == &aBottomMarginED)
661 aTopMarginED.SetUserValue(nValue, FUNIT_NONE);
663 else
665 sal_Int64 nValue = pEdit->GetValue();
666 MetricField *pOpposite = 0;
668 if (pEdit == &aLeftMarginED)
669 pOpposite = &aRightMarginED;
670 else if (pEdit == &aRightMarginED)
671 pOpposite = &aLeftMarginED;
672 else if (pEdit == &aTopMarginED)
673 pOpposite = &aBottomMarginED;
674 else if (pEdit == &aBottomMarginED)
675 pOpposite = &aTopMarginED;
677 sal_Int64 nOpposite = pOpposite->GetValue();
679 if (nValue + nOpposite > Max(pEdit->GetMax(), pOpposite->GetMax()))
680 pOpposite->SetValue(pOpposite->GetMax() - nValue);
683 return 0;
686 /*--------------------------------------------------------------------
687 Beschreibung:
688 --------------------------------------------------------------------*/
692 IMPL_LINK( SwWrapTabPage, WrapTypeHdl, ImageRadioButton *, pBtn )
694 BOOL bWrapThrough = (pBtn == &aWrapThroughRB);
695 aWrapTransparentCB.Enable( bWrapThrough && !bHtmlMode );
696 bWrapThrough |= ( nAnchorId == FLY_IN_CNTNT );
697 aWrapOutlineCB.Enable( !bWrapThrough && pBtn != &aNoWrapRB);
698 aWrapOutsideCB.Enable( !bWrapThrough && aWrapOutlineCB.IsChecked() );
699 aWrapAnchorOnlyCB.Enable( (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) &&
700 (pBtn != &aNoWrapRB) );
702 ContourHdl(0);
703 return 0;
706 /*--------------------------------------------------------------------
707 Beschreibung:
708 --------------------------------------------------------------------*/
712 IMPL_LINK( SwWrapTabPage, ContourHdl, CheckBox *, EMPTYARG )
714 BOOL bEnable = !(aWrapOutlineCB.IsChecked() && aWrapOutlineCB.IsEnabled());
716 aWrapOutsideCB.Enable(!bEnable);
718 bEnable = !aWrapOutlineCB.IsChecked();
719 if (bEnable == bContourImage) // damit es nicht immer flackert
721 bContourImage = !bEnable;
722 ApplyImageList();
725 return 0;
728 /*--------------------------------------------------------------------
729 Beschreibung:
730 --------------------------------------------------------------------*/
731 USHORT* SwWrapTabPage::GetRanges()
733 return aWrapPageRg;
735 /* -----------------------------08.05.2002 14:28------------------------------
737 ---------------------------------------------------------------------------*/
738 void SwWrapTabPage::DataChanged( const DataChangedEvent& rDCEvt )
740 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
741 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
742 ApplyImageList();
744 SfxTabPage::DataChanged( rDCEvt );
746 /* -----------------------------08.05.2002 14:28------------------------------
748 ---------------------------------------------------------------------------*/
749 void SwWrapTabPage::ApplyImageList()
751 ImageList& rImgLst = GetDisplayBackground().GetColor().IsDark() ?
752 aWrapILH : aWrapIL;
754 aWrapThroughRB.SetModeRadioImage(rImgLst.GetImage(IMG_THROUGH));
755 BOOL bWrapOutline = !aWrapOutlineCB.IsChecked();
756 if(bWrapOutline)
758 aNoWrapRB.SetModeRadioImage(rImgLst.GetImage(IMG_NONE));
759 aWrapLeftRB.SetModeRadioImage(rImgLst.GetImage(IMG_LEFT));
760 aWrapRightRB.SetModeRadioImage(rImgLst.GetImage(IMG_RIGHT));
761 aWrapParallelRB.SetModeRadioImage(rImgLst.GetImage(IMG_PARALLEL));
762 aIdealWrapRB.SetModeRadioImage(rImgLst.GetImage(IMG_IDEAL));
764 else
766 aNoWrapRB.SetModeRadioImage(rImgLst.GetImage( IMG_KON_NONE ));
767 aWrapLeftRB.SetModeRadioImage(rImgLst.GetImage( IMG_KON_LEFT ));
768 aWrapRightRB.SetModeRadioImage(rImgLst.GetImage( IMG_KON_RIGHT ));
769 aWrapParallelRB.SetModeRadioImage(rImgLst.GetImage(IMG_KON_PARALLEL ));
770 aIdealWrapRB.SetModeRadioImage(rImgLst.GetImage( IMG_KON_IDEAL ));