1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
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>
39 #define _SVX_TABLINE_CXX
41 #include "tabline.hrc"
42 //#include "dlgname.hrc"
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"
52 #define DLGWIN this->GetParent()->GetParent()
54 #define BITMAP_WIDTH 32
55 #define BITMAP_HEIGHT 12
56 #define XOUT_WIDTH 150
58 /*************************************************************************
60 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
62 \************************************************************************/
64 SvxLineTabDialog::SvxLineTabDialog
67 const SfxItemSet
* pAttr
,
69 const SdrObject
* pSdrObj
,
73 SfxTabDialog ( pParent
, CUI_RES( RID_SVXDLG_LINE
), pAttr
),
74 pDrawModel ( pModel
),
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? )
93 mbAreaTP( sal_False
),
94 mbDeleteColorTable( sal_True
)
98 bool bLineOnly
= false;
99 if( pObj
&& pObj
->GetObjInventor() == SdrInventor
)
101 switch( pObj
->GetObjIdentifier() )
117 AddTabPage( RID_SVXPAGE_LINE
, SvxLineTabPage::Create
, 0);
119 AddTabPage( RID_SVXPAGE_SHADOW
, SvxShadowTabPage::Create
, 0 );
121 RemoveTabPage( RID_SVXPAGE_SHADOW
);
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 );
127 SetCurPageId( RID_SVXPAGE_LINE
);
129 CancelButton
& rBtnCancel
= GetCancelButton();
130 rBtnCancel
.SetClickHdl( LINK( this, SvxLineTabDialog
, CancelHdlImpl
) );
131 //! rBtnCancel.SetText( CUI_RESSTR( RID_SVXSTR_CLOSE ) );
134 // -----------------------------------------------------------------------
136 SvxLineTabDialog::~SvxLineTabDialog()
140 // -----------------------------------------------------------------------
142 void SvxLineTabDialog::SavePalettes()
144 SfxObjectShell
* pShell
= SfxObjectShell::Current();
145 if( mpNewColorTab
!= pDrawModel
->GetColorTable() )
147 if(mbDeleteColorTable
)
148 delete pDrawModel
->GetColorTable();
149 pDrawModel
->SetColorTable( mpNewColorTab
);
151 pShell
->PutItem( SvxColorTableItem( mpNewColorTab
, SID_COLOR_TABLE
) );
152 pColorTab
= pDrawModel
->GetColorTable();
154 if( pNewDashList
!= pDrawModel
->GetDashList() )
156 delete pDrawModel
->GetDashList();
157 pDrawModel
->SetDashList( pNewDashList
);
159 pShell
->PutItem( SvxDashListItem( pNewDashList
, SID_DASH_LIST
) );
160 pDashList
= pDrawModel
->GetDashList();
162 if( pNewLineEndList
!= pDrawModel
->GetLineEndList() )
164 delete pDrawModel
->GetLineEndList();
165 pDrawModel
->SetLineEndList( pNewLineEndList
);
167 pShell
->PutItem( SvxLineEndListItem( pNewLineEndList
, SID_LINEEND_LIST
) );
168 pLineEndList
= pDrawModel
->GetLineEndList();
171 // Speichern der Tabellen, wenn sie geaendert wurden.
173 const String
aPath( SvtPathOptions().GetPalettePath() );
175 if( nDashListState
& CT_MODIFIED
)
177 pDashList
->SetPath( aPath
);
180 // ToolBoxControls werden benachrichtigt:
182 pShell
->PutItem( SvxDashListItem( pDashList
, SID_DASH_LIST
) );
185 if( nLineEndListState
& CT_MODIFIED
)
187 pLineEndList
->SetPath( aPath
);
188 pLineEndList
->Save();
190 // ToolBoxControls werden benachrichtigt:
192 pShell
->PutItem( SvxLineEndListItem( pLineEndList
, SID_LINEEND_LIST
) );
195 if( mnColorTableState
& CT_MODIFIED
)
197 pColorTab
->SetPath( aPath
);
200 // ToolBoxControls werden benachrichtigt:
202 pShell
->PutItem( SvxColorTableItem( pColorTab
, SID_COLOR_TABLE
) );
206 // -----------------------------------------------------------------------
208 short SvxLineTabDialog::Ok()
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() );
218 // -----------------------------------------------------------------------
220 IMPL_LINK_INLINE_START( SvxLineTabDialog
, CancelHdlImpl
, void *, EMPTYARG
)
224 EndDialog( RET_CANCEL
);
227 IMPL_LINK_INLINE_END( SvxLineTabDialog
, CancelHdlImpl
, void *, EMPTYARG
)
229 // -----------------------------------------------------------------------
231 void SvxLineTabDialog::PageCreated( sal_uInt16 nId
, SfxTabPage
&rPage
)
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
);
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();
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();
273 case RID_SVXPAGE_SHADOW
:
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();
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();