1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <vcl/msgbox.hxx>
21 #include <unotools/pathoptions.hxx>
22 #include <sfx2/app.hxx>
23 #include <sfx2/objsh.hxx>
24 #include <svx/dialogs.hrc>
28 #include "cuitabarea.hxx"
29 #include "cuitabline.hxx"
30 #include "dlgname.hxx"
31 #include <dialmgr.hxx>
32 #include <svx/svdmodel.hxx>
33 #include <svx/xtable.hxx>
34 #include "svx/drawitem.hxx"
36 SvxLineTabDialog::SvxLineTabDialog
39 const SfxItemSet
* pAttr
,
41 const SdrObject
* pSdrObj
,
45 SfxTabDialog ( pParent
47 , "cui/ui/linedialog.ui"
53 pDrawModel ( pModel
),
56 pColorList ( pModel
->GetColorList() ),
57 mpNewColorList ( pModel
->GetColorList() ),
58 pDashList ( pModel
->GetDashList() ),
59 pNewDashList ( pModel
->GetDashList() ),
60 pLineEndList ( pModel
->GetLineEndList() ),
61 pNewLineEndList ( pModel
->GetLineEndList() ),
62 bObjSelected ( bHasObj
),
63 nLineEndListState( ChangeType::NONE
),
64 nDashListState( ChangeType::NONE
),
65 mnColorListState( ChangeType::NONE
),
66 nPageType( 0 ), // We use it here primarily to get the right attributes with FillItemSet
71 bool bLineOnly
= false;
72 if( pObj
&& pObj
->GetObjInventor() == SdrInventor
)
74 switch( pObj
->GetObjIdentifier() )
90 m_nLineTabPage
= AddTabPage( "RID_SVXPAGE_LINE", SvxLineTabPage::Create
, 0);
92 m_nShadowTabPage
= AddTabPage( "RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create
, 0 );
94 RemoveTabPage( "RID_SVXPAGE_SHADOW" );
96 m_nStyleTabPage
= AddTabPage( "RID_SVXPAGE_LINE_DEF", SvxLineDefTabPage::Create
, 0);
97 m_nEndTabPage
= AddTabPage( "RID_SVXPAGE_LINEEND_DEF", SvxLineEndDefTabPage::Create
, 0);
99 SetCurPageId( "RID_SVXPAGE_LINE" );
101 CancelButton
& rBtnCancel
= GetCancelButton();
102 rBtnCancel
.SetClickHdl( LINK( this, SvxLineTabDialog
, CancelHdlImpl
) );
107 void SvxLineTabDialog::SavePalettes()
109 SfxObjectShell
* pShell
= SfxObjectShell::Current();
110 if( mpNewColorList
!= pDrawModel
->GetColorList() )
112 pDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewColorList
.get()) );
114 pShell
->PutItem( SvxColorListItem( mpNewColorList
, SID_COLOR_TABLE
) );
115 pColorList
= pDrawModel
->GetColorList();
117 if( pNewDashList
!= pDrawModel
->GetDashList() )
119 pDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(pNewDashList
.get()) );
121 pShell
->PutItem( SvxDashListItem( pNewDashList
, SID_DASH_LIST
) );
122 pDashList
= pDrawModel
->GetDashList();
124 if( pNewLineEndList
!= pDrawModel
->GetLineEndList() )
126 pDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(pNewLineEndList
.get()) );
128 pShell
->PutItem( SvxLineEndListItem( pNewLineEndList
, SID_LINEEND_LIST
) );
129 pLineEndList
= pDrawModel
->GetLineEndList();
132 // Save the tables when they have been changed
134 const OUString
aPath( SvtPathOptions().GetPalettePath() );
136 if( nDashListState
& ChangeType::MODIFIED
)
138 pDashList
->SetPath( aPath
);
141 // Notify ToolBoxControls
143 pShell
->PutItem( SvxDashListItem( pDashList
, SID_DASH_LIST
) );
146 if( nLineEndListState
& ChangeType::MODIFIED
)
148 pLineEndList
->SetPath( aPath
);
149 pLineEndList
->Save();
151 // Notify ToolBoxControls
153 pShell
->PutItem( SvxLineEndListItem( pLineEndList
, SID_LINEEND_LIST
) );
156 if( mnColorListState
& ChangeType::MODIFIED
)
158 pColorList
->SetPath( aPath
);
161 // Notify ToolBoxControls
163 pShell
->PutItem( SvxColorListItem( pColorList
, SID_COLOR_TABLE
) );
169 short SvxLineTabDialog::Ok()
173 // We return RET_OK if at least one TabPage in FillItemSet() returns sal_True.
174 // We do this by default at the moment.
175 return( SfxTabDialog::Ok() );
180 IMPL_LINK_NOARG(SvxLineTabDialog
, CancelHdlImpl
)
184 EndDialog( RET_CANCEL
);
188 void SvxLineTabDialog::PageCreated( sal_uInt16 nId
, SfxTabPage
&rPage
)
190 if( nId
== m_nLineTabPage
)
192 static_cast<SvxLineTabPage
&>(rPage
).SetColorList( pColorList
);
193 static_cast<SvxLineTabPage
&>(rPage
).SetDashList( pDashList
);
194 static_cast<SvxLineTabPage
&>(rPage
).SetLineEndList( pLineEndList
);
195 static_cast<SvxLineTabPage
&>(rPage
).SetDlgType( 0 );
196 static_cast<SvxLineTabPage
&>(rPage
).SetPageType( nPageType
);
197 static_cast<SvxLineTabPage
&>(rPage
).SetPosDashLb( &nPosDashLb
);
198 static_cast<SvxLineTabPage
&>(rPage
).SetPosLineEndLb( &nPosLineEndLb
);
199 static_cast<SvxLineTabPage
&>(rPage
).SetDashChgd( &nDashListState
);
200 static_cast<SvxLineTabPage
&>(rPage
).SetLineEndChgd( &nLineEndListState
);
201 static_cast<SvxLineTabPage
&>(rPage
).SetObjSelected( bObjSelected
);
202 static_cast<SvxLineTabPage
&>(rPage
).Construct();
203 static_cast<SvxLineTabPage
&>(rPage
).SetColorChgd( &mnColorListState
);
204 // ActivatePage() is not called the first time
205 static_cast<SvxLineTabPage
&>(rPage
).ActivatePage( rOutAttrs
);
207 else if(nId
== m_nStyleTabPage
)
209 static_cast<SvxLineDefTabPage
&>(rPage
).SetDashList( pDashList
);
210 static_cast<SvxLineDefTabPage
&>(rPage
).SetDlgType( 0 );
211 static_cast<SvxLineDefTabPage
&>(rPage
).SetPageType( &nPageType
);
212 static_cast<SvxLineDefTabPage
&>(rPage
).SetPosDashLb( &nPosDashLb
);
213 static_cast<SvxLineDefTabPage
&>(rPage
).SetDashChgd( &nDashListState
);
214 static_cast<SvxLineDefTabPage
&>(rPage
).SetObjSelected( bObjSelected
);
215 static_cast<SvxLineDefTabPage
&>(rPage
).Construct();
217 else if(nId
== m_nEndTabPage
)
219 static_cast<SvxLineEndDefTabPage
&>(rPage
).SetLineEndList( pLineEndList
);
220 static_cast<SvxLineEndDefTabPage
&>(rPage
).SetPolyObj( pObj
);
221 static_cast<SvxLineEndDefTabPage
&>(rPage
).SetDlgType( 0 );
222 static_cast<SvxLineEndDefTabPage
&>(rPage
).SetPageType( &nPageType
);
223 static_cast<SvxLineEndDefTabPage
&>(rPage
).SetPosLineEndLb( &nPosLineEndLb
);
224 static_cast<SvxLineEndDefTabPage
&>(rPage
).SetLineEndChgd( &nLineEndListState
);
225 static_cast<SvxLineEndDefTabPage
&>(rPage
).SetObjSelected( bObjSelected
);
226 static_cast<SvxLineEndDefTabPage
&>(rPage
).Construct();
228 else if (nId
== m_nShadowTabPage
)
230 static_cast<SvxShadowTabPage
&>(rPage
).SetColorList( pColorList
);
231 static_cast<SvxShadowTabPage
&>(rPage
).SetPageType( nPageType
);
232 static_cast<SvxShadowTabPage
&>(rPage
).SetDlgType( 0 );
233 static_cast<SvxShadowTabPage
&>(rPage
).SetAreaTP( &mbAreaTP
);
234 static_cast<SvxShadowTabPage
&>(rPage
).SetColorChgd( &mnColorListState
);
235 static_cast<SvxShadowTabPage
&>(rPage
).Construct();
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */