xref: /aoo42x/main/sfx2/source/dialog/styledlg.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sfx2.hxx"
30 
31 // include ---------------------------------------------------------------
32 #include <svl/whiter.hxx>
33 #include <svl/style.hxx>
34 #ifndef _MSGBOX_HXX //autogen
35 #include <vcl/msgbox.hxx>
36 #endif
37 #ifndef GCC
38 #endif
39 
40 #include <sfx2/styledlg.hxx>
41 #include <sfx2/mgetempl.hxx>
42 #include "sfx2/sfxresid.hxx"
43 #include <sfx2/sfxuno.hxx>
44 
45 #include "dialog.hrc"
46 
47 // class SfxStyleDialog --------------------------------------------------
48 
49 SfxStyleDialog::SfxStyleDialog
50 (
51 	Window* pParent,			// Parent
52 	const ResId& rResId,		// ResId
53 	SfxStyleSheetBase& rStyle,	// zu bearbeitendes StyleSheet
54 	sal_Bool bFreeRes,				// Flag Resourcen freigeben
55 	const String* pUserBtnTxt
56 ) :
57 
58 /*	[Beschreibung]
59 
60 	Konstruktor: Verwalten-TabPage zuf"ugen, ExampleSet vom Style setzen.
61 */
62 
63 	SfxTabDialog( pParent, rResId,
64 				  rStyle.GetItemSet().Clone(),
65 				  // auch ohne ParentSupport TRUE "ubergeben, aber erweitert
66 				  // um den StandardButton zu unterdr"ucken
67 				  rStyle.HasParentSupport() ? sal_True : 2,
68 				  pUserBtnTxt ),
69 
70 	pStyle( &rStyle )
71 
72 {
73 	AddTabPage( ID_TABPAGE_MANAGESTYLES,
74 				String( SfxResId( STR_TABPAGE_MANAGESTYLES ) ),
75 				SfxManageStyleSheetPage::Create, 0, sal_False, 0 );
76 
77 	// bei neuer Vorlage immer die Verwaltungsseite als aktuelle
78 	// Seite setzen
79 
80 	if( !rStyle.GetName().Len() )
81 		SetCurPageId( ID_TABPAGE_MANAGESTYLES );
82 	else
83 	{
84 		String sTxt( GetText() );
85 		sTxt += DEFINE_CONST_UNICODE(": ") ;
86 		sTxt += rStyle.GetName();
87 		SetText( sTxt );
88 	}
89 	delete pExampleSet;	// im SfxTabDialog::Ctor() schon angelegt
90 	pExampleSet = &pStyle->GetItemSet();
91 
92 	if ( bFreeRes )
93 		FreeResource();
94 	GetCancelButton().SetClickHdl( LINK(this, SfxStyleDialog, CancelHdl) );
95 }
96 
97 // -----------------------------------------------------------------------
98 
99 SfxStyleDialog::~SfxStyleDialog()
100 
101 /*	[Beschreibung]
102 
103 	Destruktor: ExampleSet auf NULL setzen, damit der SfxTabDialog nicht den
104 	Set vom Style l"oscht.
105 */
106 
107 {
108 	pExampleSet = 0;
109 	pStyle = 0;
110 	delete GetInputSetImpl();
111 }
112 
113 // -----------------------------------------------------------------------
114 
115 const SfxItemSet* SfxStyleDialog::GetRefreshedSet()
116 
117 /*  [Beschreibung]
118 
119 	Diese wird gerufen, wenn <SfxTabPage::DeactivatePage(SfxItemSet *)>
120 	<SfxTabPage::REFRESH_SET> liefert.
121 */
122 
123 {
124 	return GetInputSetImpl();
125 }
126 
127 // -----------------------------------------------------------------------
128 
129 short SfxStyleDialog::Ok()
130 
131 /*  [Beschreibung]
132 
133 	"Uberladen, damit immer RET_OK zur"uckgegeben wird.
134 */
135 
136 {
137 	SfxTabDialog::Ok();
138 	return RET_OK;
139 }
140 
141 // -----------------------------------------------------------------------
142 
143 IMPL_LINK( SfxStyleDialog, CancelHdl, Button *, pButton )
144 
145 /*  [Beschreibung]
146 
147 	Wenn der Dialog abgebrochen wurde, m"ussen alle schon eingestellten
148 	Attribute wieder zur"uckgesetzt werden.
149 */
150 
151 {
152     (void)pButton; //unused
153     SfxTabPage* pPage = GetTabPage( ID_TABPAGE_MANAGESTYLES );
154 
155 	const SfxItemSet* pInSet = GetInputSetImpl();
156 	SfxWhichIter aIter( *pInSet );
157 	sal_uInt16 nWhich = aIter.FirstWhich();
158 
159 	while ( nWhich )
160 	{
161 		SfxItemState eState = pInSet->GetItemState( nWhich, sal_False );
162 
163 		if ( SFX_ITEM_DEFAULT == eState )
164 			pExampleSet->ClearItem( nWhich );
165 		else
166 			pExampleSet->Put( pInSet->Get( nWhich ) );
167 		nWhich = aIter.NextWhich();
168 	}
169 
170 	if ( pPage )
171 		pPage->Reset( *GetInputSetImpl() );
172 	EndDialog( RET_CANCEL );
173 	return 0;
174 }
175 
176 
177