Update ooo320-m1
[ooovba.git] / svx / source / cui / tabarea.cxx
blob721154a9a9eab65a70ec2529b9411488a02a8b28
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: tabarea.cxx,v $
10 * $Revision: 1.13 $
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_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
36 #endif
38 // include ---------------------------------------------------------------
40 #include <tools/ref.hxx>
41 #include <sfx2/app.hxx>
42 #include <sfx2/objsh.hxx>
43 #ifndef _MSGBOX_HXX //autogen
44 #include <vcl/msgbox.hxx>
45 #endif
46 #include <svtools/pathoptions.hxx>
47 #include <svx/svdmark.hxx>
48 #include <svx/svdobj.hxx>
49 #include <svx/svdview.hxx>
51 #define _SVX_TABAREA_CXX
53 #include <svx/dialogs.hrc>
60 #include <svx/xtable.hxx>
61 #include "globl3d.hxx"
62 #include <svx/svdmodel.hxx>
63 #include "drawitem.hxx"
64 #include "cuitabarea.hxx"
65 #include "tabarea.hrc"
66 #include "dlgname.hxx"
67 #include "dlgname.hrc"
68 #include <svx/dialmgr.hxx>
70 #define DLGWIN this->GetParent()->GetParent()
72 /*************************************************************************
74 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
76 |************************************************************************/
78 SvxAreaTabDialog::SvxAreaTabDialog
80 Window* pParent,
81 const SfxItemSet* pAttr,
82 SdrModel* pModel,
83 const SdrView* /* pSdrView */
84 ) :
86 SfxTabDialog( pParent, SVX_RES( RID_SVXDLG_AREA ), pAttr ),
88 mpDrawModel ( pModel ),
89 // mpView ( pSdrView ),
90 mpColorTab ( pModel->GetColorTable() ),
91 mpNewColorTab ( pModel->GetColorTable() ),
92 mpGradientList ( pModel->GetGradientList() ),
93 mpNewGradientList ( pModel->GetGradientList() ),
94 mpHatchingList ( pModel->GetHatchList() ),
95 mpNewHatchingList ( pModel->GetHatchList() ),
96 mpBitmapList ( pModel->GetBitmapList() ),
97 mpNewBitmapList ( pModel->GetBitmapList() ),
98 mrOutAttrs ( *pAttr ),
99 mnColorTableState ( CT_NONE ),
100 mnBitmapListState ( CT_NONE ),
101 mnGradientListState ( CT_NONE ),
102 mnHatchingListState ( CT_NONE ),
103 mnPageType( PT_AREA ),
104 mnDlgType( 0 ),
105 mnPos( 0 ),
106 mbAreaTP( sal_False ),
107 mbDeleteColorTable( TRUE )
109 FreeResource();
111 AddTabPage( RID_SVXPAGE_AREA, SvxAreaTabPage::Create, 0 );
112 AddTabPage( RID_SVXPAGE_SHADOW, SvxShadowTabPage::Create, 0 );
113 AddTabPage( RID_SVXPAGE_TRANSPARENCE, SvxTransparenceTabPage::Create, 0);
114 AddTabPage( RID_SVXPAGE_COLOR, SvxColorTabPage::Create, 0 );
115 AddTabPage( RID_SVXPAGE_GRADIENT, SvxGradientTabPage::Create, 0 );
116 AddTabPage( RID_SVXPAGE_HATCH, SvxHatchTabPage::Create, 0 );
117 AddTabPage( RID_SVXPAGE_BITMAP, SvxBitmapTabPage::Create, 0);
119 SetCurPageId( RID_SVXPAGE_AREA );
121 CancelButton& rBtnCancel = GetCancelButton();
122 rBtnCancel.SetClickHdl( LINK( this, SvxAreaTabDialog, CancelHdlImpl ) );
123 //! rBtnCancel.SetText( SVX_RESSTR( RID_SVXSTR_CLOSE ) );
126 // -----------------------------------------------------------------------
128 SvxAreaTabDialog::~SvxAreaTabDialog()
133 // -----------------------------------------------------------------------
135 void SvxAreaTabDialog::SavePalettes()
137 SfxObjectShell* pShell = SfxObjectShell::Current();
138 /*uno::Reference< frame::XDispatchProvider > xDispatchProvider;
139 if ( !pShell )
141 uno::Reference< frame::XModel> xModel = mpDrawModel->getUnoModel();
142 if ( xModel.is() )
143 xDispatchProvider.set(xModel->getCurrentController(),uno::UNO_QUERY);
145 if( mpNewColorTab != mpDrawModel->GetColorTable() )
147 if(mbDeleteColorTable)
148 delete mpDrawModel->GetColorTable();
149 mpDrawModel->SetColorTable( mpNewColorTab );
150 SvxColorTableItem aColorTableItem( mpNewColorTab, SID_COLOR_TABLE );
151 if ( pShell )
152 pShell->PutItem( aColorTableItem );
153 else
155 mpDrawModel->GetItemPool().Put(aColorTableItem,SID_COLOR_TABLE);
157 mpColorTab = mpDrawModel->GetColorTable();
159 if( mpNewGradientList != mpDrawModel->GetGradientList() )
161 delete mpDrawModel->GetGradientList();
162 mpDrawModel->SetGradientList( mpNewGradientList );
163 SvxGradientListItem aItem( mpNewGradientList, SID_GRADIENT_LIST );
164 if ( pShell )
165 pShell->PutItem( aItem );
166 else
168 mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST);
170 mpGradientList = mpDrawModel->GetGradientList();
172 if( mpNewHatchingList != mpDrawModel->GetHatchList() )
174 delete mpDrawModel->GetHatchList();
175 mpDrawModel->SetHatchList( mpNewHatchingList );
176 SvxHatchListItem aItem( mpNewHatchingList, SID_HATCH_LIST );
177 if ( pShell )
178 pShell->PutItem( aItem );
179 else
181 mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST);
183 mpHatchingList = mpDrawModel->GetHatchList();
185 if( mpNewBitmapList != mpDrawModel->GetBitmapList() )
187 delete mpDrawModel->GetBitmapList();
188 mpDrawModel->SetBitmapList( mpNewBitmapList );
189 SvxBitmapListItem aItem( mpNewBitmapList, SID_BITMAP_LIST );
190 if ( pShell )
191 pShell->PutItem( aItem );
192 else
194 mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST);
196 mpBitmapList = mpDrawModel->GetBitmapList();
199 // Speichern der Tabellen, wenn sie geaendert wurden.
201 const String aPath( SvtPathOptions().GetPalettePath() );
203 if( mnHatchingListState & CT_MODIFIED )
205 mpHatchingList->SetPath( aPath );
206 mpHatchingList->Save();
208 SvxHatchListItem aItem( mpHatchingList, SID_HATCH_LIST );
209 // ToolBoxControls werden benachrichtigt:
210 if ( pShell )
211 pShell->PutItem( aItem );
212 else
214 mpDrawModel->GetItemPool().Put(aItem);
218 if( mnBitmapListState & CT_MODIFIED )
220 mpBitmapList->SetPath( aPath );
221 mpBitmapList->Save();
223 SvxBitmapListItem aItem( mpBitmapList, SID_BITMAP_LIST );
224 // ToolBoxControls werden benachrichtigt:
225 if ( pShell )
226 pShell->PutItem( aItem );
227 else
229 mpDrawModel->GetItemPool().Put(aItem);
233 if( mnGradientListState & CT_MODIFIED )
235 mpGradientList->SetPath( aPath );
236 mpGradientList->Save();
238 SvxGradientListItem aItem( mpGradientList, SID_GRADIENT_LIST );
239 // ToolBoxControls werden benachrichtigt:
240 if ( pShell )
241 pShell->PutItem( aItem );
242 else
244 mpDrawModel->GetItemPool().Put(aItem);
248 if( mnColorTableState & CT_MODIFIED )
250 mpColorTab->SetPath( aPath );
251 mpColorTab->Save();
253 SvxColorTableItem aItem( mpColorTab, SID_COLOR_TABLE );
254 // ToolBoxControls werden benachrichtigt:
255 if ( pShell )
256 pShell->PutItem( aItem );
257 else
259 mpDrawModel->GetItemPool().Put(aItem);
263 // -----------------------------------------------------------------------
265 short SvxAreaTabDialog::Ok()
267 SavePalettes();
269 // Es wird RET_OK zurueckgeliefert, wenn wenigstens eine
270 // TabPage in FillItemSet() TRUE zurueckliefert. Dieses
271 // geschieht z.Z. standardmaessig.
272 return( SfxTabDialog::Ok() );
275 // -----------------------------------------------------------------------
277 IMPL_LINK_INLINE_START( SvxAreaTabDialog, CancelHdlImpl, void *, EMPTYARG)
279 SavePalettes();
281 EndDialog( RET_CANCEL );
282 return 0;
284 IMPL_LINK_INLINE_END( SvxAreaTabDialog, CancelHdlImpl, void *, p )
286 // -----------------------------------------------------------------------
288 void SvxAreaTabDialog::PageCreated( USHORT nId, SfxTabPage &rPage )
290 switch( nId )
292 case RID_SVXPAGE_AREA:
293 ( (SvxAreaTabPage&) rPage ).SetColorTable( mpColorTab );
294 ( (SvxAreaTabPage&) rPage ).SetGradientList( mpGradientList );
295 ( (SvxAreaTabPage&) rPage ).SetHatchingList( mpHatchingList );
296 ( (SvxAreaTabPage&) rPage ).SetBitmapList( mpBitmapList );
297 //CHINA001 ( (SvxAreaTabPage&) rPage ).SetPageType( &mnPageType );
298 ( (SvxAreaTabPage&) rPage ).SetPageType( mnPageType ); //add CHINA001
299 //CHINA001 ( (SvxAreaTabPage&) rPage ).SetDlgType( &mnDlgType );
300 ( (SvxAreaTabPage&) rPage ).SetDlgType( mnDlgType );//add CHINA001
301 //CHINA001 ( (SvxAreaTabPage&) rPage ).SetPos( &nPos );
302 ( (SvxAreaTabPage&) rPage ).SetPos( mnPos );//add CHINA001
303 ( (SvxAreaTabPage&) rPage ).SetAreaTP( &mbAreaTP );
304 ( (SvxAreaTabPage&) rPage ).SetGrdChgd( &mnGradientListState );
305 ( (SvxAreaTabPage&) rPage ).SetHtchChgd( &mnHatchingListState );
306 ( (SvxAreaTabPage&) rPage ).SetBmpChgd( &mnBitmapListState );
307 ( (SvxAreaTabPage&) rPage ).SetColorChgd( &mnColorTableState );
308 ( (SvxAreaTabPage&) rPage ).Construct();
309 // ActivatePage() wird das erste mal nicht gerufen
310 ( (SvxAreaTabPage&) rPage ).ActivatePage( mrOutAttrs );
312 break;
314 case RID_SVXPAGE_SHADOW:
316 ( (SvxShadowTabPage&) rPage ).SetColorTable( mpColorTab );
317 ( (SvxShadowTabPage&) rPage ).SetPageType( mnPageType );//CHINA001 ( (SvxShadowTabPage&) rPage ).SetPageType( &mnPageType );
318 ( (SvxShadowTabPage&) rPage ).SetDlgType( mnDlgType );//CHINA001 ( (SvxShadowTabPage&) rPage ).SetDlgType( &mnDlgType );
319 //( (SvxShadowTabPage&) rPage ).SetPos( &nPos );
320 ( (SvxShadowTabPage&) rPage ).SetAreaTP( &mbAreaTP );
321 ( (SvxShadowTabPage&) rPage ).SetColorChgd( &mnColorTableState );
322 ( (SvxShadowTabPage&) rPage ).Construct();
324 break;
326 case RID_SVXPAGE_GRADIENT:
327 ( (SvxGradientTabPage&) rPage ).SetColorTable( mpColorTab );
328 ( (SvxGradientTabPage&) rPage ).SetGradientList( mpGradientList );
329 ( (SvxGradientTabPage&) rPage ).SetPageType( &mnPageType );
330 ( (SvxGradientTabPage&) rPage ).SetDlgType( &mnDlgType );
331 ( (SvxGradientTabPage&) rPage ).SetPos( &mnPos );
332 ( (SvxGradientTabPage&) rPage ).SetAreaTP( &mbAreaTP );
333 ( (SvxGradientTabPage&) rPage ).SetGrdChgd( &mnGradientListState );
334 ( (SvxGradientTabPage&) rPage ).SetColorChgd( &mnColorTableState );
335 ( (SvxGradientTabPage&) rPage ).Construct();
336 break;
338 case RID_SVXPAGE_HATCH:
339 ( (SvxHatchTabPage&) rPage ).SetColorTable( mpColorTab );
340 ( (SvxHatchTabPage&) rPage ).SetHatchingList( mpHatchingList );
341 ( (SvxHatchTabPage&) rPage ).SetPageType( &mnPageType );
342 ( (SvxHatchTabPage&) rPage ).SetDlgType( &mnDlgType );
343 ( (SvxHatchTabPage&) rPage ).SetPos( &mnPos );
344 ( (SvxHatchTabPage&) rPage ).SetAreaTP( &mbAreaTP );
345 ( (SvxHatchTabPage&) rPage ).SetHtchChgd( &mnHatchingListState );
346 ( (SvxHatchTabPage&) rPage ).SetColorChgd( &mnColorTableState );
347 ( (SvxHatchTabPage&) rPage ).Construct();
348 break;
350 case RID_SVXPAGE_BITMAP:
351 ( (SvxBitmapTabPage&) rPage ).SetColorTable( mpColorTab );
352 ( (SvxBitmapTabPage&) rPage ).SetBitmapList( mpBitmapList );
353 ( (SvxBitmapTabPage&) rPage ).SetPageType( &mnPageType );
354 ( (SvxBitmapTabPage&) rPage ).SetDlgType( &mnDlgType );
355 ( (SvxBitmapTabPage&) rPage ).SetPos( &mnPos );
356 ( (SvxBitmapTabPage&) rPage ).SetAreaTP( &mbAreaTP );
357 ( (SvxBitmapTabPage&) rPage ).SetBmpChgd( &mnBitmapListState );
358 ( (SvxBitmapTabPage&) rPage ).SetColorChgd( &mnColorTableState );
359 ( (SvxBitmapTabPage&) rPage ).Construct();
360 break;
362 case RID_SVXPAGE_COLOR:
363 ( (SvxColorTabPage&) rPage ).SetColorTable( mpColorTab );
364 ( (SvxColorTabPage&) rPage ).SetPageType( &mnPageType );
365 ( (SvxColorTabPage&) rPage ).SetDlgType( &mnDlgType );
366 ( (SvxColorTabPage&) rPage ).SetPos( &mnPos );
367 ( (SvxColorTabPage&) rPage ).SetAreaTP( &mbAreaTP );
368 ( (SvxColorTabPage&) rPage ).SetColorChgd( &mnColorTableState );
369 ( (SvxColorTabPage&) rPage ).SetDeleteColorTable( mbDeleteColorTable );
370 ( (SvxColorTabPage&) rPage ).Construct();
371 break;
373 case RID_SVXPAGE_TRANSPARENCE:
374 ( (SvxTransparenceTabPage&) rPage ).SetPageType( mnPageType );//CHINA001 ( (SvxTransparenceTabPage&) rPage ).SetPageType( &mnPageType );
375 ( (SvxTransparenceTabPage&) rPage ).SetDlgType( mnDlgType );//CHINA001 ( (SvxTransparenceTabPage&) rPage ).SetDlgType( &mnDlgType );
376 ( (SvxTransparenceTabPage&) rPage ).Construct();
377 break;