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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
/* -*- 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 <cmdid.h>
#include <hintids.hxx>
#include <svx/dialmgr.hxx>
#include <svx/dialogs.hrc>
#include <svx/drawitem.hxx>
#include <svx/xtable.hxx>
#include <sal/macros.h>
#include <vcl/field.hxx>
#include <vcl/svapp.hxx>
#include <unotools/localedatawrapper.hxx>
#include <unotools/syslocale.hxx>
#include <editeng/borderline.hxx>
#include <editeng/sizeitem.hxx>
#include <svx/pageitem.hxx>
#include <svl/eitem.hxx>
#include <editeng/ulspitem.hxx>
#include <uitool.hxx>
#include <pagedesc.hxx>
#include <pgfnote.hxx>
#include <uiitems.hxx>
#include <sfx2/objsh.hxx>
#include <globals.hrc>
#include <misc.hrc>
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
static const sal_uInt16 aPageRg[] = {
FN_PARAM_FTN_INFO, FN_PARAM_FTN_INFO,
0
};
// handler to switch between the different possibilities how the footnote
// region's height can be set.
IMPL_LINK_NOARG_INLINE_START(SwFootNotePage, HeightPage)
{
m_pMaxHeightEdit->Enable(false);
return 0;
}
IMPL_LINK_NOARG_INLINE_END(SwFootNotePage, HeightPage)
IMPL_LINK_NOARG_INLINE_START(SwFootNotePage, HeightMetric)
{
m_pMaxHeightEdit->Enable();
m_pMaxHeightEdit->GrabFocus();
return 0;
}
IMPL_LINK_NOARG_INLINE_END(SwFootNotePage, HeightMetric)
// handler limit values
IMPL_LINK_NOARG(SwFootNotePage, HeightModify)
{
m_pMaxHeightEdit->SetMax(m_pMaxHeightEdit->Normalize(lMaxHeight -
(m_pDistEdit->Denormalize(m_pDistEdit->GetValue(FUNIT_TWIP)) +
m_pLineDistEdit->Denormalize(m_pLineDistEdit->GetValue(FUNIT_TWIP)))),
FUNIT_TWIP);
if(m_pMaxHeightEdit->GetValue() < 0)
m_pMaxHeightEdit->SetValue(0);
m_pDistEdit->SetMax(m_pDistEdit->Normalize(lMaxHeight -
(m_pMaxHeightEdit->Denormalize(m_pMaxHeightEdit->GetValue(FUNIT_TWIP)) +
m_pLineDistEdit->Denormalize(m_pLineDistEdit->GetValue(FUNIT_TWIP)))),
FUNIT_TWIP);
if(m_pDistEdit->GetValue() < 0)
m_pDistEdit->SetValue(0);
m_pLineDistEdit->SetMax(m_pLineDistEdit->Normalize(lMaxHeight -
(m_pMaxHeightEdit->Denormalize(m_pMaxHeightEdit->GetValue(FUNIT_TWIP)) +
m_pDistEdit->Denormalize(m_pDistEdit->GetValue(FUNIT_TWIP)))),
FUNIT_TWIP);
return 0;
}
IMPL_LINK_NOARG(SwFootNotePage, LineWidthChanged_Impl)
{
sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
m_pLineWidthEdit->GetValue( ),
m_pLineWidthEdit->GetDecimalDigits( ),
m_pLineWidthEdit->GetUnit(), MAP_TWIP ));
m_pLineTypeBox->SetWidth( nVal );
return 0;
}
IMPL_LINK_NOARG(SwFootNotePage, LineColorSelected_Impl)
{
m_pLineTypeBox->SetColor( m_pLineColorBox->GetSelectEntryColor() );
return 0;
}
SwFootNotePage::SwFootNotePage(Window *pParent, const SfxItemSet &rSet)
: SfxTabPage(pParent, "FootnoteAreaPage",
"modules/swriter/ui/footnoteareapage.ui", &rSet)
, lMaxHeight(0)
{
get(m_pMaxHeightPageBtn, "maxheightpage");
get(m_pMaxHeightBtn, "maxheight");
get(m_pMaxHeightEdit, "maxheightsb");
get(m_pDistEdit, "spacetotext");
get(m_pLinePosBox, "position");
get(m_pLineTypeBox, "style");
get(m_pLineWidthEdit, "thickness");
get(m_pLineColorBox, "color");
get(m_pLineLengthEdit, "length");
get(m_pLineDistEdit, "spacingtocontents");
SetExchangeSupport();
FieldUnit aMetric = ::GetDfltMetric(false);
SetMetric(*m_pMaxHeightEdit, aMetric);
SetMetric(*m_pDistEdit, aMetric);
SetMetric(*m_pLineDistEdit, aMetric);
MeasurementSystem eSys = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
long nHeightValue = MEASURE_METRIC != eSys ? 1440 : 1134;
m_pMaxHeightEdit->SetValue(m_pMaxHeightEdit->Normalize(nHeightValue),FUNIT_TWIP);
}
SwFootNotePage::~SwFootNotePage()
{
}
SfxTabPage* SwFootNotePage::Create(Window *pParent, const SfxItemSet *rSet)
{
return new SwFootNotePage(pParent, *rSet);
}
void SwFootNotePage::Reset(const SfxItemSet *rSet)
{
// if no example exists, otherwise Init here in Activate
boost::scoped_ptr<SwPageFtnInfo> pDefFtnInfo;
const SwPageFtnInfo* pFtnInfo;
const SfxPoolItem* pItem = SfxTabPage::GetItem(*rSet, FN_PARAM_FTN_INFO);
if( pItem )
{
pFtnInfo = &((const SwPageFtnInfoItem*)pItem)->GetPageFtnInfo();
}
else
{
// when "standard" is being activated the footnote item is deleted,
// that's why a footnote structure has to be created here
pDefFtnInfo.reset(new SwPageFtnInfo());
pFtnInfo = pDefFtnInfo.get();
}
// footnote area's height
SwTwips lHeight = pFtnInfo->GetHeight();
if(lHeight)
{
m_pMaxHeightEdit->SetValue(m_pMaxHeightEdit->Normalize(lHeight),FUNIT_TWIP);
m_pMaxHeightBtn->Check(true);
}
else
{
m_pMaxHeightPageBtn->Check(true);
m_pMaxHeightEdit->Enable(false);
}
m_pMaxHeightPageBtn->SetClickHdl(LINK(this,SwFootNotePage,HeightPage));
m_pMaxHeightBtn->SetClickHdl(LINK(this,SwFootNotePage,HeightMetric));
Link aLk = LINK(this, SwFootNotePage, HeightModify);
m_pMaxHeightEdit->SetLoseFocusHdl( aLk );
m_pDistEdit->SetLoseFocusHdl( aLk );
m_pLineDistEdit->SetLoseFocusHdl( aLk );
// Separator width
m_pLineWidthEdit->SetModifyHdl( LINK( this, SwFootNotePage, LineWidthChanged_Impl ) );
sal_Int64 nWidthPt = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
sal_Int64( pFtnInfo->GetLineWidth() ), m_pLineWidthEdit->GetDecimalDigits(),
MAP_TWIP, m_pLineWidthEdit->GetUnit( ) ));
m_pLineWidthEdit->SetValue( nWidthPt );
// Separator style
m_pLineTypeBox->SetSourceUnit( FUNIT_TWIP );
m_pLineTypeBox->SetNone(SW_RESSTR(SW_STR_NONE));
m_pLineTypeBox->InsertEntry(
::editeng::SvxBorderLine::getWidthImpl(table::BorderLineStyle::SOLID),
table::BorderLineStyle::SOLID );
m_pLineTypeBox->InsertEntry(
::editeng::SvxBorderLine::getWidthImpl(table::BorderLineStyle::DOTTED),
table::BorderLineStyle::DOTTED );
m_pLineTypeBox->InsertEntry(
::editeng::SvxBorderLine::getWidthImpl(table::BorderLineStyle::DASHED),
table::BorderLineStyle::DASHED );
m_pLineTypeBox->SetWidth( pFtnInfo->GetLineWidth( ) );
m_pLineTypeBox->SelectEntry( pFtnInfo->GetLineStyle() );
// Separator Color
SfxObjectShell* pDocSh = SfxObjectShell::Current();
XColorListRef pColorList;
OSL_ENSURE( pDocSh, "DocShell not found!" );
if ( pDocSh )
{
const SfxPoolItem* pColorItem = pDocSh->GetItem( SID_COLOR_TABLE );
if ( pColorItem != NULL )
pColorList = ( (SvxColorListItem*)pColorItem )->GetColorList();
}
OSL_ENSURE( pColorList.is(), "ColorTable not found!" );
if ( pColorList.is() )
{
m_pLineColorBox->SetUpdateMode( false );
for ( long i = 0; i < pColorList->Count(); ++i )
{
XColorEntry* pEntry = pColorList->GetColor(i);
m_pLineColorBox->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
}
m_pLineColorBox->SetUpdateMode( true );
}
// select color in the list or add it as a user color
sal_Int32 nSelPos = m_pLineColorBox->GetEntryPos( pFtnInfo->GetLineColor() );
if( nSelPos == LISTBOX_ENTRY_NOTFOUND )
nSelPos = m_pLineColorBox->InsertEntry( pFtnInfo->GetLineColor(),
SVX_RESSTR(RID_SVXSTR_COLOR_USER) );
m_pLineColorBox->SetSelectHdl( LINK( this, SwFootNotePage, LineColorSelected_Impl ) );
m_pLineColorBox->SelectEntryPos( nSelPos );
m_pLineTypeBox->SetColor( pFtnInfo->GetLineColor() );
// position
m_pLinePosBox->SelectEntryPos( static_cast< sal_Int32 >(pFtnInfo->GetAdj()) );
// width
Fraction aTmp( 100, 1 );
aTmp *= pFtnInfo->GetWidth();
m_pLineLengthEdit->SetValue( static_cast<long>(aTmp) );
// gap footnote area
m_pDistEdit->SetValue(m_pDistEdit->Normalize(pFtnInfo->GetTopDist()),FUNIT_TWIP);
m_pLineDistEdit->SetValue(
m_pLineDistEdit->Normalize(pFtnInfo->GetBottomDist()), FUNIT_TWIP);
ActivatePage( *rSet );
}
// stuff attributes into the set, when OK
bool SwFootNotePage::FillItemSet(SfxItemSet *rSet)
{
SwPageFtnInfoItem aItem((const SwPageFtnInfoItem&)GetItemSet().Get(FN_PARAM_FTN_INFO));
// that's the original
SwPageFtnInfo &rFtnInfo = aItem.GetPageFtnInfo();
// footnote area's height
if(m_pMaxHeightBtn->IsChecked())
rFtnInfo.SetHeight( static_cast< SwTwips >(
m_pMaxHeightEdit->Denormalize(m_pMaxHeightEdit->GetValue(FUNIT_TWIP))));
else
rFtnInfo.SetHeight(0);
// gap footnote area
rFtnInfo.SetTopDist( static_cast< SwTwips >(
m_pDistEdit->Denormalize(m_pDistEdit->GetValue(FUNIT_TWIP))));
rFtnInfo.SetBottomDist( static_cast< SwTwips >(
m_pLineDistEdit->Denormalize(m_pLineDistEdit->GetValue(FUNIT_TWIP))));
// Separator style
rFtnInfo.SetLineStyle( ::editeng::SvxBorderStyle( m_pLineTypeBox->GetSelectEntryStyle() ) );
// Separator width
long nWidth = static_cast<long>(MetricField::ConvertDoubleValue(
m_pLineWidthEdit->GetValue( ),
m_pLineWidthEdit->GetDecimalDigits( ),
m_pLineWidthEdit->GetUnit(), MAP_TWIP ));
rFtnInfo.SetLineWidth( nWidth );
// Separator color
rFtnInfo.SetLineColor( m_pLineColorBox->GetSelectEntryColor() );
// Position
rFtnInfo.SetAdj((SwFtnAdj)m_pLinePosBox->GetSelectEntryPos());
// Breite
rFtnInfo.SetWidth(Fraction( static_cast< long >(m_pLineLengthEdit->GetValue()), 100));
const SfxPoolItem* pOldItem;
if(0 == (pOldItem = GetOldItem( *rSet, FN_PARAM_FTN_INFO )) ||
aItem != *pOldItem )
rSet->Put(aItem);
return true;
}
void SwFootNotePage::ActivatePage(const SfxItemSet& rSet)
{
const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get( RES_FRM_SIZE );
lMaxHeight = rSize.GetSize().Height();
const SfxPoolItem* pItem;
if( SfxItemState::SET == rSet.GetItemState( rSet.GetPool()->GetWhich( SID_ATTR_PAGE_HEADERSET), false, &pItem ) )
{
const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet();
const SfxBoolItem& rHeaderOn =
(const SfxBoolItem&)rHeaderSet.Get( rSet.GetPool()->GetWhich( SID_ATTR_PAGE_ON ) );
if ( rHeaderOn.GetValue() )
{
const SvxSizeItem& rSizeItem =
(const SvxSizeItem&)rHeaderSet.Get(rSet.GetPool()->GetWhich(SID_ATTR_PAGE_SIZE));
lMaxHeight -= rSizeItem.GetSize().Height();
}
}
if( SfxItemState::SET == rSet.GetItemState( rSet.GetPool()->GetWhich( SID_ATTR_PAGE_FOOTERSET),
false, &pItem ) )
{
const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet();
const SfxBoolItem& rFooterOn =
(const SfxBoolItem&)rFooterSet.Get( SID_ATTR_PAGE_ON );
if ( rFooterOn.GetValue() )
{
const SvxSizeItem& rSizeItem =
(const SvxSizeItem&)rFooterSet.Get( rSet.GetPool()->GetWhich( SID_ATTR_PAGE_SIZE ) );
lMaxHeight -= rSizeItem.GetSize().Height();
}
}
if ( rSet.GetItemState( RES_UL_SPACE , false ) == SfxItemState::SET )
{
const SvxULSpaceItem &rUL = (const SvxULSpaceItem&)rSet.Get( RES_UL_SPACE );
lMaxHeight -= rUL.GetUpper() + rUL.GetLower();
}
lMaxHeight *= 8;
lMaxHeight /= 10;
// set maximum values
HeightModify(0);
}
int SwFootNotePage::DeactivatePage( SfxItemSet* _pSet)
{
if(_pSet)
FillItemSet(_pSet);
return sal_True;
}
const sal_uInt16* SwFootNotePage::GetRanges()
{
return aPageRg;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|