1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <vcl/msgbox.hxx>
#include <unotools/pathoptions.hxx>
#include <sfx2/app.hxx>
#include <sfx2/objsh.hxx>
#include <svx/dialogs.hrc>
#include <cuires.hrc>
#include "cuitabarea.hxx"
#include "cuitabline.hxx"
#include "dlgname.hxx"
#include <dialmgr.hxx>
#include <svx/svdmodel.hxx>
#include <svx/xtable.hxx>
#include "svx/drawitem.hxx"
SvxLineTabDialog::SvxLineTabDialog
(
vcl::Window* pParent,
const SfxItemSet* pAttr,
SdrModel* pModel,
const SdrObject* pSdrObj,
bool bHasObj
) :
SfxTabDialog ( pParent
, "LineDialog"
, "cui/ui/linedialog.ui"
, pAttr ),
m_nLineTabPage(0),
m_nShadowTabPage(0),
m_nStyleTabPage(0),
m_nEndTabPage(0),
pDrawModel ( pModel ),
pObj ( pSdrObj ),
rOutAttrs ( *pAttr ),
pColorList ( pModel->GetColorList() ),
mpNewColorList ( pModel->GetColorList() ),
pDashList ( pModel->GetDashList() ),
pNewDashList ( pModel->GetDashList() ),
pLineEndList ( pModel->GetLineEndList() ),
pNewLineEndList ( pModel->GetLineEndList() ),
bObjSelected ( bHasObj ),
nLineEndListState( ChangeType::NONE ),
nDashListState( ChangeType::NONE ),
mnColorListState( ChangeType::NONE ),
nPageType( 0 ), // We use it here primarily to get the right attributes with FillItemSet
nPosDashLb( 0 ),
nPosLineEndLb( 0 ),
mbAreaTP( false )
{
bool bLineOnly = false;
if( pObj && pObj->GetObjInventor() == SdrInventor )
{
switch( pObj->GetObjIdentifier() )
{
case OBJ_LINE:
case OBJ_PLIN:
case OBJ_PATHLINE:
case OBJ_FREELINE:
case OBJ_MEASURE:
case OBJ_EDGE:
bLineOnly = true;
default:
break;
}
}
m_nLineTabPage = AddTabPage( "RID_SVXPAGE_LINE", SvxLineTabPage::Create, 0);
if( bLineOnly )
m_nShadowTabPage = AddTabPage( "RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create, 0 );
else
RemoveTabPage( "RID_SVXPAGE_SHADOW" );
m_nStyleTabPage = AddTabPage( "RID_SVXPAGE_LINE_DEF", SvxLineDefTabPage::Create, 0);
m_nEndTabPage = AddTabPage( "RID_SVXPAGE_LINEEND_DEF", SvxLineEndDefTabPage::Create, 0);
SetCurPageId( "RID_SVXPAGE_LINE" );
CancelButton& rBtnCancel = GetCancelButton();
rBtnCancel.SetClickHdl( LINK( this, SvxLineTabDialog, CancelHdlImpl ) );
}
void SvxLineTabDialog::SavePalettes()
{
SfxObjectShell* pShell = SfxObjectShell::Current();
if( mpNewColorList != pDrawModel->GetColorList() )
{
pDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
if ( pShell )
pShell->PutItem( SvxColorListItem( mpNewColorList, SID_COLOR_TABLE ) );
pColorList = pDrawModel->GetColorList();
}
if( pNewDashList != pDrawModel->GetDashList() )
{
pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewDashList.get()) );
if ( pShell )
pShell->PutItem( SvxDashListItem( pNewDashList, SID_DASH_LIST ) );
pDashList = pDrawModel->GetDashList();
}
if( pNewLineEndList != pDrawModel->GetLineEndList() )
{
pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewLineEndList.get()) );
if ( pShell )
pShell->PutItem( SvxLineEndListItem( pNewLineEndList, SID_LINEEND_LIST ) );
pLineEndList = pDrawModel->GetLineEndList();
}
// Save the tables when they have been changed
OUString aPalettePath(SvtPathOptions().GetPalettePath());
OUString aPath;
sal_Int32 nIndex = 0;
do
{
aPath = aPalettePath.getToken(0, ';', nIndex);
}
while (nIndex >= 0);
if( nDashListState & ChangeType::MODIFIED )
{
pDashList->SetPath( aPath );
pDashList->Save();
// Notify ToolBoxControls
if ( pShell )
pShell->PutItem( SvxDashListItem( pDashList, SID_DASH_LIST ) );
}
if( nLineEndListState & ChangeType::MODIFIED )
{
pLineEndList->SetPath( aPath );
pLineEndList->Save();
// Notify ToolBoxControls
if ( pShell )
pShell->PutItem( SvxLineEndListItem( pLineEndList, SID_LINEEND_LIST ) );
}
if( mnColorListState & ChangeType::MODIFIED )
{
pColorList->SetPath( aPath );
pColorList->Save();
// Notify ToolBoxControls
if ( pShell )
pShell->PutItem( SvxColorListItem( pColorList, SID_COLOR_TABLE ) );
}
}
short SvxLineTabDialog::Ok()
{
SavePalettes();
// We return RET_OK if at least one TabPage in FillItemSet() returns sal_True.
// We do this by default at the moment.
return( SfxTabDialog::Ok() );
}
IMPL_LINK_NOARG(SvxLineTabDialog, CancelHdlImpl)
{
SavePalettes();
EndDialog();
return 0;
}
void SvxLineTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
{
if( nId == m_nLineTabPage)
{
static_cast<SvxLineTabPage&>(rPage).SetColorList( pColorList );
static_cast<SvxLineTabPage&>(rPage).SetDashList( pDashList );
static_cast<SvxLineTabPage&>(rPage).SetLineEndList( pLineEndList );
static_cast<SvxLineTabPage&>(rPage).SetDlgType( 0 );
static_cast<SvxLineTabPage&>(rPage).SetPageType( nPageType );
static_cast<SvxLineTabPage&>(rPage).SetPosDashLb( &nPosDashLb );
static_cast<SvxLineTabPage&>(rPage).SetPosLineEndLb( &nPosLineEndLb );
static_cast<SvxLineTabPage&>(rPage).SetDashChgd( &nDashListState );
static_cast<SvxLineTabPage&>(rPage).SetLineEndChgd( &nLineEndListState );
static_cast<SvxLineTabPage&>(rPage).SetObjSelected( bObjSelected );
static_cast<SvxLineTabPage&>(rPage).Construct();
static_cast<SvxLineTabPage&>(rPage).SetColorChgd( &mnColorListState );
// ActivatePage() is not called the first time
static_cast<SvxLineTabPage&>(rPage).ActivatePage( rOutAttrs );
}
else if(nId == m_nStyleTabPage)
{
static_cast<SvxLineDefTabPage&>(rPage).SetDashList( pDashList );
static_cast<SvxLineDefTabPage&>(rPage).SetDlgType( 0 );
static_cast<SvxLineDefTabPage&>(rPage).SetPageType( &nPageType );
static_cast<SvxLineDefTabPage&>(rPage).SetPosDashLb( &nPosDashLb );
static_cast<SvxLineDefTabPage&>(rPage).SetDashChgd( &nDashListState );
static_cast<SvxLineDefTabPage&>(rPage).SetObjSelected( bObjSelected );
static_cast<SvxLineDefTabPage&>(rPage).Construct();
}
else if(nId == m_nEndTabPage)
{
static_cast<SvxLineEndDefTabPage&>(rPage).SetLineEndList( pLineEndList );
static_cast<SvxLineEndDefTabPage&>(rPage).SetPolyObj( pObj );
static_cast<SvxLineEndDefTabPage&>(rPage).SetDlgType( 0 );
static_cast<SvxLineEndDefTabPage&>(rPage).SetPageType( &nPageType );
static_cast<SvxLineEndDefTabPage&>(rPage).SetPosLineEndLb( &nPosLineEndLb );
static_cast<SvxLineEndDefTabPage&>(rPage).SetLineEndChgd( &nLineEndListState );
static_cast<SvxLineEndDefTabPage&>(rPage).SetObjSelected( bObjSelected );
static_cast<SvxLineEndDefTabPage&>(rPage).Construct();
}
else if (nId == m_nShadowTabPage)
{
static_cast<SvxShadowTabPage&>(rPage).SetColorList( pColorList );
static_cast<SvxShadowTabPage&>(rPage).SetPageType( nPageType );
static_cast<SvxShadowTabPage&>(rPage).SetDlgType( 0 );
static_cast<SvxShadowTabPage&>(rPage).SetAreaTP( &mbAreaTP );
static_cast<SvxShadowTabPage&>(rPage).SetColorChgd( &mnColorListState );
static_cast<SvxShadowTabPage&>(rPage).Construct();
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|