xref: /trunk/main/cui/source/tabpages/tabline.cxx (revision c7be74b1)
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 #include <tools/shl.hxx>
29 #include <vcl/msgbox.hxx>
30 #include <unotools/pathoptions.hxx>
31 #include <sfx2/app.hxx>
32 #include <sfx2/objsh.hxx>
33 #include <svx/dialogs.hrc>
34 
35 #define _SVX_TABLINE_CXX
36 #include <cuires.hrc>
37 #include "tabline.hrc"
38 //#include "dlgname.hrc"
39 
40 #include "cuitabarea.hxx"
41 #include "cuitabline.hxx"
42 #include "dlgname.hxx"
43 #include <dialmgr.hxx>
44 #include <svx/svdmodel.hxx>
45 #include <svx/xtable.hxx>
46 #include "svx/drawitem.hxx"
47 
48 #define DLGWIN this->GetParent()->GetParent()
49 
50 #define BITMAP_WIDTH   32
51 #define BITMAP_HEIGHT  12
52 #define XOUT_WIDTH    150
53 
54 /*************************************************************************
55 |*
56 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
57 |*
58 \************************************************************************/
59 
SvxLineTabDialog(Window * pParent,const SfxItemSet * pAttr,SdrModel * pModel,const SdrObject * pSdrObj,sal_Bool bHasObj)60 SvxLineTabDialog::SvxLineTabDialog
61 (
62 	Window* pParent,
63 	const SfxItemSet* pAttr,
64 	SdrModel* pModel,
65 	const SdrObject* pSdrObj,
66 	sal_Bool bHasObj
67 ) :
68 
69 	SfxTabDialog	( pParent, CUI_RES( RID_SVXDLG_LINE ), pAttr ),
70 	pDrawModel		( pModel ),
71 	pObj			( pSdrObj ),
72     rOutAttrs       ( *pAttr ),
73     maColorTab      ( pModel->GetColorTableFromSdrModel() ),
74     maNewColorTab   ( pModel->GetColorTableFromSdrModel() ),
75 	maDashList      ( pModel->GetDashListFromSdrModel() ),
76     maNewDashList   ( pModel->GetDashListFromSdrModel() ),
77     maLineEndList   ( pModel->GetLineEndListFromSdrModel() ),
78     maNewLineEndList( pModel->GetLineEndListFromSdrModel() ),
79     bObjSelected    ( bHasObj ),
80     nLineEndListState( CT_NONE ),
81     nDashListState( CT_NONE ),
82 	mnColorTableState( CT_NONE ),
83     nPageType( 0 ), // wird hier in erster Linie benutzt, um mit FillItemSet
84                    // die richtigen Attribute zu erhalten ( noch Fragen? )
85     nDlgType( 0 ),
86     nPosDashLb( 0 ),
87     nPosLineEndLb( 0 ),
88     mnPos( 0 ),
89     mbAreaTP( sal_False )
90 {
91 	FreeResource();
92 
93 	bool bLineOnly = false;
94 	if( pObj && pObj->GetObjInventor() == SdrInventor )
95 	{
96 		switch( pObj->GetObjIdentifier() )
97 		{
98 		case OBJ_LINE:
99 		case OBJ_PLIN:
100 		case OBJ_PATHLINE:
101 		case OBJ_FREELINE:
102 		case OBJ_MEASURE:
103 		case OBJ_EDGE:
104 			bLineOnly = true;
105 
106 		default:
107 			break;
108 		}
109 
110 	}
111 
112 	AddTabPage( RID_SVXPAGE_LINE, SvxLineTabPage::Create, 0);
113 	if( bLineOnly )
114 		AddTabPage( RID_SVXPAGE_SHADOW, SvxShadowTabPage::Create, 0 );
115 	else
116 		RemoveTabPage( RID_SVXPAGE_SHADOW );
117 
118 	AddTabPage( RID_SVXPAGE_LINE_DEF, SvxLineDefTabPage::Create, 0);
119 	AddTabPage( RID_SVXPAGE_LINEEND_DEF, SvxLineEndDefTabPage::Create, 0);
120 //	AddTabPage( RID_SVXPAGE_COLOR, SvxColorTabPage::Create, 0 );
121 
122 	SetCurPageId( RID_SVXPAGE_LINE );
123 
124 	CancelButton& rBtnCancel = GetCancelButton();
125 	rBtnCancel.SetClickHdl( LINK( this, SvxLineTabDialog, CancelHdlImpl ) );
126 //! rBtnCancel.SetText( CUI_RESSTR( RID_SVXSTR_CLOSE ) );
127 }
128 
129 // -----------------------------------------------------------------------
130 
~SvxLineTabDialog()131 SvxLineTabDialog::~SvxLineTabDialog()
132 {
133 }
134 
135 // -----------------------------------------------------------------------
136 
SavePalettes()137 void SvxLineTabDialog::SavePalettes()
138 {
139     SfxObjectShell* pShell = SfxObjectShell::Current();
140 	if( maNewColorTab != pDrawModel->GetColorTableFromSdrModel() )
141 	{
142 		pDrawModel->SetColorTableAtSdrModel( maNewColorTab );
143         if ( pShell )
144             pShell->PutItem( SvxColorTableItem( maNewColorTab, SID_COLOR_TABLE ) );
145 		maColorTab = pDrawModel->GetColorTableFromSdrModel();
146 	}
147 	if( maNewDashList != pDrawModel->GetDashListFromSdrModel() )
148 	{
149 		pDrawModel->SetDashListAtSdrModel( maNewDashList );
150         if ( pShell )
151             pShell->PutItem( SvxDashListItem( maNewDashList, SID_DASH_LIST ) );
152 		maDashList = pDrawModel->GetDashListFromSdrModel();
153 	}
154 	if( maNewLineEndList != pDrawModel->GetLineEndListFromSdrModel() )
155 	{
156 		pDrawModel->SetLineEndListAtSdrModel( maNewLineEndList );
157         if ( pShell )
158             pShell->PutItem( SvxLineEndListItem( maNewLineEndList, SID_LINEEND_LIST ) );
159 		maLineEndList = pDrawModel->GetLineEndListFromSdrModel();
160 	}
161 
162 	// Speichern der Tabellen, wenn sie geaendert wurden.
163 
164 	const String aPath( SvtPathOptions().GetPalettePath() );
165 
166 	if( nDashListState & CT_MODIFIED )
167 	{
168 		maDashList->SetPath( aPath );
169 		maDashList->Save();
170 
171 		// ToolBoxControls werden benachrichtigt:
172         if ( pShell )
173             pShell->PutItem( SvxDashListItem( maDashList, SID_DASH_LIST ) );
174 	}
175 
176 	if( nLineEndListState & CT_MODIFIED )
177 	{
178 		maLineEndList->SetPath( aPath );
179 		maLineEndList->Save();
180 
181 		// ToolBoxControls werden benachrichtigt:
182         if ( pShell )
183             pShell->PutItem( SvxLineEndListItem( maLineEndList, SID_LINEEND_LIST ) );
184 	}
185 
186 	if( mnColorTableState & CT_MODIFIED )
187 	{
188 		maColorTab->SetPath( aPath );
189 		maColorTab->Save();
190 
191 		// ToolBoxControls werden benachrichtigt:
192         if ( pShell )
193             pShell->PutItem( SvxColorTableItem( maColorTab, SID_COLOR_TABLE ) );
194 	}
195 }
196 
197 // -----------------------------------------------------------------------
198 
Ok()199 short SvxLineTabDialog::Ok()
200 {
201 	SavePalettes();
202 
203 	// Es wird RET_OK zurueckgeliefert, wenn wenigstens eine
204 	// TabPage in FillItemSet() sal_True zurueckliefert. Dieses
205 	// geschieht z.Z. standardmaessig.
206 	return( SfxTabDialog::Ok() );
207 }
208 
209 // -----------------------------------------------------------------------
210 
IMPL_LINK_INLINE_START(SvxLineTabDialog,CancelHdlImpl,void *,EMPTYARG)211 IMPL_LINK_INLINE_START( SvxLineTabDialog, CancelHdlImpl, void *, EMPTYARG )
212 {
213 	SavePalettes();
214 
215 	EndDialog( RET_CANCEL );
216 	return 0;
217 }
IMPL_LINK_INLINE_END(SvxLineTabDialog,CancelHdlImpl,void *,EMPTYARG)218 IMPL_LINK_INLINE_END( SvxLineTabDialog, CancelHdlImpl, void *, EMPTYARG )
219 
220 // -----------------------------------------------------------------------
221 
222 void SvxLineTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
223 {
224 	switch( nId )
225 	{
226 		case RID_SVXPAGE_LINE:
227 			( (SvxLineTabPage&) rPage ).SetColorTable( maColorTab );
228 			( (SvxLineTabPage&) rPage ).SetDashList( maDashList );
229 			( (SvxLineTabPage&) rPage ).SetLineEndList( maLineEndList );
230 			( (SvxLineTabPage&) rPage ).SetDlgType( nDlgType );//CHINA001 ( (SvxLineTabPage&) rPage ).SetDlgType( &nDlgType );
231 			( (SvxLineTabPage&) rPage ).SetPageType( nPageType );//CHINA001 ( (SvxLineTabPage&) rPage ).SetPageType( &nPageType );
232 			( (SvxLineTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
233 			( (SvxLineTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
234 			( (SvxLineTabPage&) rPage ).SetDashChgd( &nDashListState );
235 			( (SvxLineTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
236 			( (SvxLineTabPage&) rPage ).SetObjSelected( bObjSelected );
237 			( (SvxLineTabPage&) rPage ).Construct();
238 			( (SvxLineTabPage&) rPage ).SetColorChgd( &mnColorTableState );
239 			// ActivatePage() wird das erste mal nicht gerufen
240 			( (SvxLineTabPage&) rPage ).ActivatePage( rOutAttrs );
241 		break;
242 
243 		case RID_SVXPAGE_LINE_DEF:
244 			( (SvxLineDefTabPage&) rPage ).SetDashList( maDashList );
245 			( (SvxLineDefTabPage&) rPage ).SetDlgType( &nDlgType );
246 			( (SvxLineDefTabPage&) rPage ).SetPageType( &nPageType );
247 			( (SvxLineDefTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
248 			( (SvxLineDefTabPage&) rPage ).SetDashChgd( &nDashListState );
249 			( (SvxLineDefTabPage&) rPage ).SetObjSelected( bObjSelected );
250 			( (SvxLineDefTabPage&) rPage ).Construct();
251 		break;
252 
253 		case RID_SVXPAGE_LINEEND_DEF:
254 			( (SvxLineEndDefTabPage&) rPage ).SetLineEndList( maLineEndList );
255 			( (SvxLineEndDefTabPage&) rPage ).SetPolyObj( pObj );
256 			( (SvxLineEndDefTabPage&) rPage ).SetDlgType( &nDlgType );
257 			( (SvxLineEndDefTabPage&) rPage ).SetPageType( &nPageType );
258 			( (SvxLineEndDefTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
259 			( (SvxLineEndDefTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
260 			( (SvxLineEndDefTabPage&) rPage ).SetObjSelected( bObjSelected );
261 			( (SvxLineEndDefTabPage&) rPage ).Construct();
262 		break;
263 
264 		case RID_SVXPAGE_SHADOW:
265 		{
266 			( (SvxShadowTabPage&) rPage ).SetColorTable( maColorTab );
267 			( (SvxShadowTabPage&) rPage ).SetPageType( nPageType );
268 			( (SvxShadowTabPage&) rPage ).SetDlgType( nDlgType );
269 			( (SvxShadowTabPage&) rPage ).SetAreaTP( &mbAreaTP );
270 			( (SvxShadowTabPage&) rPage ).SetColorChgd( &mnColorTableState );
271 			( (SvxShadowTabPage&) rPage ).Construct();
272 		}
273 		break;
274 /*
275 		case RID_SVXPAGE_COLOR:
276 			( (SvxColorTabPage&) rPage ).SetColorTable( maColorTab );
277 			( (SvxColorTabPage&) rPage ).SetPageType( &nPageType );
278 			( (SvxColorTabPage&) rPage ).SetDlgType( &nDlgType );
279 			( (SvxColorTabPage&) rPage ).SetPos( &mnPos );
280 			( (SvxColorTabPage&) rPage ).SetAreaTP( &mbAreaTP );
281 			( (SvxColorTabPage&) rPage ).SetColorChgd( &mnColorTableState );
282 			( (SvxColorTabPage&) rPage ).Construct();
283 		break;
284 */
285 	}
286 }
287 
288 
289