LCOV - code coverage report
Current view: top level - sw/source/core/doc - poolfmt.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 73 89 82.0 %
Date: 2014-11-03 Functions: 8 9 88.9 %
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 <i18nlangtag/mslangid.hxx>
      22             : #include <unotools/localedatawrapper.hxx>
      23             : #include <editeng/paperinf.hxx>
      24             : #include <editeng/wghtitem.hxx>
      25             : #include <editeng/fontitem.hxx>
      26             : #include <editeng/fhgtitem.hxx>
      27             : #include <editeng/tstpitem.hxx>
      28             : #include <editeng/lrspitem.hxx>
      29             : #include <editeng/ulspitem.hxx>
      30             : #include <editeng/lspcitem.hxx>
      31             : #include <editeng/adjustitem.hxx>
      32             : #include <editeng/postitem.hxx>
      33             : #include <editeng/keepitem.hxx>
      34             : #include <editeng/opaqitem.hxx>
      35             : #include <editeng/boxitem.hxx>
      36             : #include <editeng/cmapitem.hxx>
      37             : #include <editeng/udlnitem.hxx>
      38             : #include <editeng/colritem.hxx>
      39             : #include <editeng/protitem.hxx>
      40             : #include <editeng/escapementitem.hxx>
      41             : #include <editeng/langitem.hxx>
      42             : #include <editeng/charrotateitem.hxx>
      43             : #include <editeng/frmdiritem.hxx>
      44             : #include <editeng/emphasismarkitem.hxx>
      45             : #include <editeng/scriptspaceitem.hxx>
      46             : #include <viewopt.hxx>
      47             : #include <doc.hxx>
      48             : #include <IDocumentUndoRedo.hxx>
      49             : #include <DocumentSettingManager.hxx>
      50             : #include <IDocumentState.hxx>
      51             : #include <IDocumentStylePoolAccess.hxx>
      52             : #include <fmtanchr.hxx>
      53             : #include <fmtornt.hxx>
      54             : #include <fmtsrnd.hxx>
      55             : #include <fmtfsize.hxx>
      56             : #include <poolfmt.hxx>
      57             : #include <paratr.hxx>
      58             : #include <pagedesc.hxx>
      59             : #include <frmtool.hxx>
      60             : #include <charfmt.hxx>
      61             : #include <docary.hxx>
      62             : #include <fmtcol.hxx>
      63             : #include <ndtxt.hxx>
      64             : #include <fmtline.hxx>
      65             : #include <poolfmt.hrc>
      66             : #include <GetMetricVal.hxx>
      67             : #include <numrule.hxx>
      68             : #include <svx/xdef.hxx>
      69             : 
      70             : //UUUU
      71             : #include <svx/xfillit0.hxx>
      72             : 
      73             : using namespace ::editeng;
      74             : using namespace ::com::sun::star;
      75             : 
      76       16778 : void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem )
      77             : {
      78       16778 :     rSet.Put( rItem );
      79       16778 :     sal_uInt16 nWhCJK = 0, nWhCTL = 0;
      80       16778 :     switch( rItem.Which() )
      81             :     {
      82             :     case RES_CHRATR_FONTSIZE:
      83       10756 :         nWhCJK = RES_CHRATR_CJK_FONTSIZE, nWhCTL = RES_CHRATR_CTL_FONTSIZE;
      84       10756 :         break;
      85             :     case RES_CHRATR_FONT:
      86          38 :         nWhCJK = RES_CHRATR_CJK_FONT, nWhCTL = RES_CHRATR_CTL_FONT;
      87          38 :         break;
      88             :     case RES_CHRATR_LANGUAGE:
      89           0 :         nWhCJK = RES_CHRATR_CJK_LANGUAGE, nWhCTL = RES_CHRATR_CTL_LANGUAGE;
      90           0 :         break;
      91             :     case RES_CHRATR_POSTURE:
      92        5304 :         nWhCJK = RES_CHRATR_CJK_POSTURE, nWhCTL = RES_CHRATR_CTL_POSTURE;
      93        5304 :         break;
      94             :     case RES_CHRATR_WEIGHT:
      95         680 :         nWhCJK = RES_CHRATR_CJK_WEIGHT, nWhCTL = RES_CHRATR_CTL_WEIGHT;
      96         680 :         break;
      97             :     }
      98             : 
      99       16778 :     if( nWhCJK )
     100       16778 :         rSet.Put( rItem, nWhCJK );
     101       16778 :     if( nWhCTL )
     102       16778 :         rSet.Put( rItem, nWhCTL );
     103       16778 : }
     104             : 
     105             : /// Return the AutoCollection by it's Id. If it doesn't
     106             : /// exist yet, create it.
     107             : /// If the String pointer is defined, then only query for
     108             : /// the Attribute descriptions. It doesn't create a style!
     109       23004 : SvxFrameDirection GetDefaultFrameDirection(sal_uLong nLanguage)
     110             : {
     111       23004 :     SvxFrameDirection eResult = (MsLangId::isRightToLeft( static_cast<LanguageType>(nLanguage)) ?
     112       23004 :             FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP);
     113       23004 :     return eResult;
     114             : }
     115             : 
     116             : // See if the Paragraph/Character/Frame/Page style is in use
     117      166976 : bool SwDoc::IsUsed( const SwModify& rModify ) const
     118             : {
     119             :     // Check if we have dependent ContentNodes in the Nodes array
     120             :     // (also indirect ones for derived Formats)
     121      166976 :     SwAutoFmtGetDocNode aGetHt( &GetNodes() );
     122      166976 :     return !rModify.GetInfo( aGetHt );
     123             : }
     124             : 
     125             : // See if the NumRule is used
     126        1816 : bool SwDoc::IsUsed( const SwNumRule& rRule ) const
     127             : {
     128        3496 :     bool bUsed = rRule.GetTxtNodeListSize() > 0 ||
     129        3496 :                      rRule.GetParagraphStyleListSize() > 0;
     130             : 
     131        1816 :     return bUsed;
     132             : }
     133             : 
     134             : // Look for the style name's position. If it doesn't exist,
     135             : // insert a anew
     136           0 : sal_uInt16 SwDoc::SetDocPattern( const OUString& rPatternName )
     137             : {
     138             :     OSL_ENSURE( !rPatternName.isEmpty(), "no Document style name" );
     139             : 
     140           0 :     size_t nNewPos = maPatternNms.size();
     141           0 :     for(size_t n = 0; n < maPatternNms.size(); ++n)
     142           0 :         if( boost::is_null(maPatternNms.begin() + n) )
     143             :         {
     144           0 :             if( nNewPos == maPatternNms.size() )
     145           0 :                 nNewPos = n;
     146             :         }
     147           0 :         else if( rPatternName == maPatternNms[n] )
     148           0 :             return n;
     149             : 
     150           0 :     if( nNewPos < maPatternNms.size() )
     151           0 :         maPatternNms.erase(maPatternNms.begin() + nNewPos);   // Free space again
     152             : 
     153           0 :     maPatternNms.insert(maPatternNms.begin() + nNewPos, new OUString(rPatternName));
     154           0 :     getIDocumentState().SetModified();
     155           0 :     return nNewPos;
     156             : }
     157             : 
     158       42692 : sal_uInt16 GetPoolParent( sal_uInt16 nId )
     159             : {
     160       42692 :     sal_uInt16 nRet = USHRT_MAX;
     161       42692 :     if( POOLGRP_NOCOLLID & nId )        // 1 == Formats / 0 == Collections
     162             :     {
     163         104 :         switch( ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID ) & nId )
     164             :         {
     165             :         case POOLGRP_CHARFMT:
     166             :         case POOLGRP_FRAMEFMT:
     167         100 :             nRet = 0;           // derived from the default
     168         100 :             break;
     169             :         case POOLGRP_PAGEDESC:
     170             :         case POOLGRP_NUMRULE:
     171           0 :             break;              // there are no derivations
     172             :         }
     173             :     }
     174             :     else
     175             :     {
     176       42588 :         switch( COLL_GET_RANGE_BITS & nId )
     177             :         {
     178             :         case COLL_TEXT_BITS:
     179       19332 :             switch( nId )
     180             :             {
     181             :             case RES_POOLCOLL_STANDARD:
     182        5090 :                     nRet = 0;                                   break;
     183             :             case RES_POOLCOLL_TEXT_IDENT:
     184             :             case RES_POOLCOLL_TEXT_NEGIDENT:
     185             :             case RES_POOLCOLL_TEXT_MOVE:
     186             :             case RES_POOLCOLL_CONFRONTATION:
     187             :             case RES_POOLCOLL_MARGINAL:
     188         290 :                     nRet = RES_POOLCOLL_TEXT;                   break;
     189             : 
     190             :             case RES_POOLCOLL_TEXT:
     191             :             case RES_POOLCOLL_GREETING:
     192             :             case RES_POOLCOLL_SIGNATURE:
     193             :             case RES_POOLCOLL_HEADLINE_BASE:
     194       10194 :                     nRet = RES_POOLCOLL_STANDARD;               break;
     195             : 
     196             :             case RES_POOLCOLL_HEADLINE1:
     197             :             case RES_POOLCOLL_HEADLINE2:
     198             :             case RES_POOLCOLL_HEADLINE3:
     199             :             case RES_POOLCOLL_HEADLINE4:
     200             :             case RES_POOLCOLL_HEADLINE5:
     201             :             case RES_POOLCOLL_HEADLINE6:
     202             :             case RES_POOLCOLL_HEADLINE7:
     203             :             case RES_POOLCOLL_HEADLINE8:
     204             :             case RES_POOLCOLL_HEADLINE9:
     205             :             case RES_POOLCOLL_HEADLINE10:
     206        3758 :                     nRet = RES_POOLCOLL_HEADLINE_BASE;          break;
     207             :             }
     208       19332 :             break;
     209             : 
     210             :         case COLL_LISTS_BITS:
     211        5626 :             switch( nId )
     212             :             {
     213             :             case RES_POOLCOLL_NUMBUL_BASE:
     214        5034 :                     nRet = RES_POOLCOLL_TEXT;                   break;
     215             : 
     216             :             default:
     217         592 :                 nRet = RES_POOLCOLL_NUMBUL_BASE;                break;
     218             :             }
     219        5626 :             break;
     220             : 
     221             :         case COLL_EXTRA_BITS:
     222        9376 :             switch( nId )
     223             :             {
     224             :             case RES_POOLCOLL_TABLE_HDLN:
     225         270 :                     nRet = RES_POOLCOLL_TABLE;                  break;
     226             : 
     227             :             case RES_POOLCOLL_FRAME:
     228             :             case RES_POOLCOLL_TABLE:
     229             :             case RES_POOLCOLL_FOOTNOTE:
     230             :             case RES_POOLCOLL_ENDNOTE:
     231             :             case RES_POOLCOLL_JAKETADRESS:
     232             :             case RES_POOLCOLL_SENDADRESS:
     233             :             case RES_POOLCOLL_HEADER:
     234             :             case RES_POOLCOLL_HEADERL:
     235             :             case RES_POOLCOLL_HEADERR:
     236             :             case RES_POOLCOLL_FOOTER:
     237             :             case RES_POOLCOLL_FOOTERL:
     238             :             case RES_POOLCOLL_FOOTERR:
     239             :             case RES_POOLCOLL_LABEL:
     240        9038 :                     nRet = RES_POOLCOLL_STANDARD;               break;
     241             : 
     242             :             case RES_POOLCOLL_LABEL_ABB:
     243             :             case RES_POOLCOLL_LABEL_TABLE:
     244             :             case RES_POOLCOLL_LABEL_FRAME:
     245             :             case RES_POOLCOLL_LABEL_DRAWING:
     246          68 :                     nRet = RES_POOLCOLL_LABEL;                  break;
     247             :             }
     248        9376 :             break;
     249             : 
     250             :         case COLL_REGISTER_BITS:
     251        7570 :             switch( nId )
     252             :             {
     253             :             case RES_POOLCOLL_REGISTER_BASE:
     254        5034 :                     nRet = RES_POOLCOLL_STANDARD;               break;
     255             : 
     256             :             case RES_POOLCOLL_TOX_USERH:
     257             :             case RES_POOLCOLL_TOX_CNTNTH:
     258             :             case RES_POOLCOLL_TOX_IDXH:
     259             :             case RES_POOLCOLL_TOX_ILLUSH:
     260             :             case RES_POOLCOLL_TOX_OBJECTH:
     261             :             case RES_POOLCOLL_TOX_TABLESH:
     262             :             case RES_POOLCOLL_TOX_AUTHORITIESH:
     263         370 :                     nRet = RES_POOLCOLL_HEADLINE_BASE;          break;
     264             : 
     265             :             default:
     266        2166 :                     nRet = RES_POOLCOLL_REGISTER_BASE;          break;
     267             :             }
     268        7570 :             break;
     269             : 
     270             :         case COLL_DOC_BITS:
     271         598 :             nRet = RES_POOLCOLL_HEADLINE_BASE;
     272         598 :             break;
     273             : 
     274             :         case COLL_HTML_BITS:
     275          86 :             nRet = RES_POOLCOLL_STANDARD;
     276          86 :             break;
     277             :         }
     278             :     }
     279             : 
     280       42692 :     return nRet;
     281             : }
     282             : 
     283         252 : void SwDoc::RemoveAllFmtLanguageDependencies()
     284             : {
     285             :     /* Restore the language independ pool defaults and styles. */
     286         252 :     GetAttrPool().ResetPoolDefaultItem( RES_PARATR_ADJUST );
     287             : 
     288         252 :     SwTxtFmtColl * pTxtFmtColl = getIDocumentStylePoolAccess().GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
     289             : 
     290         252 :     pTxtFmtColl->ResetFmtAttr( RES_PARATR_ADJUST );
     291             :     /* koreans do not like SvxScriptItem(TRUE) */
     292         252 :     pTxtFmtColl->ResetFmtAttr( RES_PARATR_SCRIPTSPACE );
     293             : 
     294         252 :     SvxFrameDirectionItem aFrameDir( FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR );
     295             : 
     296         252 :     sal_uInt16 nCount = GetPageDescCnt();
     297         508 :     for( sal_uInt16 i=0; i<nCount; ++i )
     298             :     {
     299         256 :         SwPageDesc& rDesc = GetPageDesc( i );
     300         256 :         rDesc.GetMaster().SetFmtAttr( aFrameDir );
     301         256 :         rDesc.GetLeft().SetFmtAttr( aFrameDir );
     302             :     }
     303             : 
     304             :     //#i16874# AutoKerning as default for new documents
     305         252 :     GetAttrPool().ResetPoolDefaultItem( RES_CHRATR_AUTOKERN );
     306         522 : }
     307             : 
     308             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10