LCOV - code coverage report
Current view: top level - sw/source/ui/frmdlg - wrap.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 390 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 20 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "hintids.hxx"
      21             : #include <vcl/graph.hxx>
      22             : #include <vcl/settings.hxx>
      23             : 
      24             : #include <sfx2/htmlmode.hxx>
      25             : #include <sfx2/objsh.hxx>
      26             : #include <svl/intitem.hxx>
      27             : #include <editeng/opaqitem.hxx>
      28             : #include <editeng/ulspitem.hxx>
      29             : #include <editeng/lrspitem.hxx>
      30             : #include <fmtfollowtextflow.hxx>
      31             : #include <svx/swframevalidation.hxx>
      32             : 
      33             : #include "cmdid.h"
      34             : #include <docsh.hxx>
      35             : #include "uitool.hxx"
      36             : #include "wrtsh.hxx"
      37             : #include "swmodule.hxx"
      38             : #include "viewopt.hxx"
      39             : #include "frmatr.hxx"
      40             : #include "frmmgr.hxx"
      41             : #include "globals.hrc"
      42             : #include "frmui.hrc"
      43             : #include "wrap.hxx"
      44             : 
      45             : using namespace ::com::sun::star;
      46             : 
      47             : const sal_uInt16 SwWrapTabPage::m_aWrapPageRg[] = {
      48             :     RES_LR_SPACE, RES_UL_SPACE,
      49             :     RES_PROTECT, RES_SURROUND,
      50             :     RES_PRINT, RES_PRINT,
      51             :     0
      52             : };
      53             : 
      54           0 : SwWrapDlg::SwWrapDlg(vcl::Window* pParent, SfxItemSet& rSet, SwWrtShell* pSh, bool bDrawMode)
      55             :     : SfxSingleTabDialog(pParent, rSet, "WrapDialog", "modules/swriter/ui/wrapdialog.ui")
      56           0 :     , pWrtShell(pSh)
      57             : 
      58             : {
      59             :     // create TabPage
      60           0 :     VclPtr<SwWrapTabPage> pNewPage = static_cast<SwWrapTabPage*>( SwWrapTabPage::Create(get_content_area(), &rSet).get() );
      61           0 :     pNewPage->SetFormatUsed(false, bDrawMode);
      62           0 :     pNewPage->SetShell(pWrtShell);
      63           0 :     SetTabPage(pNewPage);
      64           0 : }
      65             : 
      66           0 : SwWrapTabPage::SwWrapTabPage(vcl::Window *pParent, const SfxItemSet &rSet)
      67             :     : SfxTabPage(pParent, "WrapPage" , "modules/swriter/ui/wrappage.ui", &rSet)
      68             :     , m_nOldLeftMargin(0)
      69             :     , m_nOldRightMargin(0)
      70             :     , m_nOldUpperMargin(0)
      71             :     , m_nOldLowerMargin(0)
      72             :     , m_nAnchorId(FLY_AT_PARA)
      73             :     , m_nHtmlMode(0)
      74             :     , m_pWrtSh(0)
      75             :     , m_bFormat(false)
      76             :     , m_bNew(true)
      77             :     , m_bHtmlMode(false)
      78             :     , m_bDrawMode(false)
      79           0 :     , m_bContourImage(false)
      80             : {
      81           0 :     get(m_pNoWrapRB, "none");
      82           0 :     get(m_pWrapLeftRB, "before");
      83           0 :     get(m_pWrapRightRB, "after");
      84           0 :     get(m_pWrapParallelRB, "parallel");
      85           0 :     get(m_pWrapThroughRB, "through");
      86           0 :     get(m_pIdealWrapRB, "optimal");
      87           0 :     get(m_pLeftMarginED, "left");
      88           0 :     get(m_pRightMarginED, "right");
      89           0 :     get(m_pTopMarginED, "top");
      90           0 :     get(m_pBottomMarginED, "bottom");
      91           0 :     get(m_pWrapAnchorOnlyCB, "anchoronly");
      92           0 :     get(m_pWrapTransparentCB, "transparent");
      93           0 :     get(m_pWrapOutlineCB, "outline");
      94           0 :     get(m_pWrapOutsideCB, "outside");
      95             : 
      96           0 :     SetExchangeSupport();
      97             : 
      98           0 :     Link<> aLk = LINK(this, SwWrapTabPage, RangeModifyHdl);
      99           0 :     m_pLeftMarginED->SetUpHdl(aLk);
     100           0 :     m_pLeftMarginED->SetDownHdl(aLk);
     101           0 :     m_pLeftMarginED->SetFirstHdl(aLk);
     102           0 :     m_pLeftMarginED->SetLastHdl(aLk);
     103           0 :     m_pLeftMarginED->SetLoseFocusHdl(aLk);
     104             : 
     105           0 :     m_pRightMarginED->SetUpHdl(aLk);
     106           0 :     m_pRightMarginED->SetDownHdl(aLk);
     107           0 :     m_pRightMarginED->SetFirstHdl(aLk);
     108           0 :     m_pRightMarginED->SetLastHdl(aLk);
     109           0 :     m_pRightMarginED->SetLoseFocusHdl(aLk);
     110             : 
     111           0 :     m_pTopMarginED->SetUpHdl(aLk);
     112           0 :     m_pTopMarginED->SetDownHdl(aLk);
     113           0 :     m_pTopMarginED->SetFirstHdl(aLk);
     114           0 :     m_pTopMarginED->SetLastHdl(aLk);
     115           0 :     m_pTopMarginED->SetLoseFocusHdl(aLk);
     116             : 
     117           0 :     m_pBottomMarginED->SetUpHdl(aLk);
     118           0 :     m_pBottomMarginED->SetDownHdl(aLk);
     119           0 :     m_pBottomMarginED->SetFirstHdl(aLk);
     120           0 :     m_pBottomMarginED->SetLastHdl(aLk);
     121           0 :     m_pBottomMarginED->SetLoseFocusHdl(aLk);
     122             : 
     123           0 :     aLk = LINK(this, SwWrapTabPage, WrapTypeHdl);
     124           0 :     m_pNoWrapRB->SetClickHdl(aLk);
     125           0 :     m_pWrapLeftRB->SetClickHdl(aLk);
     126           0 :     m_pWrapRightRB->SetClickHdl(aLk);
     127           0 :     m_pWrapParallelRB->SetClickHdl(aLk);
     128           0 :     m_pWrapThroughRB->SetClickHdl(aLk);
     129           0 :     m_pIdealWrapRB->SetClickHdl(aLk);
     130           0 :     ApplyImageList();
     131           0 :     m_pWrapOutlineCB->SetClickHdl(LINK(this, SwWrapTabPage, ContourHdl));
     132           0 : }
     133             : 
     134           0 : SwWrapTabPage::~SwWrapTabPage()
     135             : {
     136           0 :     disposeOnce();
     137           0 : }
     138             : 
     139           0 : void SwWrapTabPage::dispose()
     140             : {
     141           0 :     m_pNoWrapRB.clear();
     142           0 :     m_pWrapLeftRB.clear();
     143           0 :     m_pWrapRightRB.clear();
     144           0 :     m_pWrapParallelRB.clear();
     145           0 :     m_pWrapThroughRB.clear();
     146           0 :     m_pIdealWrapRB.clear();
     147           0 :     m_pLeftMarginED.clear();
     148           0 :     m_pRightMarginED.clear();
     149           0 :     m_pTopMarginED.clear();
     150           0 :     m_pBottomMarginED.clear();
     151           0 :     m_pWrapAnchorOnlyCB.clear();
     152           0 :     m_pWrapTransparentCB.clear();
     153           0 :     m_pWrapOutlineCB.clear();
     154           0 :     m_pWrapOutsideCB.clear();
     155           0 :     SfxTabPage::dispose();
     156           0 : }
     157             : 
     158           0 : VclPtr<SfxTabPage> SwWrapTabPage::Create(vcl::Window *pParent, const SfxItemSet *rSet)
     159             : {
     160           0 :     return VclPtr<SwWrapTabPage>::Create(pParent, *rSet);
     161             : }
     162             : 
     163           0 : void SwWrapTabPage::Reset(const SfxItemSet *rSet)
     164             : {
     165             :     // contour for Draw, Graphic and OLE (Insert/Graphic/Properties still missing!)
     166           0 :     if( m_bDrawMode )
     167             :     {
     168           0 :         m_pWrapOutlineCB->Show();
     169           0 :         m_pWrapOutsideCB->Show();
     170             : 
     171             :         m_pWrapTransparentCB->Check( 0 == static_cast<const SfxInt16Item&>(rSet->Get(
     172           0 :                                         FN_DRAW_WRAP_DLG)).GetValue() );
     173           0 :         m_pWrapTransparentCB->SaveValue();
     174             :     }
     175             :     else
     176             :     {
     177           0 :         bool bShowCB = m_bFormat;
     178           0 :         if( !m_bFormat )
     179             :         {
     180           0 :             int nSelType = m_pWrtSh->GetSelectionType();
     181           0 :             if( ( nSelType & nsSelectionType::SEL_GRF ) ||
     182           0 :                 ( nSelType & nsSelectionType::SEL_OLE && GRAPHIC_NONE !=
     183           0 :                             m_pWrtSh->GetIMapGraphic().GetType() ))
     184           0 :                 bShowCB = true;
     185             :         }
     186           0 :         if( bShowCB )
     187             :         {
     188           0 :             m_pWrapOutlineCB->Show();
     189           0 :             m_pWrapOutsideCB->Show();
     190             :         }
     191             :     }
     192             : 
     193           0 :     m_nHtmlMode = ::GetHtmlMode(static_cast<const SwDocShell*>(SfxObjectShell::Current()));
     194           0 :     m_bHtmlMode = (m_nHtmlMode & HTMLMODE_ON) != 0;
     195             : 
     196           0 :     FieldUnit aMetric = ::GetDfltMetric(m_bHtmlMode);
     197           0 :     SetMetric(*m_pLeftMarginED, aMetric);
     198           0 :     SetMetric(*m_pRightMarginED, aMetric);
     199           0 :     SetMetric(*m_pTopMarginED, aMetric);
     200           0 :     SetMetric(*m_pBottomMarginED, aMetric);
     201             : 
     202           0 :     const SwFormatSurround& rSurround = static_cast<const SwFormatSurround&>(rSet->Get(RES_SURROUND));
     203             : 
     204           0 :     SwSurround nSur = rSurround.GetSurround();
     205           0 :     const SwFormatAnchor &rAnch = static_cast<const SwFormatAnchor&>(rSet->Get(RES_ANCHOR));
     206           0 :     m_nAnchorId = rAnch.GetAnchorId();
     207             : 
     208           0 :     if (((m_nAnchorId == FLY_AT_PARA) || (m_nAnchorId == FLY_AT_CHAR))
     209           0 :         && (nSur != SURROUND_NONE))
     210             :     {
     211           0 :         m_pWrapAnchorOnlyCB->Check( rSurround.IsAnchorOnly() );
     212             :     }
     213             :     else
     214             :     {
     215           0 :         m_pWrapAnchorOnlyCB->Enable( false );
     216             :     }
     217             : 
     218           0 :     bool bContour = rSurround.IsContour();
     219           0 :     m_pWrapOutlineCB->Check( bContour );
     220           0 :     m_pWrapOutsideCB->Check( rSurround.IsOutside() );
     221           0 :     m_pWrapThroughRB->Enable(!m_pWrapOutlineCB->IsChecked());
     222           0 :     m_bContourImage = !bContour;
     223             : 
     224           0 :     RadioButton* pBtn = NULL;
     225             : 
     226           0 :     switch (nSur)
     227             :     {
     228             :         case SURROUND_NONE:
     229             :         {
     230           0 :             pBtn = m_pNoWrapRB;
     231           0 :             break;
     232             :         }
     233             : 
     234             :         case SURROUND_THROUGHT:
     235             :         {
     236             :             // transparent ?
     237           0 :             pBtn = m_pWrapThroughRB;
     238             : 
     239           0 :             if (!m_bDrawMode)
     240             :             {
     241           0 :                 const SvxOpaqueItem& rOpaque = static_cast<const SvxOpaqueItem&>(rSet->Get(RES_OPAQUE));
     242           0 :                 m_pWrapTransparentCB->Check(!rOpaque.GetValue());
     243             :             }
     244           0 :             break;
     245             :         }
     246             : 
     247             :         case SURROUND_PARALLEL:
     248             :         {
     249           0 :             pBtn = m_pWrapParallelRB;
     250           0 :             break;
     251             :         }
     252             : 
     253             :         case SURROUND_IDEAL:
     254             :         {
     255           0 :             pBtn = m_pIdealWrapRB;
     256           0 :             break;
     257             :         }
     258             : 
     259             :         default:
     260             :         {
     261           0 :             if (nSur == SURROUND_LEFT)
     262           0 :                 pBtn = m_pWrapLeftRB;
     263           0 :             else if (nSur == SURROUND_RIGHT)
     264           0 :                 pBtn = m_pWrapRightRB;
     265             :         }
     266             :     }
     267           0 :     if (pBtn)
     268             :     {
     269           0 :         pBtn->Check();
     270           0 :         WrapTypeHdl(pBtn);
     271             :         // For character objects that currently are in passage, the default
     272             :         // "contour on" is prepared here, in case we switch to any other
     273             :         // passage later.
     274           0 :         if (m_bDrawMode && !m_pWrapOutlineCB->IsEnabled())
     275           0 :             m_pWrapOutlineCB->Check();
     276             :     }
     277           0 :     m_pWrapTransparentCB->Enable( pBtn == m_pWrapThroughRB && !m_bHtmlMode );
     278             : 
     279           0 :     const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>(rSet->Get(RES_UL_SPACE));
     280           0 :     const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>(rSet->Get(RES_LR_SPACE));
     281             : 
     282             :     // gap to text
     283           0 :     m_pLeftMarginED->SetValue(m_pLeftMarginED->Normalize(rLR.GetLeft()), FUNIT_TWIP);
     284           0 :     m_pRightMarginED->SetValue(m_pRightMarginED->Normalize(rLR.GetRight()), FUNIT_TWIP);
     285           0 :     m_pTopMarginED->SetValue(m_pTopMarginED->Normalize(rUL.GetUpper()), FUNIT_TWIP);
     286           0 :     m_pBottomMarginED->SetValue(m_pBottomMarginED->Normalize(rUL.GetLower()), FUNIT_TWIP);
     287             : 
     288           0 :     ContourHdl(0);
     289           0 :     ActivatePage( *rSet );
     290           0 : }
     291             : 
     292             : // stuff attributes into the set when OK
     293           0 : bool SwWrapTabPage::FillItemSet(SfxItemSet *rSet)
     294             : {
     295           0 :     bool bModified = false;
     296             :     const SfxPoolItem* pOldItem;
     297           0 :     const SwFormatSurround& rOldSur = static_cast<const SwFormatSurround&>(GetItemSet().Get(RES_SURROUND));
     298           0 :     SwFormatSurround aSur( rOldSur );
     299             : 
     300           0 :     SvxOpaqueItem aOp( RES_OPAQUE);
     301             : 
     302           0 :     if (!m_bDrawMode)
     303             :     {
     304           0 :         const SvxOpaqueItem& rOpaque = static_cast<const SvxOpaqueItem&>(GetItemSet().Get(RES_OPAQUE));
     305           0 :         aOp = rOpaque;
     306           0 :         aOp.SetValue(true);
     307             :     }
     308             : 
     309           0 :     if (m_pNoWrapRB->IsChecked())
     310           0 :         aSur.SetSurround(SURROUND_NONE);
     311           0 :     else if (m_pWrapLeftRB->IsChecked())
     312           0 :         aSur.SetSurround(SURROUND_LEFT);
     313           0 :     else if (m_pWrapRightRB->IsChecked())
     314           0 :         aSur.SetSurround(SURROUND_RIGHT);
     315           0 :     else if (m_pWrapParallelRB->IsChecked())
     316           0 :         aSur.SetSurround(SURROUND_PARALLEL);
     317           0 :     else if (m_pWrapThroughRB->IsChecked())
     318             :     {
     319           0 :         aSur.SetSurround(SURROUND_THROUGHT);
     320           0 :         if (m_pWrapTransparentCB->IsChecked() && !m_bDrawMode)
     321           0 :             aOp.SetValue(false);
     322             :     }
     323           0 :     else if (m_pIdealWrapRB->IsChecked())
     324           0 :         aSur.SetSurround(SURROUND_IDEAL);
     325             : 
     326           0 :     aSur.SetAnchorOnly( m_pWrapAnchorOnlyCB->IsChecked() );
     327           0 :     bool bContour = m_pWrapOutlineCB->IsChecked() && m_pWrapOutlineCB->IsEnabled();
     328           0 :     aSur.SetContour( bContour );
     329             : 
     330           0 :     if ( bContour )
     331           0 :         aSur.SetOutside(m_pWrapOutsideCB->IsChecked());
     332             : 
     333           0 :     if(0 == (pOldItem = GetOldItem( *rSet, RES_SURROUND )) ||
     334           0 :                 aSur != *pOldItem )
     335             :     {
     336           0 :         rSet->Put(aSur);
     337           0 :         bModified = true;
     338             :     }
     339             : 
     340           0 :     if (!m_bDrawMode)
     341             :     {
     342           0 :         if(0 == (pOldItem = GetOldItem( *rSet, FN_OPAQUE )) ||
     343           0 :                     aOp != *pOldItem )
     344             :         {
     345           0 :             rSet->Put(aOp);
     346           0 :             bModified = true;
     347             :         }
     348             :     }
     349             : 
     350           0 :     bool bTopMod = m_pTopMarginED->IsValueModified();
     351           0 :     bool bBottomMod = m_pBottomMarginED->IsValueModified();
     352             : 
     353           0 :     SvxULSpaceItem aUL( RES_UL_SPACE );
     354           0 :     aUL.SetUpper((sal_uInt16)m_pTopMarginED->Denormalize(m_pTopMarginED->GetValue(FUNIT_TWIP)));
     355           0 :     aUL.SetLower((sal_uInt16)m_pBottomMarginED->Denormalize(m_pBottomMarginED->GetValue(FUNIT_TWIP)));
     356             : 
     357           0 :     if ( bTopMod || bBottomMod )
     358             :     {
     359           0 :         if(0 == (pOldItem = GetOldItem(*rSet, RES_UL_SPACE)) ||
     360           0 :                 aUL != *pOldItem )
     361             :         {
     362           0 :             rSet->Put( aUL, RES_UL_SPACE );
     363           0 :             bModified = true;
     364             :         }
     365             :     }
     366             : 
     367           0 :     bool bLeftMod = m_pLeftMarginED->IsValueModified();
     368           0 :     bool bRightMod = m_pRightMarginED->IsValueModified();
     369             : 
     370           0 :     SvxLRSpaceItem aLR( RES_LR_SPACE );
     371           0 :     aLR.SetLeft((sal_uInt16)m_pLeftMarginED->Denormalize(m_pLeftMarginED->GetValue(FUNIT_TWIP)));
     372           0 :     aLR.SetRight((sal_uInt16)m_pRightMarginED->Denormalize(m_pRightMarginED->GetValue(FUNIT_TWIP)));
     373             : 
     374           0 :     if ( bLeftMod || bRightMod )
     375             :     {
     376           0 :         if( 0 == (pOldItem = GetOldItem(*rSet, RES_LR_SPACE)) ||
     377           0 :                 aLR != *pOldItem )
     378             :         {
     379           0 :             rSet->Put(aLR, RES_LR_SPACE);
     380           0 :             bModified = true;
     381             :         }
     382             :     }
     383             : 
     384           0 :     if ( m_bDrawMode )
     385             :     {
     386           0 :         bool bChecked = m_pWrapTransparentCB->IsChecked() && m_pWrapTransparentCB->IsEnabled();
     387           0 :         if ((m_pWrapTransparentCB->GetSavedValue() == 1) != bChecked)
     388           0 :             bModified |= 0 != rSet->Put(SfxInt16Item(FN_DRAW_WRAP_DLG, bChecked ? 0 : 1));
     389             :     }
     390             : 
     391           0 :     return bModified;
     392             : }
     393             : 
     394             : // example update
     395           0 : void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet)
     396             : {
     397             :     // anchor
     398           0 :     const SwFormatAnchor &rAnch = static_cast<const SwFormatAnchor&>(rSet.Get(RES_ANCHOR));
     399           0 :     m_nAnchorId = rAnch.GetAnchorId();
     400           0 :     bool bEnable = (m_nAnchorId != FLY_AS_CHAR);
     401             : 
     402           0 :     if (!m_bDrawMode)
     403             :     {
     404           0 :         SwWrtShell* pSh = m_bFormat ? ::GetActiveWrtShell() : m_pWrtSh;
     405           0 :         SwFlyFrmAttrMgr aMgr( m_bNew, pSh, static_cast<const SwAttrSet&>(GetItemSet()) );
     406           0 :         SvxSwFrameValidation aVal;
     407             : 
     408             :         // size
     409           0 :         const SwFormatFrmSize& rFrmSize = static_cast<const SwFormatFrmSize&>(rSet.Get(RES_FRM_SIZE));
     410           0 :         Size aSize = rFrmSize.GetSize();
     411             : 
     412             :         // margin
     413           0 :         const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>(rSet.Get(RES_UL_SPACE));
     414           0 :         const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>(rSet.Get(RES_LR_SPACE));
     415           0 :         m_nOldLeftMargin  = static_cast< sal_uInt16 >(rLR.GetLeft());
     416           0 :         m_nOldRightMargin = static_cast< sal_uInt16 >(rLR.GetRight());
     417           0 :         m_nOldUpperMargin = static_cast< sal_uInt16 >(rUL.GetUpper());
     418           0 :         m_nOldLowerMargin = static_cast< sal_uInt16 >(rUL.GetLower());
     419             : 
     420             :         // position
     421           0 :         const SwFormatHoriOrient& rHori = static_cast<const SwFormatHoriOrient&>(rSet.Get(RES_HORI_ORIENT));
     422           0 :         const SwFormatVertOrient& rVert = static_cast<const SwFormatVertOrient&>(rSet.Get(RES_VERT_ORIENT));
     423             : 
     424           0 :         aVal.nAnchorType = static_cast< sal_Int16 >(m_nAnchorId);
     425           0 :         aVal.bAutoHeight = rFrmSize.GetHeightSizeType() == ATT_MIN_SIZE;
     426           0 :         aVal.bAutoWidth = rFrmSize.GetWidthSizeType() == ATT_MIN_SIZE;
     427           0 :         aVal.bMirror = rHori.IsPosToggle();
     428             :         // #i18732#
     429             :         aVal.bFollowTextFlow =
     430           0 :             static_cast<const SwFormatFollowTextFlow&>(rSet.Get(RES_FOLLOW_TEXT_FLOW)).GetValue();
     431             : 
     432           0 :         aVal.nHoriOrient = (short)rHori.GetHoriOrient();
     433           0 :         aVal.nVertOrient = (short)rVert.GetVertOrient();
     434             : 
     435           0 :         aVal.nHPos = rHori.GetPos();
     436           0 :         aVal.nHRelOrient = rHori.GetRelationOrient();
     437           0 :         aVal.nVPos = rVert.GetPos();
     438           0 :         aVal.nVRelOrient = rVert.GetRelationOrient();
     439             : 
     440           0 :         if (rFrmSize.GetWidthPercent() && rFrmSize.GetWidthPercent() != 0xff)
     441           0 :             aSize.Width() = aSize.Width() * rFrmSize.GetWidthPercent() / 100;
     442             : 
     443           0 :         if (rFrmSize.GetHeightPercent() && rFrmSize.GetHeightPercent() != 0xff)
     444           0 :             aSize.Height() = aSize.Height() * rFrmSize.GetHeightPercent() / 100;
     445             : 
     446           0 :         aVal.nWidth  = aSize.Width();
     447           0 :         aVal.nHeight = aSize.Height();
     448           0 :         m_aFrmSize = aSize;
     449             : 
     450           0 :         aMgr.ValidateMetrics(aVal, 0);
     451             : 
     452             :         SwTwips nLeft;
     453             :         SwTwips nRight;
     454             :         SwTwips nTop;
     455             :         SwTwips nBottom;
     456             : 
     457           0 :         nLeft   = aVal.nHPos - aVal.nMinHPos;
     458           0 :         nRight  = aVal.nMaxWidth - aVal.nWidth;
     459           0 :         nTop    = aVal.nVPos - aVal.nMinVPos;
     460           0 :         nBottom = aVal.nMaxHeight - aVal.nHeight;
     461             : 
     462             :         {
     463           0 :             if (aVal.nAnchorType == FLY_AS_CHAR)
     464             :             {
     465           0 :                 nLeft = nRight;
     466             : 
     467           0 :                 if (aVal.nVPos < 0)
     468             :                 {
     469           0 :                     if (aVal.nVPos <= aVal.nMaxHeight)
     470           0 :                         nTop = aVal.nMaxVPos - aVal.nHeight;
     471             :                     else
     472           0 :                         nTop = nBottom = 0; // no passage
     473             :                 }
     474             :                 else
     475           0 :                     nTop = aVal.nMaxVPos - aVal.nHeight - aVal.nVPos;
     476             :             }
     477             :             else
     478             :             {
     479           0 :                 nLeft += nRight;
     480           0 :                 nTop += nBottom;
     481             :             }
     482             : 
     483           0 :             nBottom = nTop;
     484           0 :             nRight = nLeft;
     485             :         }
     486             : 
     487           0 :         m_pLeftMarginED->SetMax(m_pLeftMarginED->Normalize(nLeft), FUNIT_TWIP);
     488           0 :         m_pRightMarginED->SetMax(m_pRightMarginED->Normalize(nRight), FUNIT_TWIP);
     489             : 
     490           0 :         m_pTopMarginED->SetMax(m_pTopMarginED->Normalize(nTop), FUNIT_TWIP);
     491           0 :         m_pBottomMarginED->SetMax(m_pBottomMarginED->Normalize(nBottom), FUNIT_TWIP);
     492             : 
     493           0 :         RangeModifyHdl(m_pLeftMarginED);
     494           0 :         RangeModifyHdl(m_pTopMarginED);
     495             :     }
     496             : 
     497           0 :     const SwFormatSurround& rSurround = static_cast<const SwFormatSurround&>(rSet.Get(RES_SURROUND));
     498           0 :     SwSurround nSur = rSurround.GetSurround();
     499             : 
     500           0 :     m_pWrapTransparentCB->Enable( bEnable && !m_bHtmlMode && nSur == SURROUND_THROUGHT );
     501           0 :     if(m_bHtmlMode)
     502             :     {
     503           0 :         const SwFormatHoriOrient& rHori = static_cast<const SwFormatHoriOrient&>(rSet.Get(RES_HORI_ORIENT));
     504           0 :         sal_Int16 eHOrient = rHori.GetHoriOrient();
     505           0 :         sal_Int16 eHRelOrient = rHori.GetRelationOrient();
     506           0 :         m_pWrapOutlineCB->Hide();
     507             :         const bool bAllHtmlModes =
     508           0 :             ((m_nAnchorId == FLY_AT_PARA) || (m_nAnchorId == FLY_AT_CHAR)) &&
     509           0 :                             (eHOrient == text::HoriOrientation::RIGHT || eHOrient == text::HoriOrientation::LEFT);
     510           0 :         m_pWrapAnchorOnlyCB->Enable( bAllHtmlModes && nSur != SURROUND_NONE );
     511           0 :         m_pWrapOutsideCB->Hide();
     512           0 :         m_pIdealWrapRB->Enable( false );
     513             : 
     514           0 :         m_pWrapTransparentCB->Enable( false );
     515           0 :         m_pNoWrapRB->Enable( FLY_AT_PARA == m_nAnchorId );
     516           0 :         m_pWrapParallelRB->Enable( false  );
     517           0 :         m_pWrapLeftRB->Enable
     518           0 :                     (  (FLY_AT_PARA == m_nAnchorId)
     519           0 :                     || (   (FLY_AT_CHAR == m_nAnchorId)
     520           0 :                         && (eHOrient == text::HoriOrientation::RIGHT)
     521           0 :                         && (eHRelOrient == text::RelOrientation::PRINT_AREA)));
     522           0 :         m_pWrapRightRB->Enable
     523           0 :                     (  (FLY_AT_PARA == m_nAnchorId)
     524           0 :                     || (   (FLY_AT_CHAR == m_nAnchorId)
     525           0 :                         && (eHOrient == text::HoriOrientation::LEFT)
     526           0 :                         && (eHRelOrient == text::RelOrientation::PRINT_AREA)));
     527             : 
     528           0 :         m_pWrapThroughRB->Enable
     529           0 :                 (   (  (FLY_AT_PAGE == m_nAnchorId)
     530           0 :                     || (   (FLY_AT_CHAR == m_nAnchorId)
     531           0 :                         && (eHRelOrient != text::RelOrientation::PRINT_AREA))
     532           0 :                     || (FLY_AT_PARA == m_nAnchorId))
     533           0 :                 && (eHOrient != text::HoriOrientation::RIGHT));
     534           0 :         if(m_pNoWrapRB->IsChecked() && !m_pNoWrapRB->IsEnabled())
     535             :         {
     536           0 :             if(m_pWrapThroughRB->IsEnabled())
     537           0 :                 m_pWrapThroughRB->Check(true);
     538           0 :             else if(m_pWrapLeftRB->IsEnabled())
     539           0 :                 m_pWrapLeftRB->Check();
     540           0 :             else if(m_pWrapRightRB->IsEnabled())
     541           0 :                 m_pWrapRightRB->Check();
     542             : 
     543             :         }
     544           0 :         if(m_pWrapLeftRB->IsChecked() && !m_pWrapLeftRB->IsEnabled())
     545             :         {
     546           0 :             if(m_pWrapRightRB->IsEnabled())
     547           0 :                 m_pWrapRightRB->Check();
     548           0 :             else if(m_pWrapThroughRB->IsEnabled())
     549           0 :                 m_pWrapThroughRB->Check();
     550             :         }
     551           0 :         if(m_pWrapRightRB->IsChecked() && !m_pWrapRightRB->IsEnabled())
     552             :         {
     553           0 :             if(m_pWrapLeftRB->IsEnabled())
     554           0 :                 m_pWrapLeftRB->Check();
     555           0 :             else if(m_pWrapThroughRB->IsEnabled())
     556           0 :                 m_pWrapThroughRB->Check();
     557             :         }
     558           0 :         if(m_pWrapThroughRB->IsChecked() && !m_pWrapThroughRB->IsEnabled())
     559           0 :             if(m_pNoWrapRB->IsEnabled())
     560           0 :                 m_pNoWrapRB->Check();
     561             : 
     562           0 :         if(m_pWrapParallelRB->IsChecked() && !m_pWrapParallelRB->IsEnabled())
     563           0 :             m_pWrapThroughRB->Check();
     564             :     }
     565             :     else
     566             :     {
     567           0 :         m_pNoWrapRB->Enable( bEnable );
     568           0 :         m_pWrapLeftRB->Enable( bEnable );
     569           0 :         m_pWrapRightRB->Enable( bEnable );
     570           0 :         m_pIdealWrapRB->Enable( bEnable );
     571           0 :         m_pWrapThroughRB->Enable( bEnable );
     572           0 :         m_pWrapParallelRB->Enable( bEnable );
     573           0 :         m_pWrapAnchorOnlyCB->Enable(
     574           0 :                 ((m_nAnchorId == FLY_AT_PARA) || (m_nAnchorId == FLY_AT_CHAR))
     575           0 :                 && nSur != SURROUND_NONE );
     576             :     }
     577           0 :     ContourHdl(0);
     578           0 : }
     579             : 
     580           0 : SfxTabPage::sfxpg SwWrapTabPage::DeactivatePage(SfxItemSet* _pSet)
     581             : {
     582           0 :     if(_pSet)
     583           0 :         FillItemSet(_pSet);
     584             : 
     585           0 :     return LEAVE_PAGE;
     586             : }
     587             : 
     588             : // range check
     589           0 : IMPL_LINK( SwWrapTabPage, RangeModifyHdl, MetricField *, pEdit )
     590             : {
     591           0 :         sal_Int64 nValue = pEdit->GetValue();
     592           0 :         MetricField *pOpposite = 0;
     593           0 :         if (pEdit == m_pLeftMarginED)
     594           0 :             pOpposite = m_pRightMarginED;
     595           0 :         else if (pEdit == m_pRightMarginED)
     596           0 :             pOpposite = m_pLeftMarginED;
     597           0 :         else if (pEdit == m_pTopMarginED)
     598           0 :             pOpposite = m_pBottomMarginED;
     599           0 :         else if (pEdit == m_pBottomMarginED)
     600           0 :             pOpposite = m_pTopMarginED;
     601             : 
     602             :         OSL_ASSERT(pOpposite);
     603             : 
     604           0 :         if (pOpposite)
     605             :         {
     606           0 :             sal_Int64 nOpposite = pOpposite->GetValue();
     607             : 
     608           0 :             if (nValue + nOpposite > std::max(pEdit->GetMax(), pOpposite->GetMax()))
     609           0 :                 pOpposite->SetValue(pOpposite->GetMax() - nValue);
     610             :         }
     611             : 
     612           0 :     return 0;
     613             : }
     614             : 
     615           0 : IMPL_LINK( SwWrapTabPage, WrapTypeHdl, RadioButton *, pBtn )
     616             : {
     617           0 :     bool bWrapThrough = (pBtn == m_pWrapThroughRB);
     618           0 :     m_pWrapTransparentCB->Enable( bWrapThrough && !m_bHtmlMode );
     619           0 :     bWrapThrough |= ( m_nAnchorId == FLY_AS_CHAR );
     620           0 :     m_pWrapOutlineCB->Enable( !bWrapThrough && pBtn != m_pNoWrapRB);
     621           0 :     m_pWrapOutsideCB->Enable( !bWrapThrough && m_pWrapOutlineCB->IsChecked() );
     622           0 :     m_pWrapAnchorOnlyCB->Enable(
     623           0 :         ((m_nAnchorId == FLY_AT_PARA) || (m_nAnchorId == FLY_AT_CHAR)) &&
     624           0 :         (pBtn != m_pNoWrapRB) );
     625             : 
     626           0 :     ContourHdl(0);
     627           0 :     return 0;
     628             : }
     629             : 
     630           0 : IMPL_LINK_NOARG(SwWrapTabPage, ContourHdl)
     631             : {
     632           0 :     bool bEnable = !(m_pWrapOutlineCB->IsChecked() && m_pWrapOutlineCB->IsEnabled());
     633             : 
     634           0 :     m_pWrapOutsideCB->Enable(!bEnable);
     635             : 
     636           0 :     bEnable =  !m_pWrapOutlineCB->IsChecked();
     637           0 :     if (bEnable == m_bContourImage) // so that it doesn't always flicker
     638             :     {
     639           0 :         m_bContourImage = !bEnable;
     640           0 :         ApplyImageList();
     641             :     }
     642             : 
     643           0 :     return 0;
     644             : }
     645             : 
     646           0 : void SwWrapTabPage::DataChanged( const DataChangedEvent& rDCEvt )
     647             : {
     648           0 :     if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
     649           0 :          (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
     650           0 :             ApplyImageList();
     651             : 
     652           0 :     SfxTabPage::DataChanged( rDCEvt );
     653           0 : }
     654             : 
     655           0 : void SwWrapTabPage::ApplyImageList()
     656             : {
     657           0 :     m_pWrapThroughRB->SetModeRadioImage(get<FixedImage>("imgthrough")->GetImage());
     658           0 :     bool bWrapOutline =  !m_pWrapOutlineCB->IsChecked();
     659           0 :     if(bWrapOutline)
     660             :     {
     661           0 :         m_pNoWrapRB->SetModeRadioImage(get<FixedImage>("imgnone")->GetImage());
     662           0 :         m_pWrapLeftRB->SetModeRadioImage(get<FixedImage>("imgleft")->GetImage());
     663           0 :         m_pWrapRightRB->SetModeRadioImage(get<FixedImage>("imgright")->GetImage());
     664           0 :         m_pWrapParallelRB->SetModeRadioImage(get<FixedImage>("imgparallel")->GetImage());
     665           0 :         m_pIdealWrapRB->SetModeRadioImage(get<FixedImage>("imgideal")->GetImage());
     666             :     }
     667             :     else
     668             :     {
     669           0 :         m_pNoWrapRB->SetModeRadioImage(get<FixedImage>("imgkonnone")->GetImage());
     670           0 :         m_pWrapLeftRB->SetModeRadioImage(get<FixedImage>("imgkonleft")->GetImage());
     671           0 :         m_pWrapRightRB->SetModeRadioImage(get<FixedImage>("imgkonright")->GetImage());
     672           0 :         m_pWrapParallelRB->SetModeRadioImage(get<FixedImage>("imgkonparallel")->GetImage());
     673           0 :         m_pIdealWrapRB->SetModeRadioImage(get<FixedImage>("imgkonideal")->GetImage());
     674             :     }
     675           0 : }
     676             : 
     677             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11