LCOV - code coverage report
Current view: top level - sw/source/core/doc - poolfmt.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 73 89 82.0 %
Date: 2015-06-13 12:38:46 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       13243 : void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem )
      77             : {
      78       13243 :     rSet.Put( rItem );
      79       13243 :     sal_uInt16 nWhCJK = 0, nWhCTL = 0;
      80       13243 :     switch( rItem.Which() )
      81             :     {
      82             :     case RES_CHRATR_FONTSIZE:
      83        8150 :         nWhCJK = RES_CHRATR_CJK_FONTSIZE, nWhCTL = RES_CHRATR_CTL_FONTSIZE;
      84        8150 :         break;
      85             :     case RES_CHRATR_FONT:
      86          39 :         nWhCJK = RES_CHRATR_CJK_FONT, nWhCTL = RES_CHRATR_CTL_FONT;
      87          39 :         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        3123 :         nWhCJK = RES_CHRATR_CJK_POSTURE, nWhCTL = RES_CHRATR_CTL_POSTURE;
      93        3123 :         break;
      94             :     case RES_CHRATR_WEIGHT:
      95        1931 :         nWhCJK = RES_CHRATR_CJK_WEIGHT, nWhCTL = RES_CHRATR_CTL_WEIGHT;
      96        1931 :         break;
      97             :     }
      98             : 
      99       13243 :     if( nWhCJK )
     100       13243 :         rSet.Put( rItem, nWhCJK );
     101       13243 :     if( nWhCTL )
     102       13243 :         rSet.Put( rItem, nWhCTL );
     103       13243 : }
     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      144384 : SvxFrameDirection GetDefaultFrameDirection(sal_uLong nLanguage)
     110             : {
     111      144384 :     SvxFrameDirection eResult = (MsLangId::isRightToLeft( static_cast<LanguageType>(nLanguage)) ?
     112      144384 :             FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP);
     113      144384 :     return eResult;
     114             : }
     115             : 
     116             : // See if the Paragraph/Character/Frame/Page style is in use
     117      593465 : 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      593465 :     SwAutoFormatGetDocNode aGetHt( &GetNodes() );
     122      593465 :     return !rModify.GetInfo( aGetHt );
     123             : }
     124             : 
     125             : // See if the NumRule is used
     126        1331 : bool SwDoc::IsUsed( const SwNumRule& rRule )
     127             : {
     128        2520 :     bool bUsed = rRule.GetTextNodeListSize() > 0 ||
     129        2520 :                      rRule.GetParagraphStyleListSize() > 0;
     130             : 
     131        1331 :     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       27190 : sal_uInt16 GetPoolParent( sal_uInt16 nId )
     159             : {
     160       27190 :     sal_uInt16 nRet = USHRT_MAX;
     161       27190 :     if( POOLGRP_NOCOLLID & nId )        // 1 == Formats / 0 == Collections
     162             :     {
     163          52 :         switch( ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID ) & nId )
     164             :         {
     165             :         case POOLGRP_CHARFMT:
     166             :         case POOLGRP_FRAMEFMT:
     167          50 :             nRet = 0;           // derived from the default
     168          50 :             break;
     169             :         case POOLGRP_PAGEDESC:
     170             :         case POOLGRP_NUMRULE:
     171           0 :             break;              // there are no derivations
     172             :         }
     173             :     }
     174             :     else
     175             :     {
     176       27138 :         switch( COLL_GET_RANGE_BITS & nId )
     177             :         {
     178             :         case COLL_TEXT_BITS:
     179       12269 :             switch( nId )
     180             :             {
     181             :             case RES_POOLCOLL_STANDARD:
     182        2979 :                     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         183 :                     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        5967 :                     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        3140 :                     nRet = RES_POOLCOLL_HEADLINE_BASE;          break;
     207             :             }
     208       12269 :             break;
     209             : 
     210             :         case COLL_LISTS_BITS:
     211        3379 :             switch( nId )
     212             :             {
     213             :             case RES_POOLCOLL_NUMBUL_BASE:
     214        2946 :                     nRet = RES_POOLCOLL_TEXT;                   break;
     215             : 
     216             :             default:
     217         433 :                 nRet = RES_POOLCOLL_NUMBUL_BASE;                break;
     218             :             }
     219        3379 :             break;
     220             : 
     221             :         case COLL_EXTRA_BITS:
     222        5541 :             switch( nId )
     223             :             {
     224             :             case RES_POOLCOLL_TABLE_HDLN:
     225         172 :                     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        5298 :                     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          71 :                     nRet = RES_POOLCOLL_LABEL;                  break;
     247             :             }
     248        5541 :             break;
     249             : 
     250             :         case COLL_REGISTER_BITS:
     251        4497 :             switch( nId )
     252             :             {
     253             :             case RES_POOLCOLL_REGISTER_BASE:
     254        2947 :                     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         230 :                     nRet = RES_POOLCOLL_HEADLINE_BASE;          break;
     264             : 
     265             :             default:
     266        1320 :                     nRet = RES_POOLCOLL_REGISTER_BASE;          break;
     267             :             }
     268        4497 :             break;
     269             : 
     270             :         case COLL_DOC_BITS:
     271        1026 :             nRet = RES_POOLCOLL_HEADLINE_BASE;
     272        1026 :             break;
     273             : 
     274             :         case COLL_HTML_BITS:
     275         426 :             nRet = RES_POOLCOLL_STANDARD;
     276         426 :             break;
     277             :         }
     278             :     }
     279             : 
     280       27190 :     return nRet;
     281             : }
     282             : 
     283         169 : void SwDoc::RemoveAllFormatLanguageDependencies()
     284             : {
     285             :     /* Restore the language independ pool defaults and styles. */
     286         169 :     GetAttrPool().ResetPoolDefaultItem( RES_PARATR_ADJUST );
     287             : 
     288         169 :     SwTextFormatColl * pTextFormatColl = getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD );
     289             : 
     290         169 :     pTextFormatColl->ResetFormatAttr( RES_PARATR_ADJUST );
     291             :     /* koreans do not like SvxScriptItem(TRUE) */
     292         169 :     pTextFormatColl->ResetFormatAttr( RES_PARATR_SCRIPTSPACE );
     293             : 
     294         169 :     SvxFrameDirectionItem aFrameDir( FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR );
     295             : 
     296         169 :     size_t nCount = GetPageDescCnt();
     297         340 :     for( size_t i=0; i<nCount; ++i )
     298             :     {
     299         171 :         SwPageDesc& rDesc = GetPageDesc( i );
     300         171 :         rDesc.GetMaster().SetFormatAttr( aFrameDir );
     301         171 :         rDesc.GetLeft().SetFormatAttr( aFrameDir );
     302             :     }
     303             : 
     304             :     //#i16874# AutoKerning as default for new documents
     305         169 :     GetAttrPool().ResetPoolDefaultItem( RES_CHRATR_AUTOKERN );
     306         346 : }
     307             : 
     308             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11