xref: /trunk/main/sw/source/ui/app/docst.cxx (revision 34760e49)
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 
512 sal_uInt16 SwDocShell::Edit(
513     const String &rName,
514     const String &rParent,
515     const sal_uInt16 nFamily,
516     sal_uInt16 nMask,
517     const sal_Bool bNew,
518     const sal_uInt16 nSlot,
519     SwWrtShell* pActShell,
520     const sal_Bool bBasic )
521 {
522 	ASSERT(GetWrtShell(), "Keine Shell, keine Styles");
523 	SfxStyleSheetBase *pStyle = 0;
524 
525 	sal_uInt16 nRet = nMask;
526 	sal_Bool bModified = pDoc->IsModified();
527 
528 	if( bNew )
529 	{
530 		if( SFXSTYLEBIT_ALL != nMask && SFXSTYLEBIT_USED != nMask )
531 			nMask |= SFXSTYLEBIT_USERDEF;
532 		else
533 			nMask = SFXSTYLEBIT_USERDEF;
534 
535 		pStyle = &mxBasePool->Make( rName, (SfxStyleFamily)nFamily, nMask );
536 
537 		// die aktuellen als Parent setzen
538 		SwDocStyleSheet* pDStyle = (SwDocStyleSheet*)pStyle;
539 		switch( nFamily )
540 		{
541 			case SFX_STYLE_FAMILY_PARA:
542 			{
543 				if(rParent.Len())
544 				{
545 					SwTxtFmtColl* pColl = pWrtShell->FindTxtFmtCollByName( rParent );
546                     if(!pColl)
547                     {
548                         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
549                         if(USHRT_MAX != nId)
550                             pColl =  pWrtShell->GetTxtCollFromPool( nId );
551                     }
552 					pDStyle->GetCollection()->SetDerivedFrom( pColl );
553 					pDStyle->PresetParent( rParent );
554 
555 					//#outline level,add by zhaojianwei
556 					 /*When a new paragraph style is created based on a "to outline style
557 						assigned" paragraph style, the outline level attribute and the list
558 						style attribute of the new paragraph style have to be set to 0
559 						respectively "".*/
560 					if( pColl->IsAssignedToListLevelOfOutlineStyle())
561 					{
562 						SwNumRuleItem aItem(aEmptyStr);
563 						pDStyle->GetCollection()->SetFmtAttr( aItem );
564 						pDStyle->GetCollection()->SetAttrOutlineLevel( 0 );
565 					}
566 					//<-end,zhaojianwei
567 
568 				}
569 				else
570 				{
571 					SwTxtFmtColl* pColl = pWrtShell->GetCurTxtFmtColl();
572 					pDStyle->GetCollection()->SetDerivedFrom( pColl );
573 					if( pColl )
574 						pDStyle->PresetParent( pColl->GetName() );
575 				}
576 			}
577 			break;
578 			case SFX_STYLE_FAMILY_CHAR:
579 			{
580 				if(rParent.Len())
581 				{
582 					SwCharFmt* pCFmt = pWrtShell->FindCharFmtByName( rParent );
583                     if(!pCFmt)
584                     {
585                         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
586                         if(USHRT_MAX != nId)
587                             pCFmt =  pWrtShell->GetCharFmtFromPool( nId );
588                     }
589 
590 					pDStyle->GetCharFmt()->SetDerivedFrom( pCFmt );
591 					pDStyle->PresetParent( rParent );
592 				}
593 				else
594 				{
595 					SwCharFmt* pCFmt = pWrtShell->GetCurCharFmt();
596 					pDStyle->GetCharFmt()->SetDerivedFrom( pCFmt );
597 						if( pCFmt )
598 							pDStyle->PresetParent( pCFmt->GetName() );
599 				}
600 			}
601 			break;
602 			case SFX_STYLE_FAMILY_FRAME :
603 			{
604 				if(rParent.Len())
605 				{
606 					SwFrmFmt* pFFmt = pWrtShell->GetDoc()->FindFrmFmtByName( rParent );
607                     if(!pFFmt)
608                     {
609                         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT);
610                         if(USHRT_MAX != nId)
611                             pFFmt =  pWrtShell->GetFrmFmtFromPool( nId );
612                     }
613                     pDStyle->GetFrmFmt()->SetDerivedFrom( pFFmt );
614 					pDStyle->PresetParent( rParent );
615 				}
616 			}
617 			break;
618 		}
619 	}
620 	else
621 	{
622 		pStyle = mxBasePool->Find( rName, (SfxStyleFamily)nFamily );
623 		ASSERT(pStyle, "Vorlage nicht gefunden");
624 	}
625 
626 	if(!pStyle)
627 		return sal_False;
628 
629 	// Dialoge zusammenstoepseln
630 	//
631 	rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pStyle ) );
632 	if( SFX_STYLE_FAMILY_PARA == nFamily )
633 	{
634 		SfxItemSet& rSet = xTmp->GetItemSet();
635 		::SwToSfxPageDescAttr( rSet );
636 		// erstmal nur eine Null
637 		rSet.Put(SwBackgroundDestinationItem(SID_PARA_BACKGRND_DESTINATION, 0));
638         // --> OD 2008-02-13 #newlistlevelattrs#
639         // merge list level indent attributes into the item set if needed
640         xTmp->MergeIndentAttrsOfListStyle( rSet );
641         // <--
642 	}
643 /*	else if( SFX_STYLE_FAMILY_FRAME == nFamily )
644 	{
645 		// Auskommentiert wegen Bug #45776 (per default keine Breite&Groesse in Rahmenvorlagen)
646 		SfxItemSet& rSet = aTmp.GetItemSet();
647 		if( SFX_ITEM_SET != rSet.GetItemState( RES_FRM_SIZE ))
648 		{
649 			// dann sollten wir spaetesten hier eines anlegen
650 			SwFrmValid aFrmDefValues;
651 			rSet.Put( SwFmtFrmSize( ATT_VAR_SIZE, aFrmDefValues.nWidth,
652 									aFrmDefValues.nHeight ));
653 		}
654 	}*/
655 	else if( SFX_STYLE_FAMILY_CHAR == nFamily )
656 	{
657 		SfxItemSet& rSet = xTmp->GetItemSet();
658 		const SfxPoolItem *pTmpBrush;
659 		if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_BACKGROUND,
660 			sal_True, &pTmpBrush ) )
661 		{
662 			SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
663 			aTmpBrush.SetWhich( RES_BACKGROUND );
664 			rSet.Put( aTmpBrush );
665 		}
666 	}
667 	if (!bBasic)
668 	{
669 		// vor dem Dialog wird der HtmlMode an der DocShell versenkt
670 		sal_uInt16 nHtmlMode = ::GetHtmlMode(this);
671 
672         // In HTML mode, we do not always have a printer. In order to show
673         // the correct page size in the Format - Page dialog, we have to
674         // get one here.
675         SwWrtShell* pCurrShell = ( pActShell ? pActShell : pWrtShell );
676         if( ( HTMLMODE_ON & nHtmlMode ) &&
677             !pCurrShell->getIDocumentDeviceAccess()->getPrinter( false ) )
678             pCurrShell->InitPrt( pCurrShell->getIDocumentDeviceAccess()->getPrinter( true ) );
679 
680         PutItem(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
681         FieldUnit eMetric = ::GetDfltMetric(0 != (HTMLMODE_ON&nHtmlMode));
682         SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
683         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
684         DBG_ASSERT(pFact, "Dialogdiet fail!");
685         SfxAbstractTabDialog* pDlg = pFact->CreateTemplateDialog( DLG_TEMPLATE_BASE,
686                                                     0, *(xTmp.get()), nFamily, nSlot,
687                                                     pActShell ? pActShell : pWrtShell, bNew);
688         DBG_ASSERT(pDlg, "Dialogdiet fail!");
689 		if(RET_OK == pDlg->Execute())
690 		{
691 			GetWrtShell()->StartAllAction();
692 
693 			// nur bei Absatz-Vorlagen die Maske neu setzen
694 			if( bNew )
695 			{
696 				nRet = SFX_STYLE_FAMILY_PARA == pStyle->GetFamily()
697 						? xTmp->GetMask()
698 						: SFXSTYLEBIT_USERDEF;
699 			}
700 			else if( pStyle->GetMask() != xTmp->GetMask() )
701 				nRet = xTmp->GetMask();
702 
703 			if( SFX_STYLE_FAMILY_PARA == nFamily )
704 			{
705 				SfxItemSet aSet( *pDlg->GetOutputItemSet() );
706 				::SfxToSwPageDescAttr( *GetWrtShell(), aSet  );
707                 // --> OD 2008-02-12 #newlistlevelattrs#
708                 // reset indent attributes at paragraph style, if a list style
709                 // will be applied and no indent attributes will be applied.
710 				xTmp->SetItemSet( aSet, true );
711                 // <--
712 			}
713 			else
714 			{
715                 if(SFX_STYLE_FAMILY_PAGE == nFamily)
716                 {
717                     static const sal_uInt16 aInval[] = {
718                         SID_IMAGE_ORIENTATION,
719 						SID_ATTR_CHAR_FONT,
720 						FN_INSERT_CTRL, FN_INSERT_OBJ_CTRL, 0};
721                     pView->GetViewFrame()->GetBindings().Invalidate(aInval);
722                 }
723                 SfxItemSet aTmpSet( *pDlg->GetOutputItemSet() );
724 				if( SFX_STYLE_FAMILY_CHAR == nFamily )
725 				{
726 					const SfxPoolItem *pTmpBrush;
727 					if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND,
728 						sal_False, &pTmpBrush ) )
729 					{
730 						SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
731 						aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
732 						aTmpSet.Put( aTmpBrush );
733 					}
734 					aTmpSet.ClearItem( RES_BACKGROUND );
735 				}
736 				xTmp->SetItemSet( aTmpSet );
737 
738                 if( SFX_STYLE_FAMILY_PAGE == nFamily && SvtLanguageOptions().IsCTLFontEnabled() )
739                 {
740                     const SfxPoolItem *pItem = NULL;
741                     if( aTmpSet.GetItemState( GetPool().GetTrueWhich( SID_ATTR_FRAMEDIRECTION, sal_False ) , sal_True, &pItem ) == SFX_ITEM_SET )
742                         SwChartHelper::DoUpdateAllCharts( pDoc );
743                 }
744 			}
745 			if(SFX_STYLE_FAMILY_PAGE == nFamily)
746 				pView->InvalidateRulerPos();
747 
748 			if( bNew )
749 				mxBasePool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *xTmp.get() ) );
750 
751 			// JP 19.09.97:
752 			// Dialog vorm EndAction zerstoeren - bei Seitenvorlagen kann
753 			// muss der ItemSet zerstoert werden, damit die Cursor aus den
754 			// Kopf-/Fusszeilen entfernt werden. Sonst kommts zu GPFs!!!
755 			delete pDlg;
756 
757 			pDoc->SetModified();
758 			if( !bModified )	// Bug 57028
759             {
760                 pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
761             }
762 
763 			GetWrtShell()->EndAllAction();
764 		}
765 		else
766 		{
767 			if( bNew )
768             {
769                 // #116530#
770 				//pBasePool->Erase( &aTmp );
771                 GetWrtShell()->Undo(1);
772                 pDoc->GetIDocumentUndoRedo().ClearRedo();
773             }
774 
775 			if( !bModified )
776 				pDoc->ResetModified();
777 			delete pDlg;
778 		}
779 	}
780 	else
781 	{
782 		// vor dem Dialog wird der HtmlMode an der DocShell versenkt
783 		PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(this)));
784 
785 		GetWrtShell()->StartAllAction();
786 
787 		// nur bei Absatz-Vorlagen die Maske neu setzen
788 		if( bNew )
789 		{
790 			nRet = SFX_STYLE_FAMILY_PARA == pStyle->GetFamily()
791 					? xTmp->GetMask()
792 					: SFXSTYLEBIT_USERDEF;
793 		}
794 		else if( pStyle->GetMask() != xTmp->GetMask() )
795 			nRet = xTmp->GetMask();
796 
797 		if( SFX_STYLE_FAMILY_PARA == nFamily )
798 			::SfxToSwPageDescAttr( *GetWrtShell(), xTmp->GetItemSet() );
799 		else
800 		{
801 			SfxItemSet aTmpSet( xTmp->GetItemSet() );
802 			if( SFX_STYLE_FAMILY_CHAR == nFamily )
803 			{
804 				const SfxPoolItem *pTmpBrush;
805 				if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND,
806 					sal_False, &pTmpBrush ) )
807 				{
808 					SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
809 					aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
810 					aTmpSet.Put( aTmpBrush );
811 				}
812 				aTmpSet.ClearItem( RES_BACKGROUND );
813 			}
814 			xTmp->SetItemSet( aTmpSet );
815 		}
816 		if(SFX_STYLE_FAMILY_PAGE == nFamily)
817 			pView->InvalidateRulerPos();
818 
819 		if( bNew )
820 			mxBasePool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *xTmp.get() ) );
821 
822 		pDoc->SetModified();
823 		if( !bModified )		// Bug 57028
824         {
825             pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
826         }
827 		GetWrtShell()->EndAllAction();
828 	}
829 
830 	return nRet;
831 }
832 
833 /*--------------------------------------------------------------------
834 	Beschreibung:	Delete
835  --------------------------------------------------------------------*/
836 
837 
838 sal_uInt16 SwDocShell::Delete(const String &rName, sal_uInt16 nFamily)
839 {
840 	SfxStyleSheetBase *pStyle = mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
841 
842 	if(pStyle)
843 	{
844 		ASSERT(GetWrtShell(), "Keine Shell, keine Styles");
845 
846 		GetWrtShell()->StartAllAction();
847 		mxBasePool->Remove(pStyle);
848 		GetWrtShell()->EndAllAction();
849 
850 		return sal_True;
851 	}
852 	return sal_False;
853 }
854 
855 /*--------------------------------------------------------------------
856 	Beschreibung:	Vorlage anwenden
857  --------------------------------------------------------------------*/
858 
859 
860 sal_uInt16 SwDocShell::ApplyStyles(
861     const String &rName,
862     const sal_uInt16 nFamily,
863     SwWrtShell* pShell,
864     const sal_uInt16 nMode )
865 {
866     SwDocStyleSheet* pStyle = (SwDocStyleSheet*) mxBasePool->Find( rName, (SfxStyleFamily) nFamily );
867 
868     ASSERT( pStyle, "Wo ist der StyleSheet" );
869     if ( !pStyle )
870         return sal_False;
871 
872     SwWrtShell *pSh = pShell ? pShell : GetWrtShell();
873 
874     ASSERT( pSh, "Keine Shell, keine Styles" );
875 
876     pSh->StartAllAction();
877 
878     switch (nFamily)
879     {
880     case SFX_STYLE_FAMILY_CHAR:
881     {
882         SwFmtCharFmt aFmt( pStyle->GetCharFmt() );
883         pSh->SetAttrItem( aFmt, ( nMode & KEY_SHIFT ) ? nsSetAttrMode::SETATTR_DONTREPLACE : nsSetAttrMode::SETATTR_DEFAULT );
884         break;
885     }
886     case SFX_STYLE_FAMILY_PARA:
887     {
888         // --> OD 2007-11-06 #i62675#
889         // clear also list attributes at affected text nodes, if paragraph
890         // style has the list style attribute set.
891         pSh->SetTxtFmtColl( pStyle->GetCollection(), true );
892         // <--
893         break;
894     }
895     case SFX_STYLE_FAMILY_FRAME:
896     {
897         if ( pSh->IsFrmSelected() )
898             pSh->SetFrmFmt( pStyle->GetFrmFmt() );
899         break;
900     }
901     case SFX_STYLE_FAMILY_PAGE:
902     {
903         pSh->SetPageStyle( pStyle->GetPageDesc()->GetName() );
904         break;
905     }
906 
907     case SFX_STYLE_FAMILY_PSEUDO:
908     {
909         // --> OD 2008-02-08 #newlistlevelattrs#
910         // reset indent attribute on applying list style
911         // --> OD 2008-03-17 #refactorlists#
912         // continue list of list style
913         const SwNumRule* pNumRule = pStyle->GetNumRule();
914         const String sListIdForStyle = pNumRule->GetDefaultListId();
915         pSh->SetCurNumRule( *pNumRule, false, sListIdForStyle, true );
916         // <--
917         break;
918     }
919 
920     default:
921         DBG_ERROR( "Unbekannte Familie" );
922     }
923     pSh->EndAllAction();
924 
925     return nFamily;
926 }
927 
928 /*--------------------------------------------------------------------
929 	Beschreibung:	Giesskanne starten
930  --------------------------------------------------------------------*/
931 
932 
933 
934 sal_uInt16 SwDocShell::DoWaterCan(const String &rName, sal_uInt16 nFamily)
935 {
936 	ASSERT(GetWrtShell(), "Keine Shell, keine Styles");
937 
938 	SwEditWin& rEdtWin = pView->GetEditWin();
939 	SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
940 	sal_Bool bWaterCan = !(pApply && pApply->eType != 0);
941 	if( !rName.Len() )
942 		bWaterCan = sal_False;
943 	SwApplyTemplate aTemplate;
944 	aTemplate.eType = nFamily;
945 
946 	if(bWaterCan)
947 	{
948 		SwDocStyleSheet* pStyle =
949 			(SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
950 
951 		ASSERT(pStyle, "Wo ist der StyleSheet");
952 		if(!pStyle) return nFamily;
953 
954 		switch(nFamily)
955 		{
956 			case SFX_STYLE_FAMILY_CHAR:
957 				aTemplate.aColl.pCharFmt = pStyle->GetCharFmt();
958 				break;
959 			case SFX_STYLE_FAMILY_PARA:
960 				aTemplate.aColl.pTxtColl = pStyle->GetCollection();
961 				break;
962 			case SFX_STYLE_FAMILY_FRAME:
963 				aTemplate.aColl.pFrmFmt = pStyle->GetFrmFmt();
964 				break;
965 			case SFX_STYLE_FAMILY_PAGE:
966 				aTemplate.aColl.pPageDesc = (SwPageDesc*)pStyle->GetPageDesc();
967 				break;
968 			case SFX_STYLE_FAMILY_PSEUDO:
969 				aTemplate.aColl.pNumRule = (SwNumRule*)pStyle->GetNumRule();
970 				break;
971 
972 			default:
973 				DBG_ERROR( "Unbekannte Familie");
974 		}
975 	}
976 	else
977 		aTemplate.eType = 0;
978 
979 	// Template anwenden
980 	pView->GetEditWin().SetApplyTemplate(aTemplate);
981 
982 	return nFamily;
983 }
984 
985 /*--------------------------------------------------------------------
986 	Beschreibung:	Vorlage Updaten
987  --------------------------------------------------------------------*/
988 
989 
990 sal_uInt16 SwDocShell::UpdateStyle(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell)
991 {
992     SwWrtShell* pCurrWrtShell = pShell ? pShell : GetWrtShell();
993 	ASSERT(GetWrtShell(), "Keine Shell, keine Styles");
994 
995 	SwDocStyleSheet* pStyle =
996 		(SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
997 
998 	if(!pStyle)
999 		return nFamily;
1000 
1001 	switch(nFamily)
1002 	{
1003 		case SFX_STYLE_FAMILY_PARA:
1004 		{
1005 			SwTxtFmtColl* pColl = pStyle->GetCollection();
1006 			if(pColl && !pColl->IsDefault())
1007 			{
1008 				GetWrtShell()->StartAllAction();
1009 
1010                 SwRewriter aRewriter;
1011                 aRewriter.AddRule(UNDO_ARG1, pColl->GetName());
1012 
1013                 GetWrtShell()->StartUndo(UNDO_INSFMTATTR, &aRewriter);
1014 				GetWrtShell()->FillByEx(pColl);
1015 					// Vorlage auch anwenden, um harte Attributierung
1016 					// zu entfernen
1017 				GetWrtShell()->SetTxtFmtColl( pColl );
1018                 GetWrtShell()->EndUndo();
1019 				GetWrtShell()->EndAllAction();
1020 			}
1021 			break;
1022 		}
1023 		case SFX_STYLE_FAMILY_FRAME:
1024 		{
1025 			SwFrmFmt* pFrm = pStyle->GetFrmFmt();
1026             if( pCurrWrtShell->IsFrmSelected() && pFrm && !pFrm->IsDefault() )
1027 			{
1028 				SfxItemSet aSet( GetPool(), aFrmFmtSetRange );
1029                 pCurrWrtShell->StartAllAction();
1030                 pCurrWrtShell->GetFlyFrmAttr( aSet );
1031 
1032                 // --> OD 2009-12-28 #i105535#
1033                 // no update of anchor attribute
1034                 aSet.ClearItem( RES_ANCHOR );
1035                 // <--
1036 
1037                 pFrm->SetFmtAttr( aSet );
1038 
1039 					// Vorlage auch anwenden, um harte Attributierung
1040 					// zu entfernen
1041                 pCurrWrtShell->SetFrmFmt( pFrm, sal_True );
1042                 pCurrWrtShell->EndAllAction();
1043 			}
1044 		}
1045 		break;
1046 		case SFX_STYLE_FAMILY_CHAR:
1047 		{
1048 			SwCharFmt* pChar = pStyle->GetCharFmt();
1049 			if( pChar && !pChar->IsDefault() )
1050 			{
1051                 pCurrWrtShell->StartAllAction();
1052                 pCurrWrtShell->FillByEx(pChar);
1053 					// Vorlage auch anwenden, um harte Attributierung
1054 					// zu entfernen
1055                 pCurrWrtShell->EndAllAction();
1056 			}
1057 
1058 		}
1059 		break;
1060 		case SFX_STYLE_FAMILY_PSEUDO:
1061 		{
1062 			const SwNumRule* pCurRule;
1063 			if( pStyle->GetNumRule() &&
1064                 0 != ( pCurRule = pCurrWrtShell->GetNumRuleAtCurrCrsrPos() ))
1065 			{
1066 				SwNumRule aRule( *pCurRule );
1067                 // --> OD 2008-07-08 #i91400#
1068                 aRule.SetName( pStyle->GetNumRule()->GetName(),
1069                                *(pCurrWrtShell->GetDoc()) );
1070                 // <--
1071                 pCurrWrtShell->ChgNumRuleFmts( aRule );
1072 			}
1073 		}
1074 		break;
1075 	}
1076 	return nFamily;
1077 }
1078 
1079 /*--------------------------------------------------------------------
1080 	Beschreibung:	NewByExample
1081  --------------------------------------------------------------------*/
1082 
1083 
1084 sal_uInt16 SwDocShell::MakeByExample( const String &rName, sal_uInt16 nFamily,
1085 									sal_uInt16 nMask, SwWrtShell* pShell )
1086 {
1087     SwWrtShell* pCurrWrtShell = pShell ? pShell : GetWrtShell();
1088 	SwDocStyleSheet* pStyle = (SwDocStyleSheet*)mxBasePool->Find(
1089 											rName, (SfxStyleFamily)nFamily );
1090 	if(!pStyle)
1091 	{
1092 		// JP 07.07.95: behalte die akt. Maske vom PI bei, dadurch werden
1093 		//				neue sofort in den sichtbaren Bereich einsortiert
1094 		if( SFXSTYLEBIT_ALL == nMask || SFXSTYLEBIT_USED == nMask )
1095 			nMask = SFXSTYLEBIT_USERDEF;
1096 		else
1097 			nMask |= SFXSTYLEBIT_USERDEF;
1098 
1099 		pStyle = (SwDocStyleSheet*)&mxBasePool->Make(rName,
1100 								(SfxStyleFamily)nFamily, nMask );
1101 	}
1102 
1103 	switch(nFamily)
1104 	{
1105 		case  SFX_STYLE_FAMILY_PARA:
1106 		{
1107 			SwTxtFmtColl* pColl = pStyle->GetCollection();
1108 			if(pColl && !pColl->IsDefault())
1109 			{
1110                 pCurrWrtShell->StartAllAction();
1111                 pCurrWrtShell->FillByEx(pColl);
1112 					// Vorlage auch anwenden, um harte Attributierung
1113 					// zu entfernen
1114                 pColl->SetDerivedFrom(pCurrWrtShell->GetCurTxtFmtColl());
1115 
1116 					// setze die Maske noch an der Collection:
1117 				sal_uInt16 nId = pColl->GetPoolFmtId() & 0x87ff;
1118 				switch( nMask & 0x0fff )
1119 				{
1120 				case SWSTYLEBIT_TEXT:
1121 					nId |= COLL_TEXT_BITS;
1122 					break;
1123 				case SWSTYLEBIT_CHAPTER:
1124 					nId |= COLL_DOC_BITS;
1125 					break;
1126 				case SWSTYLEBIT_LIST:
1127 					nId |= COLL_LISTS_BITS;
1128 					break;
1129 				case SWSTYLEBIT_IDX:
1130 					nId |= COLL_REGISTER_BITS;
1131 					break;
1132 				case SWSTYLEBIT_EXTRA:
1133 					nId |= COLL_EXTRA_BITS;
1134 					break;
1135 				case SWSTYLEBIT_HTML:
1136 					nId |= COLL_HTML_BITS;
1137 					break;
1138 				}
1139 				pColl->SetPoolFmtId(nId);
1140 
1141                 pCurrWrtShell->SetTxtFmtColl(pColl);
1142                 pCurrWrtShell->EndAllAction();
1143 			}
1144 		}
1145 		break;
1146 		case SFX_STYLE_FAMILY_FRAME:
1147 		{
1148 			SwFrmFmt* pFrm = pStyle->GetFrmFmt();
1149             if(pCurrWrtShell->IsFrmSelected() && pFrm && !pFrm->IsDefault())
1150 			{
1151                 pCurrWrtShell->StartAllAction();
1152 
1153 				SfxItemSet aSet(GetPool(), aFrmFmtSetRange );
1154                 pCurrWrtShell->GetFlyFrmAttr( aSet );
1155 
1156                 SwFrmFmt* pFFmt = pCurrWrtShell->GetCurFrmFmt();
1157                 pFrm->SetDerivedFrom( pFFmt );
1158 
1159 				// JP 10.06.98: nur automatische Orientierungen uebernehmen
1160 /*				#61359# jetzt auch wieder alle Orientierungen
1161 				const SfxPoolItem* pItem;
1162 				if( SFX_ITEM_SET == aSet.GetItemState( RES_VERT_ORIENT,
1163 					sal_False, &pItem ) &&
1164                     text::VertOrientation::NONE == ((SwFmtVertOrient*)pItem)->GetVertOrient())
1165 					aSet.ClearItem( RES_VERT_ORIENT );
1166 
1167 				if( SFX_ITEM_SET == aSet.GetItemState( RES_HORI_ORIENT,
1168 					sal_False, &pItem ) &&
1169                     text::HoriOrientation::NONE == ((SwFmtHoriOrient*)pItem)->GetHoriOrient())
1170 					aSet.ClearItem( RES_HORI_ORIENT );
1171  */
1172 
1173                 pFrm->SetFmtAttr( aSet );
1174 					// Vorlage auch anwenden, um harte Attributierung
1175 					// zu entfernen
1176                 pCurrWrtShell->SetFrmFmt( pFrm );
1177                 pCurrWrtShell->EndAllAction();
1178 			}
1179 		}
1180 		break;
1181 		case SFX_STYLE_FAMILY_CHAR:
1182 		{
1183 			SwCharFmt* pChar = pStyle->GetCharFmt();
1184 			if(pChar && !pChar->IsDefault())
1185 			{
1186                 pCurrWrtShell->StartAllAction();
1187                 pCurrWrtShell->FillByEx( pChar );
1188                 pChar->SetDerivedFrom( pCurrWrtShell->GetCurCharFmt() );
1189 				SwFmtCharFmt aFmt( pChar );
1190                 pCurrWrtShell->SetAttrItem( aFmt );
1191                 pCurrWrtShell->EndAllAction();
1192 			}
1193 		}
1194 		break;
1195 
1196 		case SFX_STYLE_FAMILY_PAGE:
1197 		{
1198             pCurrWrtShell->StartAllAction();
1199             sal_uInt16 nPgDsc = pCurrWrtShell->GetCurPageDesc();
1200             SwPageDesc& rSrc = (SwPageDesc&)pCurrWrtShell->GetPageDesc( nPgDsc );
1201 			SwPageDesc& rDest = *(SwPageDesc*)pStyle->GetPageDesc();
1202 
1203 			sal_uInt16 nPoolId = rDest.GetPoolFmtId();
1204 			sal_uInt16 nHId = rDest.GetPoolHelpId();
1205 			sal_uInt8 nHFId = rDest.GetPoolHlpFileId();
1206 
1207             pCurrWrtShell->GetDoc()->CopyPageDesc( rSrc, rDest );
1208 
1209 			// PoolId darf NIE kopiert werden!
1210 			rDest.SetPoolFmtId( nPoolId );
1211 			rDest.SetPoolHelpId( nHId );
1212 			rDest.SetPoolHlpFileId( nHFId );
1213 
1214 			// werden Kopf-/Fusszeilen angelegt, so gibt es kein Undo mehr!
1215             pCurrWrtShell->GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
1216 
1217             pCurrWrtShell->EndAllAction();
1218 		}
1219 		break;
1220 
1221 		case SFX_STYLE_FAMILY_PSEUDO:
1222 		{
1223             pCurrWrtShell->StartAllAction();
1224 
1225             SwNumRule aRule( *pCurrWrtShell->GetNumRuleAtCurrCrsrPos() );
1226 			String sOrigRule( aRule.GetName() );
1227             // --> OD 2008-07-08 #i91400#
1228             aRule.SetName( pStyle->GetNumRule()->GetName(),
1229                            *(pCurrWrtShell->GetDoc()) );
1230             // <--
1231             pCurrWrtShell->ChgNumRuleFmts( aRule );
1232 
1233             pCurrWrtShell->ReplaceNumRule( sOrigRule, aRule.GetName() );
1234 
1235 
1236             pCurrWrtShell->EndAllAction();
1237 		}
1238 		break;
1239 	}
1240 	return nFamily;
1241 }
1242 
1243 void  SwDocShell::LoadStyles( SfxObjectShell& rSource )
1244 {
1245     _LoadStyles(rSource, sal_False);
1246 }
1247 /* -----------------16.05.2003 15:45-----------------
1248     bPreserveCurrentDocument determines whether SetFixFields() is called
1249     This call modifies the source document. This mustn't happen when the source
1250     is a document the user is working on.
1251     Calls of ::LoadStyles() normally use files especially loaded for the purpose
1252     of importing styles.
1253  --------------------------------------------------*/
1254 void SwDocShell::_LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument )
1255 {
1256 /*	[Beschreibung]
1257 
1258 	Diese Methode wird vom SFx gerufen, wenn aus einer Dokument-Vorlage
1259 	Styles nachgeladen werden sollen. Bestehende Styles soll dabei
1260 	"uberschrieben werden. Das Dokument mu"s daher neu formatiert werden.
1261 	Daher werden die Applikationen in der Regel diese Methode "uberladen
1262 	und in ihrer Implementierung die Implementierung der Basisklasse
1263 	rufen.
1264 */
1265 	// ist die Source unser Document, dann uebernehmen wir das
1266 	// abpruefen selbst (wesentlich schneller und laeuft nicht ueber
1267 	// die Kruecke SfxStylePool
1268 	if( rSource.ISA( SwDocShell ))
1269 	{
1270 		//JP 28.05.99: damit die Kopf-/Fusszeilen nicht den fixen Inhalt
1271 		// 				der Vorlage erhalten, einmal alle FixFelder der
1272 		//				Source aktualisieren
1273         if(!bPreserveCurrentDocument)
1274             ((SwDocShell&)rSource).pDoc->SetFixFields(false, NULL);
1275 		if( pWrtShell )
1276 		{
1277 			pWrtShell->StartAllAction();
1278 			pDoc->ReplaceStyles( *((SwDocShell&)rSource).pDoc );
1279 			pWrtShell->EndAllAction();
1280 		}
1281 		else
1282 		{
1283 			sal_Bool bModified = pDoc->IsModified();
1284 			pDoc->ReplaceStyles( *((SwDocShell&)rSource).pDoc );
1285 			if( !bModified && pDoc->IsModified() && !pView )
1286 			{
1287 				// die View wird spaeter angelegt, ueberschreibt aber das
1288 				// Modify-Flag. Per Undo ist sowieso nichts mehr zu machen
1289                 pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
1290             }
1291         }
1292     }
1293 	else
1294 		SfxObjectShell::LoadStyles( rSource );
1295 }
1296 
1297 
1298 void SwDocShell::FormatPage(
1299     const String& rPage,
1300     const sal_uInt16 nSlot,
1301     SwWrtShell& rActShell )
1302 {
1303     Edit( rPage, aEmptyStr, SFX_STYLE_FAMILY_PAGE, 0, sal_False, nSlot, &rActShell);
1304 }
1305 
1306 Bitmap SwDocShell::GetStyleFamilyBitmap( SfxStyleFamily eFamily, BmpColorMode eColorMode )
1307 {
1308 	if( SFX_STYLE_FAMILY_PSEUDO == eFamily )
1309 	{
1310 		if ( eColorMode == BMP_COLOR_NORMAL )
1311 			return Bitmap( SW_RES( BMP_STYLES_FAMILY_NUM ));
1312 		else
1313 			return Bitmap( SW_RES( BMP_STYLES_FAMILY_NUM_HC ));
1314 	}
1315 
1316 	return SfxObjectShell::GetStyleFamilyBitmap( eFamily, eColorMode );
1317 }
1318 
1319 
1320 
1321