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