LCOV - code coverage report
Current view: top level - sw/source/core/uibase/utlui - uitool.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 173 386 44.8 %
Date: 2014-04-11 Functions: 6 22 27.3 %
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             : 
      22             : #include <osl/diagnose.h>
      23             : #include <tools/datetime.hxx>
      24             : #include <vcl/svapp.hxx>
      25             : #include <unotools/collatorwrapper.hxx>
      26             : #include <svl/urihelper.hxx>
      27             : #include <svl/stritem.hxx>
      28             : #include <unotools/syslocale.hxx>
      29             : #include <sfx2/app.hxx>
      30             : #include <sfx2/docfile.hxx>
      31             : #include <sfx2/docfilt.hxx>
      32             : #include <editeng/pmdlitem.hxx>
      33             : #include <editeng/tstpitem.hxx>
      34             : #include <editeng/boxitem.hxx>
      35             : #include <editeng/shaditem.hxx>
      36             : #include <editeng/sizeitem.hxx>
      37             : #include <editeng/brushitem.hxx>
      38             : #include <svx/pageitem.hxx>
      39             : #include <editeng/lrspitem.hxx>
      40             : #include <svl/style.hxx>
      41             : #include <vcl/lstbox.hxx>
      42             : #include <unotools/localedatawrapper.hxx>
      43             : #include <com/sun/star/frame/XDispatch.hpp>
      44             : #include <com/sun/star/frame/XDispatchProvider.hpp>
      45             : #include <com/sun/star/util/URLTransformer.hpp>
      46             : #include <com/sun/star/util/XURLTransformer.hpp>
      47             : #include <comphelper/processfactory.hxx>
      48             : #include <sfx2/viewfrm.hxx>
      49             : #include <fmtornt.hxx>
      50             : #include <tabcol.hxx>
      51             : #include <edtwin.hxx>
      52             : #include <fmtfsize.hxx>
      53             : #include <fmthdft.hxx>
      54             : #include <fmtpdsc.hxx>
      55             : #include <wview.hxx>
      56             : #include <uiitems.hxx>
      57             : #include <docsh.hxx>
      58             : #include <wrtsh.hxx>
      59             : #include <swmodule.hxx>
      60             : #include <view.hxx>
      61             : #include <uitool.hxx>
      62             : #include <frmatr.hxx>
      63             : #include <paratr.hxx>
      64             : #include <fmtcol.hxx>
      65             : #include <poolfmt.hxx>
      66             : #include "usrpref.hxx"
      67             : 
      68             : #include <cmdid.h>
      69             : #include <globals.hrc>
      70             : #include <utlui.hrc>
      71             : #include <doc.hxx>
      72             : #include <docary.hxx>
      73             : #include <charfmt.hxx>
      74             : #include <SwStyleNameMapper.hxx>
      75             : // 50 cm 28350
      76             : 
      77             : #define MAXHEIGHT 28350
      78             : #define MAXWIDTH  28350
      79             : 
      80             : using namespace ::com::sun::star;
      81             : 
      82             : // General list of string pointer
      83             : 
      84             : // Switch metric
      85             : 
      86           0 : void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit)
      87             : {
      88           0 :     SwTwips nMin = static_cast< SwTwips >(rCtrl.GetMin(FUNIT_TWIP));
      89           0 :     SwTwips nMax = static_cast< SwTwips >(rCtrl.GetMax(FUNIT_TWIP));
      90             : 
      91           0 :     rCtrl.SetUnit(eUnit);
      92             : 
      93           0 :     rCtrl.SetMin(nMin, FUNIT_TWIP);
      94           0 :     rCtrl.SetMax(nMax, FUNIT_TWIP);
      95           0 : }
      96             : 
      97             : // Set boxinfo attribute
      98             : 
      99           0 : void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh)
     100             : {
     101           0 :     SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
     102             :     const SfxPoolItem *pBoxInfo;
     103           0 :     if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER,
     104           0 :                                         true, &pBoxInfo))
     105           0 :         aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
     106             : 
     107             :         // Table variant: If more than one table cells are selected
     108           0 :     rSh.GetCrsr();                  //So that GetCrsrCnt() returns the right thing
     109           0 :     aBoxInfo.SetTable          (rSh.IsTableMode() && rSh.GetCrsrCnt() > 1);
     110             :         // Always show the distance field
     111           0 :     aBoxInfo.SetDist           (true);
     112             :         // Set minimal size in tables and paragraphs
     113           0 :     aBoxInfo.SetMinDist        (rSh.IsTableMode() || rSh.GetSelectionType() & (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL));
     114             :         // Set always the default distance
     115           0 :     aBoxInfo.SetDefDist        (MIN_BORDER_DIST);
     116             :         // Single lines can have only in tables DontCare-Status
     117           0 :     aBoxInfo.SetValid(VALID_DISABLE, !rSh.IsTableMode());
     118             : 
     119           0 :     rSet.Put(aBoxInfo);
     120           0 : }
     121             : 
     122           0 : void ConvertAttrCharToGen(SfxItemSet& rSet, const sal_uInt8 nMode)
     123             : {
     124             :     // Background
     125             :     {
     126             :         const SfxPoolItem *pTmpBrush;
     127           0 :         if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_BACKGROUND, true, &pTmpBrush ) )
     128             :         {
     129           0 :             SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
     130           0 :             aTmpBrush.SetWhich( RES_BACKGROUND );
     131           0 :             rSet.Put( aTmpBrush );
     132             :         }
     133             :         else
     134           0 :             rSet.ClearItem(RES_BACKGROUND);
     135             :     }
     136             : 
     137           0 :     if( nMode == CONV_ATTR_STD )
     138             :     {
     139             :         // Border
     140             :         const SfxPoolItem *pTmpItem;
     141           0 :         if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_BOX, true, &pTmpItem ) )
     142             :         {
     143           0 :             SvxBoxItem aTmpBox( *((SvxBoxItem*)pTmpItem) );
     144           0 :             aTmpBox.SetWhich( RES_BOX );
     145           0 :             rSet.Put( aTmpBox );
     146             :         }
     147             :         else
     148           0 :             rSet.ClearItem(RES_BOX);
     149             : 
     150             :         // Border shadow
     151           0 :         if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_SHADOW, false, &pTmpItem ) )
     152             :         {
     153           0 :             SvxShadowItem aTmpShadow( *((SvxShadowItem*)pTmpItem) );
     154           0 :             aTmpShadow.SetWhich( RES_SHADOW );
     155           0 :             rSet.Put( aTmpShadow );
     156             :         }
     157             :         else
     158           0 :             rSet.ClearItem( RES_SHADOW );
     159             :     }
     160           0 : }
     161             : 
     162           0 : void ConvertAttrGenToChar(SfxItemSet& rSet, const sal_uInt8 nMode)
     163             : {
     164             :     // Background
     165             :     {
     166             :         const SfxPoolItem *pTmpBrush;
     167           0 :         if( SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND, false, &pTmpBrush ) )
     168             :         {
     169           0 :             SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
     170           0 :             aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
     171           0 :             rSet.Put( aTmpBrush );
     172             :         }
     173           0 :         rSet.ClearItem( RES_BACKGROUND );
     174             :     }
     175             : 
     176           0 :     if( nMode == CONV_ATTR_STD )
     177             :     {
     178             :         // Border
     179             :         const SfxPoolItem *pTmpItem;
     180           0 :         if( SFX_ITEM_SET == rSet.GetItemState( RES_BOX, false, &pTmpItem ) )
     181             :         {
     182           0 :             SvxBoxItem aTmpBox( *((SvxBoxItem*)pTmpItem) );
     183           0 :             aTmpBox.SetWhich( RES_CHRATR_BOX );
     184           0 :             rSet.Put( aTmpBox );
     185             :         }
     186           0 :         rSet.ClearItem( RES_BOX );
     187             : 
     188             :         // Border shadow
     189           0 :         if( SFX_ITEM_SET == rSet.GetItemState( RES_SHADOW, false, &pTmpItem ) )
     190             :         {
     191           0 :             SvxShadowItem aTmpShadow( *((SvxShadowItem*)pTmpItem) );
     192           0 :             aTmpShadow.SetWhich( RES_CHRATR_SHADOW );
     193           0 :             rSet.Put( aTmpShadow );
     194             :         }
     195           0 :         rSet.ClearItem( RES_SHADOW );
     196             :     }
     197           0 : }
     198             : 
     199             : // Fill header footer
     200             : 
     201        2253 : void FillHdFt(SwFrmFmt* pFmt, const  SfxItemSet& rSet)
     202             : {
     203        2253 :     SwAttrSet aSet(pFmt->GetAttrSet());
     204        2253 :     aSet.Put(rSet);
     205             : 
     206        2253 :     const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE);
     207        2253 :     const SfxBoolItem& rDynamic = (const SfxBoolItem&)rSet.Get(SID_ATTR_PAGE_DYNAMIC);
     208             : 
     209             :     // Convert size
     210        2253 :     SwFmtFrmSize aFrmSize(rDynamic.GetValue() ? ATT_MIN_SIZE : ATT_FIX_SIZE,
     211        2253 :                             rSize.GetSize().Width(),
     212        9012 :                             rSize.GetSize().Height());
     213        2253 :     aSet.Put(aFrmSize);
     214        4506 :     pFmt->SetFmtAttr(aSet);
     215        2253 : }
     216             : 
     217             : /// Convert from UseOnPage to SvxPageUsage.
     218        7478 : UseOnPage lcl_convertUseToSvx(UseOnPage nUse)
     219             : {
     220        7478 :     UseOnPage nRet = nsUseOnPage::PD_NONE;
     221        7478 :     if ((nUse & nsUseOnPage::PD_LEFT) == nsUseOnPage::PD_LEFT)
     222        7473 :         nRet |= SVX_PAGE_LEFT;
     223        7478 :     if ((nUse & nsUseOnPage::PD_RIGHT) == nsUseOnPage::PD_RIGHT)
     224        7471 :         nRet |= SVX_PAGE_RIGHT;
     225        7478 :     if ((nUse & nsUseOnPage::PD_ALL) == nsUseOnPage::PD_ALL)
     226        7466 :         nRet |= SVX_PAGE_ALL;
     227        7478 :     if ((nUse & nsUseOnPage::PD_MIRROR) == nsUseOnPage::PD_MIRROR)
     228         128 :         nRet |= SVX_PAGE_MIRROR;
     229        7478 :     return nRet;
     230             : }
     231             : 
     232             : /// Convert from SvxPageUsage to UseOnPage.
     233        3258 : UseOnPage lcl_convertUseFromSvx(UseOnPage nUse)
     234             : {
     235        3258 :     UseOnPage nRet = nsUseOnPage::PD_NONE;
     236        3258 :     if ((nUse & SVX_PAGE_LEFT) == SVX_PAGE_LEFT)
     237        3251 :         nRet |= nsUseOnPage::PD_LEFT;
     238        3258 :     if ((nUse & SVX_PAGE_RIGHT) == SVX_PAGE_RIGHT)
     239        3252 :         nRet |= nsUseOnPage::PD_RIGHT;
     240        3258 :     if ((nUse & SVX_PAGE_ALL) == SVX_PAGE_ALL)
     241        3245 :         nRet |= nsUseOnPage::PD_ALL;
     242        3258 :     if ((nUse & SVX_PAGE_MIRROR) == SVX_PAGE_MIRROR)
     243          57 :         nRet |= nsUseOnPage::PD_MIRROR;
     244        3258 :     return nRet;
     245             : }
     246             : 
     247             : // PageDesc <-> convert into sets and back
     248             : 
     249        3258 : void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc )
     250             : {
     251        3258 :     SwFrmFmt& rMaster = rPageDesc.GetMaster();
     252        3258 :     int nFirstShare = -1;
     253             : 
     254             :     // Transfer all general frame attributes
     255        3258 :     rMaster.SetFmtAttr(rSet);
     256             : 
     257             :     // PageData
     258        3258 :     if(rSet.GetItemState(SID_ATTR_PAGE) == SFX_ITEM_SET)
     259             :     {
     260        3258 :         const SvxPageItem& rPageItem = (const SvxPageItem&)rSet.Get(SID_ATTR_PAGE);
     261             : 
     262        3258 :         sal_uInt16 nUse = (sal_uInt16)rPageItem.GetPageUsage();
     263        3258 :         if(nUse)
     264        3258 :             rPageDesc.SetUseOn( lcl_convertUseFromSvx((UseOnPage) nUse) );
     265        3258 :         rPageDesc.SetLandscape(rPageItem.IsLandscape());
     266        3258 :         SvxNumberType aNumType;
     267        3258 :         aNumType.SetNumberingType( static_cast< sal_Int16 >(rPageItem.GetNumType()) );
     268        3258 :         rPageDesc.SetNumType(aNumType);
     269             :     }
     270             :     // Size
     271        3258 :     if(rSet.GetItemState(SID_ATTR_PAGE_SIZE) == SFX_ITEM_SET)
     272             :     {
     273        3258 :         const SvxSizeItem& rSizeItem = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE);
     274        3258 :         SwFmtFrmSize aSize(ATT_FIX_SIZE);
     275        3258 :         aSize.SetSize(rSizeItem.GetSize());
     276        3258 :         rMaster.SetFmtAttr(aSize);
     277             :     }
     278             :     // Evaluate header attributes
     279             :     const SfxPoolItem* pItem;
     280        3258 :     if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_HEADERSET,
     281        3258 :             false, &pItem ) )
     282             :     {
     283        1276 :         const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet();
     284        1276 :         const SfxBoolItem& rHeaderOn = (const SfxBoolItem&)rHeaderSet.Get(SID_ATTR_PAGE_ON);
     285             : 
     286        1276 :         if(rHeaderOn.GetValue())
     287             :         {
     288             :             // Take over values
     289        1276 :             if(!rMaster.GetHeader().IsActive())
     290         359 :                 rMaster.SetFmtAttr(SwFmtHeader(sal_True));
     291             : 
     292             :             // Pick out everything and adapt the header format
     293        1276 :             SwFmtHeader aHeaderFmt(rMaster.GetHeader());
     294        1276 :             SwFrmFmt *pHeaderFmt = aHeaderFmt.GetHeaderFmt();
     295             :             OSL_ENSURE(pHeaderFmt != 0, "no header format");
     296             : 
     297        1276 :             ::FillHdFt(pHeaderFmt, rHeaderSet);
     298             : 
     299             :             rPageDesc.ChgHeaderShare(((const SfxBoolItem&)
     300        1276 :                         rHeaderSet.Get(SID_ATTR_PAGE_SHARED)).GetValue());
     301        1276 :             if (nFirstShare < 0)
     302             :             {
     303             :                 rPageDesc.ChgFirstShare(((const SfxBoolItem&)
     304        1276 :                             rHeaderSet.Get(SID_ATTR_PAGE_SHARED_FIRST)).GetValue());
     305        1276 :                 nFirstShare = rPageDesc.IsFirstShared();
     306        1276 :             }
     307             :         }
     308             :         else
     309             :         {
     310             :             // Disable header
     311           0 :             if(rMaster.GetHeader().IsActive())
     312             :             {
     313           0 :                 rMaster.SetFmtAttr(SwFmtHeader(sal_Bool(sal_False)));
     314           0 :                 rPageDesc.ChgHeaderShare(sal_False);
     315             :             }
     316             :         }
     317             :     }
     318             : 
     319             :     // Evaluate footer attributes
     320        3258 :     if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_FOOTERSET,
     321        3258 :             false, &pItem ) )
     322             :     {
     323         977 :         const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet();
     324         977 :         const SfxBoolItem& rFooterOn = (const SfxBoolItem&)rFooterSet.Get(SID_ATTR_PAGE_ON);
     325             : 
     326         977 :         if(rFooterOn.GetValue())
     327             :         {
     328             :             // Take over values
     329         977 :             if(!rMaster.GetFooter().IsActive())
     330         378 :                 rMaster.SetFmtAttr(SwFmtFooter(sal_True));
     331             : 
     332             :             // Pick out everything and adapt the footer format
     333         977 :             SwFmtFooter aFooterFmt(rMaster.GetFooter());
     334         977 :             SwFrmFmt *pFooterFmt = aFooterFmt.GetFooterFmt();
     335             :             OSL_ENSURE(pFooterFmt != 0, "no footer format");
     336             : 
     337         977 :             ::FillHdFt(pFooterFmt, rFooterSet);
     338             : 
     339             :             rPageDesc.ChgFooterShare(((const SfxBoolItem&)
     340         977 :                         rFooterSet.Get(SID_ATTR_PAGE_SHARED)).GetValue());
     341         977 :             if (nFirstShare < 0)
     342             :             {
     343             :                 rPageDesc.ChgFirstShare(((const SfxBoolItem&)
     344         183 :                             rFooterSet.Get(SID_ATTR_PAGE_SHARED_FIRST)).GetValue());
     345         183 :                 nFirstShare = rPageDesc.IsFirstShared();
     346         977 :             }
     347             :         }
     348             :         else
     349             :         {
     350             :             // Disable footer
     351           0 :             if(rMaster.GetFooter().IsActive())
     352             :             {
     353           0 :                 rMaster.SetFmtAttr(SwFmtFooter(sal_Bool(sal_False)));
     354           0 :                 rPageDesc.ChgFooterShare(sal_False);
     355             :             }
     356             :         }
     357             :     }
     358             : 
     359             :     // Footnotes
     360             : 
     361        3258 :     if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_FTN_INFO,
     362        3258 :             false, &pItem ) )
     363        3258 :         rPageDesc.SetFtnInfo( ((SwPageFtnInfoItem*)pItem)->GetPageFtnInfo() );
     364             : 
     365             :     // Columns
     366             : 
     367             :     // Register compliant
     368             : 
     369        3258 :     if(SFX_ITEM_SET == rSet.GetItemState(
     370        3258 :                             SID_SWREGISTER_MODE, false, &pItem))
     371             :     {
     372        3258 :         sal_Bool bSet = ((const SfxBoolItem*)pItem)->GetValue();
     373        3258 :         if(!bSet)
     374        3258 :             rPageDesc.SetRegisterFmtColl(0);
     375           0 :         else if(SFX_ITEM_SET == rSet.GetItemState(
     376           0 :                                 SID_SWREGISTER_COLLECTION, false, &pItem))
     377             :         {
     378           0 :             const OUString& rColl = ((const SfxStringItem*)pItem)->GetValue();
     379           0 :             SwDoc& rDoc = *rMaster.GetDoc();
     380           0 :             SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( rColl );
     381           0 :             if( !pColl )
     382             :             {
     383           0 :                 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rColl, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
     384           0 :                 if( USHRT_MAX != nId )
     385           0 :                     pColl = rDoc.GetTxtCollFromPool( nId );
     386             :                 else
     387             :                     pColl = rDoc.MakeTxtFmtColl( rColl,
     388           0 :                                 (SwTxtFmtColl*)rDoc.GetDfltTxtFmtColl() );
     389             :             }
     390           0 :             if( pColl )
     391           0 :                 pColl->SetFmtAttr( SwRegisterItem ( sal_True ));
     392           0 :             rPageDesc.SetRegisterFmtColl( pColl );
     393             :         }
     394             :     }
     395        3258 : }
     396             : 
     397        7478 : void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet)
     398             : {
     399        7478 :     const SwFrmFmt& rMaster = rPageDesc.GetMaster();
     400             : 
     401             :     // Page data
     402        7478 :     SvxPageItem aPageItem(SID_ATTR_PAGE);
     403        7478 :     aPageItem.SetDescName(rPageDesc.GetName());
     404        7478 :     aPageItem.SetPageUsage(lcl_convertUseToSvx(rPageDesc.GetUseOn()));
     405        7478 :     aPageItem.SetLandscape(rPageDesc.GetLandscape());
     406        7478 :     aPageItem.SetNumType((SvxNumType)rPageDesc.GetNumType().GetNumberingType());
     407        7478 :     rSet.Put(aPageItem);
     408             : 
     409             :     // Size
     410       14956 :     SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, rMaster.GetFrmSize().GetSize());
     411        7478 :     rSet.Put(aSizeItem);
     412             : 
     413             :     // Maximum size
     414       14956 :     SvxSizeItem aMaxSizeItem(SID_ATTR_PAGE_MAXSIZE, Size(MAXWIDTH, MAXHEIGHT));
     415        7478 :     rSet.Put(aMaxSizeItem);
     416             : 
     417             :     // Margins, border and the other stuff.
     418        7478 :     rSet.Put(rMaster.GetAttrSet());
     419             : 
     420       14956 :     SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
     421             :     const SfxPoolItem *pBoxInfo;
     422        7478 :     if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER,
     423        7478 :                                             true, &pBoxInfo) )
     424         214 :         aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
     425             : 
     426        7478 :     aBoxInfo.SetTable( false );
     427             :         // Show always the distance field
     428        7478 :     aBoxInfo.SetDist( true);
     429             :         // Set minimal size in tables and paragraphs
     430        7478 :     aBoxInfo.SetMinDist( false );
     431             :         // Set always the default distance
     432        7478 :     aBoxInfo.SetDefDist( MIN_BORDER_DIST );
     433             :         // Single lines can have only in tables DontCare-Status
     434        7478 :     aBoxInfo.SetValid( VALID_DISABLE );
     435        7478 :     rSet.Put( aBoxInfo );
     436             : 
     437       14956 :     SfxStringItem aFollow(SID_ATTR_PAGE_EXT1, OUString());
     438        7478 :     if(rPageDesc.GetFollow())
     439        7478 :         aFollow.SetValue(rPageDesc.GetFollow()->GetName());
     440        7478 :     rSet.Put(aFollow);
     441             : 
     442             :     // Header
     443        7478 :     if(rMaster.GetHeader().IsActive())
     444             :     {
     445        1837 :         const SwFmtHeader &rHeaderFmt = rMaster.GetHeader();
     446        1837 :         const SwFrmFmt *pHeaderFmt = rHeaderFmt.GetHeaderFmt();
     447             :         OSL_ENSURE(pHeaderFmt != 0, "no header format");
     448             : 
     449             :         // HeaderInfo, margins, background, border
     450        1837 :         SfxItemSet aHeaderSet( *rSet.GetPool(),
     451             :                     SID_ATTR_PAGE_ON,       SID_ATTR_PAGE_SHARED,
     452             :                     SID_ATTR_PAGE_SHARED_FIRST, SID_ATTR_PAGE_SHARED_FIRST,
     453             :                     SID_ATTR_PAGE_SIZE,     SID_ATTR_PAGE_SIZE,
     454             :                     SID_ATTR_BORDER_INNER,  SID_ATTR_BORDER_INNER,
     455             :                     RES_FRMATR_BEGIN,       RES_FRMATR_END-1,
     456        1837 :                     0);
     457             : 
     458             :         // Dynamic or fixed height
     459        3674 :         SfxBoolItem aOn(SID_ATTR_PAGE_ON, true);
     460        1837 :         aHeaderSet.Put(aOn);
     461             : 
     462        1837 :         const SwFmtFrmSize &rFrmSize = pHeaderFmt->GetFrmSize();
     463        1837 :         const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType();
     464        3674 :         SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE);
     465        1837 :         aHeaderSet.Put(aDynamic);
     466             : 
     467             :         // Left equal right
     468        3674 :         SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsHeaderShared());
     469        1837 :         aHeaderSet.Put(aShared);
     470        3674 :         SfxBoolItem aFirstShared(SID_ATTR_PAGE_SHARED_FIRST, rPageDesc.IsFirstShared());
     471        1837 :         aHeaderSet.Put(aFirstShared);
     472             : 
     473             :         // Size
     474        3674 :         SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize()));
     475        1837 :         aHeaderSet.Put(aSize);
     476             : 
     477             :         // Shifting frame attributes
     478        1837 :         aHeaderSet.Put(pHeaderFmt->GetAttrSet());
     479        1837 :         aHeaderSet.Put( aBoxInfo );
     480             : 
     481             :         // Create SetItem
     482        3674 :         SvxSetItem aSetItem(SID_ATTR_PAGE_HEADERSET, aHeaderSet);
     483        3674 :         rSet.Put(aSetItem);
     484             :     }
     485             : 
     486             :     // Footer
     487        7478 :     if(rMaster.GetFooter().IsActive())
     488             :     {
     489        1471 :         const SwFmtFooter &rFooterFmt = rMaster.GetFooter();
     490        1471 :         const SwFrmFmt *pFooterFmt = rFooterFmt.GetFooterFmt();
     491             :         OSL_ENSURE(pFooterFmt != 0, "no footer format");
     492             : 
     493             :         // FooterInfo, margins, background, border
     494        1471 :         SfxItemSet aFooterSet( *rSet.GetPool(),
     495             :                     SID_ATTR_PAGE_ON,       SID_ATTR_PAGE_SHARED,
     496             :                     SID_ATTR_PAGE_SHARED_FIRST, SID_ATTR_PAGE_SHARED_FIRST,
     497             :                     SID_ATTR_PAGE_SIZE,     SID_ATTR_PAGE_SIZE,
     498             :                     SID_ATTR_BORDER_INNER,  SID_ATTR_BORDER_INNER,
     499             :                     RES_FRMATR_BEGIN,       RES_FRMATR_END-1,
     500        1471 :                     0);
     501             : 
     502             :         // Dynamic or fixed height
     503        2942 :         SfxBoolItem aOn(SID_ATTR_PAGE_ON, true);
     504        1471 :         aFooterSet.Put(aOn);
     505             : 
     506        1471 :         const SwFmtFrmSize &rFrmSize = pFooterFmt->GetFrmSize();
     507        1471 :         const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType();
     508        2942 :         SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE);
     509        1471 :         aFooterSet.Put(aDynamic);
     510             : 
     511             :         // Left equal right
     512        2942 :         SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsFooterShared());
     513        1471 :         aFooterSet.Put(aShared);
     514        2942 :         SfxBoolItem aFirstShared(SID_ATTR_PAGE_SHARED_FIRST, rPageDesc.IsFirstShared());
     515        1471 :         aFooterSet.Put(aFirstShared);
     516             : 
     517             :         // Size
     518        2942 :         SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize()));
     519        1471 :         aFooterSet.Put(aSize);
     520             : 
     521             :         // Shifting Frame attributes
     522        1471 :         aFooterSet.Put(pFooterFmt->GetAttrSet());
     523        1471 :         aFooterSet.Put( aBoxInfo );
     524             : 
     525             :         // Create SetItem
     526        2942 :         SvxSetItem aSetItem(SID_ATTR_PAGE_FOOTERSET, aFooterSet);
     527        2942 :         rSet.Put(aSetItem);
     528             :     }
     529             : 
     530             :     // Integrate footnotes
     531        7478 :     SwPageFtnInfo& rInfo = (SwPageFtnInfo&)rPageDesc.GetFtnInfo();
     532       14956 :     SwPageFtnInfoItem aFtnItem(FN_PARAM_FTN_INFO, rInfo);
     533        7478 :     rSet.Put(aFtnItem);
     534             : 
     535             :     // Register compliant
     536        7478 :     const SwTxtFmtColl* pCol = rPageDesc.GetRegisterFmtColl();
     537       14956 :     SwRegisterItem aReg(pCol != 0);
     538        7478 :     aReg.SetWhich(SID_SWREGISTER_MODE);
     539        7478 :     rSet.Put(aReg);
     540        7478 :     if(pCol)
     541        7478 :         rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION, pCol->GetName()));
     542             : 
     543        7478 : }
     544             : 
     545             : // Set DefaultTabs
     546             : 
     547           0 : void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem& rTabs)
     548             : {
     549           0 :     if( rTabs.Count() )
     550           0 :         return;
     551             :     {
     552           0 :         SvxTabStop aSwTabStop( nDefDist, SVX_TAB_ADJUST_DEFAULT );
     553           0 :         rTabs.Insert( aSwTabStop );
     554             :     }
     555             : }
     556             : 
     557             : // Distance between two tabs
     558             : 
     559         310 : sal_uInt16 GetTabDist(const SvxTabStopItem& rTabs)
     560             : {
     561             :     sal_uInt16 nDefDist;
     562         310 :     if( rTabs.Count() )
     563         310 :         nDefDist = (sal_uInt16)( rTabs[0].GetTabPos() );
     564             :     else
     565           0 :         nDefDist = 1134;     // 2cm
     566         310 :     return nDefDist;
     567             : }
     568             : 
     569             : // Inquire if in the set is a Sfx-PageDesc combination present and return it.
     570           0 : void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet )
     571             : {
     572             :     const SfxPoolItem* pItem;
     573           0 :     SwFmtPageDesc aPgDesc;
     574             : 
     575           0 :     bool bChanged = false;
     576             :     // Page number
     577           0 :     if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_PARA_PAGENUM, false, &pItem))
     578             :     {
     579           0 :         aPgDesc.SetNumOffset(((SfxUInt16Item*)pItem)->GetValue());
     580           0 :         bChanged = true;
     581             :     }
     582           0 :     if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PARA_MODEL, false, &pItem ))
     583             :     {
     584           0 :         const OUString& rDescName = ((SvxPageModelItem*)pItem)->GetValue();
     585           0 :         if( !rDescName.isEmpty() )   // No name -> disable PageDesc!
     586             :         {
     587             :             // Delete only, if PageDesc will be enabled!
     588           0 :             rSet.ClearItem( RES_BREAK );
     589             :             SwPageDesc* pDesc = ((SwWrtShell&)rShell).FindPageDescByName(
     590           0 :                                                     rDescName, sal_True );
     591           0 :             if( pDesc )
     592           0 :                 aPgDesc.RegisterToPageDesc( *pDesc );
     593             :         }
     594           0 :         rSet.ClearItem( SID_ATTR_PARA_MODEL );
     595           0 :         bChanged = true;
     596             :     }
     597             :     else
     598             :     {
     599           0 :         SfxItemSet aCoreSet(rShell.GetView().GetPool(), RES_PAGEDESC, RES_PAGEDESC );
     600           0 :         rShell.GetCurAttr( aCoreSet );
     601           0 :         if(SFX_ITEM_SET == aCoreSet.GetItemState( RES_PAGEDESC, true, &pItem ) )
     602             :         {
     603           0 :             if( ((SwFmtPageDesc*)pItem)->GetPageDesc() )
     604             :             {
     605           0 :                 aPgDesc.RegisterToPageDesc( *((SwFmtPageDesc*)pItem)->GetPageDesc() );
     606             :             }
     607           0 :         }
     608             :     }
     609             : 
     610           0 :     if(bChanged)
     611           0 :         rSet.Put( aPgDesc );
     612           0 : }
     613             : 
     614             : // Inquire if in the set is a Sfx-PageDesc combination present and return it.
     615           0 : void SwToSfxPageDescAttr( SfxItemSet& rCoreSet )
     616             : {
     617           0 :     const SfxPoolItem* pItem = 0;
     618           0 :     OUString aName;
     619           0 :     ::boost::optional<sal_uInt16> oNumOffset;
     620           0 :     bool bPut = true;
     621           0 :     switch( rCoreSet.GetItemState( RES_PAGEDESC, true, &pItem ) )
     622             :     {
     623             :     case SFX_ITEM_SET:
     624             :         {
     625           0 :             if( ((SwFmtPageDesc*)pItem)->GetPageDesc() )
     626             :             {
     627           0 :                 aName = ((SwFmtPageDesc*)pItem)->GetPageDesc()->GetName();
     628           0 :                 oNumOffset = ((SwFmtPageDesc*)pItem)->GetNumOffset();
     629             :             }
     630           0 :             rCoreSet.ClearItem( RES_PAGEDESC );
     631             :             // Page number
     632             :         }
     633           0 :         break;
     634             : 
     635             :     case SFX_ITEM_AVAILABLE:
     636           0 :         break;
     637             : 
     638             :     default:
     639           0 :         bPut = false;
     640             :     }
     641             : 
     642             :     // TODO for now always pass a page number to cui, it can't make a
     643             :     // difference between 0 and no page number at the moment.
     644             :     {
     645           0 :         SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM, oNumOffset ? oNumOffset.get() : 0 );
     646           0 :         rCoreSet.Put( aPageNum );
     647             :     }
     648             : 
     649           0 :     if(bPut)
     650           0 :         rCoreSet.Put( SvxPageModelItem( aName, true, SID_ATTR_PARA_MODEL ) );
     651           0 : }
     652             : 
     653             : // Determine metric
     654             : 
     655           0 : FieldUnit   GetDfltMetric(sal_Bool bWeb)
     656             : {
     657           0 :     return SW_MOD()->GetUsrPref(bWeb)->GetMetric();
     658             : }
     659             : 
     660             : // Determine metric
     661             : 
     662           0 : void    SetDfltMetric( FieldUnit eMetric, sal_Bool bWeb )
     663             : {
     664           0 :     SW_MOD()->ApplyUserMetric(eMetric, bWeb);
     665           0 : }
     666             : 
     667           0 : sal_Int32 InsertStringSorted(const OUString& rEntry, ListBox& rToFill, sal_Int32 nOffset )
     668             : {
     669           0 :     CollatorWrapper& rCaseColl = ::GetAppCaseCollator();
     670           0 :     const sal_Int32 nCount = rToFill.GetEntryCount();
     671           0 :     while ( nOffset < nCount )
     672             :     {
     673           0 :         if( 0 < rCaseColl.compareString( rToFill.GetEntry(nOffset), rEntry ))
     674           0 :             return rToFill.InsertEntry(rEntry, nOffset);
     675           0 :         ++nOffset;
     676             :     }
     677           0 :     return nCount;
     678             : }
     679             : 
     680           0 : void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, bool bSorted, bool bWithDefault)
     681             : {
     682           0 :     const sal_Int32 nOffset = rToFill.GetEntryCount() > 0 ? 1 : 0;
     683           0 :     SfxStyleSheetBasePool* pPool = pDocSh->GetStyleSheetPool();
     684           0 :     pPool->SetSearchMask(SFX_STYLE_FAMILY_CHAR, SFXSTYLEBIT_ALL);
     685           0 :     SwDoc* pDoc = pDocSh->GetDoc();
     686           0 :     const SfxStyleSheetBase* pBase = pPool->First();
     687           0 :     OUString sStandard;
     688           0 :     SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD, sStandard );
     689           0 :     while(pBase)
     690             :     {
     691           0 :         if(bWithDefault || pBase->GetName() !=  sStandard)
     692             :         {
     693             :             const sal_Int32 nPos = bSorted
     694           0 :                 ? InsertStringSorted(pBase->GetName(), rToFill, nOffset )
     695           0 :                 : rToFill.InsertEntry(pBase->GetName());
     696           0 :             sal_IntPtr nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( pBase->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
     697           0 :             rToFill.SetEntryData( nPos, (void*) (nPoolId));
     698             :         }
     699           0 :         pBase = pPool->Next();
     700             :     }
     701             :     // non-pool styles
     702           0 :     const SwCharFmts* pFmts = pDoc->GetCharFmts();
     703           0 :     for(size_t i = 0; i < pFmts->size(); ++i)
     704             :     {
     705           0 :         const SwCharFmt* pFmt = (*pFmts)[i];
     706           0 :         if(pFmt->IsDefault())
     707           0 :             continue;
     708           0 :         const OUString& rName = pFmt->GetName();
     709           0 :         if(rToFill.GetEntryPos(rName) == LISTBOX_ENTRY_NOTFOUND)
     710             :         {
     711             :             const sal_Int32 nPos = bSorted
     712             :                 ? InsertStringSorted(rName, rToFill, nOffset )
     713           0 :                 : rToFill.InsertEntry(rName);
     714           0 :             sal_IntPtr nPoolId = USHRT_MAX;
     715           0 :             rToFill.SetEntryData( nPos, (void*) (nPoolId));
     716             :         }
     717           0 :     }
     718           0 : };
     719             : 
     720           0 : SwTwips GetTableWidth( SwFrmFmt* pFmt, SwTabCols& rCols, sal_uInt16 *pPercent,
     721             :             SwWrtShell* pSh )
     722             : {
     723             :     // To get the width is slightly more complicated.
     724           0 :     SwTwips nWidth = 0;
     725           0 :     const sal_Int16 eOri = pFmt->GetHoriOrient().GetHoriOrient();
     726           0 :     switch(eOri)
     727             :     {
     728           0 :         case text::HoriOrientation::FULL: nWidth = rCols.GetRight(); break;
     729             :         case text::HoriOrientation::LEFT_AND_WIDTH:
     730             :         case text::HoriOrientation::LEFT:
     731             :         case text::HoriOrientation::RIGHT:
     732             :         case text::HoriOrientation::CENTER:
     733           0 :             nWidth = pFmt->GetFrmSize().GetWidth();
     734           0 :         break;
     735             :         default:
     736             :         {
     737           0 :             if(pSh)
     738             :             {
     739           0 :                 if ( 0 == pSh->GetFlyFrmFmt() )
     740             :                 {
     741           0 :                     nWidth = pSh->GetAnyCurRect(RECT_PAGE_PRT).Width();
     742             :                 }
     743             :                 else
     744             :                 {
     745           0 :                     nWidth = pSh->GetAnyCurRect(RECT_FLY_PRT_EMBEDDED).Width();
     746             :                 }
     747             :             }
     748             :             else
     749             :             {
     750             :                 OSL_FAIL("where to get the actual width from?");
     751             :             }
     752           0 :             const SvxLRSpaceItem& rLRSpace = pFmt->GetLRSpace();
     753           0 :             nWidth -= (rLRSpace.GetRight() + rLRSpace.GetLeft());
     754             :         }
     755             :     }
     756           0 :     if (pPercent)
     757           0 :         *pPercent = pFmt->GetFrmSize().GetWidthPercent();
     758           0 :     return nWidth;
     759             : }
     760             : 
     761           0 : OUString GetAppLangDateTimeString( const DateTime& rDT )
     762             : {
     763           0 :     const SvtSysLocale aSysLocale;
     764           0 :     const LocaleDataWrapper& rAppLclData = aSysLocale.GetLocaleData();
     765           0 :     OUString sRet = rAppLclData.getDate( rDT ) + " " + rAppLclData.getTime( rDT, false, false );
     766           0 :     return sRet;
     767             : }
     768             : 
     769             : // Add a new function which can get and set the current "SID_ATTR_APPLYCHARUNIT" value
     770             : 
     771           0 : sal_Bool HasCharUnit( sal_Bool bWeb)
     772             : {
     773           0 :     return SW_MOD()->GetUsrPref(bWeb)->IsApplyCharUnit();
     774             : }
     775             : 
     776           0 : void SetApplyCharUnit(sal_Bool bApplyChar, sal_Bool bWeb)
     777             : {
     778           0 :     SW_MOD()->ApplyUserCharUnit(bApplyChar, bWeb);
     779           0 : }
     780             : 
     781           0 : bool ExecuteMenuCommand( PopupMenu& rMenu, SfxViewFrame& rViewFrame, sal_uInt16 nId )
     782             : {
     783           0 :     bool bRet = false;
     784           0 :     sal_uInt16 nItemCount = rMenu.GetItemCount();
     785           0 :     OUString sCommand;
     786           0 :     for( sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem)
     787             :     {
     788           0 :         PopupMenu* pPopup = rMenu.GetPopupMenu( rMenu.GetItemId( nItem ) );
     789           0 :         if(pPopup)
     790             :         {
     791           0 :             sCommand = pPopup->GetItemCommand(nId);
     792           0 :             if(!sCommand.isEmpty())
     793           0 :                 break;
     794             :         }
     795             :     }
     796           0 :     if(!sCommand.isEmpty())
     797             :     {
     798           0 :         uno::Reference< frame::XFrame >  xFrame = rViewFrame.GetFrame().GetFrameInterface();
     799           0 :         uno::Reference < frame::XDispatchProvider > xProv( xFrame, uno::UNO_QUERY );
     800           0 :         util::URL aURL;
     801           0 :         aURL.Complete = sCommand;
     802           0 :         uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create(::comphelper::getProcessComponentContext() ) );
     803           0 :         xTrans->parseStrict( aURL );
     804           0 :         uno::Reference< frame::XDispatch >  xDisp = xProv->queryDispatch( aURL, OUString(), 0 );
     805           0 :         if( xDisp.is() )
     806             :         {
     807           0 :             uno::Sequence< beans::PropertyValue > aSeq;
     808           0 :             xDisp->dispatch( aURL, aSeq );
     809           0 :             bRet = true;
     810           0 :         }
     811             :     }
     812           0 :     return bRet;
     813             : }
     814             : 
     815             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10