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
|
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: postdlg.cxx,v $
* $Revision: 1.14 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_cui.hxx"
// include ---------------------------------------------------------------
#include <tools/shl.hxx>
#include <tools/date.hxx>
#include <tools/time.hxx>
#include <vcl/svapp.hxx>
#include <vcl/msgbox.hxx>
#include <svl/itempool.hxx>
#include <svl/itemset.hxx>
#include <unotools/useroptions.hxx>
#include <unotools/localedatawrapper.hxx>
#include <comphelper/processfactory.hxx>
#include <svx/dialogs.hrc>
#define _SVX_POSTDLG_CXX
#include <cuires.hrc>
#include "postdlg.hrc"
#include <svx/postattr.hxx>
#include "postdlg.hxx"
#include <dialmgr.hxx>
#include "helpid.hrc"
// static ----------------------------------------------------------------
static USHORT pRanges[] =
{
SID_ATTR_POSTIT_AUTHOR,
SID_ATTR_POSTIT_TEXT,
0
};
// class SvxPostItDialog -------------------------------------------------
SvxPostItDialog::SvxPostItDialog( Window* pParent,
const SfxItemSet& rCoreSet,
BOOL bPrevNext,
BOOL bRedline ) :
SfxModalDialog( pParent, CUI_RES( RID_SVXDLG_POSTIT ) ),
aPostItFL ( this, CUI_RES( FL_POSTIT ) ),
aLastEditLabelFT( this, CUI_RES( FT_LASTEDITLABEL ) ),
aLastEditFT ( this, CUI_RES( FT_LASTEDIT ) ),
aEditFT ( this, CUI_RES( FT_EDIT ) ),
aEditED ( this, CUI_RES( ED_EDIT ) ),
aAuthorFT ( this, CUI_RES( FT_AUTHOR) ),
aAuthorBtn ( this, CUI_RES( BTN_AUTHOR ) ),
aOKBtn ( this, CUI_RES( BTN_POST_OK ) ),
aCancelBtn ( this, CUI_RES( BTN_POST_CANCEL ) ),
aHelpBtn ( this, CUI_RES( BTN_POST_HELP ) ),
aPrevBtn ( this, CUI_RES( BTN_PREV ) ),
aNextBtn ( this, CUI_RES( BTN_NEXT ) ),
rSet ( rCoreSet ),
pOutSet ( 0 )
{
if (bRedline) // HelpIDs fuer Redlining
{
SetHelpId(HID_REDLINING_DLG);
aEditED.SetHelpId(HID_REDLINING_EDIT);
aPrevBtn.SetHelpId(HID_REDLINING_PREV);
aNextBtn.SetHelpId(HID_REDLINING_NEXT);
}
aPrevBtn.SetClickHdl( LINK( this, SvxPostItDialog, PrevHdl ) );
aNextBtn.SetClickHdl( LINK( this, SvxPostItDialog, NextHdl ) );
aAuthorBtn.SetClickHdl( LINK( this, SvxPostItDialog, Stamp ) );
aOKBtn.SetClickHdl( LINK( this, SvxPostItDialog, OKHdl ) );
Font aFont( aEditED.GetFont() );
aFont.SetWeight( WEIGHT_LIGHT );
aEditED.SetFont( aFont );
BOOL bNew = TRUE;
USHORT nWhich = 0;
if ( !bPrevNext )
{
aPrevBtn.Hide();
aNextBtn.Hide();
}
nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR );
String aAuthorStr, aDateStr, aTextStr;
if ( rSet.GetItemState( nWhich, TRUE ) >= SFX_ITEM_AVAILABLE )
{
bNew = FALSE;
const SvxPostItAuthorItem& rAuthor =
(const SvxPostItAuthorItem&)rSet.Get( nWhich );
aAuthorStr = rAuthor.GetValue();
}
else
aAuthorStr = SvtUserOptions().GetID();
nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE );
if ( rSet.GetItemState( nWhich, TRUE ) >= SFX_ITEM_AVAILABLE )
{
const SvxPostItDateItem& rDate =
(const SvxPostItDateItem&)rSet.Get( nWhich );
aDateStr = rDate.GetValue();
}
else
{
LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
aDateStr = aLocaleWrapper.getDate( Date() );
}
nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT );
if ( rSet.GetItemState( nWhich, TRUE ) >= SFX_ITEM_AVAILABLE )
{
const SvxPostItTextItem& rText =
(const SvxPostItTextItem&)rSet.Get( nWhich );
aTextStr = rText.GetValue();
}
ShowLastAuthor(aAuthorStr, aDateStr);
aEditED.SetText( aTextStr.ConvertLineEnd() );
if ( !bNew )
SetText( CUI_RESSTR( STR_NOTIZ_EDIT ) );
else
// neu anlegen
SetText( CUI_RESSTR( STR_NOTIZ_INSERT ) );
FreeResource();
}
// -----------------------------------------------------------------------
SvxPostItDialog::~SvxPostItDialog()
{
delete pOutSet;
pOutSet = 0;
}
// -----------------------------------------------------------------------
void SvxPostItDialog::ShowLastAuthor(const String& rAuthor, const String& rDate)
{
String sTxt( rAuthor );
sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
sTxt += rDate;
aLastEditFT.SetText( sTxt );
}
// -----------------------------------------------------------------------
USHORT* SvxPostItDialog::GetRanges()
{
return pRanges;
}
// -----------------------------------------------------------------------
void SvxPostItDialog::EnableTravel(BOOL bNext, BOOL bPrev)
{
aPrevBtn.Enable(bPrev);
aNextBtn.Enable(bNext);
}
// -----------------------------------------------------------------------
IMPL_LINK_INLINE_START( SvxPostItDialog, PrevHdl, Button *, EMPTYARG )
{
aPrevHdlLink.Call( this );
return 0;
}
IMPL_LINK_INLINE_END( SvxPostItDialog, PrevHdl, Button *, EMPTYARG )
// -----------------------------------------------------------------------
IMPL_LINK_INLINE_START( SvxPostItDialog, NextHdl, Button *, EMPTYARG )
{
aNextHdlLink.Call( this );
return 0;
}
IMPL_LINK_INLINE_END( SvxPostItDialog, NextHdl, Button *, EMPTYARG )
// -----------------------------------------------------------------------
IMPL_LINK( SvxPostItDialog, Stamp, Button *, EMPTYARG )
{
Date aDate;
Time aTime;
String aTmp( SvtUserOptions().GetID() );
LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
String aStr( aEditED.GetText() );
aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "\n---- " ) );
if ( aTmp.Len() > 0 )
{
aStr += aTmp;
aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
}
aStr += aLocaleWrapper.getDate(aDate);
aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
aStr += aLocaleWrapper.getTime(aTime, FALSE, FALSE);
aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " ----\n" ) );
aEditED.SetText( aStr.ConvertLineEnd() );
xub_StrLen nLen = aStr.Len();
aEditED.GrabFocus();
aEditED.SetSelection( Selection( nLen, nLen ) );
return 0;
}
// -----------------------------------------------------------------------
IMPL_LINK( SvxPostItDialog, OKHdl, Button *, EMPTYARG )
{
LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
pOutSet = new SfxItemSet( rSet );
pOutSet->Put( SvxPostItAuthorItem( SvtUserOptions().GetID(),
rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR ) ) );
pOutSet->Put( SvxPostItDateItem( aLocaleWrapper.getDate( Date() ),
rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE ) ) );
pOutSet->Put( SvxPostItTextItem( aEditED.GetText(),
rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT ) ) );
EndDialog( RET_OK );
return 0;
}
|