update dev300-m58
[ooovba.git] / sfx2 / source / dialog / styledlg.cxx
blobdfb707608983c085dcebedfc0128cc37faf2c131
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: styledlg.cxx,v $
10 * $Revision: 1.8 $
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>
39 #endif
40 #ifndef GCC
41 #endif
43 #include <sfx2/styledlg.hxx>
44 #include <sfx2/mgetempl.hxx>
45 #include "sfxresid.hxx"
46 #include <sfx2/sfxuno.hxx>
48 #include "dialog.hrc"
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
59 ) :
61 /* [Beschreibung]
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,
71 pUserBtnTxt ),
73 pStyle( &rStyle )
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
81 // Seite setzen
83 if( !rStyle.GetName().Len() )
84 SetCurPageId( ID_TABPAGE_MANAGESTYLES );
85 else
87 String sTxt( GetText() );
88 sTxt += DEFINE_CONST_UNICODE(": ") ;
89 sTxt += rStyle.GetName();
90 SetText( sTxt );
92 delete pExampleSet; // im SfxTabDialog::Ctor() schon angelegt
93 pExampleSet = &pStyle->GetItemSet();
95 if ( bFreeRes )
96 FreeResource();
97 GetCancelButton().SetClickHdl( LINK(this, SfxStyleDialog, CancelHdl) );
100 // -----------------------------------------------------------------------
102 SfxStyleDialog::~SfxStyleDialog()
104 /* [Beschreibung]
106 Destruktor: ExampleSet auf NULL setzen, damit der SfxTabDialog nicht den
107 Set vom Style l"oscht.
111 pExampleSet = 0;
112 pStyle = 0;
113 delete GetInputSetImpl();
116 // -----------------------------------------------------------------------
118 const SfxItemSet* SfxStyleDialog::GetRefreshedSet()
120 /* [Beschreibung]
122 Diese wird gerufen, wenn <SfxTabPage::DeactivatePage(SfxItemSet *)>
123 <SfxTabPage::REFRESH_SET> liefert.
127 return GetInputSetImpl();
130 // -----------------------------------------------------------------------
132 short SfxStyleDialog::Ok()
134 /* [Beschreibung]
136 "Uberladen, damit immer RET_OK zur"uckgegeben wird.
140 SfxTabDialog::Ok();
141 return RET_OK;
144 // -----------------------------------------------------------------------
146 IMPL_LINK( SfxStyleDialog, CancelHdl, Button *, pButton )
148 /* [Beschreibung]
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();
162 while ( nWhich )
164 SfxItemState eState = pInSet->GetItemState( nWhich, FALSE );
166 if ( SFX_ITEM_DEFAULT == eState )
167 pExampleSet->ClearItem( nWhich );
168 else
169 pExampleSet->Put( pInSet->Get( nWhich ) );
170 nWhich = aIter.NextWhich();
173 if ( pPage )
174 pPage->Reset( *GetInputSetImpl() );
175 EndDialog( RET_CANCEL );
176 return 0;