1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_cui.hxx" 30 31 // include --------------------------------------------------------------- 32 #include <tools/shl.hxx> 33 #include <vcl/msgbox.hxx> 34 #include <unotools/pathoptions.hxx> 35 #include <sfx2/app.hxx> 36 #include <sfx2/objsh.hxx> 37 #include <svx/dialogs.hrc> 38 39 #define _SVX_TABLINE_CXX 40 #include <cuires.hrc> 41 #include "tabline.hrc" 42 //#include "dlgname.hrc" 43 44 #include "cuitabarea.hxx" 45 #include "cuitabline.hxx" 46 #include "dlgname.hxx" 47 #include <dialmgr.hxx> 48 #include <svx/svdmodel.hxx> 49 #include <svx/xtable.hxx> 50 #include "svx/drawitem.hxx" 51 52 #define DLGWIN this->GetParent()->GetParent() 53 54 #define BITMAP_WIDTH 32 55 #define BITMAP_HEIGHT 12 56 #define XOUT_WIDTH 150 57 58 /************************************************************************* 59 |* 60 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu 61 |* 62 \************************************************************************/ 63 64 SvxLineTabDialog::SvxLineTabDialog 65 ( 66 Window* pParent, 67 const SfxItemSet* pAttr, 68 SdrModel* pModel, 69 const SdrObject* pSdrObj, 70 sal_Bool bHasObj 71 ) : 72 73 SfxTabDialog ( pParent, CUI_RES( RID_SVXDLG_LINE ), pAttr ), 74 pDrawModel ( pModel ), 75 pObj ( pSdrObj ), 76 rOutAttrs ( *pAttr ), 77 pColorTab ( pModel->GetColorTable() ), 78 mpNewColorTab ( pModel->GetColorTable() ), 79 pDashList ( pModel->GetDashList() ), 80 pNewDashList ( pModel->GetDashList() ), 81 pLineEndList ( pModel->GetLineEndList() ), 82 pNewLineEndList ( pModel->GetLineEndList() ), 83 bObjSelected ( bHasObj ), 84 nLineEndListState( CT_NONE ), 85 nDashListState( CT_NONE ), 86 mnColorTableState( CT_NONE ), 87 nPageType( 0 ), // wird hier in erster Linie benutzt, um mit FillItemSet 88 // die richtigen Attribute zu erhalten ( noch Fragen? ) 89 nDlgType( 0 ), 90 nPosDashLb( 0 ), 91 nPosLineEndLb( 0 ), 92 mnPos( 0 ), 93 mbAreaTP( sal_False ), 94 mbDeleteColorTable( sal_True ) 95 { 96 FreeResource(); 97 98 bool bLineOnly = false; 99 if( pObj && pObj->GetObjInventor() == SdrInventor ) 100 { 101 switch( pObj->GetObjIdentifier() ) 102 { 103 case OBJ_LINE: 104 case OBJ_PLIN: 105 case OBJ_PATHLINE: 106 case OBJ_FREELINE: 107 case OBJ_MEASURE: 108 case OBJ_EDGE: 109 bLineOnly = true; 110 111 default: 112 break; 113 } 114 115 } 116 117 AddTabPage( RID_SVXPAGE_LINE, SvxLineTabPage::Create, 0); 118 if( bLineOnly ) 119 AddTabPage( RID_SVXPAGE_SHADOW, SvxShadowTabPage::Create, 0 ); 120 else 121 RemoveTabPage( RID_SVXPAGE_SHADOW ); 122 123 AddTabPage( RID_SVXPAGE_LINE_DEF, SvxLineDefTabPage::Create, 0); 124 AddTabPage( RID_SVXPAGE_LINEEND_DEF, SvxLineEndDefTabPage::Create, 0); 125 // AddTabPage( RID_SVXPAGE_COLOR, SvxColorTabPage::Create, 0 ); 126 127 SetCurPageId( RID_SVXPAGE_LINE ); 128 129 CancelButton& rBtnCancel = GetCancelButton(); 130 rBtnCancel.SetClickHdl( LINK( this, SvxLineTabDialog, CancelHdlImpl ) ); 131 //! rBtnCancel.SetText( CUI_RESSTR( RID_SVXSTR_CLOSE ) ); 132 } 133 134 // ----------------------------------------------------------------------- 135 136 SvxLineTabDialog::~SvxLineTabDialog() 137 { 138 } 139 140 // ----------------------------------------------------------------------- 141 142 void SvxLineTabDialog::SavePalettes() 143 { 144 SfxObjectShell* pShell = SfxObjectShell::Current(); 145 if( mpNewColorTab != pDrawModel->GetColorTable() ) 146 { 147 if(mbDeleteColorTable) 148 delete pDrawModel->GetColorTable(); 149 pDrawModel->SetColorTable( mpNewColorTab ); 150 if ( pShell ) 151 pShell->PutItem( SvxColorTableItem( mpNewColorTab, SID_COLOR_TABLE ) ); 152 pColorTab = pDrawModel->GetColorTable(); 153 } 154 if( pNewDashList != pDrawModel->GetDashList() ) 155 { 156 delete pDrawModel->GetDashList(); 157 pDrawModel->SetDashList( pNewDashList ); 158 if ( pShell ) 159 pShell->PutItem( SvxDashListItem( pNewDashList, SID_DASH_LIST ) ); 160 pDashList = pDrawModel->GetDashList(); 161 } 162 if( pNewLineEndList != pDrawModel->GetLineEndList() ) 163 { 164 delete pDrawModel->GetLineEndList(); 165 pDrawModel->SetLineEndList( pNewLineEndList ); 166 if ( pShell ) 167 pShell->PutItem( SvxLineEndListItem( pNewLineEndList, SID_LINEEND_LIST ) ); 168 pLineEndList = pDrawModel->GetLineEndList(); 169 } 170 171 // Speichern der Tabellen, wenn sie geaendert wurden. 172 173 const String aPath( SvtPathOptions().GetPalettePath() ); 174 175 if( nDashListState & CT_MODIFIED ) 176 { 177 pDashList->SetPath( aPath ); 178 pDashList->Save(); 179 180 // ToolBoxControls werden benachrichtigt: 181 if ( pShell ) 182 pShell->PutItem( SvxDashListItem( pDashList, SID_DASH_LIST ) ); 183 } 184 185 if( nLineEndListState & CT_MODIFIED ) 186 { 187 pLineEndList->SetPath( aPath ); 188 pLineEndList->Save(); 189 190 // ToolBoxControls werden benachrichtigt: 191 if ( pShell ) 192 pShell->PutItem( SvxLineEndListItem( pLineEndList, SID_LINEEND_LIST ) ); 193 } 194 195 if( mnColorTableState & CT_MODIFIED ) 196 { 197 pColorTab->SetPath( aPath ); 198 pColorTab->Save(); 199 200 // ToolBoxControls werden benachrichtigt: 201 if ( pShell ) 202 pShell->PutItem( SvxColorTableItem( pColorTab, SID_COLOR_TABLE ) ); 203 } 204 } 205 206 // ----------------------------------------------------------------------- 207 208 short SvxLineTabDialog::Ok() 209 { 210 SavePalettes(); 211 212 // Es wird RET_OK zurueckgeliefert, wenn wenigstens eine 213 // TabPage in FillItemSet() sal_True zurueckliefert. Dieses 214 // geschieht z.Z. standardmaessig. 215 return( SfxTabDialog::Ok() ); 216 } 217 218 // ----------------------------------------------------------------------- 219 220 IMPL_LINK_INLINE_START( SvxLineTabDialog, CancelHdlImpl, void *, EMPTYARG ) 221 { 222 SavePalettes(); 223 224 EndDialog( RET_CANCEL ); 225 return 0; 226 } 227 IMPL_LINK_INLINE_END( SvxLineTabDialog, CancelHdlImpl, void *, EMPTYARG ) 228 229 // ----------------------------------------------------------------------- 230 231 void SvxLineTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) 232 { 233 switch( nId ) 234 { 235 case RID_SVXPAGE_LINE: 236 ( (SvxLineTabPage&) rPage ).SetColorTable( pColorTab ); 237 ( (SvxLineTabPage&) rPage ).SetDashList( pDashList ); 238 ( (SvxLineTabPage&) rPage ).SetLineEndList( pLineEndList ); 239 ( (SvxLineTabPage&) rPage ).SetDlgType( nDlgType );//CHINA001 ( (SvxLineTabPage&) rPage ).SetDlgType( &nDlgType ); 240 ( (SvxLineTabPage&) rPage ).SetPageType( nPageType );//CHINA001 ( (SvxLineTabPage&) rPage ).SetPageType( &nPageType ); 241 ( (SvxLineTabPage&) rPage ).SetPosDashLb( &nPosDashLb ); 242 ( (SvxLineTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb ); 243 ( (SvxLineTabPage&) rPage ).SetDashChgd( &nDashListState ); 244 ( (SvxLineTabPage&) rPage ).SetLineEndChgd( &nLineEndListState ); 245 ( (SvxLineTabPage&) rPage ).SetObjSelected( bObjSelected ); 246 ( (SvxLineTabPage&) rPage ).Construct(); 247 ( (SvxLineTabPage&) rPage ).SetColorChgd( &mnColorTableState ); 248 // ActivatePage() wird das erste mal nicht gerufen 249 ( (SvxLineTabPage&) rPage ).ActivatePage( rOutAttrs ); 250 break; 251 252 case RID_SVXPAGE_LINE_DEF: 253 ( (SvxLineDefTabPage&) rPage ).SetDashList( pDashList ); 254 ( (SvxLineDefTabPage&) rPage ).SetDlgType( &nDlgType ); 255 ( (SvxLineDefTabPage&) rPage ).SetPageType( &nPageType ); 256 ( (SvxLineDefTabPage&) rPage ).SetPosDashLb( &nPosDashLb ); 257 ( (SvxLineDefTabPage&) rPage ).SetDashChgd( &nDashListState ); 258 ( (SvxLineDefTabPage&) rPage ).SetObjSelected( bObjSelected ); 259 ( (SvxLineDefTabPage&) rPage ).Construct(); 260 break; 261 262 case RID_SVXPAGE_LINEEND_DEF: 263 ( (SvxLineEndDefTabPage&) rPage ).SetLineEndList( pLineEndList ); 264 ( (SvxLineEndDefTabPage&) rPage ).SetPolyObj( pObj ); 265 ( (SvxLineEndDefTabPage&) rPage ).SetDlgType( &nDlgType ); 266 ( (SvxLineEndDefTabPage&) rPage ).SetPageType( &nPageType ); 267 ( (SvxLineEndDefTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb ); 268 ( (SvxLineEndDefTabPage&) rPage ).SetLineEndChgd( &nLineEndListState ); 269 ( (SvxLineEndDefTabPage&) rPage ).SetObjSelected( bObjSelected ); 270 ( (SvxLineEndDefTabPage&) rPage ).Construct(); 271 break; 272 273 case RID_SVXPAGE_SHADOW: 274 { 275 ( (SvxShadowTabPage&) rPage ).SetColorTable( pColorTab ); 276 ( (SvxShadowTabPage&) rPage ).SetPageType( nPageType ); 277 ( (SvxShadowTabPage&) rPage ).SetDlgType( nDlgType ); 278 ( (SvxShadowTabPage&) rPage ).SetAreaTP( &mbAreaTP ); 279 ( (SvxShadowTabPage&) rPage ).SetColorChgd( &mnColorTableState ); 280 ( (SvxShadowTabPage&) rPage ).Construct(); 281 } 282 break; 283 /* 284 case RID_SVXPAGE_COLOR: 285 ( (SvxColorTabPage&) rPage ).SetColorTable( pColorTab ); 286 ( (SvxColorTabPage&) rPage ).SetPageType( &nPageType ); 287 ( (SvxColorTabPage&) rPage ).SetDlgType( &nDlgType ); 288 ( (SvxColorTabPage&) rPage ).SetPos( &mnPos ); 289 ( (SvxColorTabPage&) rPage ).SetAreaTP( &mbAreaTP ); 290 ( (SvxColorTabPage&) rPage ).SetColorChgd( &mnColorTableState ); 291 ( (SvxColorTabPage&) rPage ).SetDeleteColorTable( mbDeleteColorTable ); 292 ( (SvxColorTabPage&) rPage ).Construct(); 293 break; 294 */ 295 } 296 } 297 298 299