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 : #define _SVX_TABLINE_CXX
28 : #include <cuires.hrc>
29 : #include "tabline.hrc"
30 :
31 : #include "cuitabarea.hxx"
32 : #include "cuitabline.hxx"
33 : #include "dlgname.hxx"
34 : #include <dialmgr.hxx>
35 : #include <svx/svdmodel.hxx>
36 : #include <svx/xtable.hxx>
37 : #include "svx/drawitem.hxx"
38 :
39 0 : SvxLineTabDialog::SvxLineTabDialog
40 : (
41 : Window* pParent,
42 : const SfxItemSet* pAttr,
43 : SdrModel* pModel,
44 : const SdrObject* pSdrObj,
45 : sal_Bool bHasObj
46 : ) :
47 :
48 0 : SfxTabDialog ( pParent, CUI_RES( RID_SVXDLG_LINE ), pAttr ),
49 : pDrawModel ( pModel ),
50 : pObj ( pSdrObj ),
51 : rOutAttrs ( *pAttr ),
52 : pColorList ( pModel->GetColorList() ),
53 : mpNewColorList ( pModel->GetColorList() ),
54 : pDashList ( pModel->GetDashList() ),
55 : pNewDashList ( pModel->GetDashList() ),
56 : pLineEndList ( pModel->GetLineEndList() ),
57 : pNewLineEndList ( pModel->GetLineEndList() ),
58 : bObjSelected ( bHasObj ),
59 : nLineEndListState( CT_NONE ),
60 : nDashListState( CT_NONE ),
61 : mnColorListState( CT_NONE ),
62 : nPageType( 0 ), // We use it here primarily to get the right attributes with FillItemSet
63 : nDlgType( 0 ),
64 : nPosDashLb( 0 ),
65 : nPosLineEndLb( 0 ),
66 0 : mbAreaTP( sal_False )
67 : {
68 0 : FreeResource();
69 :
70 0 : bool bLineOnly = false;
71 0 : if( pObj && pObj->GetObjInventor() == SdrInventor )
72 : {
73 0 : switch( pObj->GetObjIdentifier() )
74 : {
75 : case OBJ_LINE:
76 : case OBJ_PLIN:
77 : case OBJ_PATHLINE:
78 : case OBJ_FREELINE:
79 : case OBJ_MEASURE:
80 : case OBJ_EDGE:
81 0 : bLineOnly = true;
82 :
83 : default:
84 0 : break;
85 : }
86 :
87 : }
88 :
89 0 : AddTabPage( RID_SVXPAGE_LINE, SvxLineTabPage::Create, 0);
90 0 : if( bLineOnly )
91 0 : AddTabPage( RID_SVXPAGE_SHADOW, SvxShadowTabPage::Create, 0 );
92 : else
93 0 : RemoveTabPage( RID_SVXPAGE_SHADOW );
94 :
95 0 : AddTabPage( RID_SVXPAGE_LINE_DEF, SvxLineDefTabPage::Create, 0);
96 0 : AddTabPage( RID_SVXPAGE_LINEEND_DEF, SvxLineEndDefTabPage::Create, 0);
97 :
98 0 : SetCurPageId( RID_SVXPAGE_LINE );
99 :
100 0 : CancelButton& rBtnCancel = GetCancelButton();
101 0 : rBtnCancel.SetClickHdl( LINK( this, SvxLineTabDialog, CancelHdlImpl ) );
102 0 : }
103 :
104 : // -----------------------------------------------------------------------
105 :
106 0 : SvxLineTabDialog::~SvxLineTabDialog()
107 : {
108 0 : }
109 :
110 : // -----------------------------------------------------------------------
111 :
112 0 : void SvxLineTabDialog::SavePalettes()
113 : {
114 0 : SfxObjectShell* pShell = SfxObjectShell::Current();
115 0 : if( mpNewColorList != pDrawModel->GetColorList() )
116 : {
117 0 : pDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
118 0 : if ( pShell )
119 0 : pShell->PutItem( SvxColorListItem( mpNewColorList, SID_COLOR_TABLE ) );
120 0 : pColorList = pDrawModel->GetColorList();
121 : }
122 0 : if( pNewDashList != pDrawModel->GetDashList() )
123 : {
124 0 : pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewDashList.get()) );
125 0 : if ( pShell )
126 0 : pShell->PutItem( SvxDashListItem( pNewDashList, SID_DASH_LIST ) );
127 0 : pDashList = pDrawModel->GetDashList();
128 : }
129 0 : if( pNewLineEndList != pDrawModel->GetLineEndList() )
130 : {
131 0 : pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewLineEndList.get()) );
132 0 : if ( pShell )
133 0 : pShell->PutItem( SvxLineEndListItem( pNewLineEndList, SID_LINEEND_LIST ) );
134 0 : pLineEndList = pDrawModel->GetLineEndList();
135 : }
136 :
137 : // Save the tables when they have been changed
138 :
139 0 : const String aPath( SvtPathOptions().GetPalettePath() );
140 :
141 0 : if( nDashListState & CT_MODIFIED )
142 : {
143 0 : pDashList->SetPath( aPath );
144 0 : pDashList->Save();
145 :
146 : // Notify ToolBoxControls
147 0 : if ( pShell )
148 0 : pShell->PutItem( SvxDashListItem( pDashList, SID_DASH_LIST ) );
149 : }
150 :
151 0 : if( nLineEndListState & CT_MODIFIED )
152 : {
153 0 : pLineEndList->SetPath( aPath );
154 0 : pLineEndList->Save();
155 :
156 : // Notify ToolBoxControls
157 0 : if ( pShell )
158 0 : pShell->PutItem( SvxLineEndListItem( pLineEndList, SID_LINEEND_LIST ) );
159 : }
160 :
161 0 : if( mnColorListState & CT_MODIFIED )
162 : {
163 0 : pColorList->SetPath( aPath );
164 0 : pColorList->Save();
165 :
166 : // Notify ToolBoxControls
167 0 : if ( pShell )
168 0 : pShell->PutItem( SvxColorListItem( pColorList, SID_COLOR_TABLE ) );
169 0 : }
170 0 : }
171 :
172 : // -----------------------------------------------------------------------
173 :
174 0 : short SvxLineTabDialog::Ok()
175 : {
176 0 : SavePalettes();
177 :
178 : // We return RET_OK if at least one TabPage in FillItemSet() returns sal_True.
179 : // We do this by default at the moment.
180 0 : return( SfxTabDialog::Ok() );
181 : }
182 :
183 : // -----------------------------------------------------------------------
184 :
185 0 : IMPL_LINK_NOARG_INLINE_START(SvxLineTabDialog, CancelHdlImpl)
186 : {
187 0 : SavePalettes();
188 :
189 0 : EndDialog( RET_CANCEL );
190 0 : return 0;
191 : }
192 0 : IMPL_LINK_NOARG_INLINE_END(SvxLineTabDialog, CancelHdlImpl)
193 :
194 : // -----------------------------------------------------------------------
195 :
196 0 : void SvxLineTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
197 : {
198 0 : switch( nId )
199 : {
200 : case RID_SVXPAGE_LINE:
201 0 : ( (SvxLineTabPage&) rPage ).SetColorList( pColorList );
202 0 : ( (SvxLineTabPage&) rPage ).SetDashList( pDashList );
203 0 : ( (SvxLineTabPage&) rPage ).SetLineEndList( pLineEndList );
204 0 : ( (SvxLineTabPage&) rPage ).SetDlgType( nDlgType );
205 0 : ( (SvxLineTabPage&) rPage ).SetPageType( nPageType );
206 0 : ( (SvxLineTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
207 0 : ( (SvxLineTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
208 0 : ( (SvxLineTabPage&) rPage ).SetDashChgd( &nDashListState );
209 0 : ( (SvxLineTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
210 0 : ( (SvxLineTabPage&) rPage ).SetObjSelected( bObjSelected );
211 0 : ( (SvxLineTabPage&) rPage ).Construct();
212 0 : ( (SvxLineTabPage&) rPage ).SetColorChgd( &mnColorListState );
213 : // ActivatePage() is not called the first time
214 0 : ( (SvxLineTabPage&) rPage ).ActivatePage( rOutAttrs );
215 0 : break;
216 :
217 : case RID_SVXPAGE_LINE_DEF:
218 0 : ( (SvxLineDefTabPage&) rPage ).SetDashList( pDashList );
219 0 : ( (SvxLineDefTabPage&) rPage ).SetDlgType( &nDlgType );
220 0 : ( (SvxLineDefTabPage&) rPage ).SetPageType( &nPageType );
221 0 : ( (SvxLineDefTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
222 0 : ( (SvxLineDefTabPage&) rPage ).SetDashChgd( &nDashListState );
223 0 : ( (SvxLineDefTabPage&) rPage ).SetObjSelected( bObjSelected );
224 0 : ( (SvxLineDefTabPage&) rPage ).Construct();
225 0 : break;
226 :
227 : case RID_SVXPAGE_LINEEND_DEF:
228 0 : ( (SvxLineEndDefTabPage&) rPage ).SetLineEndList( pLineEndList );
229 0 : ( (SvxLineEndDefTabPage&) rPage ).SetPolyObj( pObj );
230 0 : ( (SvxLineEndDefTabPage&) rPage ).SetDlgType( &nDlgType );
231 0 : ( (SvxLineEndDefTabPage&) rPage ).SetPageType( &nPageType );
232 0 : ( (SvxLineEndDefTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
233 0 : ( (SvxLineEndDefTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
234 0 : ( (SvxLineEndDefTabPage&) rPage ).SetObjSelected( bObjSelected );
235 0 : ( (SvxLineEndDefTabPage&) rPage ).Construct();
236 0 : break;
237 :
238 : case RID_SVXPAGE_SHADOW:
239 : {
240 0 : ( (SvxShadowTabPage&) rPage ).SetColorList( pColorList );
241 0 : ( (SvxShadowTabPage&) rPage ).SetPageType( nPageType );
242 0 : ( (SvxShadowTabPage&) rPage ).SetDlgType( nDlgType );
243 0 : ( (SvxShadowTabPage&) rPage ).SetAreaTP( &mbAreaTP );
244 0 : ( (SvxShadowTabPage&) rPage ).SetColorChgd( &mnColorListState );
245 0 : ( (SvxShadowTabPage&) rPage ).Construct();
246 : }
247 0 : break;
248 : }
249 3 : }
250 :
251 :
252 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|