12ee96f1cSAndrew Rist /**************************************************************
21d7f0aadSmseidel *
32ee96f1cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
42ee96f1cSAndrew Rist * or more contributor license agreements. See the NOTICE file
52ee96f1cSAndrew Rist * distributed with this work for additional information
62ee96f1cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
72ee96f1cSAndrew Rist * to you under the Apache License, Version 2.0 (the
82ee96f1cSAndrew Rist * "License"); you may not use this file except in compliance
92ee96f1cSAndrew Rist * with the License. You may obtain a copy of the License at
101d7f0aadSmseidel *
112ee96f1cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
121d7f0aadSmseidel *
132ee96f1cSAndrew Rist * Unless required by applicable law or agreed to in writing,
142ee96f1cSAndrew Rist * software distributed under the License is distributed on an
152ee96f1cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162ee96f1cSAndrew Rist * KIND, either express or implied. See the License for the
172ee96f1cSAndrew Rist * specific language governing permissions and limitations
182ee96f1cSAndrew Rist * under the License.
191d7f0aadSmseidel *
202ee96f1cSAndrew Rist *************************************************************/
212ee96f1cSAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_cui.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir // include ---------------------------------------------------------------
26cdf0e10cSrcweir #include <tools/shl.hxx>
27cdf0e10cSrcweir #include <tools/date.hxx>
28cdf0e10cSrcweir #include <tools/time.hxx>
29cdf0e10cSrcweir #include <vcl/svapp.hxx>
30cdf0e10cSrcweir #include <vcl/msgbox.hxx>
31cdf0e10cSrcweir #include <svl/itempool.hxx>
32cdf0e10cSrcweir #include <svl/itemset.hxx>
33cdf0e10cSrcweir #include <unotools/useroptions.hxx>
34cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
35cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
361d7f0aadSmseidel #include <svx/svxids.hrc> // SID_ATTR_...
371d7f0aadSmseidel #include <svx/dialogs.hrc> // RID_SVXDLG_POSTIT
38cdf0e10cSrcweir
39cdf0e10cSrcweir #define _SVX_POSTDLG_CXX
40cdf0e10cSrcweir
41cdf0e10cSrcweir #include <cuires.hrc>
42cdf0e10cSrcweir #include "postdlg.hrc"
43cdf0e10cSrcweir #include <svx/postattr.hxx>
44cdf0e10cSrcweir #include "postdlg.hxx"
45cdf0e10cSrcweir #include <dialmgr.hxx>
46cdf0e10cSrcweir
47cdf0e10cSrcweir #include "helpid.hrc"
48cdf0e10cSrcweir
49cdf0e10cSrcweir // static ----------------------------------------------------------------
50cdf0e10cSrcweir
51cdf0e10cSrcweir static sal_uInt16 pRanges[] =
52cdf0e10cSrcweir {
53cdf0e10cSrcweir SID_ATTR_POSTIT_AUTHOR,
54cdf0e10cSrcweir SID_ATTR_POSTIT_TEXT,
55cdf0e10cSrcweir 0
56cdf0e10cSrcweir };
57cdf0e10cSrcweir
58cdf0e10cSrcweir // class SvxPostItDialog -------------------------------------------------
59cdf0e10cSrcweir
SvxPostItDialog(Window * pParent,const SfxItemSet & rCoreSet,sal_Bool bPrevNext,sal_Bool bRedline)60cdf0e10cSrcweir SvxPostItDialog::SvxPostItDialog( Window* pParent,
61cdf0e10cSrcweir const SfxItemSet& rCoreSet,
62cdf0e10cSrcweir sal_Bool bPrevNext,
63cdf0e10cSrcweir sal_Bool bRedline ) :
64cdf0e10cSrcweir
65cdf0e10cSrcweir SfxModalDialog( pParent, CUI_RES( RID_SVXDLG_POSTIT ) ),
66cdf0e10cSrcweir
671d7f0aadSmseidel aPostItFL ( this, CUI_RES( FL_POSTIT ) ),
681d7f0aadSmseidel aLastEditLabelFT( this, CUI_RES( FT_LASTEDITLABEL ) ),
69cdf0e10cSrcweir aLastEditFT ( this, CUI_RES( FT_LASTEDIT ) ),
70cdf0e10cSrcweir aEditFT ( this, CUI_RES( FT_EDIT ) ),
71cdf0e10cSrcweir aEditED ( this, CUI_RES( ED_EDIT ) ),
721d7f0aadSmseidel aAuthorFT ( this, CUI_RES( FT_AUTHOR) ),
731d7f0aadSmseidel aAuthorBtn ( this, CUI_RES( BTN_AUTHOR ) ),
741d7f0aadSmseidel aOKBtn ( this, CUI_RES( BTN_POST_OK ) ),
75cdf0e10cSrcweir aCancelBtn ( this, CUI_RES( BTN_POST_CANCEL ) ),
761d7f0aadSmseidel aHelpBtn ( this, CUI_RES( BTN_POST_HELP ) ),
771d7f0aadSmseidel aPrevBtn ( this, CUI_RES( BTN_PREV ) ),
78cdf0e10cSrcweir aNextBtn ( this, CUI_RES( BTN_NEXT ) ),
79cdf0e10cSrcweir
80cdf0e10cSrcweir rSet ( rCoreSet ),
81cdf0e10cSrcweir pOutSet ( 0 )
82cdf0e10cSrcweir
83cdf0e10cSrcweir {
841d7f0aadSmseidel if (bRedline) // HelpIDs for Redlining
85cdf0e10cSrcweir {
86cdf0e10cSrcweir SetHelpId(HID_REDLINING_DLG);
87cdf0e10cSrcweir aEditED.SetHelpId(HID_REDLINING_EDIT);
88cdf0e10cSrcweir aPrevBtn.SetHelpId(HID_REDLINING_PREV);
89cdf0e10cSrcweir aNextBtn.SetHelpId(HID_REDLINING_NEXT);
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
92cdf0e10cSrcweir aPrevBtn.SetClickHdl( LINK( this, SvxPostItDialog, PrevHdl ) );
93cdf0e10cSrcweir aNextBtn.SetClickHdl( LINK( this, SvxPostItDialog, NextHdl ) );
94cdf0e10cSrcweir aAuthorBtn.SetClickHdl( LINK( this, SvxPostItDialog, Stamp ) );
95cdf0e10cSrcweir aOKBtn.SetClickHdl( LINK( this, SvxPostItDialog, OKHdl ) );
96cdf0e10cSrcweir
97cdf0e10cSrcweir Font aFont( aEditED.GetFont() );
98cdf0e10cSrcweir aFont.SetWeight( WEIGHT_LIGHT );
99cdf0e10cSrcweir aEditED.SetFont( aFont );
100cdf0e10cSrcweir
101cdf0e10cSrcweir sal_Bool bNew = sal_True;
102cdf0e10cSrcweir sal_uInt16 nWhich = 0;
103cdf0e10cSrcweir
104cdf0e10cSrcweir if ( !bPrevNext )
105cdf0e10cSrcweir {
1061d7f0aadSmseidel aPrevBtn.Disable();
1071d7f0aadSmseidel aNextBtn.Disable();
108cdf0e10cSrcweir }
109cdf0e10cSrcweir
110cdf0e10cSrcweir nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR );
111cdf0e10cSrcweir String aAuthorStr, aDateStr, aTextStr;
112cdf0e10cSrcweir
113cdf0e10cSrcweir if ( rSet.GetItemState( nWhich, sal_True ) >= SFX_ITEM_AVAILABLE )
114cdf0e10cSrcweir {
115cdf0e10cSrcweir bNew = sal_False;
116cdf0e10cSrcweir const SvxPostItAuthorItem& rAuthor =
117cdf0e10cSrcweir (const SvxPostItAuthorItem&)rSet.Get( nWhich );
118cdf0e10cSrcweir aAuthorStr = rAuthor.GetValue();
119cdf0e10cSrcweir }
120cdf0e10cSrcweir else
121cdf0e10cSrcweir aAuthorStr = SvtUserOptions().GetID();
122cdf0e10cSrcweir
123cdf0e10cSrcweir nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE );
124cdf0e10cSrcweir
125cdf0e10cSrcweir if ( rSet.GetItemState( nWhich, sal_True ) >= SFX_ITEM_AVAILABLE )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir const SvxPostItDateItem& rDate =
128cdf0e10cSrcweir (const SvxPostItDateItem&)rSet.Get( nWhich );
129cdf0e10cSrcweir aDateStr = rDate.GetValue();
130cdf0e10cSrcweir }
131cdf0e10cSrcweir else
132cdf0e10cSrcweir {
133cdf0e10cSrcweir LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
134cdf0e10cSrcweir aDateStr = aLocaleWrapper.getDate( Date() );
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
137cdf0e10cSrcweir nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT );
138cdf0e10cSrcweir
139cdf0e10cSrcweir if ( rSet.GetItemState( nWhich, sal_True ) >= SFX_ITEM_AVAILABLE )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir const SvxPostItTextItem& rText =
142cdf0e10cSrcweir (const SvxPostItTextItem&)rSet.Get( nWhich );
143cdf0e10cSrcweir aTextStr = rText.GetValue();
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
146cdf0e10cSrcweir ShowLastAuthor(aAuthorStr, aDateStr);
147cdf0e10cSrcweir aEditED.SetText( aTextStr.ConvertLineEnd() );
148cdf0e10cSrcweir
149cdf0e10cSrcweir if ( !bNew )
150cdf0e10cSrcweir SetText( CUI_RESSTR( STR_NOTIZ_EDIT ) );
151cdf0e10cSrcweir else
152cdf0e10cSrcweir // neu anlegen
153cdf0e10cSrcweir SetText( CUI_RESSTR( STR_NOTIZ_INSERT ) );
154cdf0e10cSrcweir
155cdf0e10cSrcweir FreeResource();
156cdf0e10cSrcweir
157cdf0e10cSrcweir aEditED.SetAccessibleRelationLabeledBy(&aEditFT);
158cdf0e10cSrcweir aEditED.SetAccessibleRelationMemberOf(&aPostItFL);
159cdf0e10cSrcweir aAuthorBtn.SetAccessibleRelationMemberOf(&aPostItFL);
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
162cdf0e10cSrcweir // -----------------------------------------------------------------------
163cdf0e10cSrcweir
~SvxPostItDialog()164cdf0e10cSrcweir SvxPostItDialog::~SvxPostItDialog()
165cdf0e10cSrcweir {
166cdf0e10cSrcweir delete pOutSet;
167cdf0e10cSrcweir pOutSet = 0;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir // -----------------------------------------------------------------------
171cdf0e10cSrcweir
ShowLastAuthor(const String & rAuthor,const String & rDate)172cdf0e10cSrcweir void SvxPostItDialog::ShowLastAuthor(const String& rAuthor, const String& rDate)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir String sTxt( rAuthor );
175cdf0e10cSrcweir sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
176cdf0e10cSrcweir sTxt += rDate;
177cdf0e10cSrcweir aLastEditFT.SetText( sTxt );
178cdf0e10cSrcweir }
179cdf0e10cSrcweir
180cdf0e10cSrcweir // -----------------------------------------------------------------------
181cdf0e10cSrcweir
GetRanges()182cdf0e10cSrcweir sal_uInt16* SvxPostItDialog::GetRanges()
183cdf0e10cSrcweir {
184cdf0e10cSrcweir return pRanges;
185cdf0e10cSrcweir }
186cdf0e10cSrcweir
187cdf0e10cSrcweir // -----------------------------------------------------------------------
188cdf0e10cSrcweir
EnableTravel(sal_Bool bNext,sal_Bool bPrev)189cdf0e10cSrcweir void SvxPostItDialog::EnableTravel(sal_Bool bNext, sal_Bool bPrev)
190cdf0e10cSrcweir {
191cdf0e10cSrcweir aPrevBtn.Enable(bPrev);
192cdf0e10cSrcweir aNextBtn.Enable(bNext);
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
195cdf0e10cSrcweir // -----------------------------------------------------------------------
196cdf0e10cSrcweir
IMPL_LINK_INLINE_START(SvxPostItDialog,PrevHdl,Button *,EMPTYARG)197cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvxPostItDialog, PrevHdl, Button *, EMPTYARG )
198cdf0e10cSrcweir {
199cdf0e10cSrcweir aPrevHdlLink.Call( this );
200cdf0e10cSrcweir return 0;
201cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SvxPostItDialog,PrevHdl,Button *,EMPTYARG)202cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvxPostItDialog, PrevHdl, Button *, EMPTYARG )
203cdf0e10cSrcweir
204cdf0e10cSrcweir // -----------------------------------------------------------------------
205cdf0e10cSrcweir
206cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvxPostItDialog, NextHdl, Button *, EMPTYARG )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir aNextHdlLink.Call( this );
209cdf0e10cSrcweir return 0;
210cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SvxPostItDialog,NextHdl,Button *,EMPTYARG)211cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvxPostItDialog, NextHdl, Button *, EMPTYARG )
212cdf0e10cSrcweir
213cdf0e10cSrcweir // -----------------------------------------------------------------------
214cdf0e10cSrcweir
215cdf0e10cSrcweir IMPL_LINK( SvxPostItDialog, Stamp, Button *, EMPTYARG )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir Date aDate;
218cdf0e10cSrcweir Time aTime;
219cdf0e10cSrcweir String aTmp( SvtUserOptions().GetID() );
220cdf0e10cSrcweir LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
221cdf0e10cSrcweir String aStr( aEditED.GetText() );
222cdf0e10cSrcweir aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "\n---- " ) );
223cdf0e10cSrcweir
224cdf0e10cSrcweir if ( aTmp.Len() > 0 )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir aStr += aTmp;
227cdf0e10cSrcweir aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
228cdf0e10cSrcweir }
229cdf0e10cSrcweir aStr += aLocaleWrapper.getDate(aDate);
230cdf0e10cSrcweir aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
231cdf0e10cSrcweir aStr += aLocaleWrapper.getTime(aTime, sal_False, sal_False);
232cdf0e10cSrcweir aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " ----\n" ) );
233cdf0e10cSrcweir
234cdf0e10cSrcweir
235cdf0e10cSrcweir aEditED.SetText( aStr.ConvertLineEnd() );
236cdf0e10cSrcweir xub_StrLen nLen = aStr.Len();
237cdf0e10cSrcweir aEditED.GrabFocus();
238cdf0e10cSrcweir aEditED.SetSelection( Selection( nLen, nLen ) );
239cdf0e10cSrcweir return 0;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir
242cdf0e10cSrcweir // -----------------------------------------------------------------------
243cdf0e10cSrcweir
IMPL_LINK(SvxPostItDialog,OKHdl,Button *,EMPTYARG)244cdf0e10cSrcweir IMPL_LINK( SvxPostItDialog, OKHdl, Button *, EMPTYARG )
245cdf0e10cSrcweir {
246cdf0e10cSrcweir LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
247cdf0e10cSrcweir pOutSet = new SfxItemSet( rSet );
248cdf0e10cSrcweir pOutSet->Put( SvxPostItAuthorItem( SvtUserOptions().GetID(),
2491d7f0aadSmseidel rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR ) ) );
250cdf0e10cSrcweir pOutSet->Put( SvxPostItDateItem( aLocaleWrapper.getDate( Date() ),
251cdf0e10cSrcweir rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE ) ) );
252cdf0e10cSrcweir pOutSet->Put( SvxPostItTextItem( aEditED.GetText(),
253cdf0e10cSrcweir rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT ) ) );
254cdf0e10cSrcweir EndDialog( RET_OK );
255cdf0e10cSrcweir return 0;
256cdf0e10cSrcweir }
257*108891ceSmseidel
258*108891ceSmseidel /* vim: set noet sw=4 ts=4: */
259