Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
26 :
27 : #include <cuires.hrc>
28 : #include "tabline.hrc"
29 :
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"
37 :
38 0 : SvxLineTabDialog::SvxLineTabDialog
39 : (
40 : Window* pParent,
41 : const SfxItemSet* pAttr,
42 : SdrModel* pModel,
43 : const SdrObject* pSdrObj,
44 : sal_Bool bHasObj
45 : ) :
46 :
47 0 : 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 0 : mbAreaTP( sal_False )
66 : {
67 0 : FreeResource();
68 :
69 0 : bool bLineOnly = false;
70 0 : if( pObj && pObj->GetObjInventor() == SdrInventor )
71 : {
72 0 : switch( pObj->GetObjIdentifier() )
73 : {
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 0 : bLineOnly = true;
81 :
82 : default:
83 0 : break;
84 : }
85 :
86 : }
87 :
88 0 : AddTabPage( RID_SVXPAGE_LINE, SvxLineTabPage::Create, 0);
89 0 : if( bLineOnly )
90 0 : AddTabPage( RID_SVXPAGE_SHADOW, SvxShadowTabPage::Create, 0 );
91 : else
92 0 : RemoveTabPage( RID_SVXPAGE_SHADOW );
93 :
94 0 : AddTabPage( RID_SVXPAGE_LINE_DEF, SvxLineDefTabPage::Create, 0);
95 0 : AddTabPage( RID_SVXPAGE_LINEEND_DEF, SvxLineEndDefTabPage::Create, 0);
96 :
97 0 : SetCurPageId( RID_SVXPAGE_LINE );
98 :
99 0 : CancelButton& rBtnCancel = GetCancelButton();
100 0 : rBtnCancel.SetClickHdl( LINK( this, SvxLineTabDialog, CancelHdlImpl ) );
101 0 : }
102 :
103 : // -----------------------------------------------------------------------
104 :
105 0 : SvxLineTabDialog::~SvxLineTabDialog()
106 : {
107 0 : }
108 :
109 : // -----------------------------------------------------------------------
110 :
111 0 : void SvxLineTabDialog::SavePalettes()
112 : {
113 0 : SfxObjectShell* pShell = SfxObjectShell::Current();
114 0 : if( mpNewColorList != pDrawModel->GetColorList() )
115 : {
116 0 : pDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
117 0 : if ( pShell )
118 0 : pShell->PutItem( SvxColorListItem( mpNewColorList, SID_COLOR_TABLE ) );
119 0 : pColorList = pDrawModel->GetColorList();
120 : }
121 0 : if( pNewDashList != pDrawModel->GetDashList() )
122 : {
123 0 : pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewDashList.get()) );
124 0 : if ( pShell )
125 0 : pShell->PutItem( SvxDashListItem( pNewDashList, SID_DASH_LIST ) );
126 0 : pDashList = pDrawModel->GetDashList();
127 : }
128 0 : if( pNewLineEndList != pDrawModel->GetLineEndList() )
129 : {
130 0 : pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewLineEndList.get()) );
131 0 : if ( pShell )
132 0 : pShell->PutItem( SvxLineEndListItem( pNewLineEndList, SID_LINEEND_LIST ) );
133 0 : pLineEndList = pDrawModel->GetLineEndList();
134 : }
135 :
136 : // Save the tables when they have been changed
137 :
138 0 : const String aPath( SvtPathOptions().GetPalettePath() );
139 :
140 0 : if( nDashListState & CT_MODIFIED )
141 : {
142 0 : pDashList->SetPath( aPath );
143 0 : pDashList->Save();
144 :
145 : // Notify ToolBoxControls
146 0 : if ( pShell )
147 0 : pShell->PutItem( SvxDashListItem( pDashList, SID_DASH_LIST ) );
148 : }
149 :
150 0 : if( nLineEndListState & CT_MODIFIED )
151 : {
152 0 : pLineEndList->SetPath( aPath );
153 0 : pLineEndList->Save();
154 :
155 : // Notify ToolBoxControls
156 0 : if ( pShell )
157 0 : pShell->PutItem( SvxLineEndListItem( pLineEndList, SID_LINEEND_LIST ) );
158 : }
159 :
160 0 : if( mnColorListState & CT_MODIFIED )
161 : {
162 0 : pColorList->SetPath( aPath );
163 0 : pColorList->Save();
164 :
165 : // Notify ToolBoxControls
166 0 : if ( pShell )
167 0 : pShell->PutItem( SvxColorListItem( pColorList, SID_COLOR_TABLE ) );
168 0 : }
169 0 : }
170 :
171 : // -----------------------------------------------------------------------
172 :
173 0 : short SvxLineTabDialog::Ok()
174 : {
175 0 : SavePalettes();
176 :
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 0 : return( SfxTabDialog::Ok() );
180 : }
181 :
182 : // -----------------------------------------------------------------------
183 :
184 0 : IMPL_LINK_NOARG_INLINE_START(SvxLineTabDialog, CancelHdlImpl)
185 : {
186 0 : SavePalettes();
187 :
188 0 : EndDialog( RET_CANCEL );
189 0 : return 0;
190 : }
191 0 : IMPL_LINK_NOARG_INLINE_END(SvxLineTabDialog, CancelHdlImpl)
192 :
193 : // -----------------------------------------------------------------------
194 :
195 0 : void SvxLineTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
196 : {
197 0 : switch( nId )
198 : {
199 : case RID_SVXPAGE_LINE:
200 0 : ( (SvxLineTabPage&) rPage ).SetColorList( pColorList );
201 0 : ( (SvxLineTabPage&) rPage ).SetDashList( pDashList );
202 0 : ( (SvxLineTabPage&) rPage ).SetLineEndList( pLineEndList );
203 0 : ( (SvxLineTabPage&) rPage ).SetDlgType( nDlgType );
204 0 : ( (SvxLineTabPage&) rPage ).SetPageType( nPageType );
205 0 : ( (SvxLineTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
206 0 : ( (SvxLineTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
207 0 : ( (SvxLineTabPage&) rPage ).SetDashChgd( &nDashListState );
208 0 : ( (SvxLineTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
209 0 : ( (SvxLineTabPage&) rPage ).SetObjSelected( bObjSelected );
210 0 : ( (SvxLineTabPage&) rPage ).Construct();
211 0 : ( (SvxLineTabPage&) rPage ).SetColorChgd( &mnColorListState );
212 : // ActivatePage() is not called the first time
213 0 : ( (SvxLineTabPage&) rPage ).ActivatePage( rOutAttrs );
214 0 : break;
215 :
216 : case RID_SVXPAGE_LINE_DEF:
217 0 : ( (SvxLineDefTabPage&) rPage ).SetDashList( pDashList );
218 0 : ( (SvxLineDefTabPage&) rPage ).SetDlgType( &nDlgType );
219 0 : ( (SvxLineDefTabPage&) rPage ).SetPageType( &nPageType );
220 0 : ( (SvxLineDefTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
221 0 : ( (SvxLineDefTabPage&) rPage ).SetDashChgd( &nDashListState );
222 0 : ( (SvxLineDefTabPage&) rPage ).SetObjSelected( bObjSelected );
223 0 : ( (SvxLineDefTabPage&) rPage ).Construct();
224 0 : break;
225 :
226 : case RID_SVXPAGE_LINEEND_DEF:
227 0 : ( (SvxLineEndDefTabPage&) rPage ).SetLineEndList( pLineEndList );
228 0 : ( (SvxLineEndDefTabPage&) rPage ).SetPolyObj( pObj );
229 0 : ( (SvxLineEndDefTabPage&) rPage ).SetDlgType( &nDlgType );
230 0 : ( (SvxLineEndDefTabPage&) rPage ).SetPageType( &nPageType );
231 0 : ( (SvxLineEndDefTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
232 0 : ( (SvxLineEndDefTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
233 0 : ( (SvxLineEndDefTabPage&) rPage ).SetObjSelected( bObjSelected );
234 0 : ( (SvxLineEndDefTabPage&) rPage ).Construct();
235 0 : break;
236 :
237 : case RID_SVXPAGE_SHADOW:
238 : {
239 0 : ( (SvxShadowTabPage&) rPage ).SetColorList( pColorList );
240 0 : ( (SvxShadowTabPage&) rPage ).SetPageType( nPageType );
241 0 : ( (SvxShadowTabPage&) rPage ).SetDlgType( nDlgType );
242 0 : ( (SvxShadowTabPage&) rPage ).SetAreaTP( &mbAreaTP );
243 0 : ( (SvxShadowTabPage&) rPage ).SetColorChgd( &mnColorListState );
244 0 : ( (SvxShadowTabPage&) rPage ).Construct();
245 : }
246 0 : break;
247 : }
248 0 : }
249 :
250 :
251 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|