LCOV - code coverage report
Current view: top level - sw/source/ui/app - docst.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 71 563 12.6 %
Date: 2012-08-25 Functions: 1 12 8.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 111 1159 9.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      31                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      32                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      33                 :            : 
      34                 :            : #include <hintids.hxx>
      35                 :            : #include <sfx2/app.hxx>
      36                 :            : #include <svl/whiter.hxx>
      37                 :            : #include <sfx2/templdlg.hxx>
      38                 :            : #include <sfx2/tplpitem.hxx>
      39                 :            : #include <sfx2/request.hxx>
      40                 :            : #include <sfx2/dispatch.hxx>
      41                 :            : #include <sfx2/newstyle.hxx>
      42                 :            : #include <sfx2/printer.hxx>
      43                 :            : #include <svl/macitem.hxx>
      44                 :            : #include <editeng/brshitem.hxx>
      45                 :            : #include <svl/stritem.hxx>
      46                 :            : #include <svl/languageoptions.hxx>
      47                 :            : #include <editeng/eeitem.hxx>
      48                 :            : #include <svx/htmlmode.hxx>
      49                 :            : #include <swmodule.hxx>
      50                 :            : #include <wdocsh.hxx>
      51                 :            : #include <fmtfsize.hxx>
      52                 :            : #include <fchrfmt.hxx>
      53                 :            : #include <svtools/htmlcfg.hxx>
      54                 :            : #include <SwStyleNameMapper.hxx>
      55                 :            : #include <SwRewriter.hxx>
      56                 :            : #include <numrule.hxx>
      57                 :            : #include <swundo.hxx>
      58                 :            : 
      59                 :            : #include "view.hxx"
      60                 :            : #include "wrtsh.hxx"
      61                 :            : #include "docsh.hxx"
      62                 :            : #include "uitool.hxx"
      63                 :            : #include "cmdid.h"
      64                 :            : #include "globals.hrc"
      65                 :            : #include "viewopt.hxx"
      66                 :            : #include <doc.hxx>
      67                 :            : #include <IDocumentUndoRedo.hxx>
      68                 :            : #include "swstyle.h"
      69                 :            : #include "frmfmt.hxx"
      70                 :            : #include "charfmt.hxx"
      71                 :            : #include "poolfmt.hxx"
      72                 :            : #include "pagedesc.hxx"
      73                 :            : #include "docstyle.hxx"
      74                 :            : #include "uiitems.hxx"
      75                 :            : #include "fmtcol.hxx"
      76                 :            : #include "frmmgr.hxx"       //SwFrmValid
      77                 :            : #include "swevent.hxx"
      78                 :            : #include "edtwin.hxx"
      79                 :            : #include "unochart.hxx"
      80                 :            : 
      81                 :            : #include "app.hrc"
      82                 :            : #include <fmtui.hrc>
      83                 :            : #include "swabstdlg.hxx"
      84                 :            : 
      85                 :            : #include <list.hxx>
      86                 :            : 
      87                 :            : #include <paratr.hxx>   //#outline level,add by zhaojianwei
      88                 :            : 
      89                 :            : using namespace ::com::sun::star;
      90                 :            : 
      91                 :       9707 : void  SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh)
      92                 :            : {
      93         [ +  - ]:       9707 :     SfxWhichIter aIter(rSet);
      94         [ +  - ]:       9707 :     sal_uInt16  nWhich  = aIter.FirstWhich();
      95                 :       9707 :     sal_uInt16 nActualFamily = USHRT_MAX;
      96                 :            : 
      97         [ +  + ]:       9707 :     SwWrtShell* pShell = pSh ? pSh : GetWrtShell();
      98         [ -  + ]:       9707 :     if(!pShell)
      99                 :            :     {
     100         [ #  # ]:          0 :         while (nWhich)
     101                 :            :         {
     102         [ #  # ]:          0 :             rSet.DisableItem(nWhich);
     103         [ #  # ]:          0 :             nWhich = aIter.NextWhich();
     104                 :            :         }
     105                 :       9707 :         return;
     106                 :            :     }
     107                 :            :     else
     108                 :            :     {
     109                 :       9707 :         SfxViewFrame* pFrame = pShell->GetView().GetViewFrame();
     110 [ +  - ][ +  - ]:       9707 :         const ISfxTemplateCommon* pCommon = SFX_APP()->GetCurrentTemplateCommon(pFrame->GetBindings());
     111         [ +  + ]:       9707 :         if( pCommon )
     112         [ +  - ]:       1212 :             nActualFamily = static_cast< sal_uInt16 >(pCommon->GetActualFamily());
     113                 :            :     }
     114                 :            : 
     115         [ +  + ]:      28450 :     while (nWhich)
     116                 :            :     {
     117                 :            :         // determine current template to every family
     118         [ +  - ]:      18743 :         String aName;
     119   [ +  +  +  +  :      18743 :         switch (nWhich)
          +  +  +  +  +  
                      - ]
     120                 :            :         {
     121                 :            :             case SID_STYLE_APPLY:
     122                 :            :             {// here the template and its family are passed to the StyleBox
     123                 :            :              // so that this family is being showed
     124 [ +  - ][ -  + ]:       3553 :                 if(pShell->IsFrmSelected())
     125                 :            :                 {
     126         [ #  # ]:          0 :                     SwFrmFmt* pFmt = pShell->GetCurFrmFmt();
     127         [ #  # ]:          0 :                     if( pFmt )
     128         [ #  # ]:          0 :                         aName = pFmt->GetName();
     129                 :            :                 }
     130                 :            :                 else
     131                 :            :                 {
     132         [ +  - ]:       3553 :                     SwTxtFmtColl* pColl = pShell->GetCurTxtFmtColl();
     133         [ +  - ]:       3553 :                     if(pColl)
     134         [ +  - ]:       3553 :                         aName = pColl->GetName();
     135                 :            :                 }
     136 [ +  - ][ +  - ]:       3553 :                 rSet.Put(SfxTemplateItem(nWhich, aName));
                 [ +  - ]
     137                 :            :             }
     138                 :       3553 :             break;
     139                 :            :             case SID_STYLE_FAMILY1:
     140 [ +  - ][ +  - ]:       3671 :                 if( !pShell->IsFrmSelected() )
     141                 :            :                 {
     142         [ +  - ]:       3671 :                     SwCharFmt* pFmt = pShell->GetCurCharFmt();
     143         [ +  + ]:       3671 :                     if(pFmt)
     144         [ +  - ]:         71 :                         aName = pFmt->GetName();
     145                 :            :                     else
     146         [ +  - ]:       3600 :                         aName = SwStyleNameMapper::GetTextUINameArray()[
     147 [ +  - ][ +  - ]:       3600 :                             RES_POOLCOLL_STANDARD - RES_POOLCOLL_TEXT_BEGIN ];
     148 [ +  - ][ +  - ]:       3671 :                     rSet.Put(SfxTemplateItem(nWhich, aName));
                 [ +  - ]
     149                 :            :                 }
     150                 :       3671 :                 break;
     151                 :            : 
     152                 :            :             case SID_STYLE_FAMILY2:
     153 [ +  - ][ +  - ]:       3671 :                 if(!pShell->IsFrmSelected())
     154                 :            :                 {
     155         [ +  - ]:       3671 :                     SwTxtFmtColl* pColl = pShell->GetCurTxtFmtColl();
     156         [ +  - ]:       3671 :                     if(pColl)
     157         [ +  - ]:       3671 :                         aName = pColl->GetName();
     158                 :            : 
     159         [ +  - ]:       3671 :                     SfxTemplateItem aItem(nWhich, aName);
     160                 :            : 
     161                 :       3671 :                     sal_uInt16 nMask = 0;
     162 [ +  - ][ +  + ]:       3671 :                     if( pDoc->get(IDocumentSettingAccess::HTML_MODE) )
     163                 :         12 :                         nMask = SWSTYLEBIT_HTML;
     164                 :            :                     else
     165                 :            :                     {
     166         [ +  - ]:       3659 :                         const int nSelection = pShell->GetFrmType(0,sal_True);
     167 [ +  - ][ -  + ]:       3659 :                         if(pShell->GetCurTOX())
     168                 :          0 :                             nMask = SWSTYLEBIT_IDX  ;
     169 [ +  - ][ +  - ]:       3659 :                         else if(nSelection & FRMTYPE_HEADER     ||
         [ +  + ][ +  - ]
         [ +  - ][ -  + ]
     170                 :            :                                 nSelection & FRMTYPE_FOOTER     ||
     171                 :            :                                 nSelection & FRMTYPE_TABLE      ||
     172                 :            :                                 nSelection & FRMTYPE_FLY_ANY    ||
     173                 :            :                                 nSelection & FRMTYPE_FOOTNOTE   ||
     174                 :            :                                 nSelection & FRMTYPE_FTNPAGE)
     175                 :         14 :                             nMask = SWSTYLEBIT_EXTRA;
     176                 :            :                         else
     177                 :       3645 :                             nMask = SWSTYLEBIT_TEXT;
     178                 :            :                     }
     179                 :            : 
     180                 :       3671 :                     aItem.SetValue(nMask);
     181 [ +  - ][ +  - ]:       3671 :                     rSet.Put(aItem);
     182                 :            :                 }
     183                 :            : 
     184                 :       3671 :                 break;
     185                 :            : 
     186                 :            :             case SID_STYLE_FAMILY3:
     187                 :            : 
     188 [ +  - ][ +  + ]:       3671 :                 if( pDoc->get(IDocumentSettingAccess::HTML_MODE) )
     189         [ +  - ]:         12 :                     rSet.DisableItem( nWhich );
     190                 :            :                 else
     191                 :            :                 {
     192         [ +  - ]:       3659 :                     SwFrmFmt* pFmt = pShell->GetCurFrmFmt();
     193 [ -  + ][ #  # ]:       3659 :                     if(pFmt && pShell->IsFrmSelected())
         [ #  # ][ -  + ]
     194                 :            :                     {
     195         [ #  # ]:          0 :                         aName = pFmt->GetName();
     196 [ #  # ][ #  # ]:          0 :                         rSet.Put(SfxTemplateItem(nWhich, aName));
                 [ #  # ]
     197                 :            :                     }
     198                 :            :                 }
     199                 :       3671 :                 break;
     200                 :            : 
     201                 :            :             case SID_STYLE_FAMILY4:
     202                 :            :             {
     203         [ +  - ]:       3671 :                 SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
     204 [ +  - ][ +  + ]:       3671 :                 if( pDoc->get(IDocumentSettingAccess::HTML_MODE) && !rHtmlOpt.IsPrintLayoutExtension())
         [ +  - ][ +  - ]
                 [ +  + ]
     205         [ +  - ]:         12 :                     rSet.DisableItem( nWhich );
     206                 :            :                 else
     207                 :            :                 {
     208         [ +  - ]:       3659 :                     sal_uInt16 n = pShell->GetCurPageDesc( sal_False );
     209 [ +  - ][ +  - ]:       3659 :                     if( n < pShell->GetPageDescCnt() )
     210 [ +  - ][ +  - ]:       3659 :                         aName = pShell->GetPageDesc( n ).GetName();
     211                 :            : 
     212 [ +  - ][ +  - ]:       3659 :                     rSet.Put(SfxTemplateItem(nWhich, aName));
                 [ +  - ]
     213                 :            :                 }
     214                 :            :             }
     215                 :       3671 :             break;
     216                 :            :             case SID_STYLE_FAMILY5:
     217                 :            :                 {
     218         [ +  - ]:        215 :                     const SwNumRule* pRule = pShell->GetCurNumRule();
     219         [ -  + ]:        215 :                     if( pRule )
     220         [ #  # ]:          0 :                         aName = pRule->GetName();
     221                 :            : 
     222 [ +  - ][ +  - ]:        215 :                     rSet.Put(SfxTemplateItem(nWhich, aName));
                 [ +  - ]
     223                 :            :                 }
     224                 :        215 :                 break;
     225                 :            : 
     226                 :            :             case SID_STYLE_WATERCAN:
     227                 :            :             {
     228                 :         97 :                 SwEditWin& rEdtWin = pShell->GetView().GetEditWin();
     229                 :         97 :                 SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
     230 [ #  # ][ +  - ]:         97 :                 rSet.Put(SfxBoolItem(nWhich, pApply && pApply->eType != 0));
         [ +  - ][ +  - ]
                 [ -  + ]
     231                 :            :             }
     232                 :         97 :             break;
     233                 :            :             case SID_STYLE_UPDATE_BY_EXAMPLE:
     234 [ +  - ][ -  + ]:         97 :                 if( pShell->IsFrmSelected()
         [ +  - ][ +  - ]
         [ -  + ][ #  # ]
                 [ -  + ]
     235                 :            :                         ? SFX_STYLE_FAMILY_FRAME != nActualFamily
     236                 :            :                         : ( SFX_STYLE_FAMILY_FRAME == nActualFamily ||
     237                 :            :                             SFX_STYLE_FAMILY_PAGE == nActualFamily ||
     238         [ #  # ]:          0 :                             (SFX_STYLE_FAMILY_PSEUDO == nActualFamily && !pShell->GetCurNumRule())) )
     239                 :            :                 {
     240         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     241                 :            :                 }
     242                 :         97 :                 break;
     243                 :            : 
     244                 :            :             case SID_STYLE_NEW_BY_EXAMPLE:
     245 [ +  - ][ -  + ]:         97 :                 if( (pShell->IsFrmSelected()
         [ #  # ][ +  - ]
         [ -  + ][ #  # ]
                 [ -  + ]
     246                 :            :                         ? SFX_STYLE_FAMILY_FRAME != nActualFamily
     247                 :            :                         : SFX_STYLE_FAMILY_FRAME == nActualFamily) ||
     248         [ #  # ]:          0 :                     (SFX_STYLE_FAMILY_PSEUDO == nActualFamily && !pShell->GetCurNumRule()) )
     249                 :            :                 {
     250         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     251                 :            :                 }
     252                 :         97 :                 break;
     253                 :            : 
     254                 :            :             default:
     255                 :            :                 OSL_FAIL("Invalid SlotId");
     256                 :            :         }
     257         [ +  - ]:      18743 :         nWhich = aIter.NextWhich();
     258 [ +  - ][ +  - ]:      28450 :     }
                 [ +  - ]
     259                 :            : }
     260                 :            : 
     261                 :            : 
     262                 :            : /*--------------------------------------------------------------------
     263                 :            :     Description:    evaluate StyleSheet-Requests
     264                 :            :  --------------------------------------------------------------------*/
     265                 :            : 
     266                 :            : 
     267                 :          0 : void SwDocShell::ExecStyleSheet( SfxRequest& rReq )
     268                 :            : {
     269                 :          0 :     sal_uInt16  nSlot   = rReq.GetSlot();
     270                 :          0 :     sal_uInt16  nRet    = 0xffff;
     271                 :            : 
     272                 :          0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     273                 :            :     const SfxPoolItem* pItem;
     274                 :          0 :     SwWrtShell* pActShell = 0;
     275                 :          0 :     sal_Bool bSetReturn = sal_True;
     276   [ #  #  #  # ]:          0 :     switch (nSlot)
     277                 :            :     {
     278                 :            :     case SID_STYLE_NEW:
     279 [ #  # ][ #  # ]:          0 :         if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY,
                 [ #  # ]
     280         [ #  # ]:          0 :             sal_False, &pItem ))
     281                 :            :         {
     282                 :          0 :             sal_uInt16 nFamily = ((const SfxUInt16Item*)pItem)->GetValue();
     283                 :            : 
     284         [ #  # ]:          0 :             String sName;
     285                 :          0 :             sal_uInt16 nMask = 0;
     286         [ #  # ]:          0 :             if( SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_NEW,
     287         [ #  # ]:          0 :                 sal_False, &pItem ))
     288         [ #  # ]:          0 :                 sName = ((const SfxStringItem*)pItem)->GetValue();
     289         [ #  # ]:          0 :             if( SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_MASK,
     290         [ #  # ]:          0 :                 sal_False, &pItem ))
     291                 :          0 :                 nMask = ((const SfxUInt16Item*)pItem)->GetValue();
     292         [ #  # ]:          0 :             String sParent;
     293         [ #  # ]:          0 :             if( SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_REFERENCE,
     294         [ #  # ]:          0 :                 sal_False, &pItem ))
     295         [ #  # ]:          0 :                 sParent = ((const SfxStringItem*)pItem)->GetValue();
     296                 :            : 
     297 [ #  # ][ #  # ]:          0 :             nRet = Edit( sName, sParent, nFamily, nMask, sal_True, sal_False, 0, rReq.IsAPI() );
         [ #  # ][ #  # ]
     298                 :            :         }
     299                 :          0 :         break;
     300                 :            : 
     301                 :            :         case SID_STYLE_APPLY:
     302         [ #  # ]:          0 :             if( !pArgs )
     303                 :            :             {
     304         [ #  # ]:          0 :                 GetView()->GetViewFrame()->GetDispatcher()->Execute(SID_STYLE_DESIGNER, sal_False);
     305                 :          0 :                 break;
     306                 :            :             }
     307                 :            :             else
     308                 :            :             {
     309                 :            :                 // convert internal StyleName to DisplayName (slot implementation uses the latter)
     310 [ #  # ][ #  # ]:          0 :                 SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, sal_False );
     311 [ #  # ][ #  # ]:          0 :                 SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, sal_False );
     312 [ #  # ][ #  # ]:          0 :                 if ( pFamilyItem && pNameItem )
     313                 :            :                 {
     314 [ #  # ][ #  # ]:          0 :                     uno::Reference< style::XStyleFamiliesSupplier > xModel(GetModel(), uno::UNO_QUERY);
     315                 :            :                     try
     316                 :            :                     {
     317                 :          0 :                         uno::Reference< container::XNameAccess > xStyles;
     318 [ #  # ][ #  # ]:          0 :                         uno::Reference< container::XNameAccess > xCont = xModel->getStyleFamilies();
     319 [ #  # ][ #  # ]:          0 :                         xCont->getByName(pFamilyItem->GetValue()) >>= xStyles;
         [ #  # ][ #  # ]
     320                 :          0 :                         uno::Reference< beans::XPropertySet > xInfo;
     321 [ #  # ][ #  # ]:          0 :                         xStyles->getByName( pNameItem->GetValue() ) >>= xInfo;
         [ #  # ][ #  # ]
     322                 :          0 :                         ::rtl::OUString aUIName;
     323 [ #  # ][ #  # ]:          0 :                         xInfo->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayName")) ) >>= aUIName;
                 [ #  # ]
     324         [ #  # ]:          0 :                         if ( !aUIName.isEmpty() )
     325 [ #  # ][ #  # ]:          0 :                             rReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aUIName ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     326                 :            :                     }
     327         [ #  # ]:          0 :                     catch (const uno::Exception&)
     328                 :            :                     {
     329                 :          0 :                     }
     330                 :            :                 }
     331                 :            :             }
     332                 :            : 
     333                 :            :             // intentionally no break
     334                 :            : 
     335                 :            :         case SID_STYLE_EDIT:
     336                 :            :         case SID_STYLE_DELETE:
     337                 :            :         case SID_STYLE_WATERCAN:
     338                 :            :         case SID_STYLE_FAMILY:
     339                 :            :         case SID_STYLE_UPDATE_BY_EXAMPLE:
     340                 :            :         case SID_STYLE_NEW_BY_EXAMPLE:
     341                 :            :         {
     342         [ #  # ]:          0 :             String aParam;
     343                 :          0 :             sal_uInt16 nFamily = SFX_STYLE_FAMILY_PARA;
     344                 :          0 :             sal_uInt16 nMask = 0;
     345                 :            : 
     346         [ #  # ]:          0 :             if( !pArgs )
     347                 :            :             {
     348                 :          0 :                 nFamily = SFX_STYLE_FAMILY_PARA;
     349                 :            : 
     350      [ #  #  # ]:          0 :                 switch (nSlot)
     351                 :            :                 {
     352                 :            :                     case SID_STYLE_NEW_BY_EXAMPLE:
     353                 :            :                     {
     354                 :            :                         SfxNewStyleDlg *pDlg = new SfxNewStyleDlg( 0,
     355 [ #  # ][ #  # ]:          0 :                                                     *GetStyleSheetPool());
                 [ #  # ]
     356 [ #  # ][ #  # ]:          0 :                         if(RET_OK == pDlg->Execute())
     357                 :            :                         {
     358 [ #  # ][ #  # ]:          0 :                             aParam = pDlg->GetName();
                 [ #  # ]
     359 [ #  # ][ #  # ]:          0 :                             rReq.AppendItem(SfxStringItem(nSlot, aParam));
                 [ #  # ]
     360                 :            :                         }
     361                 :            : 
     362 [ #  # ][ #  # ]:          0 :                         delete pDlg;
     363                 :            :                     }
     364                 :          0 :                     break;
     365                 :            : 
     366                 :            :                     case SID_STYLE_UPDATE_BY_EXAMPLE:
     367                 :            :                     case SID_STYLE_EDIT:
     368                 :            :                     {
     369         [ #  # ]:          0 :                         SwTxtFmtColl* pColl = GetWrtShell()->GetCurTxtFmtColl();
     370         [ #  # ]:          0 :                         if(pColl)
     371                 :            :                         {
     372         [ #  # ]:          0 :                             aParam = pColl->GetName();
     373 [ #  # ][ #  # ]:          0 :                             rReq.AppendItem(SfxStringItem(nSlot, aParam));
                 [ #  # ]
     374                 :            :                         }
     375                 :            :                     }
     376                 :          0 :                     break;
     377                 :            :                 }
     378                 :            :             }
     379                 :            :             else
     380                 :            :             {
     381                 :            :                 OSL_ENSURE( pArgs->Count(), "SfxBug ItemSet is empty");
     382                 :            : 
     383                 :          0 :                 SwWrtShell* pShell = GetWrtShell();
     384 [ #  # ][ #  # ]:          0 :                 if( SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem ))
     385         [ #  # ]:          0 :                     aParam = ((const SfxStringItem*)pItem)->GetValue();
     386                 :            : 
     387         [ #  # ]:          0 :                 if( SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_FAMILY,
     388         [ #  # ]:          0 :                     sal_False, &pItem ))
     389                 :          0 :                     nFamily = ((const SfxUInt16Item*)pItem)->GetValue();
     390                 :            : 
     391 [ #  # ][ #  # ]:          0 :                 if( SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_FAMILYNAME, sal_False, &pItem ))
     392                 :            :                 {
     393         [ #  # ]:          0 :                     String aFamily = ((const SfxStringItem*)pItem)->GetValue();
     394 [ #  # ][ #  # ]:          0 :                     if(aFamily.CompareToAscii("CharacterStyles") == COMPARE_EQUAL)
     395                 :          0 :                         nFamily = SFX_STYLE_FAMILY_CHAR;
     396                 :            :                     else
     397 [ #  # ][ #  # ]:          0 :                     if(aFamily.CompareToAscii("ParagraphStyles") == COMPARE_EQUAL)
     398                 :          0 :                         nFamily = SFX_STYLE_FAMILY_PARA;
     399                 :            :                     else
     400 [ #  # ][ #  # ]:          0 :                     if(aFamily.CompareToAscii("PageStyles") == COMPARE_EQUAL)
     401                 :          0 :                         nFamily = SFX_STYLE_FAMILY_PAGE;
     402                 :            :                     else
     403 [ #  # ][ #  # ]:          0 :                     if(aFamily.CompareToAscii("FrameStyles") == COMPARE_EQUAL)
     404                 :          0 :                         nFamily = SFX_STYLE_FAMILY_FRAME;
     405                 :            :                     else
     406 [ #  # ][ #  # ]:          0 :                     if(aFamily.CompareToAscii("NumberingStyles") == COMPARE_EQUAL)
     407         [ #  # ]:          0 :                         nFamily = SFX_STYLE_FAMILY_PSEUDO;
     408                 :            :                 }
     409                 :            : 
     410         [ #  # ]:          0 :                 if( SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_MASK,
     411         [ #  # ]:          0 :                     sal_False, &pItem ))
     412                 :          0 :                     nMask = ((const SfxUInt16Item*)pItem)->GetValue();
     413         [ #  # ]:          0 :                 if( SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_WRTSHELL,
     414         [ #  # ]:          0 :                     sal_False, &pItem ))
     415                 :          0 :                     pActShell = pShell = (SwWrtShell*)((SwPtrItem*)pItem)->GetValue();
     416                 :            : 
     417         [ #  # ]:          0 :                 if( nSlot == SID_STYLE_UPDATE_BY_EXAMPLE )
     418                 :            :                 {
     419   [ #  #  #  #  :          0 :                     switch( nFamily )
                      # ]
     420                 :            :                     {
     421                 :            :                         case SFX_STYLE_FAMILY_PARA:
     422                 :            :                         {
     423         [ #  # ]:          0 :                             SwTxtFmtColl* pColl = pShell->GetCurTxtFmtColl();
     424         [ #  # ]:          0 :                             if(pColl)
     425         [ #  # ]:          0 :                                 aParam = pColl->GetName();
     426                 :            :                         }
     427                 :          0 :                         break;
     428                 :            :                         case SFX_STYLE_FAMILY_FRAME:
     429                 :            :                         {
     430         [ #  # ]:          0 :                             SwFrmFmt* pFrm = pWrtShell->GetCurFrmFmt();
     431         [ #  # ]:          0 :                             if( pFrm )
     432         [ #  # ]:          0 :                                 aParam = pFrm->GetName();
     433                 :            :                         }
     434                 :          0 :                         break;
     435                 :            :                         case SFX_STYLE_FAMILY_CHAR:
     436                 :            :                         {
     437         [ #  # ]:          0 :                             SwCharFmt* pChar = pWrtShell->GetCurCharFmt();
     438         [ #  # ]:          0 :                             if( pChar )
     439         [ #  # ]:          0 :                                 aParam = pChar->GetName();
     440                 :            :                         }
     441                 :          0 :                         break;
     442                 :            :                         case SFX_STYLE_FAMILY_PSEUDO:
     443 [ #  # ][ #  # ]:          0 :                         if(SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_UPD_BY_EX_NAME, sal_False, &pItem))
     444                 :            :                         {
     445         [ #  # ]:          0 :                             aParam = ((const SfxStringItem*)pItem)->GetValue();
     446                 :            :                         }
     447                 :          0 :                         break;
     448                 :            :                     }
     449 [ #  # ][ #  # ]:          0 :                     rReq.AppendItem(SfxStringItem(nSlot, aParam));
                 [ #  # ]
     450                 :            :                 }
     451                 :            :             }
     452 [ #  # ][ #  # ]:          0 :             if (aParam.Len() || nSlot == SID_STYLE_WATERCAN )
                 [ #  # ]
     453                 :            :             {
     454   [ #  #  #  #  :          0 :                 switch(nSlot)
                #  #  # ]
     455                 :            :                 {
     456                 :            :                     case SID_STYLE_EDIT:
     457         [ #  # ]:          0 :                         nRet = Edit(aParam, aEmptyStr, nFamily, nMask, sal_False, sal_False, pActShell );
     458                 :          0 :                         break;
     459                 :            :                     case SID_STYLE_DELETE:
     460         [ #  # ]:          0 :                         nRet = Delete(aParam, nFamily);
     461                 :          0 :                         break;
     462                 :            :                     case SID_STYLE_APPLY:
     463                 :            :                         // Shell-switch in ApplyStyles
     464 [ #  # ][ #  # ]:          0 :                         nRet = ApplyStyles(aParam, nFamily, pActShell, rReq.GetModifier() );
     465                 :          0 :                         break;
     466                 :            :                     case SID_STYLE_WATERCAN:
     467         [ #  # ]:          0 :                         nRet = DoWaterCan(aParam, nFamily);
     468                 :          0 :                         break;
     469                 :            :                     case SID_STYLE_UPDATE_BY_EXAMPLE:
     470         [ #  # ]:          0 :                         nRet = UpdateStyle(aParam, nFamily, pActShell);
     471                 :          0 :                         break;
     472                 :            :                     case SID_STYLE_NEW_BY_EXAMPLE:
     473                 :            :                     {
     474         [ #  # ]:          0 :                         nRet = MakeByExample(aParam, nFamily, nMask, pActShell );
     475 [ #  # ][ #  # ]:          0 :                         SfxTemplateDialog* pDlg = SFX_APP()->GetTemplateDialog();
     476                 :            : 
     477 [ #  # ][ #  # ]:          0 :                         if(pDlg && pDlg->IsVisible())
         [ #  # ][ #  # ]
     478         [ #  # ]:          0 :                             pDlg->Update();
     479                 :            :                     }
     480                 :          0 :                     break;
     481                 :            : 
     482                 :            :                     default:
     483                 :            :                         OSL_FAIL("Invalid SlotId");
     484                 :            :                 }
     485                 :            : 
     486         [ #  # ]:          0 :                 rReq.Done();
     487                 :            :             }
     488                 :            : 
     489         [ #  # ]:          0 :             break;
     490                 :            :         }
     491                 :            :     }
     492                 :            : 
     493         [ #  # ]:          0 :     if(bSetReturn)
     494                 :            :     {
     495 [ #  # ][ #  # ]:          0 :         if(rReq.IsAPI()) // Basic only gets TRUE or FALSE
     496 [ #  # ][ #  # ]:          0 :             rReq.SetReturnValue(SfxUInt16Item(nSlot, nRet !=0));
                 [ #  # ]
     497                 :            :         else
     498 [ #  # ][ #  # ]:          0 :             rReq.SetReturnValue(SfxUInt16Item(nSlot, nRet));
                 [ #  # ]
     499                 :            :     }
     500                 :            : 
     501                 :          0 : }
     502                 :            : 
     503                 :            : /*--------------------------------------------------------------------
     504                 :            :     Description:    Edit
     505                 :            :  --------------------------------------------------------------------*/
     506                 :            : 
     507                 :            : 
     508                 :          0 : sal_uInt16 SwDocShell::Edit( const String &rName, const String &rParent, sal_uInt16 nFamily, sal_uInt16 nMask,
     509                 :            :                          sal_Bool bNew, sal_uInt16 nPageId, SwWrtShell* pActShell,
     510                 :            :                          sal_Bool bBasic )
     511                 :            : {
     512                 :            :     OSL_ENSURE(GetWrtShell(), "No Shell, no Styles");
     513                 :          0 :     SfxStyleSheetBase *pStyle = 0;
     514                 :            : 
     515                 :          0 :     sal_uInt16 nRet = nMask;
     516         [ #  # ]:          0 :     sal_Bool bModified = pDoc->IsModified();
     517                 :            : 
     518         [ #  # ]:          0 :     if( bNew )
     519                 :            :     {
     520 [ #  # ][ #  # ]:          0 :         if( SFXSTYLEBIT_ALL != nMask && SFXSTYLEBIT_USED != nMask )
     521                 :          0 :             nMask |= SFXSTYLEBIT_USERDEF;
     522                 :            :         else
     523                 :          0 :             nMask = SFXSTYLEBIT_USERDEF;
     524                 :            : 
     525         [ #  # ]:          0 :         pStyle = &mxBasePool->Make( rName, (SfxStyleFamily)nFamily, nMask );
     526                 :            : 
     527                 :            :         // set the current one as Parent
     528                 :          0 :         SwDocStyleSheet* pDStyle = (SwDocStyleSheet*)pStyle;
     529   [ #  #  #  # ]:          0 :         switch( nFamily )
     530                 :            :         {
     531                 :            :             case SFX_STYLE_FAMILY_PARA:
     532                 :            :             {
     533         [ #  # ]:          0 :                 if(rParent.Len())
     534                 :            :                 {
     535         [ #  # ]:          0 :                     SwTxtFmtColl* pColl = pWrtShell->FindTxtFmtCollByName( rParent );
     536         [ #  # ]:          0 :                     if(!pColl)
     537                 :            :                     {
     538         [ #  # ]:          0 :                         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
     539         [ #  # ]:          0 :                         if(USHRT_MAX != nId)
     540         [ #  # ]:          0 :                             pColl =  pWrtShell->GetTxtCollFromPool( nId );
     541                 :            :                     }
     542 [ #  # ][ #  # ]:          0 :                     pDStyle->GetCollection()->SetDerivedFrom( pColl );
     543         [ #  # ]:          0 :                     pDStyle->PresetParent( rParent );
     544                 :            : 
     545                 :            :                     //#outline level,add by zhaojianwei
     546                 :            :                      /*When a new paragraph style is created based on a "to outline style
     547                 :            :                         assigned" paragraph style, the outline level attribute and the list
     548                 :            :                         style attribute of the new paragraph style have to be set to 0
     549                 :            :                         respectively "".*/
     550         [ #  # ]:          0 :                     if( pColl->IsAssignedToListLevelOfOutlineStyle())
     551                 :            :                     {
     552         [ #  # ]:          0 :                         SwNumRuleItem aItem(aEmptyStr);
     553 [ #  # ][ #  # ]:          0 :                         pDStyle->GetCollection()->SetFmtAttr( aItem );
     554 [ #  # ][ #  # ]:          0 :                         pDStyle->GetCollection()->SetAttrOutlineLevel( 0 );
                 [ #  # ]
     555                 :            :                     }
     556                 :            :                     //<-end,zhaojianwei
     557                 :            : 
     558                 :            :                 }
     559                 :            :                 else
     560                 :            :                 {
     561         [ #  # ]:          0 :                     SwTxtFmtColl* pColl = pWrtShell->GetCurTxtFmtColl();
     562 [ #  # ][ #  # ]:          0 :                     pDStyle->GetCollection()->SetDerivedFrom( pColl );
     563         [ #  # ]:          0 :                     if( pColl )
     564         [ #  # ]:          0 :                         pDStyle->PresetParent( pColl->GetName() );
     565                 :            :                 }
     566                 :            :             }
     567                 :          0 :             break;
     568                 :            :             case SFX_STYLE_FAMILY_CHAR:
     569                 :            :             {
     570         [ #  # ]:          0 :                 if(rParent.Len())
     571                 :            :                 {
     572         [ #  # ]:          0 :                     SwCharFmt* pCFmt = pWrtShell->FindCharFmtByName( rParent );
     573         [ #  # ]:          0 :                     if(!pCFmt)
     574                 :            :                     {
     575         [ #  # ]:          0 :                         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
     576         [ #  # ]:          0 :                         if(USHRT_MAX != nId)
     577         [ #  # ]:          0 :                             pCFmt =  pWrtShell->GetCharFmtFromPool( nId );
     578                 :            :                     }
     579                 :            : 
     580 [ #  # ][ #  # ]:          0 :                     pDStyle->GetCharFmt()->SetDerivedFrom( pCFmt );
     581         [ #  # ]:          0 :                     pDStyle->PresetParent( rParent );
     582                 :            :                 }
     583                 :            :                 else
     584                 :            :                 {
     585         [ #  # ]:          0 :                     SwCharFmt* pCFmt = pWrtShell->GetCurCharFmt();
     586 [ #  # ][ #  # ]:          0 :                     pDStyle->GetCharFmt()->SetDerivedFrom( pCFmt );
     587         [ #  # ]:          0 :                         if( pCFmt )
     588         [ #  # ]:          0 :                             pDStyle->PresetParent( pCFmt->GetName() );
     589                 :            :                 }
     590                 :            :             }
     591                 :          0 :             break;
     592                 :            :             case SFX_STYLE_FAMILY_FRAME :
     593                 :            :             {
     594         [ #  # ]:          0 :                 if(rParent.Len())
     595                 :            :                 {
     596         [ #  # ]:          0 :                     SwFrmFmt* pFFmt = pWrtShell->GetDoc()->FindFrmFmtByName( rParent );
     597         [ #  # ]:          0 :                     if(!pFFmt)
     598                 :            :                     {
     599         [ #  # ]:          0 :                         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT);
     600         [ #  # ]:          0 :                         if(USHRT_MAX != nId)
     601         [ #  # ]:          0 :                             pFFmt =  pWrtShell->GetFrmFmtFromPool( nId );
     602                 :            :                     }
     603 [ #  # ][ #  # ]:          0 :                     pDStyle->GetFrmFmt()->SetDerivedFrom( pFFmt );
     604         [ #  # ]:          0 :                     pDStyle->PresetParent( rParent );
     605                 :            :                 }
     606                 :            :             }
     607                 :          0 :             break;
     608                 :            :         }
     609                 :            :     }
     610                 :            :     else
     611                 :            :     {
     612         [ #  # ]:          0 :         pStyle = mxBasePool->Find( rName, (SfxStyleFamily)nFamily );
     613                 :            :         OSL_ENSURE(pStyle, "Vorlage nicht gefunden");
     614                 :            :     }
     615                 :            : 
     616         [ #  # ]:          0 :     if(!pStyle)
     617                 :          0 :         return sal_False;
     618                 :            : 
     619                 :            :     // put dialogues together
     620         [ #  # ]:          0 :     rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pStyle ) );
     621         [ #  # ]:          0 :     if( SFX_STYLE_FAMILY_PARA == nFamily )
     622                 :            :     {
     623         [ #  # ]:          0 :         SfxItemSet& rSet = xTmp->GetItemSet();
     624         [ #  # ]:          0 :         ::SwToSfxPageDescAttr( rSet );
     625                 :            :         // firstly only a Zero
     626 [ #  # ][ #  # ]:          0 :         rSet.Put(SwBackgroundDestinationItem(SID_PARA_BACKGRND_DESTINATION, 0));
                 [ #  # ]
     627                 :            :         // merge list level indent attributes into the item set if needed
     628         [ #  # ]:          0 :         xTmp->MergeIndentAttrsOfListStyle( rSet );
     629                 :            :     }
     630         [ #  # ]:          0 :     else if( SFX_STYLE_FAMILY_CHAR == nFamily )
     631                 :            :     {
     632         [ #  # ]:          0 :         SfxItemSet& rSet = xTmp->GetItemSet();
     633                 :            :         const SfxPoolItem *pTmpBrush;
     634         [ #  # ]:          0 :         if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_BACKGROUND,
     635         [ #  # ]:          0 :             sal_True, &pTmpBrush ) )
     636                 :            :         {
     637         [ #  # ]:          0 :             SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
     638                 :          0 :             aTmpBrush.SetWhich( RES_BACKGROUND );
     639 [ #  # ][ #  # ]:          0 :             rSet.Put( aTmpBrush );
     640                 :            :         }
     641                 :            :     }
     642         [ #  # ]:          0 :     if (!bBasic)
     643                 :            :     {
     644                 :            :         // prior to the dialog the HtmlMode at the DocShell is being sunk
     645         [ #  # ]:          0 :         sal_uInt16 nHtmlMode = ::GetHtmlMode(this);
     646                 :            : 
     647                 :            :         // In HTML mode, we do not always have a printer. In order to show
     648                 :            :         // the correct page size in the Format - Page dialog, we have to
     649                 :            :         // get one here.
     650         [ #  # ]:          0 :         SwWrtShell* pCurrShell = ( pActShell ? pActShell : pWrtShell );
     651 [ #  # ][ #  # ]:          0 :         if( ( HTMLMODE_ON & nHtmlMode ) &&
                 [ #  # ]
     652 [ #  # ][ #  # ]:          0 :             !pCurrShell->getIDocumentDeviceAccess()->getPrinter( false ) )
     653 [ #  # ][ #  # ]:          0 :             pCurrShell->InitPrt( pCurrShell->getIDocumentDeviceAccess()->getPrinter( true ) );
                 [ #  # ]
     654                 :            : 
     655 [ #  # ][ #  # ]:          0 :         PutItem(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
                 [ #  # ]
     656         [ #  # ]:          0 :         FieldUnit eMetric = ::GetDfltMetric(0 != (HTMLMODE_ON&nHtmlMode));
     657 [ #  # ][ #  # ]:          0 :         SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
         [ #  # ][ #  # ]
     658         [ #  # ]:          0 :         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     659                 :            :         OSL_ENSURE(pFact, "Dialogdiet fail!");
     660                 :            :         SfxAbstractTabDialog* pDlg = pFact->CreateTemplateDialog( DLG_TEMPLATE_BASE,
     661                 :          0 :                                                     0, *(xTmp.get()), nFamily, nPageId,
     662 [ #  # ][ #  # ]:          0 :                                                     pActShell ? pActShell : pWrtShell, bNew);
     663                 :            :         OSL_ENSURE(pDlg, "Dialogdiet fail!");
     664                 :          0 :         while (true)
     665                 :            :         {
     666         [ #  # ]:          0 :             short nButton = pDlg->Execute();
     667 [ #  # ][ #  # ]:          0 :             if(RET_OK == nButton || RET_APPLY_TEMPLATE == nButton)
     668                 :            :         {
     669         [ #  # ]:          0 :             GetWrtShell()->StartAllAction();
     670                 :            : 
     671                 :            :             // newly set the mask only with paragraph-templates
     672         [ #  # ]:          0 :             if( bNew )
     673                 :            :             {
     674                 :          0 :                 nRet = SFX_STYLE_FAMILY_PARA == pStyle->GetFamily()
     675                 :          0 :                         ? xTmp->GetMask()
     676         [ #  # ]:          0 :                         : SFXSTYLEBIT_USERDEF;
     677                 :            :             }
     678         [ #  # ]:          0 :             else if( pStyle->GetMask() != xTmp->GetMask() )
     679                 :          0 :                 nRet = xTmp->GetMask();
     680                 :            : 
     681         [ #  # ]:          0 :             if( SFX_STYLE_FAMILY_PARA == nFamily )
     682                 :            :             {
     683 [ #  # ][ #  # ]:          0 :                 SfxItemSet aSet( *pDlg->GetOutputItemSet() );
     684         [ #  # ]:          0 :                 ::SfxToSwPageDescAttr( *GetWrtShell(), aSet  );
     685                 :            :                 // reset indent attributes at paragraph style, if a list style
     686                 :            :                 // will be applied and no indent attributes will be applied.
     687 [ #  # ][ #  # ]:          0 :                 xTmp->SetItemSet( aSet, true );
     688                 :            :             }
     689                 :            :             else
     690                 :            :             {
     691         [ #  # ]:          0 :                 if(SFX_STYLE_FAMILY_PAGE == nFamily)
     692                 :            :                 {
     693                 :            :                     static const sal_uInt16 aInval[] = {
     694                 :            :                         SID_IMAGE_ORIENTATION,
     695                 :            :                         SID_ATTR_CHAR_FONT,
     696                 :            :                         FN_INSERT_CTRL, FN_INSERT_OBJ_CTRL, 0};
     697         [ #  # ]:          0 :                     pView->GetViewFrame()->GetBindings().Invalidate(aInval);
     698                 :            :                 }
     699 [ #  # ][ #  # ]:          0 :                 SfxItemSet aTmpSet( *pDlg->GetOutputItemSet() );
     700         [ #  # ]:          0 :                 if( SFX_STYLE_FAMILY_CHAR == nFamily )
     701                 :            :                 {
     702                 :            :                     const SfxPoolItem *pTmpBrush;
     703         [ #  # ]:          0 :                     if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND,
     704         [ #  # ]:          0 :                         sal_False, &pTmpBrush ) )
     705                 :            :                     {
     706         [ #  # ]:          0 :                         SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
     707                 :          0 :                         aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
     708 [ #  # ][ #  # ]:          0 :                         aTmpSet.Put( aTmpBrush );
     709                 :            :                     }
     710         [ #  # ]:          0 :                     aTmpSet.ClearItem( RES_BACKGROUND );
     711                 :            :                 }
     712         [ #  # ]:          0 :                 xTmp->SetItemSet( aTmpSet );
     713                 :            : 
     714 [ #  # ][ #  # ]:          0 :                 if( SFX_STYLE_FAMILY_PAGE == nFamily && SvtLanguageOptions().IsCTLFontEnabled() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     715                 :            :                 {
     716                 :          0 :                     const SfxPoolItem *pItem = NULL;
     717 [ #  # ][ #  # ]:          0 :                     if( aTmpSet.GetItemState( GetPool().GetTrueWhich( SID_ATTR_FRAMEDIRECTION, sal_False ) , sal_True, &pItem ) == SFX_ITEM_SET )
                 [ #  # ]
     718         [ #  # ]:          0 :                         SwChartHelper::DoUpdateAllCharts( pDoc );
     719         [ #  # ]:          0 :                 }
     720                 :            :             }
     721         [ #  # ]:          0 :             if(SFX_STYLE_FAMILY_PAGE == nFamily)
     722         [ #  # ]:          0 :                 pView->InvalidateRulerPos();
     723                 :            : 
     724         [ #  # ]:          0 :             if( bNew )
     725 [ #  # ][ #  # ]:          0 :                 mxBasePool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *xTmp.get() ) );
                 [ #  # ]
     726                 :            : 
     727                 :            :             // Destroy dialog before EndAction - with page-templates the
     728                 :            :             // ItemSet must be destroyed, so that the cursors get removed
     729                 :            :             // from Headers/Footers. Otherwise "GPF" happen!!!
     730         [ #  # ]:          0 :             if(RET_OK == nButton)
     731 [ #  # ][ #  # ]:          0 :                 delete pDlg;
     732                 :            : 
     733         [ #  # ]:          0 :             pDoc->SetModified();
     734         [ #  # ]:          0 :             if( !bModified )    // Bug 57028
     735                 :            :             {
     736 [ #  # ][ #  # ]:          0 :                 pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
     737                 :            :             }
     738                 :            : 
     739         [ #  # ]:          0 :             GetWrtShell()->EndAllAction();
     740                 :            :         }
     741                 :            :         else
     742                 :            :         {
     743         [ #  # ]:          0 :             if( bNew )
     744                 :            :             {
     745         [ #  # ]:          0 :                 GetWrtShell()->Undo(1);
     746 [ #  # ][ #  # ]:          0 :                 pDoc->GetIDocumentUndoRedo().ClearRedo();
     747                 :            :             }
     748                 :            : 
     749         [ #  # ]:          0 :             if( !bModified )
     750         [ #  # ]:          0 :                 pDoc->ResetModified();
     751 [ #  # ][ #  # ]:          0 :             delete pDlg;
     752                 :            :         }
     753         [ #  # ]:          0 :             if(RET_APPLY_TEMPLATE != nButton)
     754                 :          0 :                 break;
     755                 :            :         }
     756                 :            :     }
     757                 :            :     else
     758                 :            :     {
     759                 :            :         // prior to the dialog the HtmlMode at the DocShell is being sunk
     760 [ #  # ][ #  # ]:          0 :         PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(this)));
         [ #  # ][ #  # ]
     761                 :            : 
     762         [ #  # ]:          0 :         GetWrtShell()->StartAllAction();
     763                 :            : 
     764                 :            :         // newly set the mask only with paragraph-templates
     765         [ #  # ]:          0 :         if( bNew )
     766                 :            :         {
     767                 :          0 :             nRet = SFX_STYLE_FAMILY_PARA == pStyle->GetFamily()
     768                 :          0 :                     ? xTmp->GetMask()
     769         [ #  # ]:          0 :                     : SFXSTYLEBIT_USERDEF;
     770                 :            :         }
     771         [ #  # ]:          0 :         else if( pStyle->GetMask() != xTmp->GetMask() )
     772                 :          0 :             nRet = xTmp->GetMask();
     773                 :            : 
     774         [ #  # ]:          0 :         if( SFX_STYLE_FAMILY_PARA == nFamily )
     775 [ #  # ][ #  # ]:          0 :             ::SfxToSwPageDescAttr( *GetWrtShell(), xTmp->GetItemSet() );
     776                 :            :         else
     777                 :            :         {
     778 [ #  # ][ #  # ]:          0 :             SfxItemSet aTmpSet( xTmp->GetItemSet() );
     779         [ #  # ]:          0 :             if( SFX_STYLE_FAMILY_CHAR == nFamily )
     780                 :            :             {
     781                 :            :                 const SfxPoolItem *pTmpBrush;
     782         [ #  # ]:          0 :                 if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND,
     783         [ #  # ]:          0 :                     sal_False, &pTmpBrush ) )
     784                 :            :                 {
     785         [ #  # ]:          0 :                     SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
     786                 :          0 :                     aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
     787 [ #  # ][ #  # ]:          0 :                     aTmpSet.Put( aTmpBrush );
     788                 :            :                 }
     789         [ #  # ]:          0 :                 aTmpSet.ClearItem( RES_BACKGROUND );
     790                 :            :             }
     791 [ #  # ][ #  # ]:          0 :             xTmp->SetItemSet( aTmpSet );
     792                 :            :         }
     793         [ #  # ]:          0 :         if(SFX_STYLE_FAMILY_PAGE == nFamily)
     794         [ #  # ]:          0 :             pView->InvalidateRulerPos();
     795                 :            : 
     796         [ #  # ]:          0 :         if( bNew )
     797 [ #  # ][ #  # ]:          0 :             mxBasePool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *xTmp.get() ) );
                 [ #  # ]
     798                 :            : 
     799         [ #  # ]:          0 :         pDoc->SetModified();
     800         [ #  # ]:          0 :         if( !bModified )        // Bug 57028
     801                 :            :         {
     802 [ #  # ][ #  # ]:          0 :             pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
     803                 :            :         }
     804         [ #  # ]:          0 :         GetWrtShell()->EndAllAction();
     805                 :            :     }
     806                 :            : 
     807                 :          0 :     return nRet;
     808                 :            : }
     809                 :            : 
     810                 :            : /*--------------------------------------------------------------------
     811                 :            :     Description:    Delete
     812                 :            :  --------------------------------------------------------------------*/
     813                 :            : 
     814                 :            : 
     815                 :          0 : sal_uInt16 SwDocShell::Delete(const String &rName, sal_uInt16 nFamily)
     816                 :            : {
     817                 :          0 :     SfxStyleSheetBase *pStyle = mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
     818                 :            : 
     819         [ #  # ]:          0 :     if(pStyle)
     820                 :            :     {
     821                 :            :         OSL_ENSURE(GetWrtShell(), "No Shell, no Styles");
     822                 :            : 
     823                 :          0 :         GetWrtShell()->StartAllAction();
     824                 :          0 :         mxBasePool->Remove(pStyle);
     825                 :          0 :         GetWrtShell()->EndAllAction();
     826                 :            : 
     827                 :          0 :         return sal_True;
     828                 :            :     }
     829                 :          0 :     return sal_False;
     830                 :            : }
     831                 :            : 
     832                 :            : /*--------------------------------------------------------------------
     833                 :            :     Description:    apply template
     834                 :            :  --------------------------------------------------------------------*/
     835                 :            : 
     836                 :            : 
     837                 :          0 : sal_uInt16 SwDocShell::ApplyStyles(const String &rName, sal_uInt16 nFamily,
     838                 :            :                                SwWrtShell* pShell, sal_uInt16 nMode )
     839                 :            : {
     840                 :            :     SwDocStyleSheet* pStyle =
     841                 :          0 :         (SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
     842                 :            : 
     843                 :            :     OSL_ENSURE(pStyle, "Where's the StyleSheet");
     844                 :            : 
     845         [ #  # ]:          0 :     if(!pStyle)
     846                 :          0 :         return sal_False;
     847                 :            : 
     848         [ #  # ]:          0 :     SwWrtShell *pSh = pShell ? pShell : GetWrtShell();
     849                 :            : 
     850                 :            :     OSL_ENSURE( pSh, "No Shell, no Styles");
     851                 :            : 
     852                 :          0 :     pSh->StartAllAction();
     853                 :            : 
     854   [ #  #  #  #  :          0 :     switch(nFamily)
                   #  # ]
     855                 :            :     {
     856                 :            :         case SFX_STYLE_FAMILY_CHAR:
     857                 :            :         {
     858 [ #  # ][ #  # ]:          0 :             SwFmtCharFmt aFmt(pStyle->GetCharFmt());
     859                 :            :             pSh->SetAttr( aFmt, (nMode & KEY_SHIFT) ?
     860 [ #  # ][ #  # ]:          0 :                 nsSetAttrMode::SETATTR_DONTREPLACE : nsSetAttrMode::SETATTR_DEFAULT );
     861         [ #  # ]:          0 :             break;
     862                 :            :         }
     863                 :            :         case SFX_STYLE_FAMILY_PARA:
     864                 :            :         {
     865                 :            :             // #i62675#
     866                 :            :             // clear also list attributes at affected text nodes, if paragraph
     867                 :            :             // style has the list style attribute set.
     868                 :          0 :             pSh->SetTxtFmtColl( pStyle->GetCollection(), true );
     869                 :          0 :             break;
     870                 :            :         }
     871                 :            :         case SFX_STYLE_FAMILY_FRAME:
     872                 :            :         {
     873         [ #  # ]:          0 :             if ( pSh->IsFrmSelected() )
     874                 :          0 :                 pSh->SetFrmFmt( pStyle->GetFrmFmt() );
     875                 :          0 :             break;
     876                 :            :         }
     877                 :            :         case SFX_STYLE_FAMILY_PAGE:
     878                 :            :         {
     879                 :          0 :             pSh->SetPageStyle(pStyle->GetPageDesc()->GetName());
     880                 :          0 :             break;
     881                 :            :         }
     882                 :            :         case SFX_STYLE_FAMILY_PSEUDO:
     883                 :            :         {
     884                 :            :             // reset indent attribute on applying list style
     885                 :            :             // continue list of list style
     886         [ #  # ]:          0 :             const SwNumRule* pNumRule = pStyle->GetNumRule();
     887         [ #  # ]:          0 :             const String sListIdForStyle =pNumRule->GetDefaultListId();
     888 [ #  # ][ #  # ]:          0 :             pSh->SetCurNumRule( *pNumRule, false, sListIdForStyle, true );
                 [ #  # ]
     889         [ #  # ]:          0 :             break;
     890                 :            :         }
     891                 :            :         default:
     892                 :            :             OSL_FAIL("Unknown family");
     893                 :            :     }
     894                 :          0 :     pSh->EndAllAction();
     895                 :            : 
     896                 :          0 :     return nFamily;
     897                 :            : }
     898                 :            : 
     899                 :            : /*--------------------------------------------------------------------
     900                 :            :     Description:    start watering-can
     901                 :            :  --------------------------------------------------------------------*/
     902                 :            : 
     903                 :            : 
     904                 :            : 
     905                 :          0 : sal_uInt16 SwDocShell::DoWaterCan(const String &rName, sal_uInt16 nFamily)
     906                 :            : {
     907                 :            :     OSL_ENSURE(GetWrtShell(), "No Shell, no Styles");
     908                 :            : 
     909                 :          0 :     SwEditWin& rEdtWin = pView->GetEditWin();
     910                 :          0 :     SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
     911 [ #  # ][ #  # ]:          0 :     sal_Bool bWaterCan = !(pApply && pApply->eType != 0);
     912                 :            : 
     913         [ #  # ]:          0 :     if( !rName.Len() )
     914                 :          0 :         bWaterCan = sal_False;
     915                 :            : 
     916                 :          0 :     SwApplyTemplate aTemplate;
     917                 :          0 :     aTemplate.eType = nFamily;
     918                 :            : 
     919         [ #  # ]:          0 :     if(bWaterCan)
     920                 :            :     {
     921                 :            :         SwDocStyleSheet* pStyle =
     922         [ #  # ]:          0 :             (SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
     923                 :            : 
     924                 :            :         OSL_ENSURE (pStyle, "Where's the StyleSheet");
     925                 :            : 
     926         [ #  # ]:          0 :         if(!pStyle) return nFamily;
     927                 :            : 
     928   [ #  #  #  #  :          0 :         switch(nFamily)
                   #  # ]
     929                 :            :         {
     930                 :            :             case SFX_STYLE_FAMILY_CHAR:
     931         [ #  # ]:          0 :                 aTemplate.aColl.pCharFmt = pStyle->GetCharFmt();
     932                 :          0 :                 break;
     933                 :            :             case SFX_STYLE_FAMILY_PARA:
     934         [ #  # ]:          0 :                 aTemplate.aColl.pTxtColl = pStyle->GetCollection();
     935                 :          0 :                 break;
     936                 :            :             case SFX_STYLE_FAMILY_FRAME:
     937         [ #  # ]:          0 :                 aTemplate.aColl.pFrmFmt = pStyle->GetFrmFmt();
     938                 :          0 :                 break;
     939                 :            :             case SFX_STYLE_FAMILY_PAGE:
     940         [ #  # ]:          0 :                 aTemplate.aColl.pPageDesc = (SwPageDesc*)pStyle->GetPageDesc();
     941                 :          0 :                 break;
     942                 :            :             case SFX_STYLE_FAMILY_PSEUDO:
     943         [ #  # ]:          0 :                 aTemplate.aColl.pNumRule = (SwNumRule*)pStyle->GetNumRule();
     944                 :          0 :                 break;
     945                 :            : 
     946                 :            :             default:
     947                 :            :                 OSL_FAIL("Unknown family");
     948                 :            :         }
     949                 :            :     }
     950                 :            :     else
     951                 :          0 :         aTemplate.eType = 0;
     952                 :            : 
     953         [ #  # ]:          0 :     pView->GetEditWin().SetApplyTemplate(aTemplate);
     954                 :            : 
     955                 :          0 :     return nFamily;
     956                 :            : }
     957                 :            : 
     958                 :            : /*--------------------------------------------------------------------
     959                 :            :     Description:    update template
     960                 :            :  --------------------------------------------------------------------*/
     961                 :            : 
     962                 :            : 
     963                 :          0 : sal_uInt16 SwDocShell::UpdateStyle(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell)
     964                 :            : {
     965         [ #  # ]:          0 :     SwWrtShell* pCurrWrtShell = pShell ? pShell : GetWrtShell();
     966                 :            :     OSL_ENSURE(GetWrtShell(), "No Shell, no Styles");
     967                 :            : 
     968                 :            :     SwDocStyleSheet* pStyle =
     969                 :          0 :         (SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
     970                 :            : 
     971         [ #  # ]:          0 :     if(!pStyle)
     972                 :          0 :         return nFamily;
     973                 :            : 
     974   [ #  #  #  #  :          0 :     switch(nFamily)
                      # ]
     975                 :            :     {
     976                 :            :         case SFX_STYLE_FAMILY_PARA:
     977                 :            :         {
     978                 :          0 :             SwTxtFmtColl* pColl = pStyle->GetCollection();
     979 [ #  # ][ #  # ]:          0 :             if(pColl && !pColl->IsDefault())
                 [ #  # ]
     980                 :            :             {
     981         [ #  # ]:          0 :                 GetWrtShell()->StartAllAction();
     982                 :            : 
     983         [ #  # ]:          0 :                 SwRewriter aRewriter;
     984         [ #  # ]:          0 :                 aRewriter.AddRule(UndoArg1, pColl->GetName());
     985                 :            : 
     986         [ #  # ]:          0 :                 GetWrtShell()->StartUndo(UNDO_INSFMTATTR, &aRewriter);
     987         [ #  # ]:          0 :                 GetWrtShell()->FillByEx(pColl);
     988                 :            :                     // also apply template to remove hard set attributes
     989         [ #  # ]:          0 :                 GetWrtShell()->SetTxtFmtColl( pColl );
     990         [ #  # ]:          0 :                 GetWrtShell()->EndUndo();
     991 [ #  # ][ #  # ]:          0 :                 GetWrtShell()->EndAllAction();
     992                 :            :             }
     993                 :          0 :             break;
     994                 :            :         }
     995                 :            :         case SFX_STYLE_FAMILY_FRAME:
     996                 :            :         {
     997                 :          0 :             SwFrmFmt* pFrm = pStyle->GetFrmFmt();
     998 [ #  # ][ #  # ]:          0 :             if( pCurrWrtShell->IsFrmSelected() && pFrm && !pFrm->IsDefault() )
         [ #  # ][ #  # ]
     999                 :            :             {
    1000         [ #  # ]:          0 :                 SfxItemSet aSet( GetPool(), aFrmFmtSetRange );
    1001         [ #  # ]:          0 :                 pCurrWrtShell->StartAllAction();
    1002         [ #  # ]:          0 :                 pCurrWrtShell->GetFlyFrmAttr( aSet );
    1003                 :            : 
    1004                 :            :                 // #i105535#
    1005                 :            :                 // no update of anchor attribute
    1006         [ #  # ]:          0 :                 aSet.ClearItem( RES_ANCHOR );
    1007                 :            : 
    1008         [ #  # ]:          0 :                 pFrm->SetFmtAttr( aSet );
    1009                 :            : 
    1010                 :            :                     // also apply template to remove hard set attributes
    1011         [ #  # ]:          0 :                 pCurrWrtShell->SetFrmFmt( pFrm, sal_True );
    1012 [ #  # ][ #  # ]:          0 :                 pCurrWrtShell->EndAllAction();
    1013                 :            :             }
    1014                 :            :         }
    1015                 :          0 :         break;
    1016                 :            :         case SFX_STYLE_FAMILY_CHAR:
    1017                 :            :         {
    1018                 :          0 :             SwCharFmt* pChar = pStyle->GetCharFmt();
    1019 [ #  # ][ #  # ]:          0 :             if( pChar && !pChar->IsDefault() )
                 [ #  # ]
    1020                 :            :             {
    1021                 :          0 :                 pCurrWrtShell->StartAllAction();
    1022                 :          0 :                 pCurrWrtShell->FillByEx(pChar);
    1023                 :            :                     // also apply template to remove hard set attributes
    1024                 :          0 :                 pCurrWrtShell->EndAllAction();
    1025                 :            :             }
    1026                 :            : 
    1027                 :            :         }
    1028                 :          0 :         break;
    1029                 :            :         case SFX_STYLE_FAMILY_PSEUDO:
    1030                 :            :         {
    1031                 :            :             const SwNumRule* pCurRule;
    1032 [ #  # ][ #  # ]:          0 :             if( pStyle->GetNumRule() &&
                 [ #  # ]
    1033                 :          0 :                 0 != ( pCurRule = pCurrWrtShell->GetCurNumRule() ))
    1034                 :            :             {
    1035         [ #  # ]:          0 :                 SwNumRule aRule( *pCurRule );
    1036                 :            :                 // #i91400#
    1037         [ #  # ]:          0 :                 aRule.SetName( pStyle->GetNumRule()->GetName(),
    1038         [ #  # ]:          0 :                                *(pCurrWrtShell->GetDoc()) );
    1039 [ #  # ][ #  # ]:          0 :                 pCurrWrtShell->ChgNumRuleFmts( aRule );
    1040                 :            :             }
    1041                 :            :         }
    1042                 :          0 :         break;
    1043                 :            :     }
    1044                 :          0 :     return nFamily;
    1045                 :            : }
    1046                 :            : 
    1047                 :            : /*--------------------------------------------------------------------
    1048                 :            :     Description:    NewByExample
    1049                 :            :  --------------------------------------------------------------------*/
    1050                 :            : 
    1051                 :            : 
    1052                 :          0 : sal_uInt16 SwDocShell::MakeByExample( const String &rName, sal_uInt16 nFamily,
    1053                 :            :                                     sal_uInt16 nMask, SwWrtShell* pShell )
    1054                 :            : {
    1055         [ #  # ]:          0 :     SwWrtShell* pCurrWrtShell = pShell ? pShell : GetWrtShell();
    1056                 :          0 :     SwDocStyleSheet* pStyle = (SwDocStyleSheet*)mxBasePool->Find(
    1057                 :          0 :                                             rName, (SfxStyleFamily)nFamily );
    1058         [ #  # ]:          0 :     if(!pStyle)
    1059                 :            :     {
    1060                 :            :         // preserve the current mask of PI, then the new one is
    1061                 :            :         // immediately merged with the viewable area
    1062 [ #  # ][ #  # ]:          0 :         if( SFXSTYLEBIT_ALL == nMask || SFXSTYLEBIT_USED == nMask )
    1063                 :          0 :             nMask = SFXSTYLEBIT_USERDEF;
    1064                 :            :         else
    1065                 :          0 :             nMask |= SFXSTYLEBIT_USERDEF;
    1066                 :            : 
    1067                 :          0 :         pStyle = (SwDocStyleSheet*)&mxBasePool->Make(rName,
    1068                 :          0 :                                 (SfxStyleFamily)nFamily, nMask );
    1069                 :            :     }
    1070                 :            : 
    1071   [ #  #  #  #  :          0 :     switch(nFamily)
                   #  # ]
    1072                 :            :     {
    1073                 :            :         case  SFX_STYLE_FAMILY_PARA:
    1074                 :            :         {
    1075                 :          0 :             SwTxtFmtColl* pColl = pStyle->GetCollection();
    1076 [ #  # ][ #  # ]:          0 :             if(pColl && !pColl->IsDefault())
                 [ #  # ]
    1077                 :            :             {
    1078                 :          0 :                 pCurrWrtShell->StartAllAction();
    1079                 :          0 :                 pCurrWrtShell->FillByEx(pColl);
    1080                 :            :                     // also apply template to remove hard set attributes
    1081                 :          0 :                 pColl->SetDerivedFrom(pCurrWrtShell->GetCurTxtFmtColl());
    1082                 :            : 
    1083                 :            :                     // set the mask at the Collection:
    1084                 :          0 :                 sal_uInt16 nId = pColl->GetPoolFmtId() & 0x87ff;
    1085   [ #  #  #  #  :          0 :                 switch( nMask & 0x0fff )
                #  #  # ]
    1086                 :            :                 {
    1087                 :            :                 case SWSTYLEBIT_TEXT:
    1088                 :          0 :                     nId |= COLL_TEXT_BITS;
    1089                 :          0 :                     break;
    1090                 :            :                 case SWSTYLEBIT_CHAPTER:
    1091                 :          0 :                     nId |= COLL_DOC_BITS;
    1092                 :          0 :                     break;
    1093                 :            :                 case SWSTYLEBIT_LIST:
    1094                 :          0 :                     nId |= COLL_LISTS_BITS;
    1095                 :          0 :                     break;
    1096                 :            :                 case SWSTYLEBIT_IDX:
    1097                 :          0 :                     nId |= COLL_REGISTER_BITS;
    1098                 :          0 :                     break;
    1099                 :            :                 case SWSTYLEBIT_EXTRA:
    1100                 :          0 :                     nId |= COLL_EXTRA_BITS;
    1101                 :          0 :                     break;
    1102                 :            :                 case SWSTYLEBIT_HTML:
    1103                 :          0 :                     nId |= COLL_HTML_BITS;
    1104                 :          0 :                     break;
    1105                 :            :                 }
    1106                 :          0 :                 pColl->SetPoolFmtId(nId);
    1107                 :            : 
    1108                 :          0 :                 pCurrWrtShell->SetTxtFmtColl(pColl);
    1109                 :          0 :                 pCurrWrtShell->EndAllAction();
    1110                 :            :             }
    1111                 :            :         }
    1112                 :          0 :         break;
    1113                 :            :         case SFX_STYLE_FAMILY_FRAME:
    1114                 :            :         {
    1115                 :          0 :             SwFrmFmt* pFrm = pStyle->GetFrmFmt();
    1116 [ #  # ][ #  # ]:          0 :             if(pCurrWrtShell->IsFrmSelected() && pFrm && !pFrm->IsDefault())
         [ #  # ][ #  # ]
    1117                 :            :             {
    1118         [ #  # ]:          0 :                 pCurrWrtShell->StartAllAction();
    1119                 :            : 
    1120         [ #  # ]:          0 :                 SfxItemSet aSet(GetPool(), aFrmFmtSetRange );
    1121         [ #  # ]:          0 :                 pCurrWrtShell->GetFlyFrmAttr( aSet );
    1122                 :            : 
    1123         [ #  # ]:          0 :                 SwFrmFmt* pFFmt = pCurrWrtShell->GetCurFrmFmt();
    1124         [ #  # ]:          0 :                 pFrm->SetDerivedFrom( pFFmt );
    1125                 :            : 
    1126         [ #  # ]:          0 :                 pFrm->SetFmtAttr( aSet );
    1127                 :            :                     // also apply template to remove hard set attributes
    1128         [ #  # ]:          0 :                 pCurrWrtShell->SetFrmFmt( pFrm );
    1129 [ #  # ][ #  # ]:          0 :                 pCurrWrtShell->EndAllAction();
    1130                 :            :             }
    1131                 :            :         }
    1132                 :          0 :         break;
    1133                 :            :         case SFX_STYLE_FAMILY_CHAR:
    1134                 :            :         {
    1135                 :          0 :             SwCharFmt* pChar = pStyle->GetCharFmt();
    1136 [ #  # ][ #  # ]:          0 :             if(pChar && !pChar->IsDefault())
                 [ #  # ]
    1137                 :            :             {
    1138         [ #  # ]:          0 :                 pCurrWrtShell->StartAllAction();
    1139         [ #  # ]:          0 :                 pCurrWrtShell->FillByEx( pChar );
    1140 [ #  # ][ #  # ]:          0 :                 pChar->SetDerivedFrom( pCurrWrtShell->GetCurCharFmt() );
    1141         [ #  # ]:          0 :                 SwFmtCharFmt aFmt( pChar );
    1142         [ #  # ]:          0 :                 pCurrWrtShell->SetAttr( aFmt );
    1143 [ #  # ][ #  # ]:          0 :                 pCurrWrtShell->EndAllAction();
    1144                 :            :             }
    1145                 :            :         }
    1146                 :          0 :         break;
    1147                 :            : 
    1148                 :            :         case SFX_STYLE_FAMILY_PAGE:
    1149                 :            :         {
    1150                 :          0 :             pCurrWrtShell->StartAllAction();
    1151                 :          0 :             sal_uInt16 nPgDsc = pCurrWrtShell->GetCurPageDesc();
    1152                 :          0 :             SwPageDesc& rSrc = (SwPageDesc&)pCurrWrtShell->GetPageDesc( nPgDsc );
    1153                 :          0 :             SwPageDesc& rDest = *(SwPageDesc*)pStyle->GetPageDesc();
    1154                 :            : 
    1155                 :          0 :             sal_uInt16 nPoolId = rDest.GetPoolFmtId();
    1156                 :          0 :             sal_uInt16 nHId = rDest.GetPoolHelpId();
    1157                 :          0 :             sal_uInt8 nHFId = rDest.GetPoolHlpFileId();
    1158                 :            : 
    1159                 :          0 :             pCurrWrtShell->GetDoc()->CopyPageDesc( rSrc, rDest );
    1160                 :            : 
    1161                 :            :             // PoolId must NEVER be copied!
    1162                 :          0 :             rDest.SetPoolFmtId( nPoolId );
    1163                 :          0 :             rDest.SetPoolHelpId( nHId );
    1164                 :          0 :             rDest.SetPoolHlpFileId( nHFId );
    1165                 :            : 
    1166                 :            :             // when Headers/Footers are created, there is no Undo anymore!
    1167                 :          0 :             pCurrWrtShell->GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
    1168                 :            : 
    1169                 :          0 :             pCurrWrtShell->EndAllAction();
    1170                 :            :         }
    1171                 :          0 :         break;
    1172                 :            : 
    1173                 :            :         case SFX_STYLE_FAMILY_PSEUDO:
    1174                 :            :         {
    1175         [ #  # ]:          0 :             pCurrWrtShell->StartAllAction();
    1176                 :            : 
    1177 [ #  # ][ #  # ]:          0 :             SwNumRule aRule( *pCurrWrtShell->GetCurNumRule() );
    1178         [ #  # ]:          0 :             String sOrigRule( aRule.GetName() );
    1179                 :            :             // #i91400#
    1180         [ #  # ]:          0 :             aRule.SetName( pStyle->GetNumRule()->GetName(),
    1181         [ #  # ]:          0 :                            *(pCurrWrtShell->GetDoc()) );
    1182         [ #  # ]:          0 :             pCurrWrtShell->ChgNumRuleFmts( aRule );
    1183                 :            : 
    1184         [ #  # ]:          0 :             pCurrWrtShell->ReplaceNumRule( sOrigRule, aRule.GetName() );
    1185                 :            : 
    1186                 :            : 
    1187 [ #  # ][ #  # ]:          0 :             pCurrWrtShell->EndAllAction();
                 [ #  # ]
    1188                 :            :         }
    1189                 :          0 :         break;
    1190                 :            :     }
    1191                 :          0 :     return nFamily;
    1192                 :            : }
    1193                 :            : 
    1194                 :          0 : void  SwDocShell::LoadStyles( SfxObjectShell& rSource )
    1195                 :            : {
    1196                 :          0 :     _LoadStyles(rSource, sal_False);
    1197                 :          0 : }
    1198                 :            : /* --------------------------------------------------
    1199                 :            :     bPreserveCurrentDocument determines whether SetFixFields() is called
    1200                 :            :     This call modifies the source document. This mustn't happen when the source
    1201                 :            :     is a document the user is working on.
    1202                 :            :     Calls of ::LoadStyles() normally use files especially loaded for the purpose
    1203                 :            :     of importing styles.
    1204                 :            :  --------------------------------------------------*/
    1205                 :          0 : void SwDocShell::_LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument )
    1206                 :            : {
    1207                 :            : /*  [Description]
    1208                 :            : 
    1209                 :            :     This method is called by SFx if Styles have to be reloaded from a
    1210                 :            :     document-template. Existing Styles should be overwritten by that.
    1211                 :            :     That's why the document has to be reformatted. Therefore applications
    1212                 :            :     will usually overload this method and call the baseclass' implementation
    1213                 :            :     in their implementation.
    1214                 :            : */
    1215                 :            :     // When the source is our document, we do the checking ourselves
    1216                 :            :     // (much quicker and doesn't use the crutch StxStylePool).
    1217         [ #  # ]:          0 :     if( rSource.ISA( SwDocShell ))
    1218                 :            :     {
    1219                 :            :         // in order for the Headers/Footers not to get the fixed content
    1220                 :            :         // of the template, update all the Source's
    1221                 :            :         // FixFields once.
    1222         [ #  # ]:          0 :         if(!bPreserveCurrentDocument)
    1223                 :          0 :             ((SwDocShell&)rSource).pDoc->SetFixFields(false, NULL);
    1224         [ #  # ]:          0 :         if( pWrtShell )
    1225                 :            :         {
    1226                 :          0 :             pWrtShell->StartAllAction();
    1227                 :          0 :             pDoc->ReplaceStyles( *((SwDocShell&)rSource).pDoc );
    1228                 :          0 :             pWrtShell->EndAllAction();
    1229                 :            :         }
    1230                 :            :         else
    1231                 :            :         {
    1232                 :          0 :             sal_Bool bModified = pDoc->IsModified();
    1233                 :          0 :             pDoc->ReplaceStyles( *((SwDocShell&)rSource).pDoc );
    1234 [ #  # ][ #  # ]:          0 :             if( !bModified && pDoc->IsModified() && !pView )
         [ #  # ][ #  # ]
    1235                 :            :             {
    1236                 :            :                 // the View is created later, but overwrites the Modify-Flag.
    1237                 :            :                 // Undo doesn't work anymore anyways.
    1238                 :          0 :                 pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
    1239                 :            :             }
    1240                 :            :         }
    1241                 :            :     }
    1242                 :            :     else
    1243                 :          0 :         SfxObjectShell::LoadStyles( rSource );
    1244                 :          0 : }
    1245                 :            : 
    1246                 :            : 
    1247                 :          0 : void SwDocShell::FormatPage( const String& rPage, sal_uInt16 nPageId, SwWrtShell*     pActShell )
    1248                 :            : {
    1249                 :          0 :     Edit( rPage, aEmptyStr, SFX_STYLE_FAMILY_PAGE, 0, sal_False, nPageId, pActShell);
    1250                 :          0 : }
    1251                 :            : 
    1252                 :          0 : Bitmap SwDocShell::GetStyleFamilyBitmap( SfxStyleFamily eFamily )
    1253                 :            : {
    1254         [ #  # ]:          0 :     if( SFX_STYLE_FAMILY_PSEUDO == eFamily )
    1255         [ #  # ]:          0 :         return Bitmap( SW_RES( BMP_STYLES_FAMILY_NUM ));
    1256                 :          0 :     return SfxObjectShell::GetStyleFamilyBitmap( eFamily );
    1257                 :            : }
    1258                 :            : 
    1259                 :            : 
    1260                 :            : 
    1261                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10