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