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