xref: /AOO42X/main/sw/source/ui/app/docst.cxx (revision d14fbfd3916e239ca4897a372da9c32221a6ed2b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/container/XNameAccess.hpp>
30 
31 #include <hintids.hxx>
32 #include <sfx2/app.hxx>
33 #include <svl/whiter.hxx>
34 #include <sfx2/templdlg.hxx>
35 #include <sfx2/tplpitem.hxx>
36 #include <sfx2/request.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <sfx2/newstyle.hxx>
39 #include <sfx2/printer.hxx>
40 #include <svl/macitem.hxx>
41 #include <editeng/brshitem.hxx>
42 #include <svl/stritem.hxx>
43 #include <svl/languageoptions.hxx>
44 #include <editeng/eeitem.hxx>
45 #include <svx/htmlmode.hxx>
46 #include <swmodule.hxx>
47 #include <wdocsh.hxx>
48 #include <fmtfsize.hxx>
49 #include <fchrfmt.hxx>
50 #include <svtools/htmlcfg.hxx>
51 #include <SwStyleNameMapper.hxx>
52 #include <SwRewriter.hxx>
53 #include <numrule.hxx>
54 #include <swundo.hxx>
55 
56 #include "view.hxx"
57 #include "wrtsh.hxx"
58 #include "docsh.hxx"
59 #include "uitool.hxx"
60 #include "cmdid.h"
61 #include "globals.hrc"
62 #include "viewopt.hxx"
63 #include <doc.hxx>
64 #include <IDocumentUndoRedo.hxx>
65 #include "swstyle.h"
66 #include "frmfmt.hxx"
67 #include "charfmt.hxx"
68 #include "poolfmt.hxx"
69 #include "pagedesc.hxx"
70 #include "docstyle.hxx"
71 #include "uiitems.hxx"
72 #include "fmtcol.hxx"
73 #include "frmmgr.hxx"       //SwFrmValid
74 #include "swevent.hxx"
75 #include "edtwin.hxx"
76 #include "unochart.hxx"
77 
78 #include "app.hrc"
79 #include <fmtui.hrc>
80 #include "swabstdlg.hxx"
81 // --> OD 2008-03-27 #refactorlists#
82 #include <list.hxx>
83 // <--
84 
85 #include <paratr.hxx>   //#outline level,add by zhaojianwei
86 
87 using namespace ::com::sun::star;
88 
89 /*--------------------------------------------------------------------
90     Beschreibung:
91  --------------------------------------------------------------------*/
92 
93 
94 void  SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh)
95 {
96     SfxWhichIter aIter(rSet);
97     sal_uInt16  nWhich  = aIter.FirstWhich();
98     sal_uInt16 nActualFamily = USHRT_MAX;
99 
100     SwWrtShell* pShell = pSh ? pSh : GetWrtShell();
101     if(!pShell)
102     {
103         while (nWhich)
104         {
105             rSet.DisableItem(nWhich);
106             nWhich = aIter.NextWhich();
107         }
108         return;
109     }
110     else
111     {
112         SfxViewFrame* pFrame = pShell->GetView().GetViewFrame();
113         const ISfxTemplateCommon* pCommon = SFX_APP()->GetCurrentTemplateCommon(pFrame->GetBindings());
114         if( pCommon )
115             nActualFamily = static_cast< sal_uInt16 >(pCommon->GetActualFamily());
116     }
117 
118     while (nWhich)
119     {
120         // aktuelle Vorlage zu jeder Familie ermitteln
121         //
122         String aName;
123         switch (nWhich)
124         {
125             case SID_STYLE_APPLY:
126             {//hier wird die Vorlage und ihre Familie an die StyleBox
127              //uebergeben, damit diese Familie angezeigt wird
128                 if(pShell->IsFrmSelected())
129                 {
130                     SwFrmFmt* pFmt = pShell->GetCurFrmFmt();
131                     if( pFmt )
132                         aName = pFmt->GetName();
133                 }
134                 else
135                 {
136                     SwTxtFmtColl* pColl = pShell->GetCurTxtFmtColl();
137                     if(pColl)
138                         aName = pColl->GetName();
139                 }
140                 rSet.Put(SfxTemplateItem(nWhich, aName));
141             }
142             break;
143             case SID_STYLE_FAMILY1:
144                 if( !pShell->IsFrmSelected() )
145                 {
146                     SwCharFmt* pFmt = pShell->GetCurCharFmt();
147                     if(pFmt)
148                         aName = pFmt->GetName();
149                     else
150                         aName = *SwStyleNameMapper::GetTextUINameArray()[
151                             RES_POOLCOLL_STANDARD - RES_POOLCOLL_TEXT_BEGIN ];
152                     rSet.Put(SfxTemplateItem(nWhich, aName));
153                 }
154                 break;
155 
156             case SID_STYLE_FAMILY2:
157                 if(!pShell->IsFrmSelected())
158                 {
159                     SwTxtFmtColl* pColl = pShell->GetCurTxtFmtColl();
160                     if(pColl)
161                         aName = pColl->GetName();
162 
163                     SfxTemplateItem aItem(nWhich, aName);
164 
165                     sal_uInt16 nMask = 0;
166                     if( pDoc->get(IDocumentSettingAccess::HTML_MODE) )
167                         nMask = SWSTYLEBIT_HTML;
168                     else
169                     {
170                         const int nSelection = pShell->GetFrmType(0,sal_True);
171                         if(pShell->GetCurTOX())
172                             nMask = SWSTYLEBIT_IDX  ;
173                         else if(nSelection & FRMTYPE_HEADER     ||
174                                 nSelection & FRMTYPE_FOOTER     ||
175                                 nSelection & FRMTYPE_TABLE      ||
176                                 nSelection & FRMTYPE_FLY_ANY    ||
177                                 nSelection & FRMTYPE_FOOTNOTE   ||
178                                 nSelection & FRMTYPE_FTNPAGE)
179                             nMask = SWSTYLEBIT_EXTRA;
180                         else
181                             nMask = SWSTYLEBIT_TEXT;
182                     }
183 
184                     aItem.SetValue(nMask);
185                     rSet.Put(aItem);
186                 }
187 
188                 break;
189 
190             case SID_STYLE_FAMILY3:
191 
192                 if( pDoc->get(IDocumentSettingAccess::HTML_MODE) )
193                     rSet.DisableItem( nWhich );
194                 else
195                 {
196                     SwFrmFmt* pFmt = pShell->GetCurFrmFmt();
197                     if(pFmt && pShell->IsFrmSelected())
198                     {
199                         aName = pFmt->GetName();
200                         rSet.Put(SfxTemplateItem(nWhich, aName));
201                     }
202                 }
203                 break;
204 
205             case SID_STYLE_FAMILY4:
206             {
207                 SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
208                 if( pDoc->get(IDocumentSettingAccess::HTML_MODE) && !pHtmlOpt->IsPrintLayoutExtension())
209                     rSet.DisableItem( nWhich );
210                 else
211                 {
212                     sal_uInt16 n = pShell->GetCurPageDesc( sal_False );
213                     if( n < pShell->GetPageDescCnt() )
214                         aName = pShell->GetPageDesc( n ).GetName();
215 
216                     rSet.Put(SfxTemplateItem(nWhich, aName));
217                 }
218             }
219             break;
220             case SID_STYLE_FAMILY5:
221                 {
222                     const SwNumRule* pRule = pShell->GetNumRuleAtCurrCrsrPos();
223                     if( pRule )
224                         aName = pRule->GetName();
225 
226                     rSet.Put(SfxTemplateItem(nWhich, aName));
227                 }
228                 break;
229 
230             case SID_STYLE_WATERCAN:
231             {
232                 SwEditWin& rEdtWin = pShell->GetView().GetEditWin();
233                 SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
234                 rSet.Put(SfxBoolItem(nWhich, pApply && pApply->eType != 0));
235             }
236             break;
237             case SID_STYLE_UPDATE_BY_EXAMPLE:
238                 if( pShell->IsFrmSelected()
239                         ? SFX_STYLE_FAMILY_FRAME != nActualFamily
240                         : ( SFX_STYLE_FAMILY_FRAME == nActualFamily ||
241                             SFX_STYLE_FAMILY_PAGE == nActualFamily ||
242                             (SFX_STYLE_FAMILY_PSEUDO == nActualFamily && !pShell->GetNumRuleAtCurrCrsrPos())) )
243                 {
244                     rSet.DisableItem( nWhich );
245                 }
246                 break;
247 
248             case SID_STYLE_NEW_BY_EXAMPLE:
249                 if( (pShell->IsFrmSelected()
250                         ? SFX_STYLE_FAMILY_FRAME != nActualFamily
251                         : SFX_STYLE_FAMILY_FRAME == nActualFamily) ||
252                     (SFX_STYLE_FAMILY_PSEUDO == nActualFamily && !pShell->GetNumRuleAtCurrCrsrPos()) )
253                 {
254                     rSet.DisableItem( nWhich );
255                 }
256                 break;
257 
258             default:
259                 DBG_ERROR( "Invalid SlotId");
260         }
261         nWhich = aIter.NextWhich();
262     }
263 }
264 
265 
266 /*--------------------------------------------------------------------
267     Beschreibung:   StyleSheet-Requeste auswerten
268  --------------------------------------------------------------------*/
269 
270 
271 void SwDocShell::ExecStyleSheet( SfxRequest& rReq )
272 {
273     sal_uInt16  nSlot   = rReq.GetSlot();
274     sal_uInt16  nRet    = 0xffff;
275 
276     const SfxItemSet* pArgs = rReq.GetArgs();
277     const SfxPoolItem* pItem;
278     SwWrtShell* pActShell = 0;
279     sal_Bool bSetReturn = sal_True;
280     switch (nSlot)
281     {
282     case SID_STYLE_NEW:
283         if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY,
284             sal_False, &pItem ))
285         {
286             const sal_uInt16 nFamily = ((const SfxUInt16Item*)pItem)->GetValue();
287 
288             String sName;
289             sal_uInt16 nMask = 0;
290             if( SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_NEW,
291                 sal_False, &pItem ))
292                 sName = ((const SfxStringItem*)pItem)->GetValue();
293             if( SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_MASK,
294                 sal_False, &pItem ))
295                 nMask = ((const SfxUInt16Item*)pItem)->GetValue();
296             String sParent;
297             if( SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_REFERENCE,
298                 sal_False, &pItem ))
299                 sParent = ((const SfxStringItem*)pItem)->GetValue();
300 
301             nRet = Edit( sName, sParent, nFamily, nMask, sal_True, 0, 0, rReq.IsAPI() );
302         }
303         break;
304 
305         case SID_STYLE_APPLY:
306             if( !pArgs )
307             {
308                 GetView()->GetViewFrame()->GetDispatcher()->Execute(SID_STYLE_DESIGNER, sal_False);
309                 break;
310             }
311             else
312             {
313                 // convert internal StyleName to DisplayName (slot implementation uses the latter)
314                 SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, sal_False );
315                 SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, sal_False );
316                 if ( pFamilyItem && pNameItem )
317                 {
318                     uno::Reference< style::XStyleFamiliesSupplier > xModel(GetModel(), uno::UNO_QUERY);
319                     try
320                     {
321                         uno::Reference< container::XNameAccess > xStyles;
322                         uno::Reference< container::XNameAccess > xCont = xModel->getStyleFamilies();
323                         xCont->getByName(pFamilyItem->GetValue()) >>= xStyles;
324                         uno::Reference< beans::XPropertySet > xInfo;
325                         xStyles->getByName( pNameItem->GetValue() ) >>= xInfo;
326                         ::rtl::OUString aUIName;
327                         xInfo->getPropertyValue( ::rtl::OUString::createFromAscii("DisplayName") ) >>= aUIName;
328                         if ( aUIName.getLength() )
329                             rReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aUIName ) );
330                     }
331                     catch( uno::Exception& )
332                     {
333                     }
334                 }
335             }
336 
337             // intentionally no break
338 
339         case SID_STYLE_EDIT:
340         case SID_STYLE_DELETE:
341         case SID_STYLE_WATERCAN:
342         case SID_STYLE_FAMILY:
343         case SID_STYLE_UPDATE_BY_EXAMPLE:
344         case SID_STYLE_NEW_BY_EXAMPLE:
345         {
346             String aParam;
347             sal_uInt16 nFamily = SFX_STYLE_FAMILY_PARA;
348             sal_uInt16 nMask = 0;
349 
350             if( !pArgs )
351             {
352                 nFamily = SFX_STYLE_FAMILY_PARA;
353 
354                 switch (nSlot)
355                 {
356                     case SID_STYLE_NEW_BY_EXAMPLE:
357                     {
358                         SfxNewStyleDlg *pDlg = new SfxNewStyleDlg( 0,
359                                                     *GetStyleSheetPool());
360                         if(RET_OK == pDlg->Execute())
361                         {
362                             aParam = pDlg->GetName();
363                             rReq.AppendItem(SfxStringItem(nSlot, aParam));
364                         }
365 
366                         delete pDlg;
367                     }
368                     break;
369 
370                     case SID_STYLE_UPDATE_BY_EXAMPLE:
371                     case SID_STYLE_EDIT:
372                     {
373                         SwTxtFmtColl* pColl = GetWrtShell()->GetCurTxtFmtColl();
374                         if(pColl)
375                         {
376                             aParam = pColl->GetName();
377                             rReq.AppendItem(SfxStringItem(nSlot, aParam));
378                         }
379                     }
380                     break;
381                 }
382             }
383             else
384             {
385                 ASSERT( pArgs->Count(), "SfxBug ItemSet ist leer");
386 
387                 SwWrtShell* pShell = GetWrtShell();
388                 if( SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem ))
389                     aParam = ((const SfxStringItem*)pItem)->GetValue();
390 
391                 if( SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_FAMILY,
392                     sal_False, &pItem ))
393                     nFamily = ((const SfxUInt16Item*)pItem)->GetValue();
394 
395                 if( SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_FAMILYNAME, sal_False, &pItem ))
396                 {
397                     String aFamily = ((const SfxStringItem*)pItem)->GetValue();
398                     if(aFamily.CompareToAscii("CharacterStyles") == COMPARE_EQUAL)
399                         nFamily = SFX_STYLE_FAMILY_CHAR;
400                     else
401                     if(aFamily.CompareToAscii("ParagraphStyles") == COMPARE_EQUAL)
402                         nFamily = SFX_STYLE_FAMILY_PARA;
403                     else
404                     if(aFamily.CompareToAscii("PageStyles") == COMPARE_EQUAL)
405                         nFamily = SFX_STYLE_FAMILY_PAGE;
406                     else
407                     if(aFamily.CompareToAscii("FrameStyles") == COMPARE_EQUAL)
408                         nFamily = SFX_STYLE_FAMILY_FRAME;
409                     else
410                     if(aFamily.CompareToAscii("NumberingStyles") == COMPARE_EQUAL)
411                         nFamily = SFX_STYLE_FAMILY_PSEUDO;
412                 }
413 
414                 if( SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_MASK,
415                     sal_False, &pItem ))
416                     nMask = ((const SfxUInt16Item*)pItem)->GetValue();
417                 if( SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_WRTSHELL,
418                     sal_False, &pItem ))
419                     pActShell = pShell = (SwWrtShell*)((SwPtrItem*)pItem)->GetValue();
420 
421                 if( nSlot == SID_STYLE_UPDATE_BY_EXAMPLE )
422                 {
423                     switch( nFamily )
424                     {
425                         case SFX_STYLE_FAMILY_PARA:
426                         {
427                             SwTxtFmtColl* pColl = pShell->GetCurTxtFmtColl();
428                             if(pColl)
429                                 aParam = pColl->GetName();
430                         }
431                         break;
432                         case SFX_STYLE_FAMILY_FRAME:
433                         {
434                             SwFrmFmt* pFrm = pWrtShell->GetCurFrmFmt();
435                             if( pFrm )
436                                 aParam = pFrm->GetName();
437                         }
438                         break;
439                         case SFX_STYLE_FAMILY_CHAR:
440                         {
441                             SwCharFmt* pChar = pWrtShell->GetCurCharFmt();
442                             if( pChar )
443                                 aParam = pChar->GetName();
444                         }
445                         break;
446                         case SFX_STYLE_FAMILY_PSEUDO:
447                         if(SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_UPD_BY_EX_NAME, sal_False, &pItem))
448                         {
449                             aParam = ((const SfxStringItem*)pItem)->GetValue();
450                         }
451                         break;
452                     }
453                     rReq.AppendItem(SfxStringItem(nSlot, aParam));
454                 }
455             }
456             if (aParam.Len() || nSlot == SID_STYLE_WATERCAN )
457             {
458                 switch(nSlot)
459                 {
460                     case SID_STYLE_EDIT:
461                         nRet = Edit(aParam, aEmptyStr, nFamily, nMask, sal_False, 0, pActShell );
462                         break;
463                     case SID_STYLE_DELETE:
464                         nRet = Delete(aParam, nFamily);
465                         break;
466                     case SID_STYLE_APPLY:
467                         // Shellwechsel in ApplyStyles
468                         nRet = ApplyStyles(aParam, nFamily, pActShell, rReq.GetModifier() );
469                         break;
470                     case SID_STYLE_WATERCAN:
471                         nRet = DoWaterCan(aParam, nFamily);
472                         break;
473                     case SID_STYLE_UPDATE_BY_EXAMPLE:
474                         nRet = UpdateStyle(aParam, nFamily, pActShell);
475                         break;
476                     case SID_STYLE_NEW_BY_EXAMPLE:
477                     {
478                         nRet = MakeByExample(aParam, nFamily, nMask, pActShell );
479                         SfxTemplateDialog* pDlg = SFX_APP()->GetTemplateDialog();
480 
481                         if(pDlg && pDlg->IsVisible())
482                             pDlg->Update();
483                     }
484                     break;
485 
486                     default:
487                         DBG_ERROR( "Falsche Slot-Id");
488                 }
489 
490                 rReq.Done();
491             }
492 
493             break;
494         }
495     }
496 
497     if(bSetReturn)
498     {
499         if(rReq.IsAPI()) // Basic bekommt nur sal_True oder sal_False
500             rReq.SetReturnValue(SfxUInt16Item(nSlot, nRet !=0));
501         else
502             rReq.SetReturnValue(SfxUInt16Item(nSlot, nRet));
503     }
504 
505 }
506 
507 /*--------------------------------------------------------------------
508     Beschreibung:   Edit
509  --------------------------------------------------------------------*/
510 
511 //UUUU
512 //#include <svx/svdmodel.hxx>
513 //#include <svx/drawitem.hxx>
514 
515 sal_uInt16 SwDocShell::Edit(
516     const String &rName,
517     const String &rParent,
518     const sal_uInt16 nFamily,
519     sal_uInt16 nMask,
520     const sal_Bool bNew,
521     const sal_uInt16 nSlot,
522     SwWrtShell* pActShell,
523     const sal_Bool bBasic )
524 {
525     ASSERT(GetWrtShell(), "Keine Shell, keine Styles");
526     SfxStyleSheetBase *pStyle = 0;
527 
528     sal_uInt16 nRet = nMask;
529     sal_Bool bModified = pDoc->IsModified();
530 
531     if( bNew )
532     {
533         if( SFXSTYLEBIT_ALL != nMask && SFXSTYLEBIT_USED != nMask )
534             nMask |= SFXSTYLEBIT_USERDEF;
535         else
536             nMask = SFXSTYLEBIT_USERDEF;
537 
538         pStyle = &mxBasePool->Make( rName, (SfxStyleFamily)nFamily, nMask );
539 
540         // die aktuellen als Parent setzen
541         SwDocStyleSheet* pDStyle = (SwDocStyleSheet*)pStyle;
542         switch( nFamily )
543         {
544             case SFX_STYLE_FAMILY_PARA:
545             {
546                 if(rParent.Len())
547                 {
548                     SwTxtFmtColl* pColl = pWrtShell->FindTxtFmtCollByName( rParent );
549                     if(!pColl)
550                     {
551                         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
552                         if(USHRT_MAX != nId)
553                             pColl =  pWrtShell->GetTxtCollFromPool( nId );
554                     }
555                     pDStyle->GetCollection()->SetDerivedFrom( pColl );
556                     pDStyle->PresetParent( rParent );
557 
558                     //#outline level,add by zhaojianwei
559                      /*When a new paragraph style is created based on a "to outline style
560                         assigned" paragraph style, the outline level attribute and the list
561                         style attribute of the new paragraph style have to be set to 0
562                         respectively "".*/
563                     if( pColl->IsAssignedToListLevelOfOutlineStyle())
564                     {
565                         SwNumRuleItem aItem(aEmptyStr);
566                         pDStyle->GetCollection()->SetFmtAttr( aItem );
567                         pDStyle->GetCollection()->SetAttrOutlineLevel( 0 );
568                     }
569                     //<-end,zhaojianwei
570 
571                 }
572                 else
573                 {
574                     SwTxtFmtColl* pColl = pWrtShell->GetCurTxtFmtColl();
575                     pDStyle->GetCollection()->SetDerivedFrom( pColl );
576                     if( pColl )
577                         pDStyle->PresetParent( pColl->GetName() );
578                 }
579             }
580             break;
581             case SFX_STYLE_FAMILY_CHAR:
582             {
583                 if(rParent.Len())
584                 {
585                     SwCharFmt* pCFmt = pWrtShell->FindCharFmtByName( rParent );
586                     if(!pCFmt)
587                     {
588                         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
589                         if(USHRT_MAX != nId)
590                             pCFmt =  pWrtShell->GetCharFmtFromPool( nId );
591                     }
592 
593                     pDStyle->GetCharFmt()->SetDerivedFrom( pCFmt );
594                     pDStyle->PresetParent( rParent );
595                 }
596                 else
597                 {
598                     SwCharFmt* pCFmt = pWrtShell->GetCurCharFmt();
599                     pDStyle->GetCharFmt()->SetDerivedFrom( pCFmt );
600                         if( pCFmt )
601                             pDStyle->PresetParent( pCFmt->GetName() );
602                 }
603             }
604             break;
605             case SFX_STYLE_FAMILY_FRAME :
606             {
607                 if(rParent.Len())
608                 {
609                     SwFrmFmt* pFFmt = pWrtShell->GetDoc()->FindFrmFmtByName( rParent );
610                     if(!pFFmt)
611                     {
612                         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT);
613                         if(USHRT_MAX != nId)
614                             pFFmt =  pWrtShell->GetFrmFmtFromPool( nId );
615                     }
616                     pDStyle->GetFrmFmt()->SetDerivedFrom( pFFmt );
617                     pDStyle->PresetParent( rParent );
618                 }
619             }
620             break;
621         }
622     }
623     else
624     {
625         pStyle = mxBasePool->Find( rName, (SfxStyleFamily)nFamily );
626         ASSERT(pStyle, "Vorlage nicht gefunden");
627     }
628 
629     if(!pStyle)
630         return sal_False;
631 
632     // Dialoge zusammenstoepseln
633     //
634     rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pStyle ) );
635     if( SFX_STYLE_FAMILY_PARA == nFamily )
636     {
637         SfxItemSet& rSet = xTmp->GetItemSet();
638         ::SwToSfxPageDescAttr( rSet );
639         // erstmal nur eine Null
640         rSet.Put(SwBackgroundDestinationItem(SID_PARA_BACKGRND_DESTINATION, 0));
641         // --> OD 2008-02-13 #newlistlevelattrs#
642         // merge list level indent attributes into the item set if needed
643         xTmp->MergeIndentAttrsOfListStyle( rSet );
644         // <--
645     }
646 /*  else if( SFX_STYLE_FAMILY_FRAME == nFamily )
647     {
648         // Auskommentiert wegen Bug #45776 (per default keine Breite&Groesse in Rahmenvorlagen)
649         SfxItemSet& rSet = aTmp.GetItemSet();
650         if( SFX_ITEM_SET != rSet.GetItemState( RES_FRM_SIZE ))
651         {
652             // dann sollten wir spaetesten hier eines anlegen
653             SwFrmValid aFrmDefValues;
654             rSet.Put( SwFmtFrmSize( ATT_VAR_SIZE, aFrmDefValues.nWidth,
655                                     aFrmDefValues.nHeight ));
656         }
657     }*/
658     else if( SFX_STYLE_FAMILY_CHAR == nFamily )
659     {
660         SfxItemSet& rSet = xTmp->GetItemSet();
661         const SfxPoolItem *pTmpBrush;
662         if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_BACKGROUND,
663             sal_True, &pTmpBrush ) )
664         {
665             SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
666             aTmpBrush.SetWhich( RES_BACKGROUND );
667             rSet.Put( aTmpBrush );
668         }
669     }
670     if (!bBasic)
671     {
672         //UUUU
673         //if(SFX_STYLE_FAMILY_FRAME == nFamily)
674         //{
675         //    //UUUU create needed items for XPropertyList entries from the DrawModel so that
676         //    // the Area TabPage can access them
677         //    SfxItemSet& rSet = xTmp->GetItemSet();
678         //    const SdrModel* pDrawModel = GetDoc()->GetDrawModel();
679         //
680         //    rSet.Put(SvxColorTableItem(pDrawModel->GetColorTableFromSdrModel(), SID_COLOR_TABLE));
681         //    rSet.Put(SvxGradientListItem(pDrawModel->GetGradientListFromSdrModel(), SID_GRADIENT_LIST));
682         //    rSet.Put(SvxHatchListItem(pDrawModel->GetHatchListFromSdrModel(), SID_HATCH_LIST));
683         //    rSet.Put(SvxBitmapListItem(pDrawModel->GetBitmapListFromSdrModel(), SID_BITMAP_LIST));
684         //}
685 
686         // vor dem Dialog wird der HtmlMode an der DocShell versenkt
687         sal_uInt16 nHtmlMode = ::GetHtmlMode(this);
688 
689         // In HTML mode, we do not always have a printer. In order to show
690         // the correct page size in the Format - Page dialog, we have to
691         // get one here.
692         SwWrtShell* pCurrShell = ( pActShell ? pActShell : pWrtShell );
693         if( ( HTMLMODE_ON & nHtmlMode ) &&
694             !pCurrShell->getIDocumentDeviceAccess()->getPrinter( false ) )
695             pCurrShell->InitPrt( pCurrShell->getIDocumentDeviceAccess()->getPrinter( true ) );
696 
697         PutItem(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
698         FieldUnit eMetric = ::GetDfltMetric(0 != (HTMLMODE_ON&nHtmlMode));
699         SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
700         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
701         DBG_ASSERT(pFact, "Dialogdiet fail!");
702         SfxAbstractTabDialog* pDlg = pFact->CreateTemplateDialog( DLG_TEMPLATE_BASE,
703                                                     0, *(xTmp.get()), nFamily, nSlot,
704                                                     pActShell ? pActShell : pWrtShell, bNew);
705         DBG_ASSERT(pDlg, "Dialogdiet fail!");
706         if(RET_OK == pDlg->Execute())
707         {
708             GetWrtShell()->StartAllAction();
709 
710             // nur bei Absatz-Vorlagen die Maske neu setzen
711             if( bNew )
712             {
713                 nRet = SFX_STYLE_FAMILY_PARA == pStyle->GetFamily()
714                         ? xTmp->GetMask()
715                         : SFXSTYLEBIT_USERDEF;
716             }
717             else if( pStyle->GetMask() != xTmp->GetMask() )
718                 nRet = xTmp->GetMask();
719 
720             if( SFX_STYLE_FAMILY_PARA == nFamily )
721             {
722                 SfxItemSet aSet( *pDlg->GetOutputItemSet() );
723                 ::SfxToSwPageDescAttr( *GetWrtShell(), aSet  );
724                 // --> OD 2008-02-12 #newlistlevelattrs#
725                 // reset indent attributes at paragraph style, if a list style
726                 // will be applied and no indent attributes will be applied.
727                 xTmp->SetItemSet( aSet, true );
728                 // <--
729             }
730             else
731             {
732                 if(SFX_STYLE_FAMILY_PAGE == nFamily)
733                 {
734                     static const sal_uInt16 aInval[] = {
735                         SID_IMAGE_ORIENTATION,
736                         SID_ATTR_CHAR_FONT,
737                         FN_INSERT_CTRL, FN_INSERT_OBJ_CTRL, 0};
738                     pView->GetViewFrame()->GetBindings().Invalidate(aInval);
739                 }
740                 SfxItemSet aTmpSet( *pDlg->GetOutputItemSet() );
741                 if( SFX_STYLE_FAMILY_CHAR == nFamily )
742                 {
743                     const SfxPoolItem *pTmpBrush;
744                     if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND,
745                         sal_False, &pTmpBrush ) )
746                     {
747                         SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
748                         aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
749                         aTmpSet.Put( aTmpBrush );
750                     }
751                     aTmpSet.ClearItem( RES_BACKGROUND );
752                 }
753 
754                 //UUUU
755                 if(bNew && SFX_STYLE_FAMILY_FRAME == nFamily)
756                 {
757                     // clear FillStyle so that it works as a derived attribute
758                     aTmpSet.ClearItem(XATTR_FILLSTYLE);
759                 }
760 
761                 xTmp->SetItemSet( aTmpSet );
762 
763                 if( SFX_STYLE_FAMILY_PAGE == nFamily && SvtLanguageOptions().IsCTLFontEnabled() )
764                 {
765                     const SfxPoolItem *pItem = NULL;
766                     if( aTmpSet.GetItemState( GetPool().GetTrueWhich( SID_ATTR_FRAMEDIRECTION, sal_False ) , sal_True, &pItem ) == SFX_ITEM_SET )
767                         SwChartHelper::DoUpdateAllCharts( pDoc );
768                 }
769             }
770             if(SFX_STYLE_FAMILY_PAGE == nFamily)
771                 pView->InvalidateRulerPos();
772 
773             if( bNew )
774                 mxBasePool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *xTmp.get() ) );
775 
776             // JP 19.09.97:
777             // Dialog vorm EndAction zerstoeren - bei Seitenvorlagen kann
778             // muss der ItemSet zerstoert werden, damit die Cursor aus den
779             // Kopf-/Fusszeilen entfernt werden. Sonst kommts zu GPFs!!!
780             delete pDlg;
781 
782             pDoc->SetModified();
783             if( !bModified )    // Bug 57028
784             {
785                 pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
786             }
787 
788             GetWrtShell()->EndAllAction();
789         }
790         else
791         {
792             if( bNew )
793             {
794                 // #116530#
795                 //pBasePool->Erase( &aTmp );
796                 GetWrtShell()->Undo(1);
797                 pDoc->GetIDocumentUndoRedo().ClearRedo();
798             }
799 
800             if( !bModified )
801                 pDoc->ResetModified();
802             delete pDlg;
803         }
804     }
805     else
806     {
807         // vor dem Dialog wird der HtmlMode an der DocShell versenkt
808         PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(this)));
809 
810         GetWrtShell()->StartAllAction();
811 
812         // nur bei Absatz-Vorlagen die Maske neu setzen
813         if( bNew )
814         {
815             nRet = SFX_STYLE_FAMILY_PARA == pStyle->GetFamily()
816                     ? xTmp->GetMask()
817                     : SFXSTYLEBIT_USERDEF;
818         }
819         else if( pStyle->GetMask() != xTmp->GetMask() )
820             nRet = xTmp->GetMask();
821 
822         if( SFX_STYLE_FAMILY_PARA == nFamily )
823             ::SfxToSwPageDescAttr( *GetWrtShell(), xTmp->GetItemSet() );
824         else
825         {
826             SfxItemSet aTmpSet( xTmp->GetItemSet() );
827             if( SFX_STYLE_FAMILY_CHAR == nFamily )
828             {
829                 const SfxPoolItem *pTmpBrush;
830                 if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND,
831                     sal_False, &pTmpBrush ) )
832                 {
833                     SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
834                     aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
835                     aTmpSet.Put( aTmpBrush );
836                 }
837                 aTmpSet.ClearItem( RES_BACKGROUND );
838             }
839             xTmp->SetItemSet( aTmpSet );
840         }
841         if(SFX_STYLE_FAMILY_PAGE == nFamily)
842             pView->InvalidateRulerPos();
843 
844         if( bNew )
845             mxBasePool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *xTmp.get() ) );
846 
847         pDoc->SetModified();
848         if( !bModified )        // Bug 57028
849         {
850             pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
851         }
852         GetWrtShell()->EndAllAction();
853     }
854 
855     return nRet;
856 }
857 
858 /*--------------------------------------------------------------------
859     Beschreibung:   Delete
860  --------------------------------------------------------------------*/
861 
862 
863 sal_uInt16 SwDocShell::Delete(const String &rName, sal_uInt16 nFamily)
864 {
865     SfxStyleSheetBase *pStyle = mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
866 
867     if(pStyle)
868     {
869         ASSERT(GetWrtShell(), "Keine Shell, keine Styles");
870 
871         GetWrtShell()->StartAllAction();
872         mxBasePool->Remove(pStyle);
873         GetWrtShell()->EndAllAction();
874 
875         return sal_True;
876     }
877     return sal_False;
878 }
879 
880 /*--------------------------------------------------------------------
881     Beschreibung:   Vorlage anwenden
882  --------------------------------------------------------------------*/
883 
884 
885 sal_uInt16 SwDocShell::ApplyStyles(
886     const String &rName,
887     const sal_uInt16 nFamily,
888     SwWrtShell* pShell,
889     const sal_uInt16 nMode )
890 {
891     SwDocStyleSheet* pStyle = (SwDocStyleSheet*) mxBasePool->Find( rName, (SfxStyleFamily) nFamily );
892 
893     ASSERT( pStyle, "Wo ist der StyleSheet" );
894     if ( !pStyle )
895         return sal_False;
896 
897     SwWrtShell *pSh = pShell ? pShell : GetWrtShell();
898 
899     ASSERT( pSh, "Keine Shell, keine Styles" );
900 
901     pSh->StartAllAction();
902 
903     switch (nFamily)
904     {
905     case SFX_STYLE_FAMILY_CHAR:
906     {
907         SwFmtCharFmt aFmt( pStyle->GetCharFmt() );
908         pSh->SetAttrItem( aFmt, ( nMode & KEY_SHIFT ) ? nsSetAttrMode::SETATTR_DONTREPLACE : nsSetAttrMode::SETATTR_DEFAULT );
909         break;
910     }
911     case SFX_STYLE_FAMILY_PARA:
912     {
913         // --> OD 2007-11-06 #i62675#
914         // clear also list attributes at affected text nodes, if paragraph
915         // style has the list style attribute set.
916         pSh->SetTxtFmtColl( pStyle->GetCollection(), true );
917         // <--
918         break;
919     }
920     case SFX_STYLE_FAMILY_FRAME:
921     {
922         if ( pSh->IsFrmSelected() )
923             pSh->SetFrmFmt( pStyle->GetFrmFmt() );
924         break;
925     }
926     case SFX_STYLE_FAMILY_PAGE:
927     {
928         pSh->SetPageStyle( pStyle->GetPageDesc()->GetName() );
929         break;
930     }
931 
932     case SFX_STYLE_FAMILY_PSEUDO:
933     {
934         // --> OD 2008-02-08 #newlistlevelattrs#
935         // reset indent attribute on applying list style
936         // --> OD 2008-03-17 #refactorlists#
937         // continue list of list style
938         const SwNumRule* pNumRule = pStyle->GetNumRule();
939         const String sListIdForStyle = pNumRule->GetDefaultListId();
940         pSh->SetCurNumRule( *pNumRule, false, sListIdForStyle, true );
941         // <--
942         break;
943     }
944 
945     default:
946         DBG_ERROR( "Unbekannte Familie" );
947     }
948     pSh->EndAllAction();
949 
950     return nFamily;
951 }
952 
953 /*--------------------------------------------------------------------
954     Beschreibung:   Giesskanne starten
955  --------------------------------------------------------------------*/
956 
957 
958 
959 sal_uInt16 SwDocShell::DoWaterCan(const String &rName, sal_uInt16 nFamily)
960 {
961     ASSERT(GetWrtShell(), "Keine Shell, keine Styles");
962 
963     SwEditWin& rEdtWin = pView->GetEditWin();
964     SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
965     sal_Bool bWaterCan = !(pApply && pApply->eType != 0);
966     if( !rName.Len() )
967         bWaterCan = sal_False;
968     SwApplyTemplate aTemplate;
969     aTemplate.eType = nFamily;
970 
971     if(bWaterCan)
972     {
973         SwDocStyleSheet* pStyle =
974             (SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
975 
976         ASSERT(pStyle, "Wo ist der StyleSheet");
977         if(!pStyle) return nFamily;
978 
979         switch(nFamily)
980         {
981             case SFX_STYLE_FAMILY_CHAR:
982                 aTemplate.aColl.pCharFmt = pStyle->GetCharFmt();
983                 break;
984             case SFX_STYLE_FAMILY_PARA:
985                 aTemplate.aColl.pTxtColl = pStyle->GetCollection();
986                 break;
987             case SFX_STYLE_FAMILY_FRAME:
988                 aTemplate.aColl.pFrmFmt = pStyle->GetFrmFmt();
989                 break;
990             case SFX_STYLE_FAMILY_PAGE:
991                 aTemplate.aColl.pPageDesc = (SwPageDesc*)pStyle->GetPageDesc();
992                 break;
993             case SFX_STYLE_FAMILY_PSEUDO:
994                 aTemplate.aColl.pNumRule = (SwNumRule*)pStyle->GetNumRule();
995                 break;
996 
997             default:
998                 DBG_ERROR( "Unbekannte Familie");
999         }
1000     }
1001     else
1002         aTemplate.eType = 0;
1003 
1004     // Template anwenden
1005     pView->GetEditWin().SetApplyTemplate(aTemplate);
1006 
1007     return nFamily;
1008 }
1009 
1010 /*--------------------------------------------------------------------
1011     Beschreibung:   Vorlage Updaten
1012  --------------------------------------------------------------------*/
1013 
1014 
1015 sal_uInt16 SwDocShell::UpdateStyle(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell)
1016 {
1017     SwWrtShell* pCurrWrtShell = pShell ? pShell : GetWrtShell();
1018     ASSERT(GetWrtShell(), "Keine Shell, keine Styles");
1019 
1020     SwDocStyleSheet* pStyle =
1021         (SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
1022 
1023     if(!pStyle)
1024         return nFamily;
1025 
1026     switch(nFamily)
1027     {
1028         case SFX_STYLE_FAMILY_PARA:
1029         {
1030             SwTxtFmtColl* pColl = pStyle->GetCollection();
1031             if(pColl && !pColl->IsDefault())
1032             {
1033                 GetWrtShell()->StartAllAction();
1034 
1035                 SwRewriter aRewriter;
1036                 aRewriter.AddRule(UNDO_ARG1, pColl->GetName());
1037 
1038                 GetWrtShell()->StartUndo(UNDO_INSFMTATTR, &aRewriter);
1039                 GetWrtShell()->FillByEx(pColl);
1040                     // Vorlage auch anwenden, um harte Attributierung
1041                     // zu entfernen
1042                 GetWrtShell()->SetTxtFmtColl( pColl );
1043                 GetWrtShell()->EndUndo();
1044                 GetWrtShell()->EndAllAction();
1045             }
1046             break;
1047         }
1048         case SFX_STYLE_FAMILY_FRAME:
1049         {
1050             SwFrmFmt* pFrm = pStyle->GetFrmFmt();
1051             if( pCurrWrtShell->IsFrmSelected() && pFrm && !pFrm->IsDefault() )
1052             {
1053                 SfxItemSet aSet( GetPool(), aFrmFmtSetRange );
1054                 pCurrWrtShell->StartAllAction();
1055                 pCurrWrtShell->GetFlyFrmAttr( aSet );
1056 
1057                 // --> OD 2009-12-28 #i105535#
1058                 // no update of anchor attribute
1059                 aSet.ClearItem( RES_ANCHOR );
1060                 // <--
1061 
1062                 pFrm->SetFmtAttr( aSet );
1063 
1064                     // Vorlage auch anwenden, um harte Attributierung
1065                     // zu entfernen
1066                 pCurrWrtShell->SetFrmFmt( pFrm, sal_True );
1067                 pCurrWrtShell->EndAllAction();
1068             }
1069         }
1070         break;
1071         case SFX_STYLE_FAMILY_CHAR:
1072         {
1073             SwCharFmt* pChar = pStyle->GetCharFmt();
1074             if( pChar && !pChar->IsDefault() )
1075             {
1076                 pCurrWrtShell->StartAllAction();
1077                 pCurrWrtShell->FillByEx(pChar);
1078                     // Vorlage auch anwenden, um harte Attributierung
1079                     // zu entfernen
1080                 pCurrWrtShell->EndAllAction();
1081             }
1082 
1083         }
1084         break;
1085         case SFX_STYLE_FAMILY_PSEUDO:
1086         {
1087             const SwNumRule* pCurRule;
1088             if( pStyle->GetNumRule() &&
1089                 0 != ( pCurRule = pCurrWrtShell->GetNumRuleAtCurrCrsrPos() ))
1090             {
1091                 SwNumRule aRule( *pCurRule );
1092                 // --> OD 2008-07-08 #i91400#
1093                 aRule.SetName( pStyle->GetNumRule()->GetName(),
1094                                *(pCurrWrtShell->GetDoc()) );
1095                 // <--
1096                 pCurrWrtShell->ChgNumRuleFmts( aRule );
1097             }
1098         }
1099         break;
1100     }
1101     return nFamily;
1102 }
1103 
1104 /*--------------------------------------------------------------------
1105     Beschreibung:   NewByExample
1106  --------------------------------------------------------------------*/
1107 
1108 
1109 sal_uInt16 SwDocShell::MakeByExample( const String &rName, sal_uInt16 nFamily,
1110                                     sal_uInt16 nMask, SwWrtShell* pShell )
1111 {
1112     SwWrtShell* pCurrWrtShell = pShell ? pShell : GetWrtShell();
1113     SwDocStyleSheet* pStyle = (SwDocStyleSheet*)mxBasePool->Find(
1114                                             rName, (SfxStyleFamily)nFamily );
1115     if(!pStyle)
1116     {
1117         // JP 07.07.95: behalte die akt. Maske vom PI bei, dadurch werden
1118         //              neue sofort in den sichtbaren Bereich einsortiert
1119         if( SFXSTYLEBIT_ALL == nMask || SFXSTYLEBIT_USED == nMask )
1120             nMask = SFXSTYLEBIT_USERDEF;
1121         else
1122             nMask |= SFXSTYLEBIT_USERDEF;
1123 
1124         pStyle = (SwDocStyleSheet*)&mxBasePool->Make(rName,
1125                                 (SfxStyleFamily)nFamily, nMask );
1126     }
1127 
1128     switch(nFamily)
1129     {
1130         case  SFX_STYLE_FAMILY_PARA:
1131         {
1132             SwTxtFmtColl* pColl = pStyle->GetCollection();
1133             if(pColl && !pColl->IsDefault())
1134             {
1135                 pCurrWrtShell->StartAllAction();
1136                 pCurrWrtShell->FillByEx(pColl);
1137                     // Vorlage auch anwenden, um harte Attributierung
1138                     // zu entfernen
1139                 pColl->SetDerivedFrom(pCurrWrtShell->GetCurTxtFmtColl());
1140 
1141                     // setze die Maske noch an der Collection:
1142                 sal_uInt16 nId = pColl->GetPoolFmtId() & 0x87ff;
1143                 switch( nMask & 0x0fff )
1144                 {
1145                 case SWSTYLEBIT_TEXT:
1146                     nId |= COLL_TEXT_BITS;
1147                     break;
1148                 case SWSTYLEBIT_CHAPTER:
1149                     nId |= COLL_DOC_BITS;
1150                     break;
1151                 case SWSTYLEBIT_LIST:
1152                     nId |= COLL_LISTS_BITS;
1153                     break;
1154                 case SWSTYLEBIT_IDX:
1155                     nId |= COLL_REGISTER_BITS;
1156                     break;
1157                 case SWSTYLEBIT_EXTRA:
1158                     nId |= COLL_EXTRA_BITS;
1159                     break;
1160                 case SWSTYLEBIT_HTML:
1161                     nId |= COLL_HTML_BITS;
1162                     break;
1163                 }
1164                 pColl->SetPoolFmtId(nId);
1165 
1166                 pCurrWrtShell->SetTxtFmtColl(pColl);
1167                 pCurrWrtShell->EndAllAction();
1168             }
1169         }
1170         break;
1171         case SFX_STYLE_FAMILY_FRAME:
1172         {
1173             SwFrmFmt* pFrm = pStyle->GetFrmFmt();
1174             if(pCurrWrtShell->IsFrmSelected() && pFrm && !pFrm->IsDefault())
1175             {
1176                 pCurrWrtShell->StartAllAction();
1177 
1178                 SfxItemSet aSet(GetPool(), aFrmFmtSetRange );
1179                 pCurrWrtShell->GetFlyFrmAttr( aSet );
1180 
1181                 SwFrmFmt* pFFmt = pCurrWrtShell->GetCurFrmFmt();
1182                 pFrm->SetDerivedFrom( pFFmt );
1183 
1184                 // JP 10.06.98: nur automatische Orientierungen uebernehmen
1185 /*              #61359# jetzt auch wieder alle Orientierungen
1186                 const SfxPoolItem* pItem;
1187                 if( SFX_ITEM_SET == aSet.GetItemState( RES_VERT_ORIENT,
1188                     sal_False, &pItem ) &&
1189                     text::VertOrientation::NONE == ((SwFmtVertOrient*)pItem)->GetVertOrient())
1190                     aSet.ClearItem( RES_VERT_ORIENT );
1191 
1192                 if( SFX_ITEM_SET == aSet.GetItemState( RES_HORI_ORIENT,
1193                     sal_False, &pItem ) &&
1194                     text::HoriOrientation::NONE == ((SwFmtHoriOrient*)pItem)->GetHoriOrient())
1195                     aSet.ClearItem( RES_HORI_ORIENT );
1196  */
1197 
1198                 pFrm->SetFmtAttr( aSet );
1199                     // Vorlage auch anwenden, um harte Attributierung
1200                     // zu entfernen
1201                 pCurrWrtShell->SetFrmFmt( pFrm );
1202                 pCurrWrtShell->EndAllAction();
1203             }
1204         }
1205         break;
1206         case SFX_STYLE_FAMILY_CHAR:
1207         {
1208             SwCharFmt* pChar = pStyle->GetCharFmt();
1209             if(pChar && !pChar->IsDefault())
1210             {
1211                 pCurrWrtShell->StartAllAction();
1212                 pCurrWrtShell->FillByEx( pChar );
1213                 pChar->SetDerivedFrom( pCurrWrtShell->GetCurCharFmt() );
1214                 SwFmtCharFmt aFmt( pChar );
1215                 pCurrWrtShell->SetAttrItem( aFmt );
1216                 pCurrWrtShell->EndAllAction();
1217             }
1218         }
1219         break;
1220 
1221         case SFX_STYLE_FAMILY_PAGE:
1222         {
1223             pCurrWrtShell->StartAllAction();
1224             sal_uInt16 nPgDsc = pCurrWrtShell->GetCurPageDesc();
1225             SwPageDesc& rSrc = (SwPageDesc&)pCurrWrtShell->GetPageDesc( nPgDsc );
1226             SwPageDesc& rDest = *(SwPageDesc*)pStyle->GetPageDesc();
1227 
1228             sal_uInt16 nPoolId = rDest.GetPoolFmtId();
1229             sal_uInt16 nHId = rDest.GetPoolHelpId();
1230             sal_uInt8 nHFId = rDest.GetPoolHlpFileId();
1231 
1232             pCurrWrtShell->GetDoc()->CopyPageDesc( rSrc, rDest );
1233 
1234             // PoolId darf NIE kopiert werden!
1235             rDest.SetPoolFmtId( nPoolId );
1236             rDest.SetPoolHelpId( nHId );
1237             rDest.SetPoolHlpFileId( nHFId );
1238 
1239             // werden Kopf-/Fusszeilen angelegt, so gibt es kein Undo mehr!
1240             pCurrWrtShell->GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
1241 
1242             pCurrWrtShell->EndAllAction();
1243         }
1244         break;
1245 
1246         case SFX_STYLE_FAMILY_PSEUDO:
1247         {
1248             pCurrWrtShell->StartAllAction();
1249 
1250             SwNumRule aRule( *pCurrWrtShell->GetNumRuleAtCurrCrsrPos() );
1251             String sOrigRule( aRule.GetName() );
1252             // --> OD 2008-07-08 #i91400#
1253             aRule.SetName( pStyle->GetNumRule()->GetName(),
1254                            *(pCurrWrtShell->GetDoc()) );
1255             // <--
1256             pCurrWrtShell->ChgNumRuleFmts( aRule );
1257 
1258             pCurrWrtShell->ReplaceNumRule( sOrigRule, aRule.GetName() );
1259 
1260 
1261             pCurrWrtShell->EndAllAction();
1262         }
1263         break;
1264     }
1265     return nFamily;
1266 }
1267 
1268 void  SwDocShell::LoadStyles( SfxObjectShell& rSource )
1269 {
1270     _LoadStyles(rSource, sal_False);
1271 }
1272 /* -----------------16.05.2003 15:45-----------------
1273     bPreserveCurrentDocument determines whether SetFixFields() is called
1274     This call modifies the source document. This mustn't happen when the source
1275     is a document the user is working on.
1276     Calls of ::LoadStyles() normally use files especially loaded for the purpose
1277     of importing styles.
1278  --------------------------------------------------*/
1279 void SwDocShell::_LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument )
1280 {
1281 /*  [Beschreibung]
1282 
1283     Diese Methode wird vom SFx gerufen, wenn aus einer Dokument-Vorlage
1284     Styles nachgeladen werden sollen. Bestehende Styles soll dabei
1285     "uberschrieben werden. Das Dokument mu"s daher neu formatiert werden.
1286     Daher werden die Applikationen in der Regel diese Methode "uberladen
1287     und in ihrer Implementierung die Implementierung der Basisklasse
1288     rufen.
1289 */
1290     // ist die Source unser Document, dann uebernehmen wir das
1291     // abpruefen selbst (wesentlich schneller und laeuft nicht ueber
1292     // die Kruecke SfxStylePool
1293     if( rSource.ISA( SwDocShell ))
1294     {
1295         //JP 28.05.99: damit die Kopf-/Fusszeilen nicht den fixen Inhalt
1296         //              der Vorlage erhalten, einmal alle FixFelder der
1297         //              Source aktualisieren
1298         if(!bPreserveCurrentDocument)
1299             ((SwDocShell&)rSource).pDoc->SetFixFields(false, NULL);
1300         if( pWrtShell )
1301         {
1302             pWrtShell->StartAllAction();
1303             pDoc->ReplaceStyles( *((SwDocShell&)rSource).pDoc );
1304             pWrtShell->EndAllAction();
1305         }
1306         else
1307         {
1308             sal_Bool bModified = pDoc->IsModified();
1309             pDoc->ReplaceStyles( *((SwDocShell&)rSource).pDoc );
1310             if( !bModified && pDoc->IsModified() && !pView )
1311             {
1312                 // die View wird spaeter angelegt, ueberschreibt aber das
1313                 // Modify-Flag. Per Undo ist sowieso nichts mehr zu machen
1314                 pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
1315             }
1316         }
1317     }
1318     else
1319         SfxObjectShell::LoadStyles( rSource );
1320 }
1321 
1322 
1323 void SwDocShell::FormatPage(
1324     const String& rPage,
1325     const sal_uInt16 nSlot,
1326     SwWrtShell& rActShell )
1327 {
1328     Edit( rPage, aEmptyStr, SFX_STYLE_FAMILY_PAGE, 0, sal_False, nSlot, &rActShell);
1329 }
1330 
1331 Bitmap SwDocShell::GetStyleFamilyBitmap( SfxStyleFamily eFamily, BmpColorMode eColorMode )
1332 {
1333     if( SFX_STYLE_FAMILY_PSEUDO == eFamily )
1334     {
1335         if ( eColorMode == BMP_COLOR_NORMAL )
1336             return Bitmap( SW_RES( BMP_STYLES_FAMILY_NUM ));
1337         else
1338             return Bitmap( SW_RES( BMP_STYLES_FAMILY_NUM_HC ));
1339     }
1340 
1341     return SfxObjectShell::GetStyleFamilyBitmap( eFamily, eColorMode );
1342 }
1343 
1344 
1345 
1346