xref: /aoo41x/main/sw/source/ui/frmdlg/wrap.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "hintids.hxx"
33cdf0e10cSrcweir #include <vcl/graph.hxx>
34cdf0e10cSrcweir #include <svx/htmlmode.hxx>
35cdf0e10cSrcweir #include <sfx2/objsh.hxx>
36cdf0e10cSrcweir #include <svl/intitem.hxx>
37cdf0e10cSrcweir #include <editeng/opaqitem.hxx>
38cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
39cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
40cdf0e10cSrcweir // OD 18.09.2003 #i18732#
41cdf0e10cSrcweir #include <fmtfollowtextflow.hxx>
42cdf0e10cSrcweir #include <svx/swframevalidation.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include "cmdid.h"
46cdf0e10cSrcweir #include "uitool.hxx"
47cdf0e10cSrcweir #include "wrtsh.hxx"
48cdf0e10cSrcweir #include "swmodule.hxx"
49cdf0e10cSrcweir #include "viewopt.hxx"
50cdf0e10cSrcweir #include "frmatr.hxx"
51cdf0e10cSrcweir #include "frmmgr.hxx"
52cdf0e10cSrcweir #include "globals.hrc"
53cdf0e10cSrcweir #include "frmui.hrc"
54cdf0e10cSrcweir #include "wrap.hrc"
55cdf0e10cSrcweir #include "wrap.hxx"
56cdf0e10cSrcweir 
57cdf0e10cSrcweir using namespace ::com::sun::star;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 
60cdf0e10cSrcweir /*--------------------------------------------------------------------
61cdf0e10cSrcweir 	Beschreibung:
62cdf0e10cSrcweir  --------------------------------------------------------------------*/
63cdf0e10cSrcweir 
64cdf0e10cSrcweir static sal_uInt16 __FAR_DATA aWrapPageRg[] = {
65cdf0e10cSrcweir 	RES_LR_SPACE, RES_UL_SPACE,
66cdf0e10cSrcweir 	RES_PROTECT, RES_SURROUND,
67cdf0e10cSrcweir 	RES_PRINT, RES_PRINT,
68cdf0e10cSrcweir 	0
69cdf0e10cSrcweir };
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
72cdf0e10cSrcweir /*--------------------------------------------------------------------
73cdf0e10cSrcweir 	Beschreibung:
74cdf0e10cSrcweir  --------------------------------------------------------------------*/
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 
SwWrapDlg(Window * pParent,SfxItemSet & rSet,SwWrtShell * pSh,sal_Bool bDrawMode)78cdf0e10cSrcweir SwWrapDlg::SwWrapDlg(Window* pParent, SfxItemSet& rSet, SwWrtShell* pSh, sal_Bool bDrawMode) :
79cdf0e10cSrcweir 	SfxSingleTabDialog(pParent, rSet, 0),
80cdf0e10cSrcweir 	pWrtShell(pSh)
81cdf0e10cSrcweir 
82cdf0e10cSrcweir {
83cdf0e10cSrcweir 	// TabPage erzeugen
84cdf0e10cSrcweir     SwWrapTabPage* pNewPage = (SwWrapTabPage*) SwWrapTabPage::Create(this, rSet);
85cdf0e10cSrcweir     pNewPage->SetFormatUsed(sal_False, bDrawMode);
86cdf0e10cSrcweir     pNewPage->SetShell(pWrtShell);
87cdf0e10cSrcweir     SetTabPage(pNewPage);
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	String sTitle(SW_RES(STR_FRMUI_WRAP));
90cdf0e10cSrcweir 	SetText(sTitle);
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 
~SwWrapDlg()95cdf0e10cSrcweir SwWrapDlg::~SwWrapDlg()
96cdf0e10cSrcweir {
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir /*--------------------------------------------------------------------
100cdf0e10cSrcweir 	Beschreibung:
101cdf0e10cSrcweir  --------------------------------------------------------------------*/
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 
SwWrapTabPage(Window * pParent,const SfxItemSet & rSet)105cdf0e10cSrcweir SwWrapTabPage::SwWrapTabPage(Window *pParent, const SfxItemSet &rSet) :
106cdf0e10cSrcweir 	SfxTabPage(pParent, SW_RES(TP_FRM_WRAP), rSet),
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     aWrapFLC           (this, SW_RES(C_WRAP_FL)),
109cdf0e10cSrcweir 	aNoWrapRB			(this, SW_RES(RB_NO_WRAP)),
110cdf0e10cSrcweir 	aWrapLeftRB			(this, SW_RES(RB_WRAP_LEFT)),
111cdf0e10cSrcweir 	aWrapRightRB		(this, SW_RES(RB_WRAP_RIGHT)),
112cdf0e10cSrcweir 	aWrapParallelRB		(this, SW_RES(RB_WRAP_PARALLEL)),
113cdf0e10cSrcweir 	aWrapThroughRB		(this, SW_RES(RB_WRAP_THROUGH)),
114cdf0e10cSrcweir 	aIdealWrapRB		(this, SW_RES(RB_WRAP_IDEAL)),
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     aMarginFL           (this, SW_RES(FL_MARGIN)),
117cdf0e10cSrcweir     aLeftMarginFT       (this, SW_RES(FT_LEFT_MARGIN)),
118cdf0e10cSrcweir     aLeftMarginED       (this, SW_RES(ED_LEFT_MARGIN)),
119cdf0e10cSrcweir     aRightMarginFT      (this, SW_RES(FT_RIGHT_MARGIN)),
120cdf0e10cSrcweir     aRightMarginED      (this, SW_RES(ED_RIGHT_MARGIN)),
121cdf0e10cSrcweir     aTopMarginFT        (this, SW_RES(FT_TOP_MARGIN)),
122cdf0e10cSrcweir     aTopMarginED        (this, SW_RES(ED_TOP_MARGIN)),
123cdf0e10cSrcweir     aBottomMarginFT     (this, SW_RES(FT_BOTTOM_MARGIN)),
124cdf0e10cSrcweir     aBottomMarginED     (this, SW_RES(ED_BOTTOM_MARGIN)),
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     aOptionsSepFL       (this, SW_RES(FL_OPTION_SEP)),
127cdf0e10cSrcweir     aOptionsFL          (this, SW_RES(FL_OPTION)),
128cdf0e10cSrcweir     aWrapAnchorOnlyCB   (this, SW_RES(CB_ANCHOR_ONLY)),
129cdf0e10cSrcweir 	aWrapTransparentCB	(this, SW_RES(CB_TRANSPARENT)),
130cdf0e10cSrcweir 	aWrapOutlineCB		(this, SW_RES(CB_OUTLINE)),
131cdf0e10cSrcweir 	aWrapOutsideCB		(this, SW_RES(CB_ONLYOUTSIDE)),
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     aWrapIL             (SW_RES(IL_WRAP)),
134cdf0e10cSrcweir     aWrapILH            (SW_RES(ILH_WRAP)),
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     nAnchorId(FLY_AT_PARA),
137cdf0e10cSrcweir     nHtmlMode(0),
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     pWrtSh(0),
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     bFormat(sal_False),
142cdf0e10cSrcweir 	bNew(sal_True),
143cdf0e10cSrcweir 	bHtmlMode(sal_False),
144cdf0e10cSrcweir     bContourImage(sal_False)
145cdf0e10cSrcweir 
146cdf0e10cSrcweir {
147cdf0e10cSrcweir 	FreeResource();
148cdf0e10cSrcweir 	SetExchangeSupport();
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	Link aLk = LINK(this, SwWrapTabPage, RangeModifyHdl);
151cdf0e10cSrcweir 	aLeftMarginED.SetUpHdl(aLk);
152cdf0e10cSrcweir 	aLeftMarginED.SetDownHdl(aLk);
153cdf0e10cSrcweir 	aLeftMarginED.SetFirstHdl(aLk);
154cdf0e10cSrcweir 	aLeftMarginED.SetLastHdl(aLk);
155cdf0e10cSrcweir 	aLeftMarginED.SetLoseFocusHdl(aLk);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	aRightMarginED.SetUpHdl(aLk);
158cdf0e10cSrcweir 	aRightMarginED.SetDownHdl(aLk);
159cdf0e10cSrcweir 	aRightMarginED.SetFirstHdl(aLk);
160cdf0e10cSrcweir 	aRightMarginED.SetLastHdl(aLk);
161cdf0e10cSrcweir 	aRightMarginED.SetLoseFocusHdl(aLk);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	aTopMarginED.SetUpHdl(aLk);
164cdf0e10cSrcweir 	aTopMarginED.SetDownHdl(aLk);
165cdf0e10cSrcweir 	aTopMarginED.SetFirstHdl(aLk);
166cdf0e10cSrcweir 	aTopMarginED.SetLastHdl(aLk);
167cdf0e10cSrcweir 	aTopMarginED.SetLoseFocusHdl(aLk);
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	aBottomMarginED.SetUpHdl(aLk);
170cdf0e10cSrcweir 	aBottomMarginED.SetDownHdl(aLk);
171cdf0e10cSrcweir 	aBottomMarginED.SetFirstHdl(aLk);
172cdf0e10cSrcweir 	aBottomMarginED.SetLastHdl(aLk);
173cdf0e10cSrcweir 	aBottomMarginED.SetLoseFocusHdl(aLk);
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	aLk = LINK(this, SwWrapTabPage, WrapTypeHdl);
176cdf0e10cSrcweir 	aNoWrapRB.SetClickHdl(aLk);
177cdf0e10cSrcweir 	aWrapLeftRB.SetClickHdl(aLk);
178cdf0e10cSrcweir 	aWrapRightRB.SetClickHdl(aLk);
179cdf0e10cSrcweir 	aWrapParallelRB.SetClickHdl(aLk);
180cdf0e10cSrcweir 	aWrapThroughRB.SetClickHdl(aLk);
181cdf0e10cSrcweir 	aIdealWrapRB.SetClickHdl(aLk);
182cdf0e10cSrcweir     ApplyImageList();
183cdf0e10cSrcweir 	aWrapOutlineCB.SetClickHdl(LINK(this, SwWrapTabPage, ContourHdl));
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 
~SwWrapTabPage()188cdf0e10cSrcweir SwWrapTabPage::~SwWrapTabPage()
189cdf0e10cSrcweir {
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 
Create(Window * pParent,const SfxItemSet & rSet)194cdf0e10cSrcweir SfxTabPage* SwWrapTabPage::Create(Window *pParent, const SfxItemSet &rSet)
195cdf0e10cSrcweir {
196cdf0e10cSrcweir 	return new SwWrapTabPage(pParent, rSet);
197cdf0e10cSrcweir }
198cdf0e10cSrcweir /*--------------------------------------------------------------------
199cdf0e10cSrcweir 	Beschreibung:
200cdf0e10cSrcweir  --------------------------------------------------------------------*/
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 
Reset(const SfxItemSet & rSet)204cdf0e10cSrcweir void SwWrapTabPage::Reset(const SfxItemSet &rSet)
205cdf0e10cSrcweir {
206cdf0e10cSrcweir 	//Contour fuer Draw, Grafik und OLE (Einfuegen/Grafik/Eigenschaften fehlt noch!)
207cdf0e10cSrcweir 	if( bDrawMode )
208cdf0e10cSrcweir 	{
209cdf0e10cSrcweir 		aWrapOutlineCB.Show();
210cdf0e10cSrcweir 		aWrapOutsideCB.Show();
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 		aWrapTransparentCB.Check( 0 == ((const SfxInt16Item&)rSet.Get(
213cdf0e10cSrcweir 										FN_DRAW_WRAP_DLG)).GetValue() );
214cdf0e10cSrcweir 		aWrapTransparentCB.SaveValue();
215cdf0e10cSrcweir 	}
216cdf0e10cSrcweir 	else
217cdf0e10cSrcweir 	{
218cdf0e10cSrcweir 		sal_Bool bShowCB = bFormat;
219cdf0e10cSrcweir 		if( !bFormat )
220cdf0e10cSrcweir 		{
221cdf0e10cSrcweir 			int nSelType = pWrtSh->GetSelectionType();
222cdf0e10cSrcweir 			if( ( nSelType & nsSelectionType::SEL_GRF ) ||
223cdf0e10cSrcweir 			    ( nSelType & nsSelectionType::SEL_OLE && GRAPHIC_NONE !=
224cdf0e10cSrcweir 				            pWrtSh->GetIMapGraphic().GetType() ))
225cdf0e10cSrcweir 				bShowCB = sal_True;
226cdf0e10cSrcweir 		}
227cdf0e10cSrcweir 		if( bShowCB )
228cdf0e10cSrcweir 		{
229cdf0e10cSrcweir 			aWrapOutlineCB.Show();
230cdf0e10cSrcweir 			aWrapOutsideCB.Show();
231cdf0e10cSrcweir 		}
232cdf0e10cSrcweir 	}
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 	nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
235cdf0e10cSrcweir 	bHtmlMode = nHtmlMode & HTMLMODE_ON ? sal_True : sal_False;
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 	FieldUnit aMetric = ::GetDfltMetric(bHtmlMode);
238cdf0e10cSrcweir 	SetMetric( aLeftMarginED  , aMetric );
239cdf0e10cSrcweir 	SetMetric( aRightMarginED , aMetric );
240cdf0e10cSrcweir 	SetMetric( aTopMarginED   , aMetric );
241cdf0e10cSrcweir 	SetMetric( aBottomMarginED, aMetric );
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 	const SwFmtSurround& rSurround = (const SwFmtSurround&)rSet.Get(RES_SURROUND);
244cdf0e10cSrcweir 
245cdf0e10cSrcweir     SwSurround nSur = rSurround.GetSurround();
246cdf0e10cSrcweir 	const SwFmtAnchor &rAnch = (const SwFmtAnchor&)rSet.Get(RES_ANCHOR);
247cdf0e10cSrcweir 	nAnchorId = rAnch.GetAnchorId();
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     if (((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR))
250cdf0e10cSrcweir         && (nSur != SURROUND_NONE))
251cdf0e10cSrcweir     {
252cdf0e10cSrcweir 		aWrapAnchorOnlyCB.Check( rSurround.IsAnchorOnly() );
253cdf0e10cSrcweir     }
254cdf0e10cSrcweir 	else
255cdf0e10cSrcweir     {
256cdf0e10cSrcweir 		aWrapAnchorOnlyCB.Enable( sal_False );
257cdf0e10cSrcweir     }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	sal_Bool bContour = rSurround.IsContour();
260cdf0e10cSrcweir 	aWrapOutlineCB.Check( bContour );
261cdf0e10cSrcweir 	aWrapOutsideCB.Check( rSurround.IsOutside() );
262cdf0e10cSrcweir 	aWrapThroughRB.Enable(!aWrapOutlineCB.IsChecked());
263cdf0e10cSrcweir 	bContourImage = !bContour;
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 	ImageRadioButton* pBtn = NULL;
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 	switch (nSur)
268cdf0e10cSrcweir 	{
269cdf0e10cSrcweir 		case SURROUND_NONE:
270cdf0e10cSrcweir 		{
271cdf0e10cSrcweir 			pBtn = &aNoWrapRB;
272cdf0e10cSrcweir 			break;
273cdf0e10cSrcweir 		}
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 		case SURROUND_THROUGHT:
276cdf0e10cSrcweir 		{
277cdf0e10cSrcweir 			// transparent ?
278cdf0e10cSrcweir 			pBtn = &aWrapThroughRB;
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 			if (!bDrawMode)
281cdf0e10cSrcweir 			{
282cdf0e10cSrcweir 				const SvxOpaqueItem& rOpaque = (const SvxOpaqueItem&)rSet.Get(RES_OPAQUE);
283cdf0e10cSrcweir 				aWrapTransparentCB.Check(!rOpaque.GetValue());
284cdf0e10cSrcweir 			}
285cdf0e10cSrcweir 			break;
286cdf0e10cSrcweir 		}
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 		case SURROUND_PARALLEL:
289cdf0e10cSrcweir 		{
290cdf0e10cSrcweir 			pBtn = &aWrapParallelRB;
291cdf0e10cSrcweir 			break;
292cdf0e10cSrcweir 		}
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 		case SURROUND_IDEAL:
295cdf0e10cSrcweir 		{
296cdf0e10cSrcweir 			pBtn = &aIdealWrapRB;
297cdf0e10cSrcweir 			break;
298cdf0e10cSrcweir 		}
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 		default:
301cdf0e10cSrcweir 		{
302cdf0e10cSrcweir 			if (nSur == SURROUND_LEFT)
303cdf0e10cSrcweir 				pBtn = &aWrapLeftRB;
304cdf0e10cSrcweir 			else if (nSur == SURROUND_RIGHT)
305cdf0e10cSrcweir 				pBtn = &aWrapRightRB;
306cdf0e10cSrcweir 		}
307cdf0e10cSrcweir 	}
308cdf0e10cSrcweir 	if (pBtn)
309cdf0e10cSrcweir 	{
310cdf0e10cSrcweir 		pBtn->Check();
311cdf0e10cSrcweir 		WrapTypeHdl(pBtn);
312cdf0e10cSrcweir 		// Hier wird fuer Zeichenobjekte, die im Moment auf Durchlauf stehen,
313cdf0e10cSrcweir 		// schon mal der Default "Kontur an" vorbereitet, falls man spaeter auf
314cdf0e10cSrcweir 		// irgendeinen Umlauf umschaltet.
315cdf0e10cSrcweir 		if (bDrawMode && !aWrapOutlineCB.IsEnabled())
316cdf0e10cSrcweir 			aWrapOutlineCB.Check();
317cdf0e10cSrcweir 	}
318cdf0e10cSrcweir 	aWrapTransparentCB.Enable( pBtn == &aWrapThroughRB && !bHtmlMode );
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 	const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rSet.Get(RES_UL_SPACE);
321cdf0e10cSrcweir 	const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rSet.Get(RES_LR_SPACE);
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 	// Abstand zum Text
324cdf0e10cSrcweir 	aLeftMarginED.SetValue(aLeftMarginED.Normalize(rLR.GetLeft()), FUNIT_TWIP);
325cdf0e10cSrcweir 	aRightMarginED.SetValue(aRightMarginED.Normalize(rLR.GetRight()), FUNIT_TWIP);
326cdf0e10cSrcweir 	aTopMarginED.SetValue(aTopMarginED.Normalize(rUL.GetUpper()), FUNIT_TWIP);
327cdf0e10cSrcweir 	aBottomMarginED.SetValue(aBottomMarginED.Normalize(rUL.GetLower()), FUNIT_TWIP);
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 	ContourHdl(0);
330cdf0e10cSrcweir 	ActivatePage( rSet );
331cdf0e10cSrcweir }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir /*--------------------------------------------------------------------
334cdf0e10cSrcweir 	Beschreibung:	Attribute in den Set stopfen bei OK
335cdf0e10cSrcweir  --------------------------------------------------------------------*/
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 
FillItemSet(SfxItemSet & rSet)339cdf0e10cSrcweir sal_Bool SwWrapTabPage::FillItemSet(SfxItemSet &rSet)
340cdf0e10cSrcweir {
341cdf0e10cSrcweir 	sal_Bool bModified = sal_False;
342cdf0e10cSrcweir 	const SfxPoolItem* pOldItem;
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 	const SwFmtSurround& rOldSur = (const SwFmtSurround&)GetItemSet().Get(RES_SURROUND);
345cdf0e10cSrcweir 	SwFmtSurround aSur( rOldSur );
346cdf0e10cSrcweir 
347cdf0e10cSrcweir     SvxOpaqueItem aOp( RES_OPAQUE);
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 	if (!bDrawMode)
350cdf0e10cSrcweir 	{
351cdf0e10cSrcweir 		const SvxOpaqueItem& rOpaque = (const SvxOpaqueItem&)GetItemSet().Get(RES_OPAQUE);
352cdf0e10cSrcweir         aOp = rOpaque;
353cdf0e10cSrcweir 		aOp.SetValue(sal_True);
354cdf0e10cSrcweir 	}
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 	if (aNoWrapRB.IsChecked())
357cdf0e10cSrcweir 		aSur.SetSurround(SURROUND_NONE);
358cdf0e10cSrcweir 	else if (aWrapLeftRB.IsChecked())
359cdf0e10cSrcweir 		aSur.SetSurround(SURROUND_LEFT);
360cdf0e10cSrcweir 	else if (aWrapRightRB.IsChecked())
361cdf0e10cSrcweir 		aSur.SetSurround(SURROUND_RIGHT);
362cdf0e10cSrcweir 	else if (aWrapParallelRB.IsChecked())
363cdf0e10cSrcweir 		aSur.SetSurround(SURROUND_PARALLEL);
364cdf0e10cSrcweir 	else if (aWrapThroughRB.IsChecked())
365cdf0e10cSrcweir 	{
366cdf0e10cSrcweir 		aSur.SetSurround(SURROUND_THROUGHT);
367cdf0e10cSrcweir 		if (aWrapTransparentCB.IsChecked() && !bDrawMode)
368cdf0e10cSrcweir 			aOp.SetValue(sal_False);
369cdf0e10cSrcweir 	}
370cdf0e10cSrcweir 	else if (aIdealWrapRB.IsChecked())
371cdf0e10cSrcweir 		aSur.SetSurround(SURROUND_IDEAL);
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 	aSur.SetAnchorOnly( aWrapAnchorOnlyCB.IsChecked() );
374cdf0e10cSrcweir 	sal_Bool bContour = aWrapOutlineCB.IsChecked() && aWrapOutlineCB.IsEnabled();
375cdf0e10cSrcweir 	aSur.SetContour( bContour );
376cdf0e10cSrcweir 
377cdf0e10cSrcweir 	if ( bContour )
378cdf0e10cSrcweir 		aSur.SetOutside(aWrapOutsideCB.IsChecked());
379cdf0e10cSrcweir 
380cdf0e10cSrcweir 	if(0 == (pOldItem = GetOldItem( rSet, RES_SURROUND )) ||
381cdf0e10cSrcweir 				aSur != *pOldItem )
382cdf0e10cSrcweir 	{
383cdf0e10cSrcweir 		rSet.Put(aSur);
384cdf0e10cSrcweir 		bModified = sal_True;
385cdf0e10cSrcweir 	}
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 	if (!bDrawMode)
388cdf0e10cSrcweir 	{
389cdf0e10cSrcweir 		if(0 == (pOldItem = GetOldItem( rSet, FN_OPAQUE )) ||
390cdf0e10cSrcweir 					aOp != *pOldItem )
391cdf0e10cSrcweir 		{
392cdf0e10cSrcweir 			rSet.Put(aOp);
393cdf0e10cSrcweir 			bModified = sal_True;
394cdf0e10cSrcweir 		}
395cdf0e10cSrcweir 	}
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 	sal_Bool bTopMod = aTopMarginED.IsValueModified();
398cdf0e10cSrcweir 	sal_Bool bBottomMod = aBottomMarginED.IsValueModified();
399cdf0e10cSrcweir 
400cdf0e10cSrcweir     SvxULSpaceItem aUL( RES_UL_SPACE );
401cdf0e10cSrcweir 	aUL.SetUpper((sal_uInt16)aTopMarginED.Denormalize(aTopMarginED.GetValue(FUNIT_TWIP)));
402cdf0e10cSrcweir 	aUL.SetLower((sal_uInt16)aBottomMarginED.Denormalize(aBottomMarginED.GetValue(FUNIT_TWIP)));
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 	if ( bTopMod || bBottomMod )
405cdf0e10cSrcweir 	{
406cdf0e10cSrcweir 		if(0 == (pOldItem = GetOldItem(rSet, RES_UL_SPACE)) ||
407cdf0e10cSrcweir 				aUL != *pOldItem )
408cdf0e10cSrcweir 		{
409cdf0e10cSrcweir 			rSet.Put( aUL, RES_UL_SPACE );
410cdf0e10cSrcweir 			bModified = sal_True;
411cdf0e10cSrcweir 		}
412cdf0e10cSrcweir 	}
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 	sal_Bool bLeftMod = aLeftMarginED.IsValueModified();
415cdf0e10cSrcweir 	sal_Bool bRightMod = aRightMarginED.IsValueModified();
416cdf0e10cSrcweir 
417cdf0e10cSrcweir     SvxLRSpaceItem aLR( RES_LR_SPACE );
418cdf0e10cSrcweir 	aLR.SetLeft((sal_uInt16)aLeftMarginED.Denormalize(aLeftMarginED.GetValue(FUNIT_TWIP)));
419cdf0e10cSrcweir 	aLR.SetRight((sal_uInt16)aRightMarginED.Denormalize(aRightMarginED.GetValue(FUNIT_TWIP)));
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 	if ( bLeftMod || bRightMod )
422cdf0e10cSrcweir 	{
423cdf0e10cSrcweir 		if( 0 == (pOldItem = GetOldItem(rSet, RES_LR_SPACE)) ||
424cdf0e10cSrcweir 				aLR != *pOldItem )
425cdf0e10cSrcweir 		{
426cdf0e10cSrcweir 			rSet.Put(aLR, RES_LR_SPACE);
427cdf0e10cSrcweir 			bModified = sal_True;
428cdf0e10cSrcweir 		}
429cdf0e10cSrcweir 	}
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 	if ( bDrawMode )
432cdf0e10cSrcweir 	{
433cdf0e10cSrcweir 		sal_Bool bChecked = aWrapTransparentCB.IsChecked() & aWrapTransparentCB.IsEnabled();
434cdf0e10cSrcweir 		if (aWrapTransparentCB.GetSavedValue() != bChecked)
435cdf0e10cSrcweir 			bModified |= 0 != rSet.Put(SfxInt16Item(FN_DRAW_WRAP_DLG, bChecked ? 0 : 1));
436cdf0e10cSrcweir 	}
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 	return bModified;
439cdf0e10cSrcweir }
440cdf0e10cSrcweir 
441cdf0e10cSrcweir /*--------------------------------------------------------------------
442cdf0e10cSrcweir 	Beschreibung:	Bsp - Update
443cdf0e10cSrcweir  --------------------------------------------------------------------*/
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 
ActivatePage(const SfxItemSet & rSet)447cdf0e10cSrcweir void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet)
448cdf0e10cSrcweir {
449cdf0e10cSrcweir 	// Anchor
450cdf0e10cSrcweir 	const SwFmtAnchor &rAnch = (const SwFmtAnchor&)rSet.Get(RES_ANCHOR);
451cdf0e10cSrcweir 	nAnchorId = rAnch.GetAnchorId();
452cdf0e10cSrcweir     sal_Bool bEnable = (nAnchorId != FLY_AS_CHAR);
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 	if (!bDrawMode)
455cdf0e10cSrcweir 	{
456cdf0e10cSrcweir 		SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell() : pWrtSh;
457cdf0e10cSrcweir 		SwFlyFrmAttrMgr aMgr( bNew, pSh, (const SwAttrSet&)GetItemSet() );
458cdf0e10cSrcweir         SvxSwFrameValidation aVal;
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 		// Size
461cdf0e10cSrcweir 		const SwFmtFrmSize& rFrmSize = (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE);
462cdf0e10cSrcweir 		Size aSize = rFrmSize.GetSize();
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 		// Rand
465cdf0e10cSrcweir 		const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rSet.Get(RES_UL_SPACE);
466cdf0e10cSrcweir 		const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rSet.Get(RES_LR_SPACE);
467cdf0e10cSrcweir         nOldLeftMargin  = static_cast< sal_uInt16 >(rLR.GetLeft());
468cdf0e10cSrcweir         nOldRightMargin = static_cast< sal_uInt16 >(rLR.GetRight());
469cdf0e10cSrcweir         nOldUpperMargin = static_cast< sal_uInt16 >(rUL.GetUpper());
470cdf0e10cSrcweir         nOldLowerMargin = static_cast< sal_uInt16 >(rUL.GetLower());
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 		// Position
473cdf0e10cSrcweir 		const SwFmtHoriOrient& rHori = (const SwFmtHoriOrient&)rSet.Get(RES_HORI_ORIENT);
474cdf0e10cSrcweir 		const SwFmtVertOrient& rVert = (const SwFmtVertOrient&)rSet.Get(RES_VERT_ORIENT);
475cdf0e10cSrcweir 
476cdf0e10cSrcweir         aVal.nAnchorType = static_cast< sal_Int16 >(nAnchorId);
477cdf0e10cSrcweir 		aVal.bAutoHeight = rFrmSize.GetHeightSizeType() == ATT_MIN_SIZE;
478cdf0e10cSrcweir 		aVal.bAutoWidth = rFrmSize.GetWidthSizeType() == ATT_MIN_SIZE;
479cdf0e10cSrcweir 		aVal.bMirror = rHori.IsPosToggle();
480cdf0e10cSrcweir         // OD 18.09.2003 #i18732#
481cdf0e10cSrcweir         aVal.bFollowTextFlow =
482cdf0e10cSrcweir             static_cast<const SwFmtFollowTextFlow&>(rSet.Get(RES_FOLLOW_TEXT_FLOW)).GetValue();
483cdf0e10cSrcweir 
484cdf0e10cSrcweir         aVal.nHoriOrient = (short)rHori.GetHoriOrient();
485cdf0e10cSrcweir         aVal.nVertOrient = (short)rVert.GetVertOrient();
486cdf0e10cSrcweir 
487cdf0e10cSrcweir 		aVal.nHPos = rHori.GetPos();
488cdf0e10cSrcweir         aVal.nHRelOrient = rHori.GetRelationOrient();
489cdf0e10cSrcweir 		aVal.nVPos = rVert.GetPos();
490cdf0e10cSrcweir         aVal.nVRelOrient = rVert.GetRelationOrient();
491cdf0e10cSrcweir 
492cdf0e10cSrcweir 		if (rFrmSize.GetWidthPercent() && rFrmSize.GetWidthPercent() != 0xff)
493cdf0e10cSrcweir 			aSize.Width() = aSize.Width() * rFrmSize.GetWidthPercent() / 100;
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 		if (rFrmSize.GetHeightPercent() && rFrmSize.GetHeightPercent() != 0xff)
496cdf0e10cSrcweir 			aSize.Height() = aSize.Height() * rFrmSize.GetHeightPercent() / 100;
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 		aVal.nWidth  = aSize.Width();
499cdf0e10cSrcweir 		aVal.nHeight = aSize.Height();
500cdf0e10cSrcweir 		aFrmSize = aSize;
501cdf0e10cSrcweir 
502cdf0e10cSrcweir         aMgr.ValidateMetrics(aVal, 0);
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 		SwTwips nLeft;
505cdf0e10cSrcweir 		SwTwips nRight;
506cdf0e10cSrcweir 		SwTwips nTop;
507cdf0e10cSrcweir 		SwTwips nBottom;
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 		nLeft	= aVal.nHPos - aVal.nMinHPos;
510cdf0e10cSrcweir 		nRight	= aVal.nMaxWidth - aVal.nWidth;
511cdf0e10cSrcweir 		nTop	= aVal.nVPos - aVal.nMinVPos;
512cdf0e10cSrcweir 		nBottom	= aVal.nMaxHeight - aVal.nHeight;
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 		if (bHtmlMode && 0 == (nHtmlMode & HTMLMODE_FULL_ABS_POS))
515cdf0e10cSrcweir 		{
516cdf0e10cSrcweir 			nLeft = nRight = ( nLeft + nRight ) / 2;
517cdf0e10cSrcweir 			nTop = nBottom = ( nTop + nBottom ) / 2;
518cdf0e10cSrcweir 		}
519cdf0e10cSrcweir 		else
520cdf0e10cSrcweir 		{
521cdf0e10cSrcweir             if (aVal.nAnchorType == FLY_AS_CHAR)
522cdf0e10cSrcweir 			{
523cdf0e10cSrcweir 				nLeft = nRight;
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 				if (aVal.nVPos < 0)
526cdf0e10cSrcweir 				{
527cdf0e10cSrcweir 					if (aVal.nVPos <= aVal.nMaxHeight)
528cdf0e10cSrcweir 						nTop = aVal.nMaxVPos - aVal.nHeight;
529cdf0e10cSrcweir 					else
530cdf0e10cSrcweir 						nTop = nBottom = 0;	// Kein Umlauf
531cdf0e10cSrcweir 				}
532cdf0e10cSrcweir 				else
533cdf0e10cSrcweir 					nTop = aVal.nMaxVPos - aVal.nHeight - aVal.nVPos;
534cdf0e10cSrcweir 			}
535cdf0e10cSrcweir 			else
536cdf0e10cSrcweir 			{
537cdf0e10cSrcweir 				nLeft += nRight;
538cdf0e10cSrcweir 				nTop += nBottom;
539cdf0e10cSrcweir 			}
540cdf0e10cSrcweir 
541cdf0e10cSrcweir 			nBottom	= nTop;
542cdf0e10cSrcweir 			nRight = nLeft;
543cdf0e10cSrcweir 		}
544cdf0e10cSrcweir 
545cdf0e10cSrcweir 		aLeftMarginED.SetMax(aLeftMarginED.Normalize(nLeft), FUNIT_TWIP);
546cdf0e10cSrcweir 		aRightMarginED.SetMax(aRightMarginED.Normalize(nRight), FUNIT_TWIP);
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 		aTopMarginED.SetMax(aTopMarginED.Normalize(nTop), FUNIT_TWIP);
549cdf0e10cSrcweir 		aBottomMarginED.SetMax(aBottomMarginED.Normalize(nBottom), FUNIT_TWIP);
550cdf0e10cSrcweir 
551cdf0e10cSrcweir 		RangeModifyHdl(&aLeftMarginED);
552cdf0e10cSrcweir 		RangeModifyHdl(&aTopMarginED);
553cdf0e10cSrcweir 	}
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 	const SwFmtSurround& rSurround = (const SwFmtSurround&)rSet.Get(RES_SURROUND);
556cdf0e10cSrcweir     SwSurround nSur = rSurround.GetSurround();
557cdf0e10cSrcweir 
558cdf0e10cSrcweir 	aWrapTransparentCB.Enable( bEnable && !bHtmlMode && nSur == SURROUND_THROUGHT );
559cdf0e10cSrcweir 	if(bHtmlMode)
560cdf0e10cSrcweir 	{
561cdf0e10cSrcweir 		sal_Bool bSomeAbsPos = 0 != (nHtmlMode & HTMLMODE_SOME_ABS_POS);
562cdf0e10cSrcweir 		const SwFmtHoriOrient& rHori = (const SwFmtHoriOrient&)rSet.Get(RES_HORI_ORIENT);
563cdf0e10cSrcweir         sal_Int16 eHOrient = rHori.GetHoriOrient();
564cdf0e10cSrcweir         sal_Int16 eHRelOrient = rHori.GetRelationOrient();
565cdf0e10cSrcweir 		aWrapOutlineCB.Hide();
566cdf0e10cSrcweir         const bool bAllHtmlModes =
567cdf0e10cSrcweir             ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) &&
568cdf0e10cSrcweir                             (eHOrient == text::HoriOrientation::RIGHT || eHOrient == text::HoriOrientation::LEFT);
569cdf0e10cSrcweir 		aWrapAnchorOnlyCB.Enable( bAllHtmlModes && nSur != SURROUND_NONE );
570cdf0e10cSrcweir 		aWrapOutsideCB.Hide();
571cdf0e10cSrcweir 		aIdealWrapRB.Enable( sal_False );
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 		aWrapTransparentCB.Enable( sal_False );
575cdf0e10cSrcweir         aNoWrapRB.Enable( FLY_AT_PARA == nAnchorId );
576cdf0e10cSrcweir 		aWrapParallelRB.Enable( sal_False  );
577cdf0e10cSrcweir         aWrapLeftRB       .Enable
578cdf0e10cSrcweir                     (  (FLY_AT_PARA == nAnchorId)
579cdf0e10cSrcweir                     || (   (FLY_AT_CHAR == nAnchorId)
580cdf0e10cSrcweir                         && (eHOrient == text::HoriOrientation::RIGHT)
581cdf0e10cSrcweir                         && (eHRelOrient == text::RelOrientation::PRINT_AREA)));
582cdf0e10cSrcweir         aWrapRightRB      .Enable
583cdf0e10cSrcweir                     (  (FLY_AT_PARA == nAnchorId)
584cdf0e10cSrcweir                     || (   (FLY_AT_CHAR == nAnchorId)
585cdf0e10cSrcweir                         && (eHOrient == text::HoriOrientation::LEFT)
586cdf0e10cSrcweir                         && (eHRelOrient == text::RelOrientation::PRINT_AREA)));
587cdf0e10cSrcweir 
588cdf0e10cSrcweir         aWrapThroughRB.Enable
589cdf0e10cSrcweir                 (   (  (FLY_AT_PAGE == nAnchorId)
590cdf0e10cSrcweir                     || (   (FLY_AT_CHAR == nAnchorId)
591cdf0e10cSrcweir                         && (eHRelOrient != text::RelOrientation::PRINT_AREA))
592cdf0e10cSrcweir                     || (FLY_AT_PARA == nAnchorId))
593cdf0e10cSrcweir                 && bSomeAbsPos
594cdf0e10cSrcweir                 && (eHOrient != text::HoriOrientation::RIGHT));
595cdf0e10cSrcweir 		if(aNoWrapRB.IsChecked() && !aNoWrapRB.IsEnabled())
596cdf0e10cSrcweir 		{
597cdf0e10cSrcweir 			if(aWrapThroughRB.IsEnabled())
598cdf0e10cSrcweir 				aWrapThroughRB.Check(sal_True);
599cdf0e10cSrcweir 			else if(aWrapLeftRB.IsEnabled())
600cdf0e10cSrcweir 				aWrapLeftRB.Check();
601cdf0e10cSrcweir 			else if(aWrapRightRB.IsEnabled())
602cdf0e10cSrcweir 				aWrapRightRB.Check();
603cdf0e10cSrcweir 
604cdf0e10cSrcweir 		}
605cdf0e10cSrcweir 		if(aWrapLeftRB.IsChecked() && !aWrapLeftRB.IsEnabled())
606cdf0e10cSrcweir 		{
607cdf0e10cSrcweir 			if(aWrapRightRB.IsEnabled())
608cdf0e10cSrcweir 				aWrapRightRB.Check();
609cdf0e10cSrcweir 			else if(aWrapThroughRB.IsEnabled())
610cdf0e10cSrcweir 				aWrapThroughRB.Check();
611cdf0e10cSrcweir 		}
612cdf0e10cSrcweir 		if(aWrapRightRB.IsChecked() && !aWrapRightRB.IsEnabled())
613cdf0e10cSrcweir 		{
614cdf0e10cSrcweir 			if(aWrapLeftRB.IsEnabled())
615cdf0e10cSrcweir 				aWrapLeftRB.Check();
616cdf0e10cSrcweir 			else if(aWrapThroughRB.IsEnabled())
617cdf0e10cSrcweir 				aWrapThroughRB.Check();
618cdf0e10cSrcweir 		}
619cdf0e10cSrcweir 		if(aWrapThroughRB.IsChecked() && !aWrapThroughRB.IsEnabled())
620cdf0e10cSrcweir 			if(aNoWrapRB.IsEnabled())
621cdf0e10cSrcweir 				aNoWrapRB.Check();
622cdf0e10cSrcweir 
623cdf0e10cSrcweir 		if(aWrapParallelRB.IsChecked() && !aWrapParallelRB.IsEnabled())
624cdf0e10cSrcweir 			aWrapThroughRB.Check();
625cdf0e10cSrcweir 	}
626cdf0e10cSrcweir 	else
627cdf0e10cSrcweir 	{
628cdf0e10cSrcweir 		aNoWrapRB.Enable( bEnable );
629cdf0e10cSrcweir 		aWrapLeftRB.Enable( bEnable );
630cdf0e10cSrcweir 		aWrapRightRB.Enable( bEnable );
631cdf0e10cSrcweir 		aIdealWrapRB.Enable( bEnable );
632cdf0e10cSrcweir 		aWrapThroughRB.Enable( bEnable );
633cdf0e10cSrcweir 		aWrapParallelRB.Enable( bEnable );
634cdf0e10cSrcweir         aWrapAnchorOnlyCB.Enable(
635cdf0e10cSrcweir                 ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR))
636cdf0e10cSrcweir 				&& nSur != SURROUND_NONE );
637cdf0e10cSrcweir 	}
638cdf0e10cSrcweir 	ContourHdl(0);
639cdf0e10cSrcweir }
640cdf0e10cSrcweir 
641cdf0e10cSrcweir 
642cdf0e10cSrcweir 
DeactivatePage(SfxItemSet * _pSet)643cdf0e10cSrcweir int SwWrapTabPage::DeactivatePage(SfxItemSet* _pSet)
644cdf0e10cSrcweir {
645cdf0e10cSrcweir     if(_pSet)
646cdf0e10cSrcweir         FillItemSet(*_pSet);
647cdf0e10cSrcweir 
648cdf0e10cSrcweir 	return sal_True;
649cdf0e10cSrcweir }
650cdf0e10cSrcweir 
651cdf0e10cSrcweir /*--------------------------------------------------------------------
652cdf0e10cSrcweir 	Beschreibung:	Bereichspruefung
653cdf0e10cSrcweir  --------------------------------------------------------------------*/
654cdf0e10cSrcweir 
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 
IMPL_LINK(SwWrapTabPage,RangeModifyHdl,MetricField *,pEdit)657cdf0e10cSrcweir IMPL_LINK( SwWrapTabPage, RangeModifyHdl, MetricField *, pEdit )
658cdf0e10cSrcweir {
659cdf0e10cSrcweir 	if(bHtmlMode && 0 == (nHtmlMode & HTMLMODE_FULL_ABS_POS))
660cdf0e10cSrcweir 	{
661cdf0e10cSrcweir         sal_Int64 nValue = pEdit->GetValue();
662cdf0e10cSrcweir 		if (pEdit == &aLeftMarginED)
663cdf0e10cSrcweir 			aRightMarginED.SetUserValue(nValue, FUNIT_NONE);
664cdf0e10cSrcweir 		else if (pEdit == &aRightMarginED)
665cdf0e10cSrcweir 			aLeftMarginED.SetUserValue(nValue, FUNIT_NONE);
666cdf0e10cSrcweir 		else if (pEdit == &aTopMarginED)
667cdf0e10cSrcweir 			aBottomMarginED.SetUserValue(nValue, FUNIT_NONE);
668cdf0e10cSrcweir 		else if (pEdit == &aBottomMarginED)
669cdf0e10cSrcweir 			aTopMarginED.SetUserValue(nValue, FUNIT_NONE);
670cdf0e10cSrcweir 	}
671cdf0e10cSrcweir 	else
672cdf0e10cSrcweir 	{
673cdf0e10cSrcweir         sal_Int64 nValue = pEdit->GetValue();
674cdf0e10cSrcweir         MetricField *pOpposite = 0;
675cdf0e10cSrcweir 
676cdf0e10cSrcweir 		if (pEdit == &aLeftMarginED)
677cdf0e10cSrcweir 			pOpposite = &aRightMarginED;
678cdf0e10cSrcweir 		else if (pEdit == &aRightMarginED)
679cdf0e10cSrcweir 			pOpposite = &aLeftMarginED;
680cdf0e10cSrcweir 		else if (pEdit == &aTopMarginED)
681cdf0e10cSrcweir 			pOpposite = &aBottomMarginED;
682cdf0e10cSrcweir 		else if (pEdit == &aBottomMarginED)
683cdf0e10cSrcweir 			pOpposite = &aTopMarginED;
684cdf0e10cSrcweir 
685cdf0e10cSrcweir         sal_Int64 nOpposite = pOpposite->GetValue();
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 		if (nValue + nOpposite > Max(pEdit->GetMax(), pOpposite->GetMax()))
688cdf0e10cSrcweir 			pOpposite->SetValue(pOpposite->GetMax() - nValue);
689cdf0e10cSrcweir 	}
690cdf0e10cSrcweir 
691cdf0e10cSrcweir 	return 0;
692cdf0e10cSrcweir }
693cdf0e10cSrcweir 
694cdf0e10cSrcweir /*--------------------------------------------------------------------
695cdf0e10cSrcweir 	Beschreibung:
696cdf0e10cSrcweir  --------------------------------------------------------------------*/
697cdf0e10cSrcweir 
698cdf0e10cSrcweir 
699cdf0e10cSrcweir 
IMPL_LINK(SwWrapTabPage,WrapTypeHdl,ImageRadioButton *,pBtn)700cdf0e10cSrcweir IMPL_LINK( SwWrapTabPage, WrapTypeHdl, ImageRadioButton *, pBtn )
701cdf0e10cSrcweir {
702cdf0e10cSrcweir 	sal_Bool bWrapThrough = (pBtn == &aWrapThroughRB);
703cdf0e10cSrcweir 	aWrapTransparentCB.Enable( bWrapThrough && !bHtmlMode );
704cdf0e10cSrcweir     bWrapThrough |= ( nAnchorId == FLY_AS_CHAR );
705cdf0e10cSrcweir 	aWrapOutlineCB.Enable( !bWrapThrough && pBtn != &aNoWrapRB);
706cdf0e10cSrcweir 	aWrapOutsideCB.Enable( !bWrapThrough && aWrapOutlineCB.IsChecked() );
707cdf0e10cSrcweir     aWrapAnchorOnlyCB.Enable(
708cdf0e10cSrcweir         ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) &&
709cdf0e10cSrcweir 		(pBtn != &aNoWrapRB) );
710cdf0e10cSrcweir 
711cdf0e10cSrcweir 	ContourHdl(0);
712cdf0e10cSrcweir 	return 0;
713cdf0e10cSrcweir }
714cdf0e10cSrcweir 
715cdf0e10cSrcweir /*--------------------------------------------------------------------
716cdf0e10cSrcweir 	Beschreibung:
717cdf0e10cSrcweir  --------------------------------------------------------------------*/
718cdf0e10cSrcweir 
719cdf0e10cSrcweir 
720cdf0e10cSrcweir 
IMPL_LINK(SwWrapTabPage,ContourHdl,CheckBox *,EMPTYARG)721cdf0e10cSrcweir IMPL_LINK( SwWrapTabPage, ContourHdl, CheckBox *, EMPTYARG )
722cdf0e10cSrcweir {
723cdf0e10cSrcweir 	sal_Bool bEnable = !(aWrapOutlineCB.IsChecked() && aWrapOutlineCB.IsEnabled());
724cdf0e10cSrcweir 
725cdf0e10cSrcweir 	aWrapOutsideCB.Enable(!bEnable);
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 	bEnable =  !aWrapOutlineCB.IsChecked();
728cdf0e10cSrcweir 	if (bEnable == bContourImage) // damit es nicht immer flackert
729cdf0e10cSrcweir 	{
730cdf0e10cSrcweir         bContourImage = !bEnable;
731cdf0e10cSrcweir         ApplyImageList();
732cdf0e10cSrcweir     }
733cdf0e10cSrcweir 
734cdf0e10cSrcweir 	return 0;
735cdf0e10cSrcweir }
736cdf0e10cSrcweir 
737cdf0e10cSrcweir /*--------------------------------------------------------------------
738cdf0e10cSrcweir 	Beschreibung:
739cdf0e10cSrcweir  --------------------------------------------------------------------*/
GetRanges()740cdf0e10cSrcweir sal_uInt16* SwWrapTabPage::GetRanges()
741cdf0e10cSrcweir {
742cdf0e10cSrcweir 	return aWrapPageRg;
743cdf0e10cSrcweir }
744cdf0e10cSrcweir /* -----------------------------08.05.2002 14:28------------------------------
745cdf0e10cSrcweir 
746cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
DataChanged(const DataChangedEvent & rDCEvt)747cdf0e10cSrcweir void SwWrapTabPage::DataChanged( const DataChangedEvent& rDCEvt )
748cdf0e10cSrcweir {
749cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
750cdf0e10cSrcweir          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
751cdf0e10cSrcweir             ApplyImageList();
752cdf0e10cSrcweir 
753cdf0e10cSrcweir     SfxTabPage::DataChanged( rDCEvt );
754cdf0e10cSrcweir }
755cdf0e10cSrcweir /* -----------------------------08.05.2002 14:28------------------------------
756cdf0e10cSrcweir 
757cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
ApplyImageList()758cdf0e10cSrcweir void SwWrapTabPage::ApplyImageList()
759cdf0e10cSrcweir {
760cdf0e10cSrcweir     ImageList& rImgLst = GetSettings().GetStyleSettings().GetHighContrastMode() ?
761cdf0e10cSrcweir         aWrapILH : aWrapIL;
762cdf0e10cSrcweir 
763cdf0e10cSrcweir     aWrapThroughRB.SetModeRadioImage(rImgLst.GetImage(IMG_THROUGH));
764cdf0e10cSrcweir     sal_Bool bWrapOutline =  !aWrapOutlineCB.IsChecked();
765cdf0e10cSrcweir     if(bWrapOutline)
766cdf0e10cSrcweir     {
767cdf0e10cSrcweir         aNoWrapRB.SetModeRadioImage(rImgLst.GetImage(IMG_NONE));
768cdf0e10cSrcweir         aWrapLeftRB.SetModeRadioImage(rImgLst.GetImage(IMG_LEFT));
769cdf0e10cSrcweir         aWrapRightRB.SetModeRadioImage(rImgLst.GetImage(IMG_RIGHT));
770cdf0e10cSrcweir         aWrapParallelRB.SetModeRadioImage(rImgLst.GetImage(IMG_PARALLEL));
771cdf0e10cSrcweir         aIdealWrapRB.SetModeRadioImage(rImgLst.GetImage(IMG_IDEAL));
772cdf0e10cSrcweir     }
773cdf0e10cSrcweir     else
774cdf0e10cSrcweir     {
775cdf0e10cSrcweir         aNoWrapRB.SetModeRadioImage(rImgLst.GetImage( IMG_KON_NONE ));
776cdf0e10cSrcweir         aWrapLeftRB.SetModeRadioImage(rImgLst.GetImage( IMG_KON_LEFT ));
777cdf0e10cSrcweir         aWrapRightRB.SetModeRadioImage(rImgLst.GetImage( IMG_KON_RIGHT ));
778cdf0e10cSrcweir         aWrapParallelRB.SetModeRadioImage(rImgLst.GetImage(IMG_KON_PARALLEL ));
779cdf0e10cSrcweir         aIdealWrapRB.SetModeRadioImage(rImgLst.GetImage( IMG_KON_IDEAL ));
780cdf0e10cSrcweir     }
781cdf0e10cSrcweir }
782