xref: /aoo42x/main/sfx2/source/dialog/styledlg.cxx (revision d119d52d)
1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d119d52dSAndrew Rist  * distributed with this work for additional information
6*d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d119d52dSAndrew Rist  *
11*d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist  *
13*d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d119d52dSAndrew Rist  * specific language governing permissions and limitations
18*d119d52dSAndrew Rist  * under the License.
19*d119d52dSAndrew Rist  *
20*d119d52dSAndrew Rist  *************************************************************/
21*d119d52dSAndrew Rist 
22*d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir #include <svl/whiter.hxx>
29cdf0e10cSrcweir #include <svl/style.hxx>
30cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
31cdf0e10cSrcweir #include <vcl/msgbox.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef GCC
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <sfx2/styledlg.hxx>
37cdf0e10cSrcweir #include <sfx2/mgetempl.hxx>
38cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
39cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include "dialog.hrc"
42cdf0e10cSrcweir 
43cdf0e10cSrcweir // class SfxStyleDialog --------------------------------------------------
44cdf0e10cSrcweir 
SfxStyleDialog(Window * pParent,const ResId & rResId,SfxStyleSheetBase & rStyle,sal_Bool bFreeRes,const String * pUserBtnTxt)45cdf0e10cSrcweir SfxStyleDialog::SfxStyleDialog
46cdf0e10cSrcweir (
47cdf0e10cSrcweir 	Window* pParent,			// Parent
48cdf0e10cSrcweir 	const ResId& rResId,		// ResId
49cdf0e10cSrcweir 	SfxStyleSheetBase& rStyle,	// zu bearbeitendes StyleSheet
50cdf0e10cSrcweir 	sal_Bool bFreeRes,				// Flag Resourcen freigeben
51cdf0e10cSrcweir 	const String* pUserBtnTxt
52cdf0e10cSrcweir ) :
53cdf0e10cSrcweir 
54cdf0e10cSrcweir /*	[Beschreibung]
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	Konstruktor: Verwalten-TabPage zuf"ugen, ExampleSet vom Style setzen.
57cdf0e10cSrcweir */
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 	SfxTabDialog( pParent, rResId,
60cdf0e10cSrcweir 				  rStyle.GetItemSet().Clone(),
61cdf0e10cSrcweir 				  // auch ohne ParentSupport TRUE "ubergeben, aber erweitert
62cdf0e10cSrcweir 				  // um den StandardButton zu unterdr"ucken
63cdf0e10cSrcweir 				  rStyle.HasParentSupport() ? sal_True : 2,
64cdf0e10cSrcweir 				  pUserBtnTxt ),
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	pStyle( &rStyle )
67cdf0e10cSrcweir 
68cdf0e10cSrcweir {
69cdf0e10cSrcweir 	AddTabPage( ID_TABPAGE_MANAGESTYLES,
70cdf0e10cSrcweir 				String( SfxResId( STR_TABPAGE_MANAGESTYLES ) ),
71cdf0e10cSrcweir 				SfxManageStyleSheetPage::Create, 0, sal_False, 0 );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	// bei neuer Vorlage immer die Verwaltungsseite als aktuelle
74cdf0e10cSrcweir 	// Seite setzen
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	if( !rStyle.GetName().Len() )
77cdf0e10cSrcweir 		SetCurPageId( ID_TABPAGE_MANAGESTYLES );
78cdf0e10cSrcweir 	else
79cdf0e10cSrcweir 	{
80cdf0e10cSrcweir 		String sTxt( GetText() );
81cdf0e10cSrcweir 		sTxt += DEFINE_CONST_UNICODE(": ") ;
82cdf0e10cSrcweir 		sTxt += rStyle.GetName();
83cdf0e10cSrcweir 		SetText( sTxt );
84cdf0e10cSrcweir 	}
85cdf0e10cSrcweir 	delete pExampleSet;	// im SfxTabDialog::Ctor() schon angelegt
86cdf0e10cSrcweir 	pExampleSet = &pStyle->GetItemSet();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	if ( bFreeRes )
89cdf0e10cSrcweir 		FreeResource();
90cdf0e10cSrcweir 	GetCancelButton().SetClickHdl( LINK(this, SfxStyleDialog, CancelHdl) );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir // -----------------------------------------------------------------------
94cdf0e10cSrcweir 
~SfxStyleDialog()95cdf0e10cSrcweir SfxStyleDialog::~SfxStyleDialog()
96cdf0e10cSrcweir 
97cdf0e10cSrcweir /*	[Beschreibung]
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	Destruktor: ExampleSet auf NULL setzen, damit der SfxTabDialog nicht den
100cdf0e10cSrcweir 	Set vom Style l"oscht.
101cdf0e10cSrcweir */
102cdf0e10cSrcweir 
103cdf0e10cSrcweir {
104cdf0e10cSrcweir 	pExampleSet = 0;
105cdf0e10cSrcweir 	pStyle = 0;
106cdf0e10cSrcweir 	delete GetInputSetImpl();
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir // -----------------------------------------------------------------------
110cdf0e10cSrcweir 
GetRefreshedSet()111cdf0e10cSrcweir const SfxItemSet* SfxStyleDialog::GetRefreshedSet()
112cdf0e10cSrcweir 
113cdf0e10cSrcweir /*  [Beschreibung]
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	Diese wird gerufen, wenn <SfxTabPage::DeactivatePage(SfxItemSet *)>
116cdf0e10cSrcweir 	<SfxTabPage::REFRESH_SET> liefert.
117cdf0e10cSrcweir */
118cdf0e10cSrcweir 
119cdf0e10cSrcweir {
120cdf0e10cSrcweir 	return GetInputSetImpl();
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir // -----------------------------------------------------------------------
124cdf0e10cSrcweir 
Ok()125cdf0e10cSrcweir short SfxStyleDialog::Ok()
126cdf0e10cSrcweir 
127cdf0e10cSrcweir /*  [Beschreibung]
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	"Uberladen, damit immer RET_OK zur"uckgegeben wird.
130cdf0e10cSrcweir */
131cdf0e10cSrcweir 
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	SfxTabDialog::Ok();
134cdf0e10cSrcweir 	return RET_OK;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir // -----------------------------------------------------------------------
138cdf0e10cSrcweir 
IMPL_LINK(SfxStyleDialog,CancelHdl,Button *,pButton)139cdf0e10cSrcweir IMPL_LINK( SfxStyleDialog, CancelHdl, Button *, pButton )
140cdf0e10cSrcweir 
141cdf0e10cSrcweir /*  [Beschreibung]
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 	Wenn der Dialog abgebrochen wurde, m"ussen alle schon eingestellten
144cdf0e10cSrcweir 	Attribute wieder zur"uckgesetzt werden.
145cdf0e10cSrcweir */
146cdf0e10cSrcweir 
147cdf0e10cSrcweir {
148cdf0e10cSrcweir     (void)pButton; //unused
149cdf0e10cSrcweir     SfxTabPage* pPage = GetTabPage( ID_TABPAGE_MANAGESTYLES );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	const SfxItemSet* pInSet = GetInputSetImpl();
152cdf0e10cSrcweir 	SfxWhichIter aIter( *pInSet );
153cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	while ( nWhich )
156cdf0e10cSrcweir 	{
157cdf0e10cSrcweir 		SfxItemState eState = pInSet->GetItemState( nWhich, sal_False );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 		if ( SFX_ITEM_DEFAULT == eState )
160cdf0e10cSrcweir 			pExampleSet->ClearItem( nWhich );
161cdf0e10cSrcweir 		else
162cdf0e10cSrcweir 			pExampleSet->Put( pInSet->Get( nWhich ) );
163cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
164cdf0e10cSrcweir 	}
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	if ( pPage )
167cdf0e10cSrcweir 		pPage->Reset( *GetInputSetImpl() );
168cdf0e10cSrcweir 	EndDialog( RET_CANCEL );
169cdf0e10cSrcweir 	return 0;
170cdf0e10cSrcweir }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 
173