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 <vcl/graph.hxx>
31 : : #include <svx/htmlmode.hxx>
32 : : #include <sfx2/objsh.hxx>
33 : : #include <svl/intitem.hxx>
34 : : #include <editeng/opaqitem.hxx>
35 : : #include <editeng/ulspitem.hxx>
36 : : #include <editeng/lrspitem.hxx>
37 : : // #i18732#
38 : : #include <fmtfollowtextflow.hxx>
39 : : #include <svx/swframevalidation.hxx>
40 : :
41 : :
42 : : #include "cmdid.h"
43 : : #include "uitool.hxx"
44 : : #include "wrtsh.hxx"
45 : : #include "swmodule.hxx"
46 : : #include "viewopt.hxx"
47 : : #include "frmatr.hxx"
48 : : #include "frmmgr.hxx"
49 : : #include "globals.hrc"
50 : : #include "frmui.hrc"
51 : : #include "wrap.hrc"
52 : : #include "wrap.hxx"
53 : :
54 : : using namespace ::com::sun::star;
55 : :
56 : : static sal_uInt16 aWrapPageRg[] = {
57 : : RES_LR_SPACE, RES_UL_SPACE,
58 : : RES_PROTECT, RES_SURROUND,
59 : : RES_PRINT, RES_PRINT,
60 : : 0
61 : : };
62 : :
63 : 0 : SwWrapDlg::SwWrapDlg(Window* pParent, SfxItemSet& rSet, SwWrtShell* pSh, sal_Bool bDrawMode) :
64 : : SfxSingleTabDialog(pParent, rSet, 0),
65 : 0 : pWrtShell(pSh)
66 : :
67 : : {
68 : : // create TabPage
69 : 0 : SwWrapTabPage* pNewPage = (SwWrapTabPage*) SwWrapTabPage::Create(this, rSet);
70 : 0 : pNewPage->SetFormatUsed(sal_False, bDrawMode);
71 : 0 : pNewPage->SetShell(pWrtShell);
72 : 0 : SetTabPage(pNewPage);
73 : :
74 : 0 : String sTitle(SW_RES(STR_FRMUI_WRAP));
75 : 0 : SetText(sTitle);
76 : 0 : }
77 : :
78 : 0 : SwWrapDlg::~SwWrapDlg()
79 : : {
80 : 0 : }
81 : :
82 : 0 : SwWrapTabPage::SwWrapTabPage(Window *pParent, const SfxItemSet &rSet) :
83 : : SfxTabPage(pParent, SW_RES(TP_FRM_WRAP), rSet),
84 : :
85 : : aWrapFLC (this, SW_RES(C_WRAP_FL)),
86 : : aNoWrapRB (this, SW_RES(RB_NO_WRAP)),
87 : : aWrapLeftRB (this, SW_RES(RB_WRAP_LEFT)),
88 : : aWrapRightRB (this, SW_RES(RB_WRAP_RIGHT)),
89 : : aWrapParallelRB (this, SW_RES(RB_WRAP_PARALLEL)),
90 : : aWrapThroughRB (this, SW_RES(RB_WRAP_THROUGH)),
91 : : aIdealWrapRB (this, SW_RES(RB_WRAP_IDEAL)),
92 : :
93 : : aMarginFL (this, SW_RES(FL_MARGIN)),
94 : : aLeftMarginFT (this, SW_RES(FT_LEFT_MARGIN)),
95 : : aLeftMarginED (this, SW_RES(ED_LEFT_MARGIN)),
96 : : aRightMarginFT (this, SW_RES(FT_RIGHT_MARGIN)),
97 : : aRightMarginED (this, SW_RES(ED_RIGHT_MARGIN)),
98 : : aTopMarginFT (this, SW_RES(FT_TOP_MARGIN)),
99 : : aTopMarginED (this, SW_RES(ED_TOP_MARGIN)),
100 : : aBottomMarginFT (this, SW_RES(FT_BOTTOM_MARGIN)),
101 : : aBottomMarginED (this, SW_RES(ED_BOTTOM_MARGIN)),
102 : :
103 : : aOptionsSepFL (this, SW_RES(FL_OPTION_SEP)),
104 : : aOptionsFL (this, SW_RES(FL_OPTION)),
105 : : aWrapAnchorOnlyCB (this, SW_RES(CB_ANCHOR_ONLY)),
106 : : aWrapTransparentCB (this, SW_RES(CB_TRANSPARENT)),
107 : : aWrapOutlineCB (this, SW_RES(CB_OUTLINE)),
108 : : aWrapOutsideCB (this, SW_RES(CB_ONLYOUTSIDE)),
109 : :
110 : : aWrapIL (SW_RES(IL_WRAP)),
111 : :
112 : : nAnchorId(FLY_AT_PARA),
113 : : nHtmlMode(0),
114 : :
115 : : pWrtSh(0),
116 : :
117 : : bFormat(sal_False),
118 : : bNew(sal_True),
119 : : bHtmlMode(sal_False),
120 : 0 : bContourImage(sal_False)
121 : :
122 : : {
123 : 0 : FreeResource();
124 : 0 : SetExchangeSupport();
125 : :
126 : 0 : Link aLk = LINK(this, SwWrapTabPage, RangeModifyHdl);
127 : 0 : aLeftMarginED.SetUpHdl(aLk);
128 : 0 : aLeftMarginED.SetDownHdl(aLk);
129 : 0 : aLeftMarginED.SetFirstHdl(aLk);
130 : 0 : aLeftMarginED.SetLastHdl(aLk);
131 : 0 : aLeftMarginED.SetLoseFocusHdl(aLk);
132 : :
133 : 0 : aRightMarginED.SetUpHdl(aLk);
134 : 0 : aRightMarginED.SetDownHdl(aLk);
135 : 0 : aRightMarginED.SetFirstHdl(aLk);
136 : 0 : aRightMarginED.SetLastHdl(aLk);
137 : 0 : aRightMarginED.SetLoseFocusHdl(aLk);
138 : :
139 : 0 : aTopMarginED.SetUpHdl(aLk);
140 : 0 : aTopMarginED.SetDownHdl(aLk);
141 : 0 : aTopMarginED.SetFirstHdl(aLk);
142 : 0 : aTopMarginED.SetLastHdl(aLk);
143 : 0 : aTopMarginED.SetLoseFocusHdl(aLk);
144 : :
145 : 0 : aBottomMarginED.SetUpHdl(aLk);
146 : 0 : aBottomMarginED.SetDownHdl(aLk);
147 : 0 : aBottomMarginED.SetFirstHdl(aLk);
148 : 0 : aBottomMarginED.SetLastHdl(aLk);
149 : 0 : aBottomMarginED.SetLoseFocusHdl(aLk);
150 : :
151 : 0 : aLk = LINK(this, SwWrapTabPage, WrapTypeHdl);
152 : 0 : aNoWrapRB.SetClickHdl(aLk);
153 : 0 : aWrapLeftRB.SetClickHdl(aLk);
154 : 0 : aWrapRightRB.SetClickHdl(aLk);
155 : 0 : aWrapParallelRB.SetClickHdl(aLk);
156 : 0 : aWrapThroughRB.SetClickHdl(aLk);
157 : 0 : aIdealWrapRB.SetClickHdl(aLk);
158 : 0 : ApplyImageList();
159 : 0 : aWrapOutlineCB.SetClickHdl(LINK(this, SwWrapTabPage, ContourHdl));
160 : 0 : }
161 : :
162 : 0 : SwWrapTabPage::~SwWrapTabPage()
163 : : {
164 : 0 : }
165 : :
166 : 0 : SfxTabPage* SwWrapTabPage::Create(Window *pParent, const SfxItemSet &rSet)
167 : : {
168 : 0 : return new SwWrapTabPage(pParent, rSet);
169 : : }
170 : :
171 : 0 : void SwWrapTabPage::Reset(const SfxItemSet &rSet)
172 : : {
173 : : // contour for Draw, Graphic and OLE (Insert/Graphic/Properties still missing!)
174 : 0 : if( bDrawMode )
175 : : {
176 : 0 : aWrapOutlineCB.Show();
177 : 0 : aWrapOutsideCB.Show();
178 : :
179 : : aWrapTransparentCB.Check( 0 == ((const SfxInt16Item&)rSet.Get(
180 : 0 : FN_DRAW_WRAP_DLG)).GetValue() );
181 : 0 : aWrapTransparentCB.SaveValue();
182 : : }
183 : : else
184 : : {
185 : 0 : sal_Bool bShowCB = bFormat;
186 : 0 : if( !bFormat )
187 : : {
188 : 0 : int nSelType = pWrtSh->GetSelectionType();
189 : 0 : if( ( nSelType & nsSelectionType::SEL_GRF ) ||
190 : : ( nSelType & nsSelectionType::SEL_OLE && GRAPHIC_NONE !=
191 : 0 : pWrtSh->GetIMapGraphic().GetType() ))
192 : 0 : bShowCB = sal_True;
193 : : }
194 : 0 : if( bShowCB )
195 : : {
196 : 0 : aWrapOutlineCB.Show();
197 : 0 : aWrapOutsideCB.Show();
198 : : }
199 : : }
200 : :
201 : 0 : nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
202 : 0 : bHtmlMode = nHtmlMode & HTMLMODE_ON ? sal_True : sal_False;
203 : :
204 : 0 : FieldUnit aMetric = ::GetDfltMetric(bHtmlMode);
205 : 0 : SetMetric( aLeftMarginED , aMetric );
206 : 0 : SetMetric( aRightMarginED , aMetric );
207 : 0 : SetMetric( aTopMarginED , aMetric );
208 : 0 : SetMetric( aBottomMarginED, aMetric );
209 : :
210 : 0 : const SwFmtSurround& rSurround = (const SwFmtSurround&)rSet.Get(RES_SURROUND);
211 : :
212 : 0 : SwSurround nSur = rSurround.GetSurround();
213 : 0 : const SwFmtAnchor &rAnch = (const SwFmtAnchor&)rSet.Get(RES_ANCHOR);
214 : 0 : nAnchorId = rAnch.GetAnchorId();
215 : :
216 : 0 : if (((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR))
217 : : && (nSur != SURROUND_NONE))
218 : : {
219 : 0 : aWrapAnchorOnlyCB.Check( rSurround.IsAnchorOnly() );
220 : : }
221 : : else
222 : : {
223 : 0 : aWrapAnchorOnlyCB.Enable( sal_False );
224 : : }
225 : :
226 : 0 : sal_Bool bContour = rSurround.IsContour();
227 : 0 : aWrapOutlineCB.Check( bContour );
228 : 0 : aWrapOutsideCB.Check( rSurround.IsOutside() );
229 : 0 : aWrapThroughRB.Enable(!aWrapOutlineCB.IsChecked());
230 : 0 : bContourImage = !bContour;
231 : :
232 : 0 : ImageRadioButton* pBtn = NULL;
233 : :
234 : 0 : switch (nSur)
235 : : {
236 : : case SURROUND_NONE:
237 : : {
238 : 0 : pBtn = &aNoWrapRB;
239 : 0 : break;
240 : : }
241 : :
242 : : case SURROUND_THROUGHT:
243 : : {
244 : : // transparent ?
245 : 0 : pBtn = &aWrapThroughRB;
246 : :
247 : 0 : if (!bDrawMode)
248 : : {
249 : 0 : const SvxOpaqueItem& rOpaque = (const SvxOpaqueItem&)rSet.Get(RES_OPAQUE);
250 : 0 : aWrapTransparentCB.Check(!rOpaque.GetValue());
251 : : }
252 : 0 : break;
253 : : }
254 : :
255 : : case SURROUND_PARALLEL:
256 : : {
257 : 0 : pBtn = &aWrapParallelRB;
258 : 0 : break;
259 : : }
260 : :
261 : : case SURROUND_IDEAL:
262 : : {
263 : 0 : pBtn = &aIdealWrapRB;
264 : 0 : break;
265 : : }
266 : :
267 : : default:
268 : : {
269 : 0 : if (nSur == SURROUND_LEFT)
270 : 0 : pBtn = &aWrapLeftRB;
271 : 0 : else if (nSur == SURROUND_RIGHT)
272 : 0 : pBtn = &aWrapRightRB;
273 : : }
274 : : }
275 : 0 : if (pBtn)
276 : : {
277 : 0 : pBtn->Check();
278 : 0 : WrapTypeHdl(pBtn);
279 : : // For character objects that currently are in passage, the default
280 : : // "contour on" is prepared here, in case we switch to any other
281 : : // passage later.
282 : 0 : if (bDrawMode && !aWrapOutlineCB.IsEnabled())
283 : 0 : aWrapOutlineCB.Check();
284 : : }
285 : 0 : aWrapTransparentCB.Enable( pBtn == &aWrapThroughRB && !bHtmlMode );
286 : :
287 : 0 : const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rSet.Get(RES_UL_SPACE);
288 : 0 : const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rSet.Get(RES_LR_SPACE);
289 : :
290 : : // gap to text
291 : 0 : aLeftMarginED.SetValue(aLeftMarginED.Normalize(rLR.GetLeft()), FUNIT_TWIP);
292 : 0 : aRightMarginED.SetValue(aRightMarginED.Normalize(rLR.GetRight()), FUNIT_TWIP);
293 : 0 : aTopMarginED.SetValue(aTopMarginED.Normalize(rUL.GetUpper()), FUNIT_TWIP);
294 : 0 : aBottomMarginED.SetValue(aBottomMarginED.Normalize(rUL.GetLower()), FUNIT_TWIP);
295 : :
296 : 0 : ContourHdl(0);
297 : 0 : ActivatePage( rSet );
298 : 0 : }
299 : :
300 : : /*--------------------------------------------------------------------
301 : : Description: stuff attributes into the set when OK
302 : : --------------------------------------------------------------------*/
303 : 0 : sal_Bool SwWrapTabPage::FillItemSet(SfxItemSet &rSet)
304 : : {
305 : 0 : sal_Bool bModified = sal_False;
306 : : const SfxPoolItem* pOldItem;
307 : :
308 : 0 : const SwFmtSurround& rOldSur = (const SwFmtSurround&)GetItemSet().Get(RES_SURROUND);
309 : 0 : SwFmtSurround aSur( rOldSur );
310 : :
311 : 0 : SvxOpaqueItem aOp( RES_OPAQUE);
312 : :
313 : 0 : if (!bDrawMode)
314 : : {
315 : 0 : const SvxOpaqueItem& rOpaque = (const SvxOpaqueItem&)GetItemSet().Get(RES_OPAQUE);
316 : 0 : aOp = rOpaque;
317 : 0 : aOp.SetValue(sal_True);
318 : : }
319 : :
320 : 0 : if (aNoWrapRB.IsChecked())
321 : 0 : aSur.SetSurround(SURROUND_NONE);
322 : 0 : else if (aWrapLeftRB.IsChecked())
323 : 0 : aSur.SetSurround(SURROUND_LEFT);
324 : 0 : else if (aWrapRightRB.IsChecked())
325 : 0 : aSur.SetSurround(SURROUND_RIGHT);
326 : 0 : else if (aWrapParallelRB.IsChecked())
327 : 0 : aSur.SetSurround(SURROUND_PARALLEL);
328 : 0 : else if (aWrapThroughRB.IsChecked())
329 : : {
330 : 0 : aSur.SetSurround(SURROUND_THROUGHT);
331 : 0 : if (aWrapTransparentCB.IsChecked() && !bDrawMode)
332 : 0 : aOp.SetValue(sal_False);
333 : : }
334 : 0 : else if (aIdealWrapRB.IsChecked())
335 : 0 : aSur.SetSurround(SURROUND_IDEAL);
336 : :
337 : 0 : aSur.SetAnchorOnly( aWrapAnchorOnlyCB.IsChecked() );
338 : 0 : sal_Bool bContour = aWrapOutlineCB.IsChecked() && aWrapOutlineCB.IsEnabled();
339 : 0 : aSur.SetContour( bContour );
340 : :
341 : 0 : if ( bContour )
342 : 0 : aSur.SetOutside(aWrapOutsideCB.IsChecked());
343 : :
344 : 0 : if(0 == (pOldItem = GetOldItem( rSet, RES_SURROUND )) ||
345 : 0 : aSur != *pOldItem )
346 : : {
347 : 0 : rSet.Put(aSur);
348 : 0 : bModified = sal_True;
349 : : }
350 : :
351 : 0 : if (!bDrawMode)
352 : : {
353 : 0 : if(0 == (pOldItem = GetOldItem( rSet, FN_OPAQUE )) ||
354 : 0 : aOp != *pOldItem )
355 : : {
356 : 0 : rSet.Put(aOp);
357 : 0 : bModified = sal_True;
358 : : }
359 : : }
360 : :
361 : 0 : sal_Bool bTopMod = aTopMarginED.IsValueModified();
362 : 0 : sal_Bool bBottomMod = aBottomMarginED.IsValueModified();
363 : :
364 : 0 : SvxULSpaceItem aUL( RES_UL_SPACE );
365 : 0 : aUL.SetUpper((sal_uInt16)aTopMarginED.Denormalize(aTopMarginED.GetValue(FUNIT_TWIP)));
366 : 0 : aUL.SetLower((sal_uInt16)aBottomMarginED.Denormalize(aBottomMarginED.GetValue(FUNIT_TWIP)));
367 : :
368 : 0 : if ( bTopMod || bBottomMod )
369 : : {
370 : 0 : if(0 == (pOldItem = GetOldItem(rSet, RES_UL_SPACE)) ||
371 : 0 : aUL != *pOldItem )
372 : : {
373 : 0 : rSet.Put( aUL, RES_UL_SPACE );
374 : 0 : bModified = sal_True;
375 : : }
376 : : }
377 : :
378 : 0 : sal_Bool bLeftMod = aLeftMarginED.IsValueModified();
379 : 0 : sal_Bool bRightMod = aRightMarginED.IsValueModified();
380 : :
381 : 0 : SvxLRSpaceItem aLR( RES_LR_SPACE );
382 : 0 : aLR.SetLeft((sal_uInt16)aLeftMarginED.Denormalize(aLeftMarginED.GetValue(FUNIT_TWIP)));
383 : 0 : aLR.SetRight((sal_uInt16)aRightMarginED.Denormalize(aRightMarginED.GetValue(FUNIT_TWIP)));
384 : :
385 : 0 : if ( bLeftMod || bRightMod )
386 : : {
387 : 0 : if( 0 == (pOldItem = GetOldItem(rSet, RES_LR_SPACE)) ||
388 : 0 : aLR != *pOldItem )
389 : : {
390 : 0 : rSet.Put(aLR, RES_LR_SPACE);
391 : 0 : bModified = sal_True;
392 : : }
393 : : }
394 : :
395 : 0 : if ( bDrawMode )
396 : : {
397 : 0 : sal_Bool bChecked = aWrapTransparentCB.IsChecked() & aWrapTransparentCB.IsEnabled();
398 : 0 : if (aWrapTransparentCB.GetSavedValue() != bChecked)
399 : 0 : bModified |= 0 != rSet.Put(SfxInt16Item(FN_DRAW_WRAP_DLG, bChecked ? 0 : 1));
400 : : }
401 : :
402 : 0 : return bModified;
403 : : }
404 : :
405 : : /*--------------------------------------------------------------------
406 : : Description: example update
407 : : --------------------------------------------------------------------*/
408 : 0 : void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet)
409 : : {
410 : : // anchor
411 : 0 : const SwFmtAnchor &rAnch = (const SwFmtAnchor&)rSet.Get(RES_ANCHOR);
412 : 0 : nAnchorId = rAnch.GetAnchorId();
413 : 0 : sal_Bool bEnable = (nAnchorId != FLY_AS_CHAR);
414 : :
415 : 0 : if (!bDrawMode)
416 : : {
417 : 0 : SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell() : pWrtSh;
418 : 0 : SwFlyFrmAttrMgr aMgr( bNew, pSh, (const SwAttrSet&)GetItemSet() );
419 : 0 : SvxSwFrameValidation aVal;
420 : :
421 : : // size
422 : 0 : const SwFmtFrmSize& rFrmSize = (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE);
423 : 0 : Size aSize = rFrmSize.GetSize();
424 : :
425 : : // margin
426 : 0 : const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rSet.Get(RES_UL_SPACE);
427 : 0 : const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rSet.Get(RES_LR_SPACE);
428 : 0 : nOldLeftMargin = static_cast< sal_uInt16 >(rLR.GetLeft());
429 : 0 : nOldRightMargin = static_cast< sal_uInt16 >(rLR.GetRight());
430 : 0 : nOldUpperMargin = static_cast< sal_uInt16 >(rUL.GetUpper());
431 : 0 : nOldLowerMargin = static_cast< sal_uInt16 >(rUL.GetLower());
432 : :
433 : : // position
434 : 0 : const SwFmtHoriOrient& rHori = (const SwFmtHoriOrient&)rSet.Get(RES_HORI_ORIENT);
435 : 0 : const SwFmtVertOrient& rVert = (const SwFmtVertOrient&)rSet.Get(RES_VERT_ORIENT);
436 : :
437 : 0 : aVal.nAnchorType = static_cast< sal_Int16 >(nAnchorId);
438 : 0 : aVal.bAutoHeight = rFrmSize.GetHeightSizeType() == ATT_MIN_SIZE;
439 : 0 : aVal.bAutoWidth = rFrmSize.GetWidthSizeType() == ATT_MIN_SIZE;
440 : 0 : aVal.bMirror = rHori.IsPosToggle();
441 : : // #i18732#
442 : : aVal.bFollowTextFlow =
443 : 0 : static_cast<const SwFmtFollowTextFlow&>(rSet.Get(RES_FOLLOW_TEXT_FLOW)).GetValue();
444 : :
445 : 0 : aVal.nHoriOrient = (short)rHori.GetHoriOrient();
446 : 0 : aVal.nVertOrient = (short)rVert.GetVertOrient();
447 : :
448 : 0 : aVal.nHPos = rHori.GetPos();
449 : 0 : aVal.nHRelOrient = rHori.GetRelationOrient();
450 : 0 : aVal.nVPos = rVert.GetPos();
451 : 0 : aVal.nVRelOrient = rVert.GetRelationOrient();
452 : :
453 : 0 : if (rFrmSize.GetWidthPercent() && rFrmSize.GetWidthPercent() != 0xff)
454 : 0 : aSize.Width() = aSize.Width() * rFrmSize.GetWidthPercent() / 100;
455 : :
456 : 0 : if (rFrmSize.GetHeightPercent() && rFrmSize.GetHeightPercent() != 0xff)
457 : 0 : aSize.Height() = aSize.Height() * rFrmSize.GetHeightPercent() / 100;
458 : :
459 : 0 : aVal.nWidth = aSize.Width();
460 : 0 : aVal.nHeight = aSize.Height();
461 : 0 : aFrmSize = aSize;
462 : :
463 : 0 : aMgr.ValidateMetrics(aVal, 0);
464 : :
465 : : SwTwips nLeft;
466 : : SwTwips nRight;
467 : : SwTwips nTop;
468 : : SwTwips nBottom;
469 : :
470 : 0 : nLeft = aVal.nHPos - aVal.nMinHPos;
471 : 0 : nRight = aVal.nMaxWidth - aVal.nWidth;
472 : 0 : nTop = aVal.nVPos - aVal.nMinVPos;
473 : 0 : nBottom = aVal.nMaxHeight - aVal.nHeight;
474 : :
475 : : {
476 : 0 : if (aVal.nAnchorType == FLY_AS_CHAR)
477 : : {
478 : 0 : nLeft = nRight;
479 : :
480 : 0 : if (aVal.nVPos < 0)
481 : : {
482 : 0 : if (aVal.nVPos <= aVal.nMaxHeight)
483 : 0 : nTop = aVal.nMaxVPos - aVal.nHeight;
484 : : else
485 : 0 : nTop = nBottom = 0; // no passage
486 : : }
487 : : else
488 : 0 : nTop = aVal.nMaxVPos - aVal.nHeight - aVal.nVPos;
489 : : }
490 : : else
491 : : {
492 : 0 : nLeft += nRight;
493 : 0 : nTop += nBottom;
494 : : }
495 : :
496 : 0 : nBottom = nTop;
497 : 0 : nRight = nLeft;
498 : : }
499 : :
500 : 0 : aLeftMarginED.SetMax(aLeftMarginED.Normalize(nLeft), FUNIT_TWIP);
501 : 0 : aRightMarginED.SetMax(aRightMarginED.Normalize(nRight), FUNIT_TWIP);
502 : :
503 : 0 : aTopMarginED.SetMax(aTopMarginED.Normalize(nTop), FUNIT_TWIP);
504 : 0 : aBottomMarginED.SetMax(aBottomMarginED.Normalize(nBottom), FUNIT_TWIP);
505 : :
506 : 0 : RangeModifyHdl(&aLeftMarginED);
507 : 0 : RangeModifyHdl(&aTopMarginED);
508 : : }
509 : :
510 : 0 : const SwFmtSurround& rSurround = (const SwFmtSurround&)rSet.Get(RES_SURROUND);
511 : 0 : SwSurround nSur = rSurround.GetSurround();
512 : :
513 : 0 : aWrapTransparentCB.Enable( bEnable && !bHtmlMode && nSur == SURROUND_THROUGHT );
514 : 0 : if(bHtmlMode)
515 : : {
516 : 0 : const SwFmtHoriOrient& rHori = (const SwFmtHoriOrient&)rSet.Get(RES_HORI_ORIENT);
517 : 0 : sal_Int16 eHOrient = rHori.GetHoriOrient();
518 : 0 : sal_Int16 eHRelOrient = rHori.GetRelationOrient();
519 : 0 : aWrapOutlineCB.Hide();
520 : : const bool bAllHtmlModes =
521 : : ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) &&
522 : 0 : (eHOrient == text::HoriOrientation::RIGHT || eHOrient == text::HoriOrientation::LEFT);
523 : 0 : aWrapAnchorOnlyCB.Enable( bAllHtmlModes && nSur != SURROUND_NONE );
524 : 0 : aWrapOutsideCB.Hide();
525 : 0 : aIdealWrapRB.Enable( sal_False );
526 : :
527 : :
528 : 0 : aWrapTransparentCB.Enable( sal_False );
529 : 0 : aNoWrapRB.Enable( FLY_AT_PARA == nAnchorId );
530 : 0 : aWrapParallelRB.Enable( sal_False );
531 : : aWrapLeftRB .Enable
532 : : ( (FLY_AT_PARA == nAnchorId)
533 : : || ( (FLY_AT_CHAR == nAnchorId)
534 : : && (eHOrient == text::HoriOrientation::RIGHT)
535 : 0 : && (eHRelOrient == text::RelOrientation::PRINT_AREA)));
536 : : aWrapRightRB .Enable
537 : : ( (FLY_AT_PARA == nAnchorId)
538 : : || ( (FLY_AT_CHAR == nAnchorId)
539 : : && (eHOrient == text::HoriOrientation::LEFT)
540 : 0 : && (eHRelOrient == text::RelOrientation::PRINT_AREA)));
541 : :
542 : : aWrapThroughRB.Enable
543 : : ( ( (FLY_AT_PAGE == nAnchorId)
544 : : || ( (FLY_AT_CHAR == nAnchorId)
545 : : && (eHRelOrient != text::RelOrientation::PRINT_AREA))
546 : : || (FLY_AT_PARA == nAnchorId))
547 : 0 : && (eHOrient != text::HoriOrientation::RIGHT));
548 : 0 : if(aNoWrapRB.IsChecked() && !aNoWrapRB.IsEnabled())
549 : : {
550 : 0 : if(aWrapThroughRB.IsEnabled())
551 : 0 : aWrapThroughRB.Check(sal_True);
552 : 0 : else if(aWrapLeftRB.IsEnabled())
553 : 0 : aWrapLeftRB.Check();
554 : 0 : else if(aWrapRightRB.IsEnabled())
555 : 0 : aWrapRightRB.Check();
556 : :
557 : : }
558 : 0 : if(aWrapLeftRB.IsChecked() && !aWrapLeftRB.IsEnabled())
559 : : {
560 : 0 : if(aWrapRightRB.IsEnabled())
561 : 0 : aWrapRightRB.Check();
562 : 0 : else if(aWrapThroughRB.IsEnabled())
563 : 0 : aWrapThroughRB.Check();
564 : : }
565 : 0 : if(aWrapRightRB.IsChecked() && !aWrapRightRB.IsEnabled())
566 : : {
567 : 0 : if(aWrapLeftRB.IsEnabled())
568 : 0 : aWrapLeftRB.Check();
569 : 0 : else if(aWrapThroughRB.IsEnabled())
570 : 0 : aWrapThroughRB.Check();
571 : : }
572 : 0 : if(aWrapThroughRB.IsChecked() && !aWrapThroughRB.IsEnabled())
573 : 0 : if(aNoWrapRB.IsEnabled())
574 : 0 : aNoWrapRB.Check();
575 : :
576 : 0 : if(aWrapParallelRB.IsChecked() && !aWrapParallelRB.IsEnabled())
577 : 0 : aWrapThroughRB.Check();
578 : : }
579 : : else
580 : : {
581 : 0 : aNoWrapRB.Enable( bEnable );
582 : 0 : aWrapLeftRB.Enable( bEnable );
583 : 0 : aWrapRightRB.Enable( bEnable );
584 : 0 : aIdealWrapRB.Enable( bEnable );
585 : 0 : aWrapThroughRB.Enable( bEnable );
586 : 0 : aWrapParallelRB.Enable( bEnable );
587 : : aWrapAnchorOnlyCB.Enable(
588 : : ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR))
589 : 0 : && nSur != SURROUND_NONE );
590 : : }
591 : 0 : ContourHdl(0);
592 : 0 : }
593 : :
594 : 0 : int SwWrapTabPage::DeactivatePage(SfxItemSet* _pSet)
595 : : {
596 : 0 : if(_pSet)
597 : 0 : FillItemSet(*_pSet);
598 : :
599 : 0 : return sal_True;
600 : : }
601 : :
602 : : /*--------------------------------------------------------------------
603 : : Description: range check
604 : : --------------------------------------------------------------------*/
605 : 0 : IMPL_LINK( SwWrapTabPage, RangeModifyHdl, MetricField *, pEdit )
606 : : {
607 : 0 : sal_Int64 nValue = pEdit->GetValue();
608 : 0 : MetricField *pOpposite = 0;
609 : :
610 : 0 : if (pEdit == &aLeftMarginED)
611 : 0 : pOpposite = &aRightMarginED;
612 : 0 : else if (pEdit == &aRightMarginED)
613 : 0 : pOpposite = &aLeftMarginED;
614 : 0 : else if (pEdit == &aTopMarginED)
615 : 0 : pOpposite = &aBottomMarginED;
616 : 0 : else if (pEdit == &aBottomMarginED)
617 : 0 : pOpposite = &aTopMarginED;
618 : :
619 : : OSL_ASSERT(pOpposite);
620 : :
621 : 0 : if (pOpposite)
622 : : {
623 : 0 : sal_Int64 nOpposite = pOpposite->GetValue();
624 : :
625 : 0 : if (nValue + nOpposite > Max(pEdit->GetMax(), pOpposite->GetMax()))
626 : 0 : pOpposite->SetValue(pOpposite->GetMax() - nValue);
627 : : }
628 : :
629 : 0 : return 0;
630 : : }
631 : :
632 : 0 : IMPL_LINK( SwWrapTabPage, WrapTypeHdl, ImageRadioButton *, pBtn )
633 : : {
634 : 0 : sal_Bool bWrapThrough = (pBtn == &aWrapThroughRB);
635 : 0 : aWrapTransparentCB.Enable( bWrapThrough && !bHtmlMode );
636 : 0 : bWrapThrough |= ( nAnchorId == FLY_AS_CHAR );
637 : 0 : aWrapOutlineCB.Enable( !bWrapThrough && pBtn != &aNoWrapRB);
638 : 0 : aWrapOutsideCB.Enable( !bWrapThrough && aWrapOutlineCB.IsChecked() );
639 : : aWrapAnchorOnlyCB.Enable(
640 : : ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) &&
641 : 0 : (pBtn != &aNoWrapRB) );
642 : :
643 : 0 : ContourHdl(0);
644 : 0 : return 0;
645 : : }
646 : :
647 : 0 : IMPL_LINK_NOARG(SwWrapTabPage, ContourHdl)
648 : : {
649 : 0 : sal_Bool bEnable = !(aWrapOutlineCB.IsChecked() && aWrapOutlineCB.IsEnabled());
650 : :
651 : 0 : aWrapOutsideCB.Enable(!bEnable);
652 : :
653 : 0 : bEnable = !aWrapOutlineCB.IsChecked();
654 : 0 : if (bEnable == bContourImage) // so that it doesn't always flicker
655 : : {
656 : 0 : bContourImage = !bEnable;
657 : 0 : ApplyImageList();
658 : : }
659 : :
660 : 0 : return 0;
661 : : }
662 : :
663 : 0 : sal_uInt16* SwWrapTabPage::GetRanges()
664 : : {
665 : 0 : return aWrapPageRg;
666 : : }
667 : :
668 : 0 : void SwWrapTabPage::DataChanged( const DataChangedEvent& rDCEvt )
669 : : {
670 : 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
671 : 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
672 : 0 : ApplyImageList();
673 : :
674 : 0 : SfxTabPage::DataChanged( rDCEvt );
675 : 0 : }
676 : :
677 : 0 : void SwWrapTabPage::ApplyImageList()
678 : : {
679 : 0 : ImageList& rImgLst = aWrapIL;
680 : :
681 : 0 : aWrapThroughRB.SetModeRadioImage(rImgLst.GetImage(IMG_THROUGH));
682 : 0 : sal_Bool bWrapOutline = !aWrapOutlineCB.IsChecked();
683 : 0 : if(bWrapOutline)
684 : : {
685 : 0 : aNoWrapRB.SetModeRadioImage( rImgLst.GetImage( IMG_NONE ));
686 : 0 : aWrapLeftRB.SetModeRadioImage( rImgLst.GetImage( IMG_LEFT ));
687 : 0 : aWrapRightRB.SetModeRadioImage( rImgLst.GetImage( IMG_RIGHT ));
688 : 0 : aWrapParallelRB.SetModeRadioImage( rImgLst.GetImage( IMG_PARALLEL ));
689 : 0 : aIdealWrapRB.SetModeRadioImage( rImgLst.GetImage( IMG_IDEAL ));
690 : : }
691 : : else
692 : : {
693 : 0 : aNoWrapRB.SetModeRadioImage( rImgLst.GetImage( IMG_KON_NONE ));
694 : 0 : aWrapLeftRB.SetModeRadioImage( rImgLst.GetImage( IMG_KON_LEFT ));
695 : 0 : aWrapRightRB.SetModeRadioImage( rImgLst.GetImage( IMG_KON_RIGHT ));
696 : 0 : aWrapParallelRB.SetModeRadioImage( rImgLst.GetImage( IMG_KON_PARALLEL ));
697 : 0 : aIdealWrapRB.SetModeRadioImage( rImgLst.GetImage( IMG_KON_IDEAL ));
698 : : }
699 : 0 : }
700 : :
701 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|