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: styledlg.cxx,v $
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_sfx2.hxx"
34 // include ---------------------------------------------------------------
35 #include <svtools/whiter.hxx>
36 #include <svtools/style.hxx>
37 #ifndef _MSGBOX_HXX //autogen
38 #include <vcl/msgbox.hxx>
43 #include <sfx2/styledlg.hxx>
44 #include <sfx2/mgetempl.hxx>
45 #include "sfxresid.hxx"
46 #include <sfx2/sfxuno.hxx>
50 // class SfxStyleDialog --------------------------------------------------
52 SfxStyleDialog::SfxStyleDialog
54 Window
* pParent
, // Parent
55 const ResId
& rResId
, // ResId
56 SfxStyleSheetBase
& rStyle
, // zu bearbeitendes StyleSheet
57 BOOL bFreeRes
, // Flag Resourcen freigeben
58 const String
* pUserBtnTxt
63 Konstruktor: Verwalten-TabPage zuf"ugen, ExampleSet vom Style setzen.
66 SfxTabDialog( pParent
, rResId
,
67 rStyle
.GetItemSet().Clone(),
68 // auch ohne ParentSupport TRUE "ubergeben, aber erweitert
69 // um den StandardButton zu unterdr"ucken
70 rStyle
.HasParentSupport() ? TRUE
: 2,
76 AddTabPage( ID_TABPAGE_MANAGESTYLES
,
77 String( SfxResId( STR_TABPAGE_MANAGESTYLES
) ),
78 SfxManageStyleSheetPage::Create
, 0, FALSE
, 0 );
80 // bei neuer Vorlage immer die Verwaltungsseite als aktuelle
83 if( !rStyle
.GetName().Len() )
84 SetCurPageId( ID_TABPAGE_MANAGESTYLES
);
87 String
sTxt( GetText() );
88 sTxt
+= DEFINE_CONST_UNICODE(": ") ;
89 sTxt
+= rStyle
.GetName();
92 delete pExampleSet
; // im SfxTabDialog::Ctor() schon angelegt
93 pExampleSet
= &pStyle
->GetItemSet();
97 GetCancelButton().SetClickHdl( LINK(this, SfxStyleDialog
, CancelHdl
) );
100 // -----------------------------------------------------------------------
102 SfxStyleDialog::~SfxStyleDialog()
106 Destruktor: ExampleSet auf NULL setzen, damit der SfxTabDialog nicht den
107 Set vom Style l"oscht.
113 delete GetInputSetImpl();
116 // -----------------------------------------------------------------------
118 const SfxItemSet
* SfxStyleDialog::GetRefreshedSet()
122 Diese wird gerufen, wenn <SfxTabPage::DeactivatePage(SfxItemSet *)>
123 <SfxTabPage::REFRESH_SET> liefert.
127 return GetInputSetImpl();
130 // -----------------------------------------------------------------------
132 short SfxStyleDialog::Ok()
136 "Uberladen, damit immer RET_OK zur"uckgegeben wird.
144 // -----------------------------------------------------------------------
146 IMPL_LINK( SfxStyleDialog
, CancelHdl
, Button
*, pButton
)
150 Wenn der Dialog abgebrochen wurde, m"ussen alle schon eingestellten
151 Attribute wieder zur"uckgesetzt werden.
155 (void)pButton
; //unused
156 SfxTabPage
* pPage
= GetTabPage( ID_TABPAGE_MANAGESTYLES
);
158 const SfxItemSet
* pInSet
= GetInputSetImpl();
159 SfxWhichIter
aIter( *pInSet
);
160 USHORT nWhich
= aIter
.FirstWhich();
164 SfxItemState eState
= pInSet
->GetItemState( nWhich
, FALSE
);
166 if ( SFX_ITEM_DEFAULT
== eState
)
167 pExampleSet
->ClearItem( nWhich
);
169 pExampleSet
->Put( pInSet
->Get( nWhich
) );
170 nWhich
= aIter
.NextWhich();
174 pPage
->Reset( *GetInputSetImpl() );
175 EndDialog( RET_CANCEL
);