update credits
[LibreOffice.git] / cui / source / tabpages / tabline.cxx
blobf213077d62968179511aded55295fccf0d9bf92d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/shl.hxx>
21 #include <vcl/msgbox.hxx>
22 #include <unotools/pathoptions.hxx>
23 #include <sfx2/app.hxx>
24 #include <sfx2/objsh.hxx>
25 #include <svx/dialogs.hrc>
27 #include <cuires.hrc>
28 #include "tabline.hrc"
30 #include "cuitabarea.hxx"
31 #include "cuitabline.hxx"
32 #include "dlgname.hxx"
33 #include <dialmgr.hxx>
34 #include <svx/svdmodel.hxx>
35 #include <svx/xtable.hxx>
36 #include "svx/drawitem.hxx"
38 SvxLineTabDialog::SvxLineTabDialog
40 Window* pParent,
41 const SfxItemSet* pAttr,
42 SdrModel* pModel,
43 const SdrObject* pSdrObj,
44 sal_Bool bHasObj
45 ) :
47 SfxTabDialog ( pParent, CUI_RES( RID_SVXDLG_LINE ), pAttr ),
48 pDrawModel ( pModel ),
49 pObj ( pSdrObj ),
50 rOutAttrs ( *pAttr ),
51 pColorList ( pModel->GetColorList() ),
52 mpNewColorList ( pModel->GetColorList() ),
53 pDashList ( pModel->GetDashList() ),
54 pNewDashList ( pModel->GetDashList() ),
55 pLineEndList ( pModel->GetLineEndList() ),
56 pNewLineEndList ( pModel->GetLineEndList() ),
57 bObjSelected ( bHasObj ),
58 nLineEndListState( CT_NONE ),
59 nDashListState( CT_NONE ),
60 mnColorListState( CT_NONE ),
61 nPageType( 0 ), // We use it here primarily to get the right attributes with FillItemSet
62 nDlgType( 0 ),
63 nPosDashLb( 0 ),
64 nPosLineEndLb( 0 ),
65 mbAreaTP( sal_False )
67 FreeResource();
69 bool bLineOnly = false;
70 if( pObj && pObj->GetObjInventor() == SdrInventor )
72 switch( pObj->GetObjIdentifier() )
74 case OBJ_LINE:
75 case OBJ_PLIN:
76 case OBJ_PATHLINE:
77 case OBJ_FREELINE:
78 case OBJ_MEASURE:
79 case OBJ_EDGE:
80 bLineOnly = true;
82 default:
83 break;
88 AddTabPage( RID_SVXPAGE_LINE, SvxLineTabPage::Create, 0);
89 if( bLineOnly )
90 AddTabPage( RID_SVXPAGE_SHADOW, SvxShadowTabPage::Create, 0 );
91 else
92 RemoveTabPage( RID_SVXPAGE_SHADOW );
94 AddTabPage( RID_SVXPAGE_LINE_DEF, SvxLineDefTabPage::Create, 0);
95 AddTabPage( RID_SVXPAGE_LINEEND_DEF, SvxLineEndDefTabPage::Create, 0);
97 SetCurPageId( RID_SVXPAGE_LINE );
99 CancelButton& rBtnCancel = GetCancelButton();
100 rBtnCancel.SetClickHdl( LINK( this, SvxLineTabDialog, CancelHdlImpl ) );
103 // -----------------------------------------------------------------------
105 SvxLineTabDialog::~SvxLineTabDialog()
109 // -----------------------------------------------------------------------
111 void SvxLineTabDialog::SavePalettes()
113 SfxObjectShell* pShell = SfxObjectShell::Current();
114 if( mpNewColorList != pDrawModel->GetColorList() )
116 pDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
117 if ( pShell )
118 pShell->PutItem( SvxColorListItem( mpNewColorList, SID_COLOR_TABLE ) );
119 pColorList = pDrawModel->GetColorList();
121 if( pNewDashList != pDrawModel->GetDashList() )
123 pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewDashList.get()) );
124 if ( pShell )
125 pShell->PutItem( SvxDashListItem( pNewDashList, SID_DASH_LIST ) );
126 pDashList = pDrawModel->GetDashList();
128 if( pNewLineEndList != pDrawModel->GetLineEndList() )
130 pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewLineEndList.get()) );
131 if ( pShell )
132 pShell->PutItem( SvxLineEndListItem( pNewLineEndList, SID_LINEEND_LIST ) );
133 pLineEndList = pDrawModel->GetLineEndList();
136 // Save the tables when they have been changed
138 const String aPath( SvtPathOptions().GetPalettePath() );
140 if( nDashListState & CT_MODIFIED )
142 pDashList->SetPath( aPath );
143 pDashList->Save();
145 // Notify ToolBoxControls
146 if ( pShell )
147 pShell->PutItem( SvxDashListItem( pDashList, SID_DASH_LIST ) );
150 if( nLineEndListState & CT_MODIFIED )
152 pLineEndList->SetPath( aPath );
153 pLineEndList->Save();
155 // Notify ToolBoxControls
156 if ( pShell )
157 pShell->PutItem( SvxLineEndListItem( pLineEndList, SID_LINEEND_LIST ) );
160 if( mnColorListState & CT_MODIFIED )
162 pColorList->SetPath( aPath );
163 pColorList->Save();
165 // Notify ToolBoxControls
166 if ( pShell )
167 pShell->PutItem( SvxColorListItem( pColorList, SID_COLOR_TABLE ) );
171 // -----------------------------------------------------------------------
173 short SvxLineTabDialog::Ok()
175 SavePalettes();
177 // We return RET_OK if at least one TabPage in FillItemSet() returns sal_True.
178 // We do this by default at the moment.
179 return( SfxTabDialog::Ok() );
182 // -----------------------------------------------------------------------
184 IMPL_LINK_NOARG_INLINE_START(SvxLineTabDialog, CancelHdlImpl)
186 SavePalettes();
188 EndDialog( RET_CANCEL );
189 return 0;
191 IMPL_LINK_NOARG_INLINE_END(SvxLineTabDialog, CancelHdlImpl)
193 // -----------------------------------------------------------------------
195 void SvxLineTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
197 switch( nId )
199 case RID_SVXPAGE_LINE:
200 ( (SvxLineTabPage&) rPage ).SetColorList( pColorList );
201 ( (SvxLineTabPage&) rPage ).SetDashList( pDashList );
202 ( (SvxLineTabPage&) rPage ).SetLineEndList( pLineEndList );
203 ( (SvxLineTabPage&) rPage ).SetDlgType( nDlgType );
204 ( (SvxLineTabPage&) rPage ).SetPageType( nPageType );
205 ( (SvxLineTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
206 ( (SvxLineTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
207 ( (SvxLineTabPage&) rPage ).SetDashChgd( &nDashListState );
208 ( (SvxLineTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
209 ( (SvxLineTabPage&) rPage ).SetObjSelected( bObjSelected );
210 ( (SvxLineTabPage&) rPage ).Construct();
211 ( (SvxLineTabPage&) rPage ).SetColorChgd( &mnColorListState );
212 // ActivatePage() is not called the first time
213 ( (SvxLineTabPage&) rPage ).ActivatePage( rOutAttrs );
214 break;
216 case RID_SVXPAGE_LINE_DEF:
217 ( (SvxLineDefTabPage&) rPage ).SetDashList( pDashList );
218 ( (SvxLineDefTabPage&) rPage ).SetDlgType( &nDlgType );
219 ( (SvxLineDefTabPage&) rPage ).SetPageType( &nPageType );
220 ( (SvxLineDefTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
221 ( (SvxLineDefTabPage&) rPage ).SetDashChgd( &nDashListState );
222 ( (SvxLineDefTabPage&) rPage ).SetObjSelected( bObjSelected );
223 ( (SvxLineDefTabPage&) rPage ).Construct();
224 break;
226 case RID_SVXPAGE_LINEEND_DEF:
227 ( (SvxLineEndDefTabPage&) rPage ).SetLineEndList( pLineEndList );
228 ( (SvxLineEndDefTabPage&) rPage ).SetPolyObj( pObj );
229 ( (SvxLineEndDefTabPage&) rPage ).SetDlgType( &nDlgType );
230 ( (SvxLineEndDefTabPage&) rPage ).SetPageType( &nPageType );
231 ( (SvxLineEndDefTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
232 ( (SvxLineEndDefTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
233 ( (SvxLineEndDefTabPage&) rPage ).SetObjSelected( bObjSelected );
234 ( (SvxLineEndDefTabPage&) rPage ).Construct();
235 break;
237 case RID_SVXPAGE_SHADOW:
239 ( (SvxShadowTabPage&) rPage ).SetColorList( pColorList );
240 ( (SvxShadowTabPage&) rPage ).SetPageType( nPageType );
241 ( (SvxShadowTabPage&) rPage ).SetDlgType( nDlgType );
242 ( (SvxShadowTabPage&) rPage ).SetAreaTP( &mbAreaTP );
243 ( (SvxShadowTabPage&) rPage ).SetColorChgd( &mnColorListState );
244 ( (SvxShadowTabPage&) rPage ).Construct();
246 break;
251 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */