xref: /aoo4110/main/cui/source/tabpages/tabarea.cxx (revision b1cdbd2c)
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_cui.hxx"
26 
27 // include ---------------------------------------------------------------
28 
29 #include <tools/ref.hxx>
30 #include <sfx2/app.hxx>
31 #include <sfx2/objsh.hxx>
32 #include <vcl/msgbox.hxx>
33 #include <unotools/pathoptions.hxx>
34 #include <svx/svdmark.hxx>
35 #include <svx/svdobj.hxx>
36 #include <svx/svdview.hxx>
37 #include <svx/dialogs.hrc>
38 
39 #define _SVX_TABAREA_CXX
40 
41 #include <cuires.hrc>
42 #include <svx/xtable.hxx>
43 #include "svx/globl3d.hxx"
44 #include <svx/svdmodel.hxx>
45 #include "svx/drawitem.hxx"
46 #include "cuitabarea.hxx"
47 #include "tabarea.hrc"
48 #include "dlgname.hxx"
49 //#include "dlgname.hrc"
50 #include <dialmgr.hxx>
51 
52 #define DLGWIN this->GetParent()->GetParent()
53 
54 /*************************************************************************
55 |*
56 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
57 |*
58 |************************************************************************/
59 
SvxAreaTabDialog(Window * pParent,const SfxItemSet * pAttr,SdrModel * pModel,const SdrView *)60 SvxAreaTabDialog::SvxAreaTabDialog
61 (
62 	Window* pParent,
63 	const SfxItemSet* pAttr,
64 	SdrModel* pModel,
65 	const SdrView* /* pSdrView */
66 ) :
67 
68 	SfxTabDialog( pParent, CUI_RES( RID_SVXDLG_AREA ), pAttr ),
69 
70     mpDrawModel          ( pModel ),
71     maColorTab           ( pModel->GetColorTableFromSdrModel() ),
72     maNewColorTab        ( pModel->GetColorTableFromSdrModel() ),
73     maGradientList       ( pModel->GetGradientListFromSdrModel() ),
74     maNewGradientList    ( pModel->GetGradientListFromSdrModel() ),
75     maHatchingList       ( pModel->GetHatchListFromSdrModel() ),
76     maNewHatchingList    ( pModel->GetHatchListFromSdrModel() ),
77     maBitmapList         ( pModel->GetBitmapListFromSdrModel() ),
78     maNewBitmapList      ( pModel->GetBitmapListFromSdrModel() ),
79     mrOutAttrs           ( *pAttr ),
80     mnColorTableState ( CT_NONE ),
81     mnBitmapListState ( CT_NONE ),
82     mnGradientListState ( CT_NONE ),
83     mnHatchingListState ( CT_NONE ),
84     mnPageType( PT_AREA ),
85     mnDlgType( 0 ),
86     mnPos( 0 ),
87     mbAreaTP( sal_False )
88 {
89 	FreeResource();
90 
91 	AddTabPage( RID_SVXPAGE_AREA, SvxAreaTabPage::Create, 0 );
92 	AddTabPage( RID_SVXPAGE_SHADOW, SvxShadowTabPage::Create, 0 );
93 	AddTabPage( RID_SVXPAGE_TRANSPARENCE, SvxTransparenceTabPage::Create,  0);
94 	AddTabPage( RID_SVXPAGE_COLOR, SvxColorTabPage::Create, 0 );
95 	AddTabPage( RID_SVXPAGE_GRADIENT, SvxGradientTabPage::Create, 0 );
96 	AddTabPage( RID_SVXPAGE_HATCH, SvxHatchTabPage::Create, 0 );
97 	AddTabPage( RID_SVXPAGE_BITMAP, SvxBitmapTabPage::Create,  0);
98 
99 	SetCurPageId( RID_SVXPAGE_AREA );
100 
101 	CancelButton& rBtnCancel = GetCancelButton();
102 	rBtnCancel.SetClickHdl( LINK( this, SvxAreaTabDialog, CancelHdlImpl ) );
103 //! rBtnCancel.SetText( CUI_RESSTR( RID_SVXSTR_CLOSE ) );
104 }
105 
106 // -----------------------------------------------------------------------
107 
~SvxAreaTabDialog()108 SvxAreaTabDialog::~SvxAreaTabDialog()
109 {
110 }
111 
112 
113 // -----------------------------------------------------------------------
114 
SavePalettes()115 void SvxAreaTabDialog::SavePalettes()
116 {
117     SfxObjectShell* pShell = SfxObjectShell::Current();
118     /*uno::Reference< frame::XDispatchProvider > xDispatchProvider;
119     if ( !pShell )
120     {
121         uno::Reference< frame::XModel> xModel = mpDrawModel->getUnoModel();
122         if ( xModel.is() )
123             xDispatchProvider.set(xModel->getCurrentController(),uno::UNO_QUERY);
124     }*/
125 	if( maNewColorTab != mpDrawModel->GetColorTableFromSdrModel() )
126 	{
127 		mpDrawModel->SetColorTableAtSdrModel( maNewColorTab );
128         SvxColorTableItem aColorTableItem( maNewColorTab, SID_COLOR_TABLE );
129         if ( pShell )
130             pShell->PutItem( aColorTableItem );
131         else
132         {
133             mpDrawModel->GetItemPool().Put(aColorTableItem,SID_COLOR_TABLE);
134         }
135 		maColorTab = mpDrawModel->GetColorTableFromSdrModel();
136 	}
137 	if( maNewGradientList != mpDrawModel->GetGradientListFromSdrModel() )
138 	{
139 		mpDrawModel->SetGradientListAtSdrModel( maNewGradientList );
140         SvxGradientListItem aItem( maNewGradientList, SID_GRADIENT_LIST );
141         if ( pShell )
142             pShell->PutItem( aItem );
143         else
144         {
145             mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST);
146         }
147 		maGradientList = mpDrawModel->GetGradientListFromSdrModel();
148 	}
149 	if( maNewHatchingList != mpDrawModel->GetHatchListFromSdrModel() )
150 	{
151 		mpDrawModel->SetHatchListAtSdrModel( maNewHatchingList );
152         SvxHatchListItem aItem( maNewHatchingList, SID_HATCH_LIST );
153         if ( pShell )
154             pShell->PutItem( aItem );
155         else
156         {
157             mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST);
158         }
159 		maHatchingList = mpDrawModel->GetHatchListFromSdrModel();
160 	}
161 	if( maNewBitmapList != mpDrawModel->GetBitmapListFromSdrModel() )
162 	{
163 		mpDrawModel->SetBitmapListAtSdrModel( maNewBitmapList );
164         SvxBitmapListItem aItem( maNewBitmapList, SID_BITMAP_LIST );
165         if ( pShell )
166             pShell->PutItem( aItem );
167         else
168         {
169             mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST);
170         }
171 		maBitmapList = mpDrawModel->GetBitmapListFromSdrModel();
172 	}
173 
174 	// Speichern der Tabellen, wenn sie geaendert wurden.
175 
176 	const String aPath( SvtPathOptions().GetPalettePath() );
177 
178 	if( mnHatchingListState & CT_MODIFIED )
179 	{
180 		maHatchingList->SetPath( aPath );
181 		maHatchingList->Save();
182 
183         SvxHatchListItem aItem( maHatchingList, SID_HATCH_LIST );
184 		// ToolBoxControls werden benachrichtigt:
185         if ( pShell )
186             pShell->PutItem( aItem );
187         else
188         {
189             mpDrawModel->GetItemPool().Put(aItem);
190         }
191 	}
192 
193 	if( mnBitmapListState & CT_MODIFIED )
194 	{
195 		maBitmapList->SetPath( aPath );
196 		maBitmapList->Save();
197 
198         SvxBitmapListItem aItem( maBitmapList, SID_BITMAP_LIST );
199 		// ToolBoxControls werden benachrichtigt:
200         if ( pShell )
201             pShell->PutItem( aItem );
202         else
203         {
204             mpDrawModel->GetItemPool().Put(aItem);
205         }
206 	}
207 
208 	if( mnGradientListState & CT_MODIFIED )
209 	{
210 		maGradientList->SetPath( aPath );
211 		maGradientList->Save();
212 
213         SvxGradientListItem aItem( maGradientList, SID_GRADIENT_LIST );
214 		// ToolBoxControls werden benachrichtigt:
215         if ( pShell )
216             pShell->PutItem( aItem );
217         else
218         {
219             mpDrawModel->GetItemPool().Put(aItem);
220         }
221 	}
222 
223 	if( mnColorTableState & CT_MODIFIED )
224 	{
225 		maColorTab->SetPath( aPath );
226 		maColorTab->Save();
227 
228         SvxColorTableItem aItem( maColorTab, SID_COLOR_TABLE );
229 		// ToolBoxControls werden benachrichtigt:
230         if ( pShell )
231             pShell->PutItem( aItem );
232         else
233         {
234             mpDrawModel->GetItemPool().Put(aItem);
235         }
236 	}
237 }
238 // -----------------------------------------------------------------------
239 
Ok()240 short SvxAreaTabDialog::Ok()
241 {
242 	SavePalettes();
243 
244 	// Es wird RET_OK zurueckgeliefert, wenn wenigstens eine
245 	// TabPage in FillItemSet() sal_True zurueckliefert. Dieses
246 	// geschieht z.Z. standardmaessig.
247 	return( SfxTabDialog::Ok() );
248 }
249 
250 // -----------------------------------------------------------------------
251 
IMPL_LINK_INLINE_START(SvxAreaTabDialog,CancelHdlImpl,void *,EMPTYARG)252 IMPL_LINK_INLINE_START( SvxAreaTabDialog, CancelHdlImpl, void *, EMPTYARG)
253 {
254 	SavePalettes();
255 
256 	EndDialog( RET_CANCEL );
257 	return 0;
258 }
IMPL_LINK_INLINE_END(SvxAreaTabDialog,CancelHdlImpl,void *,p)259 IMPL_LINK_INLINE_END( SvxAreaTabDialog, CancelHdlImpl, void *, p )
260 
261 // -----------------------------------------------------------------------
262 
263 void SvxAreaTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
264 {
265 	switch( nId )
266 	{
267 		case RID_SVXPAGE_AREA:
268 			( (SvxAreaTabPage&) rPage ).SetColorTable( maColorTab );
269 			( (SvxAreaTabPage&) rPage ).SetGradientList( maGradientList );
270 			( (SvxAreaTabPage&) rPage ).SetHatchingList( maHatchingList );
271 			( (SvxAreaTabPage&) rPage ).SetBitmapList( maBitmapList );
272 			//CHINA001 ( (SvxAreaTabPage&) rPage ).SetPageType( &mnPageType );
273 			( (SvxAreaTabPage&) rPage ).SetPageType( mnPageType ); //add CHINA001
274 			//CHINA001 ( (SvxAreaTabPage&) rPage ).SetDlgType( &mnDlgType );
275 			( (SvxAreaTabPage&) rPage ).SetDlgType( mnDlgType );//add CHINA001
276 			//CHINA001 ( (SvxAreaTabPage&) rPage ).SetPos( &nPos );
277 			( (SvxAreaTabPage&) rPage ).SetPos( mnPos );//add CHINA001
278 			( (SvxAreaTabPage&) rPage ).SetAreaTP( &mbAreaTP );
279 			( (SvxAreaTabPage&) rPage ).SetGrdChgd( &mnGradientListState );
280 			( (SvxAreaTabPage&) rPage ).SetHtchChgd( &mnHatchingListState );
281 			( (SvxAreaTabPage&) rPage ).SetBmpChgd( &mnBitmapListState );
282 			( (SvxAreaTabPage&) rPage ).SetColorChgd( &mnColorTableState );
283 			( (SvxAreaTabPage&) rPage ).Construct();
284 			// ActivatePage() wird das erste mal nicht gerufen
285 			( (SvxAreaTabPage&) rPage ).ActivatePage( mrOutAttrs );
286 
287 		break;
288 
289 		case RID_SVXPAGE_SHADOW:
290 		{
291 			( (SvxShadowTabPage&) rPage ).SetColorTable( maColorTab );
292 			( (SvxShadowTabPage&) rPage ).SetPageType( mnPageType );//CHINA001 ( (SvxShadowTabPage&) rPage ).SetPageType( &mnPageType );
293 			( (SvxShadowTabPage&) rPage ).SetDlgType( mnDlgType );//CHINA001 ( (SvxShadowTabPage&) rPage ).SetDlgType( &mnDlgType );
294 			//( (SvxShadowTabPage&) rPage ).SetPos( &nPos );
295 			( (SvxShadowTabPage&) rPage ).SetAreaTP( &mbAreaTP );
296 			( (SvxShadowTabPage&) rPage ).SetColorChgd( &mnColorTableState );
297 			( (SvxShadowTabPage&) rPage ).Construct();
298 		}
299 		break;
300 
301 		case RID_SVXPAGE_GRADIENT:
302 			( (SvxGradientTabPage&) rPage ).SetColorTable( maColorTab );
303 			( (SvxGradientTabPage&) rPage ).SetGradientList( maGradientList );
304 			( (SvxGradientTabPage&) rPage ).SetPageType( &mnPageType );
305 			( (SvxGradientTabPage&) rPage ).SetDlgType( &mnDlgType );
306 			( (SvxGradientTabPage&) rPage ).SetPos( &mnPos );
307 			( (SvxGradientTabPage&) rPage ).SetAreaTP( &mbAreaTP );
308 			( (SvxGradientTabPage&) rPage ).SetGrdChgd( &mnGradientListState );
309 			( (SvxGradientTabPage&) rPage ).SetColorChgd( &mnColorTableState );
310 			( (SvxGradientTabPage&) rPage ).Construct();
311 		break;
312 
313 		case RID_SVXPAGE_HATCH:
314 			( (SvxHatchTabPage&) rPage ).SetColorTable( maColorTab );
315 			( (SvxHatchTabPage&) rPage ).SetHatchingList( maHatchingList );
316 			( (SvxHatchTabPage&) rPage ).SetPageType( &mnPageType );
317 			( (SvxHatchTabPage&) rPage ).SetDlgType( &mnDlgType );
318 			( (SvxHatchTabPage&) rPage ).SetPos( &mnPos );
319 			( (SvxHatchTabPage&) rPage ).SetAreaTP( &mbAreaTP );
320 			( (SvxHatchTabPage&) rPage ).SetHtchChgd( &mnHatchingListState );
321 			( (SvxHatchTabPage&) rPage ).SetColorChgd( &mnColorTableState );
322 			( (SvxHatchTabPage&) rPage ).Construct();
323 		break;
324 
325 		case RID_SVXPAGE_BITMAP:
326 			( (SvxBitmapTabPage&) rPage ).SetColorTable( maColorTab );
327 			( (SvxBitmapTabPage&) rPage ).SetBitmapList( maBitmapList );
328 			( (SvxBitmapTabPage&) rPage ).SetPageType( &mnPageType );
329 			( (SvxBitmapTabPage&) rPage ).SetDlgType( &mnDlgType );
330 			( (SvxBitmapTabPage&) rPage ).SetPos( &mnPos );
331 			( (SvxBitmapTabPage&) rPage ).SetAreaTP( &mbAreaTP );
332 			( (SvxBitmapTabPage&) rPage ).SetBmpChgd( &mnBitmapListState );
333 			( (SvxBitmapTabPage&) rPage ).SetColorChgd( &mnColorTableState );
334 			( (SvxBitmapTabPage&) rPage ).Construct();
335 		break;
336 
337 		case RID_SVXPAGE_COLOR:
338 			( (SvxColorTabPage&) rPage ).SetColorTable( maColorTab );
339 			( (SvxColorTabPage&) rPage ).SetPageType( &mnPageType );
340 			( (SvxColorTabPage&) rPage ).SetDlgType( &mnDlgType );
341 			( (SvxColorTabPage&) rPage ).SetPos( &mnPos );
342 			( (SvxColorTabPage&) rPage ).SetAreaTP( &mbAreaTP );
343 			( (SvxColorTabPage&) rPage ).SetColorChgd( &mnColorTableState );
344 			( (SvxColorTabPage&) rPage ).Construct();
345 		break;
346 
347 		case RID_SVXPAGE_TRANSPARENCE:
348 			( (SvxTransparenceTabPage&) rPage ).SetPageType( mnPageType );//CHINA001 ( (SvxTransparenceTabPage&) rPage ).SetPageType( &mnPageType );
349 			( (SvxTransparenceTabPage&) rPage ).SetDlgType( mnDlgType );//CHINA001 ( (SvxTransparenceTabPage&) rPage ).SetDlgType( &mnDlgType );
350 			( (SvxTransparenceTabPage&) rPage ).Construct();
351 		break;
352 
353 	}
354 }
355 
356 
357