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