xref: /trunk/main/cui/source/tabpages/tabarea.cxx (revision 64b14621)
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,bool bShadow)60 SvxAreaTabDialog::SvxAreaTabDialog
61 (
62 	Window* pParent,
63 	const SfxItemSet* pAttr,
64 	SdrModel* pModel,
65     bool bShadow
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 
93     if(bShadow)
94     {
95         AddTabPage( RID_SVXPAGE_SHADOW, SvxShadowTabPage::Create, 0 );
96     }
97     else
98     {
99         RemoveTabPage( RID_SVXPAGE_SHADOW );
100     }
101 
102     AddTabPage( RID_SVXPAGE_TRANSPARENCE, SvxTransparenceTabPage::Create,  0);
103     AddTabPage( RID_SVXPAGE_COLOR, SvxColorTabPage::Create, 0 );
104     AddTabPage( RID_SVXPAGE_GRADIENT, SvxGradientTabPage::Create, 0 );
105     AddTabPage( RID_SVXPAGE_HATCH, SvxHatchTabPage::Create, 0 );
106     AddTabPage( RID_SVXPAGE_BITMAP, SvxBitmapTabPage::Create,  0);
107 
108     SetCurPageId( RID_SVXPAGE_AREA );
109 
110     CancelButton& rBtnCancel = GetCancelButton();
111     rBtnCancel.SetClickHdl( LINK( this, SvxAreaTabDialog, CancelHdlImpl ) );
112 //! rBtnCancel.SetText( CUI_RESSTR( RID_SVXSTR_CLOSE ) );
113 }
114 
115 // -----------------------------------------------------------------------
116 
~SvxAreaTabDialog()117 SvxAreaTabDialog::~SvxAreaTabDialog()
118 {
119 }
120 
121 
122 // -----------------------------------------------------------------------
123 
SavePalettes()124 void SvxAreaTabDialog::SavePalettes()
125 {
126     SfxObjectShell* pShell = SfxObjectShell::Current();
127     /*uno::Reference< frame::XDispatchProvider > xDispatchProvider;
128     if ( !pShell )
129     {
130         uno::Reference< frame::XModel> xModel = mpDrawModel->getUnoModel();
131         if ( xModel.is() )
132             xDispatchProvider.set(xModel->getCurrentController(),uno::UNO_QUERY);
133     }*/
134 	if( maNewColorTab != mpDrawModel->GetColorTableFromSdrModel() )
135 	{
136 		mpDrawModel->SetColorTableAtSdrModel( maNewColorTab );
137         SvxColorTableItem aColorTableItem( maNewColorTab, SID_COLOR_TABLE );
138         if ( pShell )
139             pShell->PutItem( aColorTableItem );
140         else
141         {
142             mpDrawModel->GetItemPool().Put(aColorTableItem,SID_COLOR_TABLE);
143         }
144 		maColorTab = mpDrawModel->GetColorTableFromSdrModel();
145 	}
146 	if( maNewGradientList != mpDrawModel->GetGradientListFromSdrModel() )
147 	{
148 		mpDrawModel->SetGradientListAtSdrModel( maNewGradientList );
149         SvxGradientListItem aItem( maNewGradientList, SID_GRADIENT_LIST );
150         if ( pShell )
151             pShell->PutItem( aItem );
152         else
153         {
154             mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST);
155         }
156 		maGradientList = mpDrawModel->GetGradientListFromSdrModel();
157 	}
158 	if( maNewHatchingList != mpDrawModel->GetHatchListFromSdrModel() )
159 	{
160 		mpDrawModel->SetHatchListAtSdrModel( maNewHatchingList );
161         SvxHatchListItem aItem( maNewHatchingList, SID_HATCH_LIST );
162         if ( pShell )
163             pShell->PutItem( aItem );
164         else
165         {
166             mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST);
167         }
168 		maHatchingList = mpDrawModel->GetHatchListFromSdrModel();
169 	}
170 	if( maNewBitmapList != mpDrawModel->GetBitmapListFromSdrModel() )
171 	{
172 		mpDrawModel->SetBitmapListAtSdrModel( maNewBitmapList );
173         SvxBitmapListItem aItem( maNewBitmapList, SID_BITMAP_LIST );
174         if ( pShell )
175             pShell->PutItem( aItem );
176         else
177         {
178             mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST);
179         }
180 		maBitmapList = mpDrawModel->GetBitmapListFromSdrModel();
181 	}
182 
183 	// Speichern der Tabellen, wenn sie geaendert wurden.
184 
185 	const String aPath( SvtPathOptions().GetPalettePath() );
186 
187 	if( mnHatchingListState & CT_MODIFIED )
188 	{
189 		maHatchingList->SetPath( aPath );
190 		maHatchingList->Save();
191 
192         SvxHatchListItem aItem( maHatchingList, SID_HATCH_LIST );
193 		// ToolBoxControls werden benachrichtigt:
194         if ( pShell )
195             pShell->PutItem( aItem );
196         else
197         {
198             mpDrawModel->GetItemPool().Put(aItem);
199         }
200 	}
201 
202 	if( mnBitmapListState & CT_MODIFIED )
203 	{
204 		maBitmapList->SetPath( aPath );
205 		maBitmapList->Save();
206 
207         SvxBitmapListItem aItem( maBitmapList, SID_BITMAP_LIST );
208 		// ToolBoxControls werden benachrichtigt:
209         if ( pShell )
210             pShell->PutItem( aItem );
211         else
212         {
213             mpDrawModel->GetItemPool().Put(aItem);
214         }
215 	}
216 
217 	if( mnGradientListState & CT_MODIFIED )
218 	{
219 		maGradientList->SetPath( aPath );
220 		maGradientList->Save();
221 
222         SvxGradientListItem aItem( maGradientList, SID_GRADIENT_LIST );
223 		// ToolBoxControls werden benachrichtigt:
224         if ( pShell )
225             pShell->PutItem( aItem );
226         else
227         {
228             mpDrawModel->GetItemPool().Put(aItem);
229         }
230 	}
231 
232 	if( mnColorTableState & CT_MODIFIED )
233 	{
234 		maColorTab->SetPath( aPath );
235 		maColorTab->Save();
236 
237         SvxColorTableItem aItem( maColorTab, SID_COLOR_TABLE );
238 		// ToolBoxControls werden benachrichtigt:
239         if ( pShell )
240             pShell->PutItem( aItem );
241         else
242         {
243             mpDrawModel->GetItemPool().Put(aItem);
244         }
245 	}
246 }
247 // -----------------------------------------------------------------------
248 
Ok()249 short SvxAreaTabDialog::Ok()
250 {
251 	SavePalettes();
252 
253 	// Es wird RET_OK zurueckgeliefert, wenn wenigstens eine
254 	// TabPage in FillItemSet() sal_True zurueckliefert. Dieses
255 	// geschieht z.Z. standardmaessig.
256 	return( SfxTabDialog::Ok() );
257 }
258 
259 // -----------------------------------------------------------------------
260 
IMPL_LINK_INLINE_START(SvxAreaTabDialog,CancelHdlImpl,void *,EMPTYARG)261 IMPL_LINK_INLINE_START( SvxAreaTabDialog, CancelHdlImpl, void *, EMPTYARG)
262 {
263 	SavePalettes();
264 
265 	EndDialog( RET_CANCEL );
266 	return 0;
267 }
IMPL_LINK_INLINE_END(SvxAreaTabDialog,CancelHdlImpl,void *,p)268 IMPL_LINK_INLINE_END( SvxAreaTabDialog, CancelHdlImpl, void *, p )
269 
270 // -----------------------------------------------------------------------
271 
272 void SvxAreaTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
273 {
274 	switch( nId )
275 	{
276 		case RID_SVXPAGE_AREA:
277 			( (SvxAreaTabPage&) rPage ).SetColorTable( maColorTab );
278 			( (SvxAreaTabPage&) rPage ).SetGradientList( maGradientList );
279 			( (SvxAreaTabPage&) rPage ).SetHatchingList( maHatchingList );
280 			( (SvxAreaTabPage&) rPage ).SetBitmapList( maBitmapList );
281 			//CHINA001 ( (SvxAreaTabPage&) rPage ).SetPageType( &mnPageType );
282 			( (SvxAreaTabPage&) rPage ).SetPageType( mnPageType ); //add CHINA001
283 			//CHINA001 ( (SvxAreaTabPage&) rPage ).SetDlgType( &mnDlgType );
284 			( (SvxAreaTabPage&) rPage ).SetDlgType( mnDlgType );//add CHINA001
285 			//CHINA001 ( (SvxAreaTabPage&) rPage ).SetPos( &nPos );
286 			( (SvxAreaTabPage&) rPage ).SetPos( mnPos );//add CHINA001
287 			( (SvxAreaTabPage&) rPage ).SetAreaTP( &mbAreaTP );
288 			( (SvxAreaTabPage&) rPage ).SetGrdChgd( &mnGradientListState );
289 			( (SvxAreaTabPage&) rPage ).SetHtchChgd( &mnHatchingListState );
290 			( (SvxAreaTabPage&) rPage ).SetBmpChgd( &mnBitmapListState );
291 			( (SvxAreaTabPage&) rPage ).SetColorChgd( &mnColorTableState );
292 			( (SvxAreaTabPage&) rPage ).Construct();
293 			// ActivatePage() wird das erste mal nicht gerufen
294 			( (SvxAreaTabPage&) rPage ).ActivatePage( mrOutAttrs );
295 
296 		break;
297 
298 		case RID_SVXPAGE_SHADOW:
299 		{
300 			( (SvxShadowTabPage&) rPage ).SetColorTable( maColorTab );
301 			( (SvxShadowTabPage&) rPage ).SetPageType( mnPageType );//CHINA001 ( (SvxShadowTabPage&) rPage ).SetPageType( &mnPageType );
302 			( (SvxShadowTabPage&) rPage ).SetDlgType( mnDlgType );//CHINA001 ( (SvxShadowTabPage&) rPage ).SetDlgType( &mnDlgType );
303 			//( (SvxShadowTabPage&) rPage ).SetPos( &nPos );
304 			( (SvxShadowTabPage&) rPage ).SetAreaTP( &mbAreaTP );
305 			( (SvxShadowTabPage&) rPage ).SetColorChgd( &mnColorTableState );
306 			( (SvxShadowTabPage&) rPage ).Construct();
307 		}
308 		break;
309 
310 		case RID_SVXPAGE_GRADIENT:
311 			( (SvxGradientTabPage&) rPage ).SetColorTable( maColorTab );
312 			( (SvxGradientTabPage&) rPage ).SetGradientList( maGradientList );
313 			( (SvxGradientTabPage&) rPage ).SetPageType( &mnPageType );
314 			( (SvxGradientTabPage&) rPage ).SetDlgType( &mnDlgType );
315 			( (SvxGradientTabPage&) rPage ).SetPos( &mnPos );
316 			( (SvxGradientTabPage&) rPage ).SetAreaTP( &mbAreaTP );
317 			( (SvxGradientTabPage&) rPage ).SetGrdChgd( &mnGradientListState );
318 			( (SvxGradientTabPage&) rPage ).SetColorChgd( &mnColorTableState );
319 			( (SvxGradientTabPage&) rPage ).Construct();
320 		break;
321 
322 		case RID_SVXPAGE_HATCH:
323 			( (SvxHatchTabPage&) rPage ).SetColorTable( maColorTab );
324 			( (SvxHatchTabPage&) rPage ).SetHatchingList( maHatchingList );
325 			( (SvxHatchTabPage&) rPage ).SetPageType( &mnPageType );
326 			( (SvxHatchTabPage&) rPage ).SetDlgType( &mnDlgType );
327 			( (SvxHatchTabPage&) rPage ).SetPos( &mnPos );
328 			( (SvxHatchTabPage&) rPage ).SetAreaTP( &mbAreaTP );
329 			( (SvxHatchTabPage&) rPage ).SetHtchChgd( &mnHatchingListState );
330 			( (SvxHatchTabPage&) rPage ).SetColorChgd( &mnColorTableState );
331 			( (SvxHatchTabPage&) rPage ).Construct();
332 		break;
333 
334 		case RID_SVXPAGE_BITMAP:
335 			( (SvxBitmapTabPage&) rPage ).SetColorTable( maColorTab );
336 			( (SvxBitmapTabPage&) rPage ).SetBitmapList( maBitmapList );
337 			( (SvxBitmapTabPage&) rPage ).SetPageType( &mnPageType );
338 			( (SvxBitmapTabPage&) rPage ).SetDlgType( &mnDlgType );
339 			( (SvxBitmapTabPage&) rPage ).SetPos( &mnPos );
340 			( (SvxBitmapTabPage&) rPage ).SetAreaTP( &mbAreaTP );
341 			( (SvxBitmapTabPage&) rPage ).SetBmpChgd( &mnBitmapListState );
342 			( (SvxBitmapTabPage&) rPage ).SetColorChgd( &mnColorTableState );
343 			( (SvxBitmapTabPage&) rPage ).Construct();
344 		break;
345 
346 		case RID_SVXPAGE_COLOR:
347 			( (SvxColorTabPage&) rPage ).SetColorTable( maColorTab );
348 			( (SvxColorTabPage&) rPage ).SetPageType( &mnPageType );
349 			( (SvxColorTabPage&) rPage ).SetDlgType( &mnDlgType );
350 			( (SvxColorTabPage&) rPage ).SetPos( &mnPos );
351 			( (SvxColorTabPage&) rPage ).SetAreaTP( &mbAreaTP );
352 			( (SvxColorTabPage&) rPage ).SetColorChgd( &mnColorTableState );
353 			( (SvxColorTabPage&) rPage ).Construct();
354 		break;
355 
356 		case RID_SVXPAGE_TRANSPARENCE:
357 			( (SvxTransparenceTabPage&) rPage ).SetPageType( mnPageType );//CHINA001 ( (SvxTransparenceTabPage&) rPage ).SetPageType( &mnPageType );
358 			( (SvxTransparenceTabPage&) rPage ).SetDlgType( mnDlgType );//CHINA001 ( (SvxTransparenceTabPage&) rPage ).SetDlgType( &mnDlgType );
359 			( (SvxTransparenceTabPage&) rPage ).Construct();
360 		break;
361 
362 	}
363 }
364 
365 
366