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