merge the formfield patch from ooo-build
[ooovba.git] / svx / source / cui / tabline.cxx
blob2479a229564d11639e189fef3e73f0aa2fe50f63
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: tabline.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 ---------------------------------------------------------------
39 #include <tools/shl.hxx>
40 #ifndef _MSGBOX_HXX //autogen
41 #include <vcl/msgbox.hxx>
42 #endif
43 #include <svtools/pathoptions.hxx>
44 #include <sfx2/app.hxx>
45 #include <sfx2/objsh.hxx>
47 #define _SVX_TABLINE_CXX
48 #include <svx/dialogs.hrc>
49 #include "tabline.hrc"
50 #include "dlgname.hrc"
52 #include "cuitabarea.hxx"
53 #include "cuitabline.hxx"
54 #include "dlgname.hxx"
55 #include <svx/dialmgr.hxx>
56 #include <svx/svdmodel.hxx>
57 #include <svx/xtable.hxx>
58 #include "drawitem.hxx"
60 #define DLGWIN this->GetParent()->GetParent()
62 #define BITMAP_WIDTH 32
63 #define BITMAP_HEIGHT 12
64 #define XOUT_WIDTH 150
66 /*************************************************************************
68 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
70 \************************************************************************/
72 SvxLineTabDialog::SvxLineTabDialog
74 Window* pParent,
75 const SfxItemSet* pAttr,
76 SdrModel* pModel,
77 const SdrObject* pSdrObj,
78 BOOL bHasObj
79 ) :
81 SfxTabDialog ( pParent, SVX_RES( RID_SVXDLG_LINE ), pAttr ),
82 pDrawModel ( pModel ),
83 pObj ( pSdrObj ),
84 rOutAttrs ( *pAttr ),
85 pColorTab ( pModel->GetColorTable() ),
86 mpNewColorTab ( pModel->GetColorTable() ),
87 pDashList ( pModel->GetDashList() ),
88 pNewDashList ( pModel->GetDashList() ),
89 pLineEndList ( pModel->GetLineEndList() ),
90 pNewLineEndList ( pModel->GetLineEndList() ),
91 bObjSelected ( bHasObj ),
92 nLineEndListState( CT_NONE ),
93 nDashListState( CT_NONE ),
94 mnColorTableState( CT_NONE ),
95 nPageType( 0 ), // wird hier in erster Linie benutzt, um mit FillItemSet
96 // die richtigen Attribute zu erhalten ( noch Fragen? )
97 nDlgType( 0 ),
98 nPosDashLb( 0 ),
99 nPosLineEndLb( 0 ),
100 mnPos( 0 ),
101 mbAreaTP( sal_False ),
102 mbDeleteColorTable( TRUE )
104 FreeResource();
106 bool bLineOnly = false;
107 if( pObj && pObj->GetObjInventor() == SdrInventor )
109 switch( pObj->GetObjIdentifier() )
111 case OBJ_LINE:
112 case OBJ_PLIN:
113 case OBJ_PATHLINE:
114 case OBJ_FREELINE:
115 case OBJ_MEASURE:
116 case OBJ_EDGE:
117 bLineOnly = true;
119 default:
120 break;
125 AddTabPage( RID_SVXPAGE_LINE, SvxLineTabPage::Create, 0);
126 if( bLineOnly )
127 AddTabPage( RID_SVXPAGE_SHADOW, SvxShadowTabPage::Create, 0 );
128 else
129 RemoveTabPage( RID_SVXPAGE_SHADOW );
131 AddTabPage( RID_SVXPAGE_LINE_DEF, SvxLineDefTabPage::Create, 0);
132 AddTabPage( RID_SVXPAGE_LINEEND_DEF, SvxLineEndDefTabPage::Create, 0);
133 // AddTabPage( RID_SVXPAGE_COLOR, SvxColorTabPage::Create, 0 );
135 SetCurPageId( RID_SVXPAGE_LINE );
137 CancelButton& rBtnCancel = GetCancelButton();
138 rBtnCancel.SetClickHdl( LINK( this, SvxLineTabDialog, CancelHdlImpl ) );
139 //! rBtnCancel.SetText( SVX_RESSTR( RID_SVXSTR_CLOSE ) );
142 // -----------------------------------------------------------------------
144 SvxLineTabDialog::~SvxLineTabDialog()
148 // -----------------------------------------------------------------------
150 void SvxLineTabDialog::SavePalettes()
152 SfxObjectShell* pShell = SfxObjectShell::Current();
153 if( mpNewColorTab != pDrawModel->GetColorTable() )
155 if(mbDeleteColorTable)
156 delete pDrawModel->GetColorTable();
157 pDrawModel->SetColorTable( mpNewColorTab );
158 if ( pShell )
159 pShell->PutItem( SvxColorTableItem( mpNewColorTab, SID_COLOR_TABLE ) );
160 pColorTab = pDrawModel->GetColorTable();
162 if( pNewDashList != pDrawModel->GetDashList() )
164 delete pDrawModel->GetDashList();
165 pDrawModel->SetDashList( pNewDashList );
166 if ( pShell )
167 pShell->PutItem( SvxDashListItem( pNewDashList, SID_DASH_LIST ) );
168 pDashList = pDrawModel->GetDashList();
170 if( pNewLineEndList != pDrawModel->GetLineEndList() )
172 delete pDrawModel->GetLineEndList();
173 pDrawModel->SetLineEndList( pNewLineEndList );
174 if ( pShell )
175 pShell->PutItem( SvxLineEndListItem( pNewLineEndList, SID_LINEEND_LIST ) );
176 pLineEndList = pDrawModel->GetLineEndList();
179 // Speichern der Tabellen, wenn sie geaendert wurden.
181 const String aPath( SvtPathOptions().GetPalettePath() );
183 if( nDashListState & CT_MODIFIED )
185 pDashList->SetPath( aPath );
186 pDashList->Save();
188 // ToolBoxControls werden benachrichtigt:
189 if ( pShell )
190 pShell->PutItem( SvxDashListItem( pDashList, SID_DASH_LIST ) );
193 if( nLineEndListState & CT_MODIFIED )
195 pLineEndList->SetPath( aPath );
196 pLineEndList->Save();
198 // ToolBoxControls werden benachrichtigt:
199 if ( pShell )
200 pShell->PutItem( SvxLineEndListItem( pLineEndList, SID_LINEEND_LIST ) );
203 if( mnColorTableState & CT_MODIFIED )
205 pColorTab->SetPath( aPath );
206 pColorTab->Save();
208 // ToolBoxControls werden benachrichtigt:
209 if ( pShell )
210 pShell->PutItem( SvxColorTableItem( pColorTab, SID_COLOR_TABLE ) );
214 // -----------------------------------------------------------------------
216 short SvxLineTabDialog::Ok()
218 SavePalettes();
220 // Es wird RET_OK zurueckgeliefert, wenn wenigstens eine
221 // TabPage in FillItemSet() TRUE zurueckliefert. Dieses
222 // geschieht z.Z. standardmaessig.
223 return( SfxTabDialog::Ok() );
226 // -----------------------------------------------------------------------
228 IMPL_LINK_INLINE_START( SvxLineTabDialog, CancelHdlImpl, void *, EMPTYARG )
230 SavePalettes();
232 EndDialog( RET_CANCEL );
233 return 0;
235 IMPL_LINK_INLINE_END( SvxLineTabDialog, CancelHdlImpl, void *, EMPTYARG )
237 // -----------------------------------------------------------------------
239 void SvxLineTabDialog::PageCreated( USHORT nId, SfxTabPage &rPage )
241 switch( nId )
243 case RID_SVXPAGE_LINE:
244 ( (SvxLineTabPage&) rPage ).SetColorTable( pColorTab );
245 ( (SvxLineTabPage&) rPage ).SetDashList( pDashList );
246 ( (SvxLineTabPage&) rPage ).SetLineEndList( pLineEndList );
247 ( (SvxLineTabPage&) rPage ).SetDlgType( nDlgType );//CHINA001 ( (SvxLineTabPage&) rPage ).SetDlgType( &nDlgType );
248 ( (SvxLineTabPage&) rPage ).SetPageType( nPageType );//CHINA001 ( (SvxLineTabPage&) rPage ).SetPageType( &nPageType );
249 ( (SvxLineTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
250 ( (SvxLineTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
251 ( (SvxLineTabPage&) rPage ).SetDashChgd( &nDashListState );
252 ( (SvxLineTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
253 ( (SvxLineTabPage&) rPage ).SetObjSelected( bObjSelected );
254 ( (SvxLineTabPage&) rPage ).Construct();
255 ( (SvxLineTabPage&) rPage ).SetColorChgd( &mnColorTableState );
256 // ActivatePage() wird das erste mal nicht gerufen
257 ( (SvxLineTabPage&) rPage ).ActivatePage( rOutAttrs );
258 break;
260 case RID_SVXPAGE_LINE_DEF:
261 ( (SvxLineDefTabPage&) rPage ).SetDashList( pDashList );
262 ( (SvxLineDefTabPage&) rPage ).SetDlgType( &nDlgType );
263 ( (SvxLineDefTabPage&) rPage ).SetPageType( &nPageType );
264 ( (SvxLineDefTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
265 ( (SvxLineDefTabPage&) rPage ).SetDashChgd( &nDashListState );
266 ( (SvxLineDefTabPage&) rPage ).SetObjSelected( bObjSelected );
267 ( (SvxLineDefTabPage&) rPage ).Construct();
268 break;
270 case RID_SVXPAGE_LINEEND_DEF:
271 ( (SvxLineEndDefTabPage&) rPage ).SetLineEndList( pLineEndList );
272 ( (SvxLineEndDefTabPage&) rPage ).SetPolyObj( pObj );
273 ( (SvxLineEndDefTabPage&) rPage ).SetDlgType( &nDlgType );
274 ( (SvxLineEndDefTabPage&) rPage ).SetPageType( &nPageType );
275 ( (SvxLineEndDefTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
276 ( (SvxLineEndDefTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
277 ( (SvxLineEndDefTabPage&) rPage ).SetObjSelected( bObjSelected );
278 ( (SvxLineEndDefTabPage&) rPage ).Construct();
279 break;
281 case RID_SVXPAGE_SHADOW:
283 ( (SvxShadowTabPage&) rPage ).SetColorTable( pColorTab );
284 ( (SvxShadowTabPage&) rPage ).SetPageType( nPageType );
285 ( (SvxShadowTabPage&) rPage ).SetDlgType( nDlgType );
286 ( (SvxShadowTabPage&) rPage ).SetAreaTP( &mbAreaTP );
287 ( (SvxShadowTabPage&) rPage ).SetColorChgd( &mnColorTableState );
288 ( (SvxShadowTabPage&) rPage ).Construct();
290 break;
292 case RID_SVXPAGE_COLOR:
293 ( (SvxColorTabPage&) rPage ).SetColorTable( pColorTab );
294 ( (SvxColorTabPage&) rPage ).SetPageType( &nPageType );
295 ( (SvxColorTabPage&) rPage ).SetDlgType( &nDlgType );
296 ( (SvxColorTabPage&) rPage ).SetPos( &mnPos );
297 ( (SvxColorTabPage&) rPage ).SetAreaTP( &mbAreaTP );
298 ( (SvxColorTabPage&) rPage ).SetColorChgd( &mnColorTableState );
299 ( (SvxColorTabPage&) rPage ).SetDeleteColorTable( mbDeleteColorTable );
300 ( (SvxColorTabPage&) rPage ).Construct();
301 break;