1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docst.cxx,v $
10 * $Revision: 1.36.136.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/container/XNameAccess.hpp>
37 #include <hintids.hxx>
38 #include <sfx2/app.hxx>
39 #include <svtools/whiter.hxx>
40 #include <sfx2/templdlg.hxx>
41 #include <sfx2/tplpitem.hxx>
42 #include <sfx2/request.hxx>
43 #include <sfx2/dispatch.hxx>
44 #include <sfx2/newstyle.hxx>
45 #include <svtools/macitem.hxx>
46 #include <svx/brshitem.hxx>
47 #include <svtools/stritem.hxx>
48 #include <svtools/languageoptions.hxx>
49 #include <svx/eeitem.hxx>
50 #include <svx/htmlmode.hxx>
51 #include <swmodule.hxx>
53 #include <fmtfsize.hxx>
54 #include <fchrfmt.hxx>
55 #include <svx/htmlcfg.hxx>
56 #include <SwStyleNameMapper.hxx>
65 #include "globals.hrc"
66 #include "viewopt.hxx"
70 #include "charfmt.hxx"
71 #include "poolfmt.hxx"
72 #include "pagedesc.hxx"
73 #include "docstyle.hxx"
74 #include "uiitems.hxx"
76 #include "frmmgr.hxx" //SwFrmValid
77 #include "swevent.hxx"
79 #include "unochart.hxx"
83 #include "swabstdlg.hxx"
84 // --> OD 2008-03-27 #refactorlists#
88 #include <paratr.hxx> //#outline level,add by zhaojianwei
90 using namespace ::com::sun::star
;
92 /*--------------------------------------------------------------------
94 --------------------------------------------------------------------*/
97 void SwDocShell::StateStyleSheet(SfxItemSet
& rSet
, SwWrtShell
* pSh
)
99 SfxWhichIter
aIter(rSet
);
100 USHORT nWhich
= aIter
.FirstWhich();
101 USHORT nActualFamily
= USHRT_MAX
;
103 SwWrtShell
* pShell
= pSh
? pSh
: GetWrtShell();
108 rSet
.DisableItem(nWhich
);
109 nWhich
= aIter
.NextWhich();
115 SfxViewFrame
* pFrame
= pShell
->GetView().GetViewFrame();
116 const ISfxTemplateCommon
* pCommon
= SFX_APP()->GetCurrentTemplateCommon(pFrame
->GetBindings());
118 nActualFamily
= static_cast< USHORT
>(pCommon
->GetActualFamily());
123 // aktuelle Vorlage zu jeder Familie ermitteln
128 case SID_STYLE_APPLY
:
129 {//hier wird die Vorlage und ihre Familie an die StyleBox
130 //uebergeben, damit diese Familie angezeigt wird
131 if(pShell
->IsFrmSelected())
133 SwFrmFmt
* pFmt
= pShell
->GetCurFrmFmt();
135 aName
= pFmt
->GetName();
139 SwTxtFmtColl
* pColl
= pShell
->GetCurTxtFmtColl();
141 aName
= pColl
->GetName();
143 rSet
.Put(SfxTemplateItem(nWhich
, aName
));
146 case SID_STYLE_FAMILY1
:
147 if( !pShell
->IsFrmSelected() )
149 SwCharFmt
* pFmt
= pShell
->GetCurCharFmt();
151 aName
= pFmt
->GetName();
153 aName
= *SwStyleNameMapper::GetTextUINameArray()[
154 RES_POOLCOLL_STANDARD
- RES_POOLCOLL_TEXT_BEGIN
];
155 rSet
.Put(SfxTemplateItem(nWhich
, aName
));
159 case SID_STYLE_FAMILY2
:
160 if(!pShell
->IsFrmSelected())
162 SwTxtFmtColl
* pColl
= pShell
->GetCurTxtFmtColl();
164 aName
= pColl
->GetName();
166 SfxTemplateItem
aItem(nWhich
, aName
);
169 if( pDoc
->get(IDocumentSettingAccess::HTML_MODE
) )
170 nMask
= SWSTYLEBIT_HTML
;
173 const int nSelection
= pShell
->GetFrmType(0,TRUE
);
174 if(pShell
->GetCurTOX())
175 nMask
= SWSTYLEBIT_IDX
;
176 else if(nSelection
& FRMTYPE_HEADER
||
177 nSelection
& FRMTYPE_FOOTER
||
178 nSelection
& FRMTYPE_TABLE
||
179 nSelection
& FRMTYPE_FLY_ANY
||
180 nSelection
& FRMTYPE_FOOTNOTE
||
181 nSelection
& FRMTYPE_FTNPAGE
)
182 nMask
= SWSTYLEBIT_EXTRA
;
184 nMask
= SWSTYLEBIT_TEXT
;
187 aItem
.SetValue(nMask
);
193 case SID_STYLE_FAMILY3
:
195 if( pDoc
->get(IDocumentSettingAccess::HTML_MODE
) )
196 rSet
.DisableItem( nWhich
);
199 SwFrmFmt
* pFmt
= pShell
->GetCurFrmFmt();
200 if(pFmt
&& pShell
->IsFrmSelected())
202 aName
= pFmt
->GetName();
203 rSet
.Put(SfxTemplateItem(nWhich
, aName
));
208 case SID_STYLE_FAMILY4
:
210 SvxHtmlOptions
* pHtmlOpt
= SvxHtmlOptions::Get();
211 if( pDoc
->get(IDocumentSettingAccess::HTML_MODE
) && !pHtmlOpt
->IsPrintLayoutExtension())
212 rSet
.DisableItem( nWhich
);
215 USHORT n
= pShell
->GetCurPageDesc( FALSE
);
216 if( n
< pShell
->GetPageDescCnt() )
217 aName
= pShell
->GetPageDesc( n
).GetName();
219 rSet
.Put(SfxTemplateItem(nWhich
, aName
));
223 case SID_STYLE_FAMILY5
:
225 const SwNumRule
* pRule
= pShell
->GetCurNumRule();
227 aName
= pRule
->GetName();
229 rSet
.Put(SfxTemplateItem(nWhich
, aName
));
233 case SID_STYLE_WATERCAN
:
235 SwEditWin
& rEdtWin
= pShell
->GetView().GetEditWin();
236 SwApplyTemplate
* pApply
= rEdtWin
.GetApplyTemplate();
237 rSet
.Put(SfxBoolItem(nWhich
, pApply
&& pApply
->eType
!= 0));
240 case SID_STYLE_UPDATE_BY_EXAMPLE
:
241 if( pShell
->IsFrmSelected()
242 ? SFX_STYLE_FAMILY_FRAME
!= nActualFamily
243 : ( SFX_STYLE_FAMILY_FRAME
== nActualFamily
||
244 SFX_STYLE_FAMILY_PAGE
== nActualFamily
||
245 (SFX_STYLE_FAMILY_PSEUDO
== nActualFamily
&& !pShell
->GetCurNumRule())) )
247 rSet
.DisableItem( nWhich
);
251 case SID_STYLE_NEW_BY_EXAMPLE
:
252 if( (pShell
->IsFrmSelected()
253 ? SFX_STYLE_FAMILY_FRAME
!= nActualFamily
254 : SFX_STYLE_FAMILY_FRAME
== nActualFamily
) ||
255 (SFX_STYLE_FAMILY_PSEUDO
== nActualFamily
&& !pShell
->GetCurNumRule()) )
257 rSet
.DisableItem( nWhich
);
262 DBG_ERROR( "Invalid SlotId");
264 nWhich
= aIter
.NextWhich();
269 /*--------------------------------------------------------------------
270 Beschreibung: StyleSheet-Requeste auswerten
271 --------------------------------------------------------------------*/
274 void SwDocShell::ExecStyleSheet( SfxRequest
& rReq
)
276 USHORT nSlot
= rReq
.GetSlot();
277 USHORT nRet
= 0xffff;
279 const SfxItemSet
* pArgs
= rReq
.GetArgs();
280 const SfxPoolItem
* pItem
;
281 SwWrtShell
* pActShell
= 0;
282 BOOL bSetReturn
= TRUE
;
286 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( SID_STYLE_FAMILY
,
289 USHORT nFamily
= ((const SfxUInt16Item
*)pItem
)->GetValue();
293 if( SFX_ITEM_SET
== pArgs
->GetItemState( SID_STYLE_NEW
,
295 sName
= ((const SfxStringItem
*)pItem
)->GetValue();
296 if( SFX_ITEM_SET
== pArgs
->GetItemState( SID_STYLE_MASK
,
298 nMask
= ((const SfxUInt16Item
*)pItem
)->GetValue();
300 if( SFX_ITEM_SET
== pArgs
->GetItemState( SID_STYLE_REFERENCE
,
302 sParent
= ((const SfxStringItem
*)pItem
)->GetValue();
304 nRet
= Edit( sName
, sParent
, nFamily
, nMask
, TRUE
, FALSE
, 0, rReq
.IsAPI() );
308 case SID_STYLE_APPLY
:
311 GetView()->GetViewFrame()->GetDispatcher()->Execute(SID_STYLE_DESIGNER
, FALSE
);
316 // convert internal StyleName to DisplayName (slot implementation uses the latter)
317 SFX_REQUEST_ARG( rReq
, pNameItem
, SfxStringItem
, SID_APPLY_STYLE
, sal_False
);
318 SFX_REQUEST_ARG( rReq
, pFamilyItem
, SfxStringItem
, SID_STYLE_FAMILYNAME
, sal_False
);
319 if ( pFamilyItem
&& pNameItem
)
321 uno::Reference
< style::XStyleFamiliesSupplier
> xModel(GetModel(), uno::UNO_QUERY
);
324 uno::Reference
< container::XNameAccess
> xStyles
;
325 uno::Reference
< container::XNameAccess
> xCont
= xModel
->getStyleFamilies();
326 xCont
->getByName(pFamilyItem
->GetValue()) >>= xStyles
;
327 uno::Reference
< beans::XPropertySet
> xInfo
;
328 xStyles
->getByName( pNameItem
->GetValue() ) >>= xInfo
;
329 ::rtl::OUString aUIName
;
330 xInfo
->getPropertyValue( ::rtl::OUString::createFromAscii("DisplayName") ) >>= aUIName
;
331 if ( aUIName
.getLength() )
332 rReq
.AppendItem( SfxStringItem( SID_STYLE_APPLY
, aUIName
) );
334 catch( uno::Exception
& )
340 // intentionally no break
343 case SID_STYLE_DELETE
:
344 case SID_STYLE_WATERCAN
:
345 case SID_STYLE_FAMILY
:
346 case SID_STYLE_UPDATE_BY_EXAMPLE
:
347 case SID_STYLE_NEW_BY_EXAMPLE
:
350 USHORT nFamily
= SFX_STYLE_FAMILY_PARA
;
355 nFamily
= SFX_STYLE_FAMILY_PARA
;
359 case SID_STYLE_NEW_BY_EXAMPLE
:
361 SfxNewStyleDlg
*pDlg
= new SfxNewStyleDlg( 0,
362 *GetStyleSheetPool());
363 if(RET_OK
== pDlg
->Execute())
365 aParam
= pDlg
->GetName();
366 rReq
.AppendItem(SfxStringItem(nSlot
, aParam
));
373 case SID_STYLE_UPDATE_BY_EXAMPLE
:
376 SwTxtFmtColl
* pColl
= GetWrtShell()->GetCurTxtFmtColl();
379 aParam
= pColl
->GetName();
380 rReq
.AppendItem(SfxStringItem(nSlot
, aParam
));
388 ASSERT( pArgs
->Count(), "SfxBug ItemSet ist leer");
390 SwWrtShell
* pShell
= GetWrtShell();
391 if( SFX_ITEM_SET
== pArgs
->GetItemState(nSlot
, FALSE
, &pItem
))
392 aParam
= ((const SfxStringItem
*)pItem
)->GetValue();
394 if( SFX_ITEM_SET
== pArgs
->GetItemState(SID_STYLE_FAMILY
,
396 nFamily
= ((const SfxUInt16Item
*)pItem
)->GetValue();
398 if( SFX_ITEM_SET
== pArgs
->GetItemState(SID_STYLE_FAMILYNAME
, FALSE
, &pItem
))
400 String aFamily
= ((const SfxStringItem
*)pItem
)->GetValue();
401 if(aFamily
.CompareToAscii("CharacterStyles") == COMPARE_EQUAL
)
402 nFamily
= SFX_STYLE_FAMILY_CHAR
;
404 if(aFamily
.CompareToAscii("ParagraphStyles") == COMPARE_EQUAL
)
405 nFamily
= SFX_STYLE_FAMILY_PARA
;
407 if(aFamily
.CompareToAscii("PageStyles") == COMPARE_EQUAL
)
408 nFamily
= SFX_STYLE_FAMILY_PAGE
;
410 if(aFamily
.CompareToAscii("FrameStyles") == COMPARE_EQUAL
)
411 nFamily
= SFX_STYLE_FAMILY_FRAME
;
413 if(aFamily
.CompareToAscii("NumberingStyles") == COMPARE_EQUAL
)
414 nFamily
= SFX_STYLE_FAMILY_PSEUDO
;
417 if( SFX_ITEM_SET
== pArgs
->GetItemState(SID_STYLE_MASK
,
419 nMask
= ((const SfxUInt16Item
*)pItem
)->GetValue();
420 if( SFX_ITEM_SET
== pArgs
->GetItemState(FN_PARAM_WRTSHELL
,
422 pActShell
= pShell
= (SwWrtShell
*)((SwPtrItem
*)pItem
)->GetValue();
424 if( nSlot
== SID_STYLE_UPDATE_BY_EXAMPLE
)
428 case SFX_STYLE_FAMILY_PARA
:
430 SwTxtFmtColl
* pColl
= pShell
->GetCurTxtFmtColl();
432 aParam
= pColl
->GetName();
435 case SFX_STYLE_FAMILY_FRAME
:
437 SwFrmFmt
* pFrm
= pWrtShell
->GetCurFrmFmt();
439 aParam
= pFrm
->GetName();
442 case SFX_STYLE_FAMILY_CHAR
:
444 SwCharFmt
* pChar
= pWrtShell
->GetCurCharFmt();
446 aParam
= pChar
->GetName();
449 case SFX_STYLE_FAMILY_PSEUDO
:
450 if(SFX_ITEM_SET
== pArgs
->GetItemState(SID_STYLE_UPD_BY_EX_NAME
, FALSE
, &pItem
))
452 aParam
= ((const SfxStringItem
*)pItem
)->GetValue();
456 rReq
.AppendItem(SfxStringItem(nSlot
, aParam
));
459 if (aParam
.Len() || nSlot
== SID_STYLE_WATERCAN
)
464 nRet
= Edit(aParam
, aEmptyStr
, nFamily
, nMask
, FALSE
, FALSE
, pActShell
);
466 case SID_STYLE_DELETE
:
467 nRet
= Delete(aParam
, nFamily
);
469 case SID_STYLE_APPLY
:
470 // Shellwechsel in ApplyStyles
471 nRet
= ApplyStyles(aParam
, nFamily
, pActShell
, rReq
.GetModifier() );
473 case SID_STYLE_WATERCAN
:
474 nRet
= DoWaterCan(aParam
, nFamily
);
476 case SID_STYLE_UPDATE_BY_EXAMPLE
:
477 nRet
= UpdateStyle(aParam
, nFamily
, pActShell
);
479 case SID_STYLE_NEW_BY_EXAMPLE
:
481 nRet
= MakeByExample(aParam
, nFamily
, nMask
, pActShell
);
482 SfxTemplateDialog
* pDlg
= SFX_APP()->GetTemplateDialog();
484 if(pDlg
&& pDlg
->IsVisible())
490 DBG_ERROR( "Falsche Slot-Id");
502 if(rReq
.IsAPI()) // Basic bekommt nur TRUE oder FALSE
503 rReq
.SetReturnValue(SfxUInt16Item(nSlot
, nRet
!=0));
505 rReq
.SetReturnValue(SfxUInt16Item(nSlot
, nRet
));
510 /*--------------------------------------------------------------------
512 --------------------------------------------------------------------*/
515 USHORT
SwDocShell::Edit( const String
&rName
, const String
&rParent
, USHORT nFamily
, USHORT nMask
,
516 BOOL bNew
, BOOL bColumn
, SwWrtShell
* pActShell
,
519 ASSERT(GetWrtShell(), "Keine Shell, keine Styles");
520 SfxStyleSheetBase
*pStyle
= 0;
523 BOOL bModified
= pDoc
->IsModified();
527 if( SFXSTYLEBIT_ALL
!= nMask
&& SFXSTYLEBIT_USED
!= nMask
)
528 nMask
|= SFXSTYLEBIT_USERDEF
;
530 nMask
= SFXSTYLEBIT_USERDEF
;
532 pStyle
= &mxBasePool
->Make( rName
, (SfxStyleFamily
)nFamily
, nMask
);
534 // die aktuellen als Parent setzen
535 SwDocStyleSheet
* pDStyle
= (SwDocStyleSheet
*)pStyle
;
538 case SFX_STYLE_FAMILY_PARA
:
542 SwTxtFmtColl
* pColl
= pWrtShell
->FindTxtFmtCollByName( rParent
);
545 USHORT nId
= SwStyleNameMapper::GetPoolIdFromUIName(rParent
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
);
547 pColl
= pWrtShell
->GetTxtCollFromPool( nId
);
549 pDStyle
->GetCollection()->SetDerivedFrom( pColl
);
550 pDStyle
->PresetParent( rParent
);
552 //#outline level,add by zhaojianwei
553 /*When a new paragraph style is created based on a "to outline style
554 assigned" paragraph style, the outline level attribute and the list
555 style attribute of the new paragraph style have to be set to 0
557 if( pColl
->IsAssignedToListLevelOfOutlineStyle())
559 SwNumRuleItem
aItem(aEmptyStr
);
560 pDStyle
->GetCollection()->SetFmtAttr( aItem
);
561 pDStyle
->GetCollection()->SetAttrOutlineLevel( 0 );
568 SwTxtFmtColl
* pColl
= pWrtShell
->GetCurTxtFmtColl();
569 pDStyle
->GetCollection()->SetDerivedFrom( pColl
);
571 pDStyle
->PresetParent( pColl
->GetName() );
575 case SFX_STYLE_FAMILY_CHAR
:
579 SwCharFmt
* pCFmt
= pWrtShell
->FindCharFmtByName( rParent
);
582 USHORT nId
= SwStyleNameMapper::GetPoolIdFromUIName(rParent
, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
);
584 pCFmt
= pWrtShell
->GetCharFmtFromPool( nId
);
587 pDStyle
->GetCharFmt()->SetDerivedFrom( pCFmt
);
588 pDStyle
->PresetParent( rParent
);
592 SwCharFmt
* pCFmt
= pWrtShell
->GetCurCharFmt();
593 pDStyle
->GetCharFmt()->SetDerivedFrom( pCFmt
);
595 pDStyle
->PresetParent( pCFmt
->GetName() );
599 case SFX_STYLE_FAMILY_FRAME
:
603 SwFrmFmt
* pFFmt
= pWrtShell
->GetDoc()->FindFrmFmtByName( rParent
);
606 USHORT nId
= SwStyleNameMapper::GetPoolIdFromUIName(rParent
, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT
);
608 pFFmt
= pWrtShell
->GetFrmFmtFromPool( nId
);
610 pDStyle
->GetFrmFmt()->SetDerivedFrom( pFFmt
);
611 pDStyle
->PresetParent( rParent
);
619 pStyle
= mxBasePool
->Find( rName
, (SfxStyleFamily
)nFamily
);
620 ASSERT(pStyle
, "Vorlage nicht gefunden");
626 // Dialoge zusammenstoepseln
628 rtl::Reference
< SwDocStyleSheet
> xTmp( new SwDocStyleSheet( *(SwDocStyleSheet
*)pStyle
) );
629 if( SFX_STYLE_FAMILY_PARA
== nFamily
)
631 SfxItemSet
& rSet
= xTmp
->GetItemSet();
632 ::SwToSfxPageDescAttr( rSet
);
633 // erstmal nur eine Null
634 rSet
.Put(SwBackgroundDestinationItem(SID_PARA_BACKGRND_DESTINATION
, 0));
635 // --> OD 2008-02-13 #newlistlevelattrs#
636 // merge list level indent attributes into the item set if needed
637 xTmp
->MergeIndentAttrsOfListStyle( rSet
);
640 /* else if( SFX_STYLE_FAMILY_FRAME == nFamily )
642 // Auskommentiert wegen Bug #45776 (per default keine Breite&Groesse in Rahmenvorlagen)
643 SfxItemSet& rSet = aTmp.GetItemSet();
644 if( SFX_ITEM_SET != rSet.GetItemState( RES_FRM_SIZE ))
646 // dann sollten wir spaetesten hier eines anlegen
647 SwFrmValid aFrmDefValues;
648 rSet.Put( SwFmtFrmSize( ATT_VAR_SIZE, aFrmDefValues.nWidth,
649 aFrmDefValues.nHeight ));
652 else if( SFX_STYLE_FAMILY_CHAR
== nFamily
)
654 SfxItemSet
& rSet
= xTmp
->GetItemSet();
655 const SfxPoolItem
*pTmpBrush
;
656 if( SFX_ITEM_SET
== rSet
.GetItemState( RES_CHRATR_BACKGROUND
,
659 SvxBrushItem
aTmpBrush( *((SvxBrushItem
*)pTmpBrush
) );
660 aTmpBrush
.SetWhich( RES_BACKGROUND
);
661 rSet
.Put( aTmpBrush
);
666 // vor dem Dialog wird der HtmlMode an der DocShell versenkt
667 USHORT nHtmlMode
= ::GetHtmlMode(this);
669 // In HTML mode, we do not always have a printer. In order to show
670 // the correct page size in the Format - Page dialog, we have to
672 SwWrtShell
* pCurrShell
= ( pActShell
? pActShell
: pWrtShell
);
673 if( ( HTMLMODE_ON
& nHtmlMode
) &&
674 !pCurrShell
->getIDocumentDeviceAccess()->getPrinter( false ) )
675 pCurrShell
->InitPrt( pCurrShell
->getIDocumentDeviceAccess()->getPrinter( true ) );
677 PutItem(SfxUInt16Item(SID_HTML_MODE
, nHtmlMode
));
678 FieldUnit eMetric
= ::GetDfltMetric(0 != (HTMLMODE_ON
&nHtmlMode
));
679 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< UINT16
>(eMetric
)));
680 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
681 DBG_ASSERT(pFact
, "Dialogdiet fail!");
682 SfxAbstractTabDialog
* pDlg
= pFact
->CreateTemplateDialog( DLG_TEMPLATE_BASE
,
683 0, *(xTmp
.get()), nFamily
, bColumn
,
684 pActShell
? pActShell
: pWrtShell
, bNew
);
685 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
686 if(RET_OK
== pDlg
->Execute())
688 GetWrtShell()->StartAllAction();
690 // nur bei Absatz-Vorlagen die Maske neu setzen
693 nRet
= SFX_STYLE_FAMILY_PARA
== pStyle
->GetFamily()
695 : SFXSTYLEBIT_USERDEF
;
697 else if( pStyle
->GetMask() != xTmp
->GetMask() )
698 nRet
= xTmp
->GetMask();
700 if( SFX_STYLE_FAMILY_PARA
== nFamily
)
702 SfxItemSet
aSet( *pDlg
->GetOutputItemSet() );
703 ::SfxToSwPageDescAttr( *GetWrtShell(), aSet
);
704 // --> OD 2008-02-12 #newlistlevelattrs#
705 // reset indent attributes at paragraph style, if a list style
706 // will be applied and no indent attributes will be applied.
707 xTmp
->SetItemSet( aSet
, true );
712 if(SFX_STYLE_FAMILY_PAGE
== nFamily
)
714 static const USHORT aInval
[] = {
715 SID_IMAGE_ORIENTATION
,
717 FN_INSERT_CTRL
, FN_INSERT_OBJ_CTRL
, 0};
718 pView
->GetViewFrame()->GetBindings().Invalidate(aInval
);
720 SfxItemSet
aTmpSet( *pDlg
->GetOutputItemSet() );
721 if( SFX_STYLE_FAMILY_CHAR
== nFamily
)
723 const SfxPoolItem
*pTmpBrush
;
724 if( SFX_ITEM_SET
== aTmpSet
.GetItemState( RES_BACKGROUND
,
725 FALSE
, &pTmpBrush
) )
727 SvxBrushItem
aTmpBrush( *((SvxBrushItem
*)pTmpBrush
) );
728 aTmpBrush
.SetWhich( RES_CHRATR_BACKGROUND
);
729 aTmpSet
.Put( aTmpBrush
);
731 aTmpSet
.ClearItem( RES_BACKGROUND
);
733 xTmp
->SetItemSet( aTmpSet
);
735 if( SFX_STYLE_FAMILY_PAGE
== nFamily
&& SvtLanguageOptions().IsCTLFontEnabled() )
737 const SfxPoolItem
*pItem
= NULL
;
738 if( aTmpSet
.GetItemState( GetPool().GetTrueWhich( SID_ATTR_FRAMEDIRECTION
, FALSE
) , TRUE
, &pItem
) == SFX_ITEM_SET
)
739 SwChartHelper::DoUpdateAllCharts( pDoc
);
742 if(SFX_STYLE_FAMILY_PAGE
== nFamily
)
743 pView
->InvalidateRulerPos();
746 mxBasePool
->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED
, *xTmp
.get() ) );
749 // Dialog vorm EndAction zerstoeren - bei Seitenvorlagen kann
750 // muss der ItemSet zerstoert werden, damit die Cursor aus den
751 // Kopf-/Fusszeilen entfernt werden. Sonst kommts zu GPFs!!!
755 if( !bModified
) // Bug 57028
756 pDoc
->SetUndoNoResetModified();
758 GetWrtShell()->EndAllAction();
765 //pBasePool->Erase( &aTmp );
766 GetWrtShell()->Undo(UNDO_EMPTY
, 1);
771 pDoc
->ResetModified();
777 // vor dem Dialog wird der HtmlMode an der DocShell versenkt
778 PutItem(SfxUInt16Item(SID_HTML_MODE
, ::GetHtmlMode(this)));
780 GetWrtShell()->StartAllAction();
782 // nur bei Absatz-Vorlagen die Maske neu setzen
785 nRet
= SFX_STYLE_FAMILY_PARA
== pStyle
->GetFamily()
787 : SFXSTYLEBIT_USERDEF
;
789 else if( pStyle
->GetMask() != xTmp
->GetMask() )
790 nRet
= xTmp
->GetMask();
792 if( SFX_STYLE_FAMILY_PARA
== nFamily
)
793 ::SfxToSwPageDescAttr( *GetWrtShell(), xTmp
->GetItemSet() );
796 SfxItemSet
aTmpSet( xTmp
->GetItemSet() );
797 if( SFX_STYLE_FAMILY_CHAR
== nFamily
)
799 const SfxPoolItem
*pTmpBrush
;
800 if( SFX_ITEM_SET
== aTmpSet
.GetItemState( RES_BACKGROUND
,
801 FALSE
, &pTmpBrush
) )
803 SvxBrushItem
aTmpBrush( *((SvxBrushItem
*)pTmpBrush
) );
804 aTmpBrush
.SetWhich( RES_CHRATR_BACKGROUND
);
805 aTmpSet
.Put( aTmpBrush
);
807 aTmpSet
.ClearItem( RES_BACKGROUND
);
809 xTmp
->SetItemSet( aTmpSet
);
811 if(SFX_STYLE_FAMILY_PAGE
== nFamily
)
812 pView
->InvalidateRulerPos();
815 mxBasePool
->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED
, *xTmp
.get() ) );
818 if( !bModified
) // Bug 57028
819 pDoc
->SetUndoNoResetModified();
820 GetWrtShell()->EndAllAction();
826 /*--------------------------------------------------------------------
828 --------------------------------------------------------------------*/
831 USHORT
SwDocShell::Delete(const String
&rName
, USHORT nFamily
)
833 SfxStyleSheetBase
*pStyle
= mxBasePool
->Find(rName
, (SfxStyleFamily
)nFamily
);
837 ASSERT(GetWrtShell(), "Keine Shell, keine Styles");
839 GetWrtShell()->StartAllAction();
840 mxBasePool
->Remove(pStyle
);
841 GetWrtShell()->EndAllAction();
848 /*--------------------------------------------------------------------
849 Beschreibung: Vorlage anwenden
850 --------------------------------------------------------------------*/
853 USHORT
SwDocShell::ApplyStyles(const String
&rName
, USHORT nFamily
,
854 SwWrtShell
* pShell
, USHORT nMode
)
856 SwDocStyleSheet
* pStyle
=
857 (SwDocStyleSheet
*)mxBasePool
->Find(rName
, (SfxStyleFamily
)nFamily
);
859 ASSERT(pStyle
, "Wo ist der StyleSheet");
863 SwWrtShell
*pSh
= pShell
? pShell
: GetWrtShell();
865 ASSERT( pSh
, "Keine Shell, keine Styles");
867 pSh
->StartAllAction();
871 case SFX_STYLE_FAMILY_CHAR
:
873 SwFmtCharFmt
aFmt(pStyle
->GetCharFmt());
874 pSh
->SetAttr( aFmt
, (nMode
& KEY_SHIFT
) ?
875 nsSetAttrMode::SETATTR_DONTREPLACE
: nsSetAttrMode::SETATTR_DEFAULT
);
878 case SFX_STYLE_FAMILY_PARA
:
880 // --> OD 2007-11-06 #i62675#
881 // clear also list attributes at affected text nodes, if paragraph
882 // style has the list style attribute set.
883 pSh
->SetTxtFmtColl( pStyle
->GetCollection(), true );
887 case SFX_STYLE_FAMILY_FRAME
:
889 if ( pSh
->IsFrmSelected() )
890 pSh
->SetFrmFmt( pStyle
->GetFrmFmt() );
893 case SFX_STYLE_FAMILY_PAGE
:
895 pSh
->SetPageStyle(pStyle
->GetPageDesc()->GetName());
898 case SFX_STYLE_FAMILY_PSEUDO
:
900 // --> OD 2008-02-08 #newlistlevelattrs#
901 // reset indent attribute on applying list style
902 // --> OD 2008-03-17 #refactorlists#
903 // continue list of list style
904 const SwNumRule
* pNumRule
= pStyle
->GetNumRule();
905 const String sListIdForStyle
=pNumRule
->GetDefaultListId();
906 pSh
->SetCurNumRule( *pNumRule
, false, sListIdForStyle
, true );
911 DBG_ERROR("Unbekannte Familie");
918 /*--------------------------------------------------------------------
919 Beschreibung: Giesskanne starten
920 --------------------------------------------------------------------*/
924 USHORT
SwDocShell::DoWaterCan(const String
&rName
, USHORT nFamily
)
926 ASSERT(GetWrtShell(), "Keine Shell, keine Styles");
928 SwEditWin
& rEdtWin
= pView
->GetEditWin();
929 SwApplyTemplate
* pApply
= rEdtWin
.GetApplyTemplate();
930 BOOL bWaterCan
= !(pApply
&& pApply
->eType
!= 0);
933 SwApplyTemplate aTemplate
;
934 aTemplate
.eType
= nFamily
;
938 SwDocStyleSheet
* pStyle
=
939 (SwDocStyleSheet
*)mxBasePool
->Find(rName
, (SfxStyleFamily
)nFamily
);
941 ASSERT(pStyle
, "Wo ist der StyleSheet");
942 if(!pStyle
) return nFamily
;
946 case SFX_STYLE_FAMILY_CHAR
:
947 aTemplate
.aColl
.pCharFmt
= pStyle
->GetCharFmt();
949 case SFX_STYLE_FAMILY_PARA
:
950 aTemplate
.aColl
.pTxtColl
= pStyle
->GetCollection();
952 case SFX_STYLE_FAMILY_FRAME
:
953 aTemplate
.aColl
.pFrmFmt
= pStyle
->GetFrmFmt();
955 case SFX_STYLE_FAMILY_PAGE
:
956 aTemplate
.aColl
.pPageDesc
= (SwPageDesc
*)pStyle
->GetPageDesc();
958 case SFX_STYLE_FAMILY_PSEUDO
:
959 aTemplate
.aColl
.pNumRule
= (SwNumRule
*)pStyle
->GetNumRule();
963 DBG_ERROR( "Unbekannte Familie");
970 pView
->GetEditWin().SetApplyTemplate(aTemplate
);
975 /*--------------------------------------------------------------------
976 Beschreibung: Vorlage Updaten
977 --------------------------------------------------------------------*/
980 USHORT
SwDocShell::UpdateStyle(const String
&rName
, USHORT nFamily
, SwWrtShell
* pShell
)
982 SwWrtShell
* pCurrWrtShell
= pShell
? pShell
: GetWrtShell();
983 ASSERT(GetWrtShell(), "Keine Shell, keine Styles");
985 SwDocStyleSheet
* pStyle
=
986 (SwDocStyleSheet
*)mxBasePool
->Find(rName
, (SfxStyleFamily
)nFamily
);
993 case SFX_STYLE_FAMILY_PARA
:
995 SwTxtFmtColl
* pColl
= pStyle
->GetCollection();
996 if(pColl
&& !pColl
->IsDefault())
998 GetWrtShell()->StartAllAction();
1000 SwRewriter aRewriter
;
1001 aRewriter
.AddRule(UNDO_ARG1
, pColl
->GetName());
1003 GetWrtShell()->StartUndo(UNDO_INSFMTATTR
, &aRewriter
);
1004 GetWrtShell()->FillByEx(pColl
);
1005 // Vorlage auch anwenden, um harte Attributierung
1007 GetWrtShell()->SetTxtFmtColl( pColl
);
1008 GetWrtShell()->EndUndo(UNDO_INSFMTATTR
, NULL
);
1009 GetWrtShell()->EndAllAction();
1013 case SFX_STYLE_FAMILY_FRAME
:
1015 SwFrmFmt
* pFrm
= pStyle
->GetFrmFmt();
1016 if( pCurrWrtShell
->IsFrmSelected() && pFrm
&& !pFrm
->IsDefault() )
1018 SfxItemSet
aSet( GetPool(), aFrmFmtSetRange
);
1019 pCurrWrtShell
->StartAllAction();
1020 pCurrWrtShell
->GetFlyFrmAttr( aSet
);
1022 // JP 10.06.98: nur automatische Orientierungen uebernehmen
1023 /* #61359# jetzt auch wieder alle Orientierungen
1024 * const SfxPoolItem* pItem;
1025 if( SFX_ITEM_SET == aSet.GetItemState( RES_VERT_ORIENT,
1027 text::VertOrientation::NONE == ((SwFmtVertOrient*)pItem)->GetVertOrient())
1028 aSet.ClearItem( RES_VERT_ORIENT );
1030 if( SFX_ITEM_SET == aSet.GetItemState( RES_HORI_ORIENT,
1032 text::HoriOrientation::NONE == ((SwFmtHoriOrient*)pItem)->GetHoriOrient())
1033 aSet.ClearItem( RES_HORI_ORIENT );*/
1035 pFrm
->SetFmtAttr( aSet
);
1037 // Vorlage auch anwenden, um harte Attributierung
1039 pCurrWrtShell
->SetFrmFmt( pFrm
, TRUE
);
1040 pCurrWrtShell
->EndAllAction();
1044 case SFX_STYLE_FAMILY_CHAR
:
1046 SwCharFmt
* pChar
= pStyle
->GetCharFmt();
1047 if( pChar
&& !pChar
->IsDefault() )
1049 pCurrWrtShell
->StartAllAction();
1050 pCurrWrtShell
->FillByEx(pChar
);
1051 // Vorlage auch anwenden, um harte Attributierung
1053 pCurrWrtShell
->EndAllAction();
1058 case SFX_STYLE_FAMILY_PSEUDO
:
1060 const SwNumRule
* pCurRule
;
1061 if( pStyle
->GetNumRule() &&
1062 0 != ( pCurRule
= pCurrWrtShell
->GetCurNumRule() ))
1064 SwNumRule
aRule( *pCurRule
);
1065 // --> OD 2008-07-08 #i91400#
1066 aRule
.SetName( pStyle
->GetNumRule()->GetName(),
1067 *(pCurrWrtShell
->GetDoc()) );
1069 pCurrWrtShell
->ChgNumRuleFmts( aRule
);
1077 /*--------------------------------------------------------------------
1078 Beschreibung: NewByExample
1079 --------------------------------------------------------------------*/
1082 USHORT
SwDocShell::MakeByExample( const String
&rName
, USHORT nFamily
,
1083 USHORT nMask
, SwWrtShell
* pShell
)
1085 SwWrtShell
* pCurrWrtShell
= pShell
? pShell
: GetWrtShell();
1086 SwDocStyleSheet
* pStyle
= (SwDocStyleSheet
*)mxBasePool
->Find(
1087 rName
, (SfxStyleFamily
)nFamily
);
1090 // JP 07.07.95: behalte die akt. Maske vom PI bei, dadurch werden
1091 // neue sofort in den sichtbaren Bereich einsortiert
1092 if( SFXSTYLEBIT_ALL
== nMask
|| SFXSTYLEBIT_USED
== nMask
)
1093 nMask
= SFXSTYLEBIT_USERDEF
;
1095 nMask
|= SFXSTYLEBIT_USERDEF
;
1097 pStyle
= (SwDocStyleSheet
*)&mxBasePool
->Make(rName
,
1098 (SfxStyleFamily
)nFamily
, nMask
);
1103 case SFX_STYLE_FAMILY_PARA
:
1105 SwTxtFmtColl
* pColl
= pStyle
->GetCollection();
1106 if(pColl
&& !pColl
->IsDefault())
1108 pCurrWrtShell
->StartAllAction();
1109 pCurrWrtShell
->FillByEx(pColl
);
1110 // Vorlage auch anwenden, um harte Attributierung
1112 pColl
->SetDerivedFrom(pCurrWrtShell
->GetCurTxtFmtColl());
1114 // setze die Maske noch an der Collection:
1115 USHORT nId
= pColl
->GetPoolFmtId() & 0x87ff;
1116 switch( nMask
& 0x0fff )
1118 case SWSTYLEBIT_TEXT
:
1119 nId
|= COLL_TEXT_BITS
;
1121 case SWSTYLEBIT_CHAPTER
:
1122 nId
|= COLL_DOC_BITS
;
1124 case SWSTYLEBIT_LIST
:
1125 nId
|= COLL_LISTS_BITS
;
1127 case SWSTYLEBIT_IDX
:
1128 nId
|= COLL_REGISTER_BITS
;
1130 case SWSTYLEBIT_EXTRA
:
1131 nId
|= COLL_EXTRA_BITS
;
1133 case SWSTYLEBIT_HTML
:
1134 nId
|= COLL_HTML_BITS
;
1137 pColl
->SetPoolFmtId(nId
);
1139 pCurrWrtShell
->SetTxtFmtColl(pColl
);
1140 pCurrWrtShell
->EndAllAction();
1144 case SFX_STYLE_FAMILY_FRAME
:
1146 SwFrmFmt
* pFrm
= pStyle
->GetFrmFmt();
1147 if(pCurrWrtShell
->IsFrmSelected() && pFrm
&& !pFrm
->IsDefault())
1149 pCurrWrtShell
->StartAllAction();
1151 SfxItemSet
aSet(GetPool(), aFrmFmtSetRange
);
1152 pCurrWrtShell
->GetFlyFrmAttr( aSet
);
1154 SwFrmFmt
* pFFmt
= pCurrWrtShell
->GetCurFrmFmt();
1155 pFrm
->SetDerivedFrom( pFFmt
);
1157 // JP 10.06.98: nur automatische Orientierungen uebernehmen
1158 /* #61359# jetzt auch wieder alle Orientierungen
1159 const SfxPoolItem* pItem;
1160 if( SFX_ITEM_SET == aSet.GetItemState( RES_VERT_ORIENT,
1162 text::VertOrientation::NONE == ((SwFmtVertOrient*)pItem)->GetVertOrient())
1163 aSet.ClearItem( RES_VERT_ORIENT );
1165 if( SFX_ITEM_SET == aSet.GetItemState( RES_HORI_ORIENT,
1167 text::HoriOrientation::NONE == ((SwFmtHoriOrient*)pItem)->GetHoriOrient())
1168 aSet.ClearItem( RES_HORI_ORIENT );
1171 pFrm
->SetFmtAttr( aSet
);
1172 // Vorlage auch anwenden, um harte Attributierung
1174 pCurrWrtShell
->SetFrmFmt( pFrm
);
1175 pCurrWrtShell
->EndAllAction();
1179 case SFX_STYLE_FAMILY_CHAR
:
1181 SwCharFmt
* pChar
= pStyle
->GetCharFmt();
1182 if(pChar
&& !pChar
->IsDefault())
1184 pCurrWrtShell
->StartAllAction();
1185 pCurrWrtShell
->FillByEx( pChar
);
1186 pChar
->SetDerivedFrom( pCurrWrtShell
->GetCurCharFmt() );
1187 SwFmtCharFmt
aFmt( pChar
);
1188 pCurrWrtShell
->SetAttr( aFmt
);
1189 pCurrWrtShell
->EndAllAction();
1194 case SFX_STYLE_FAMILY_PAGE
:
1196 pCurrWrtShell
->StartAllAction();
1197 USHORT nPgDsc
= pCurrWrtShell
->GetCurPageDesc();
1198 SwPageDesc
& rSrc
= (SwPageDesc
&)pCurrWrtShell
->GetPageDesc( nPgDsc
);
1199 SwPageDesc
& rDest
= *(SwPageDesc
*)pStyle
->GetPageDesc();
1201 USHORT nPoolId
= rDest
.GetPoolFmtId();
1202 USHORT nHId
= rDest
.GetPoolHelpId();
1203 BYTE nHFId
= rDest
.GetPoolHlpFileId();
1205 pCurrWrtShell
->GetDoc()->CopyPageDesc( rSrc
, rDest
);
1207 // PoolId darf NIE kopiert werden!
1208 rDest
.SetPoolFmtId( nPoolId
);
1209 rDest
.SetPoolHelpId( nHId
);
1210 rDest
.SetPoolHlpFileId( nHFId
);
1212 // werden Kopf-/Fusszeilen angelegt, so gibt es kein Undo mehr!
1213 pCurrWrtShell
->GetDoc()->DelAllUndoObj();
1215 pCurrWrtShell
->EndAllAction();
1219 case SFX_STYLE_FAMILY_PSEUDO
:
1221 pCurrWrtShell
->StartAllAction();
1223 SwNumRule
aRule( *pCurrWrtShell
->GetCurNumRule() );
1224 String
sOrigRule( aRule
.GetName() );
1225 // --> OD 2008-07-08 #i91400#
1226 aRule
.SetName( pStyle
->GetNumRule()->GetName(),
1227 *(pCurrWrtShell
->GetDoc()) );
1229 pCurrWrtShell
->ChgNumRuleFmts( aRule
);
1231 pCurrWrtShell
->ReplaceNumRule( sOrigRule
, aRule
.GetName() );
1234 pCurrWrtShell
->EndAllAction();
1241 void SwDocShell::LoadStyles( SfxObjectShell
& rSource
)
1243 _LoadStyles(rSource
, FALSE
);
1245 /* -----------------16.05.2003 15:45-----------------
1246 bPreserveCurrentDocument determines whether SetFixFields() is called
1247 This call modifies the source document. This mustn't happen when the source
1248 is a document the user is working on.
1249 Calls of ::LoadStyles() normally use files especially loaded for the purpose
1250 of importing styles.
1251 --------------------------------------------------*/
1252 void SwDocShell::_LoadStyles( SfxObjectShell
& rSource
, BOOL bPreserveCurrentDocument
)
1256 Diese Methode wird vom SFx gerufen, wenn aus einer Dokument-Vorlage
1257 Styles nachgeladen werden sollen. Bestehende Styles soll dabei
1258 "uberschrieben werden. Das Dokument mu"s daher neu formatiert werden.
1259 Daher werden die Applikationen in der Regel diese Methode "uberladen
1260 und in ihrer Implementierung die Implementierung der Basisklasse
1263 // ist die Source unser Document, dann uebernehmen wir das
1264 // abpruefen selbst (wesentlich schneller und laeuft nicht ueber
1265 // die Kruecke SfxStylePool
1266 if( rSource
.ISA( SwDocShell
))
1268 //JP 28.05.99: damit die Kopf-/Fusszeilen nicht den fixen Inhalt
1269 // der Vorlage erhalten, einmal alle FixFelder der
1270 // Source aktualisieren
1271 if(!bPreserveCurrentDocument
)
1272 ((SwDocShell
&)rSource
).pDoc
->SetFixFields(false, NULL
);
1275 pWrtShell
->StartAllAction();
1276 pDoc
->ReplaceStyles( *((SwDocShell
&)rSource
).pDoc
);
1277 pWrtShell
->EndAllAction();
1281 BOOL bModified
= pDoc
->IsModified();
1282 pDoc
->ReplaceStyles( *((SwDocShell
&)rSource
).pDoc
);
1283 if( !bModified
&& pDoc
->IsModified() && !pView
)
1285 // die View wird spaeter angelegt, ueberschreibt aber das
1286 // Modify-Flag. Per Undo ist sowieso nichts mehr zu machen
1287 pDoc
->SetUndoNoResetModified();
1292 SfxObjectShell::LoadStyles( rSource
);
1296 void SwDocShell::FormatPage( const String
& rPage
, BOOL bColumn
, SwWrtShell
* pActShell
)
1298 Edit( rPage
, aEmptyStr
, SFX_STYLE_FAMILY_PAGE
, 0, FALSE
, bColumn
, pActShell
);
1301 Bitmap
SwDocShell::GetStyleFamilyBitmap( SfxStyleFamily eFamily
, BmpColorMode eColorMode
)
1303 if( SFX_STYLE_FAMILY_PSEUDO
== eFamily
)
1305 if ( eColorMode
== BMP_COLOR_NORMAL
)
1306 return Bitmap( SW_RES( BMP_STYLES_FAMILY_NUM
));
1308 return Bitmap( SW_RES( BMP_STYLES_FAMILY_NUM_HC
));
1311 return SfxObjectShell::GetStyleFamilyBitmap( eFamily
, eColorMode
);