1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2a97ec55SAndrew Rist  * distributed with this work for additional information
6*2a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2a97ec55SAndrew Rist  *
11*2a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2a97ec55SAndrew Rist  *
13*2a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist  * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2a97ec55SAndrew Rist  * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist  * under the License.
19*2a97ec55SAndrew Rist  *
20*2a97ec55SAndrew Rist  *************************************************************/
21*2a97ec55SAndrew Rist 
22*2a97ec55SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir #include "oemwiz.hxx"
27cdf0e10cSrcweir #include "componentmodule.hxx"
28cdf0e10cSrcweir #include <tools/debug.hxx>
29cdf0e10cSrcweir #include <sfx2/docfile.hxx>
30cdf0e10cSrcweir #include <svl/itemset.hxx>
31cdf0e10cSrcweir #include <svl/itempool.hxx>
32cdf0e10cSrcweir #include <vcl/msgbox.hxx>
33cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
34cdf0e10cSrcweir #ifndef _EXTENSIONS_PRELOAD_PRELOAD_HRC_
35cdf0e10cSrcweir #include "preload.hrc"
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC
38cdf0e10cSrcweir #include <svx/svxids.hrc>
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir #include <sfx2/app.hxx>
41cdf0e10cSrcweir #include <svtools/xtextedt.hxx>
42cdf0e10cSrcweir #include "osl/diagnose.h"
43cdf0e10cSrcweir #include "tools/urlobj.hxx"
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <sfx2/sfxdlg.hxx>
46cdf0e10cSrcweir #include <sfx2/tabdlg.hxx>
47cdf0e10cSrcweir #include <svx/dialogs.hrc>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir //.........................................................................
50cdf0e10cSrcweir namespace preload
51cdf0e10cSrcweir {
52cdf0e10cSrcweir //.........................................................................
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
55cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
56cdf0e10cSrcweir     using namespace ::com::sun::star::beans;
57cdf0e10cSrcweir //.........................................................................
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     struct OEMPreloadDialog_Impl
60cdf0e10cSrcweir     {
61cdf0e10cSrcweir         SfxItemSet*     pSet;
62cdf0e10cSrcweir         TabPage* pWelcomePage;
63cdf0e10cSrcweir         TabPage* pLicensePage;
64cdf0e10cSrcweir         TabPage* pUserDataPage;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir         OEMPreloadDialog_Impl(OEMPreloadDialog* pDialog);
~OEMPreloadDialog_Implpreload::OEMPreloadDialog_Impl67cdf0e10cSrcweir         ~OEMPreloadDialog_Impl()
68cdf0e10cSrcweir         {
69cdf0e10cSrcweir             delete pWelcomePage;
70cdf0e10cSrcweir             delete pLicensePage;
71cdf0e10cSrcweir             delete pUserDataPage;
72cdf0e10cSrcweir             delete pSet;
73cdf0e10cSrcweir         }
74cdf0e10cSrcweir         void WriteUserData();
75cdf0e10cSrcweir     };
76cdf0e10cSrcweir /* -----------------------------14.11.2001 11:33------------------------------
77cdf0e10cSrcweir 
78cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
OEMPreloadDialog_Impl(OEMPreloadDialog * pDialog)79cdf0e10cSrcweir     OEMPreloadDialog_Impl::OEMPreloadDialog_Impl(OEMPreloadDialog* pDialog)
80cdf0e10cSrcweir         {
81cdf0e10cSrcweir             SfxItemPool& rPool = SFX_APP()->GetPool();
82cdf0e10cSrcweir             pSet = new SfxItemSet(rPool, SID_FIELD_GRABFOCUS, SID_FIELD_GRABFOCUS);
83cdf0e10cSrcweir 			SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
84cdf0e10cSrcweir 			if ( pFact )
85cdf0e10cSrcweir 			{
86cdf0e10cSrcweir 				CreateTabPage pFunc = pFact->GetTabPageCreatorFunc(RID_SFXPAGE_GENERAL);
87cdf0e10cSrcweir             	pUserDataPage = (*pFunc)(pDialog, *pSet);
88cdf0e10cSrcweir             	((SfxTabPage*)pUserDataPage)->Reset(*pSet);
89cdf0e10cSrcweir 			}
90cdf0e10cSrcweir 			else
91cdf0e10cSrcweir 				pUserDataPage = NULL;
92cdf0e10cSrcweir             pWelcomePage = new OEMWelcomeTabPage(pDialog);
93cdf0e10cSrcweir             pLicensePage = new OEMLicenseTabPage(pDialog);
94cdf0e10cSrcweir         }
95cdf0e10cSrcweir /* -----------------------------14.11.2001 11:33------------------------------
96cdf0e10cSrcweir 
97cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
WriteUserData()98cdf0e10cSrcweir         void OEMPreloadDialog_Impl::WriteUserData()
99cdf0e10cSrcweir         {
100cdf0e10cSrcweir 			if ( pUserDataPage )
101cdf0e10cSrcweir             	((SfxTabPage*)pUserDataPage)->FillItemSet(*pSet);
102cdf0e10cSrcweir         }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir /* -----------------------------14.11.2001 11:33------------------------------
105cdf0e10cSrcweir 
106cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
107cdf0e10cSrcweir     //=====================================================================
108cdf0e10cSrcweir     //= OEMPreloadDialog
109cdf0e10cSrcweir 	//=====================================================================
110cdf0e10cSrcweir 	//---------------------------------------------------------------------
OEMPreloadDialog(Window * _pParent,const Reference<XPropertySet> &,const Reference<XMultiServiceFactory> &)111cdf0e10cSrcweir     OEMPreloadDialog::OEMPreloadDialog( Window* _pParent,
112cdf0e10cSrcweir 			const Reference< XPropertySet >& /*_rxObjectModel*/, const Reference< XMultiServiceFactory >& /*_rxORB*/ )
113cdf0e10cSrcweir         :WizardDialog(_pParent, ModuleRes(RID_DLG_OEMWIZARD)/*, _rxObjectModel, _rxORB*/)
114cdf0e10cSrcweir         ,aPrevPB(this,      ModuleRes(PB_PREV   ))
115cdf0e10cSrcweir         ,aNextPB(this,      ModuleRes(PB_NEXT   ))
116cdf0e10cSrcweir         ,aCancelPB(this,    ModuleRes(PB_CANCEL ))
117cdf0e10cSrcweir         ,aAcceptST(ModuleRes(ST_ACCEPT))
118cdf0e10cSrcweir         ,aFinishST(ModuleRes(ST_FINISH))
119cdf0e10cSrcweir         ,aLicense(ModuleRes(ST_LICENSE_AGREEMENT))
120cdf0e10cSrcweir         ,aUserData(ModuleRes(ST_INSERT_USER_DATA))
121cdf0e10cSrcweir         ,pImpl(new OEMPreloadDialog_Impl(this))
122cdf0e10cSrcweir 	{
123cdf0e10cSrcweir           FreeResource();
124cdf0e10cSrcweir           aDlgTitle = GetText();
125cdf0e10cSrcweir           aPrevPB.Enable(sal_False);
126cdf0e10cSrcweir           aNextST = aNextPB.GetText();
127cdf0e10cSrcweir           aPrevPB.SetClickHdl(LINK(this, OEMPreloadDialog, NextPrevPageHdl));
128cdf0e10cSrcweir           aNextPB.SetClickHdl(LINK(this, OEMPreloadDialog, NextPrevPageHdl));
129cdf0e10cSrcweir           AddButton( &aPrevPB, WIZARDDIALOG_BUTTON_STDOFFSET_X );
130cdf0e10cSrcweir           AddButton( &aNextPB, WIZARDDIALOG_BUTTON_STDOFFSET_X );
131cdf0e10cSrcweir           AddButton( &aCancelPB, WIZARDDIALOG_BUTTON_STDOFFSET_X );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir           SetPrevButton(&aPrevPB);
134cdf0e10cSrcweir           SetNextButton(&aNextPB);
135cdf0e10cSrcweir 
136cdf0e10cSrcweir           AddPage( pImpl->pWelcomePage );
137cdf0e10cSrcweir           AddPage( pImpl->pLicensePage );
138cdf0e10cSrcweir 		  if ( pImpl->pUserDataPage )
139cdf0e10cSrcweir           	AddPage( pImpl->pUserDataPage );
140cdf0e10cSrcweir           SetPage( OEM_WELCOME, pImpl->pWelcomePage );
141cdf0e10cSrcweir           SetPage( OEM_LICENSE, pImpl->pLicensePage );
142cdf0e10cSrcweir 		  if ( pImpl->pUserDataPage )
143cdf0e10cSrcweir           	SetPage( OEM_USERDATA, pImpl->pUserDataPage );
144cdf0e10cSrcweir           ShowPage( OEM_WELCOME );
145cdf0e10cSrcweir     }
146cdf0e10cSrcweir /* -----------------------------14.11.2001 11:33------------------------------
147cdf0e10cSrcweir 
148cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
~OEMPreloadDialog()149cdf0e10cSrcweir     OEMPreloadDialog::~OEMPreloadDialog( )
150cdf0e10cSrcweir     {
151cdf0e10cSrcweir         delete pImpl;
152cdf0e10cSrcweir     }
153cdf0e10cSrcweir /* -----------------------------14.11.2001 11:33------------------------------
154cdf0e10cSrcweir 
155cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
IMPL_LINK(OEMPreloadDialog,NextPrevPageHdl,PushButton *,pButton)156cdf0e10cSrcweir     IMPL_LINK(OEMPreloadDialog, NextPrevPageHdl, PushButton*, pButton)
157cdf0e10cSrcweir     {
158cdf0e10cSrcweir         if(pButton == &aPrevPB)
159cdf0e10cSrcweir         {
160cdf0e10cSrcweir             if(GetCurLevel())
161cdf0e10cSrcweir                 ShowPage(GetCurLevel() - 1);
162cdf0e10cSrcweir         }
163cdf0e10cSrcweir            else if(OEM_USERDATA > GetCurLevel())
164cdf0e10cSrcweir             ShowPage(GetCurLevel() + 1);
165cdf0e10cSrcweir 		else
166cdf0e10cSrcweir 		{
167cdf0e10cSrcweir             pImpl->WriteUserData();
168cdf0e10cSrcweir             Finnish(RET_OK);
169cdf0e10cSrcweir 		}
170cdf0e10cSrcweir 
171cdf0e10cSrcweir         String sTitle(aDlgTitle);
172cdf0e10cSrcweir 
173cdf0e10cSrcweir         switch(GetCurLevel())
174cdf0e10cSrcweir         {
175cdf0e10cSrcweir             case OEM_WELCOME:
176cdf0e10cSrcweir                 aNextPB.SetText(aNextST);
177cdf0e10cSrcweir                 aNextPB.Enable(sal_True);
178cdf0e10cSrcweir             break;
179cdf0e10cSrcweir             case OEM_LICENSE:
180cdf0e10cSrcweir                 sTitle += aLicense;
181cdf0e10cSrcweir                 aNextPB.SetText(aNextST);
182cdf0e10cSrcweir                 aCancelPB.GrabFocus();
183cdf0e10cSrcweir             break;
184cdf0e10cSrcweir             case OEM_USERDATA:
185cdf0e10cSrcweir                 sTitle += aUserData;
186cdf0e10cSrcweir                 aNextPB.SetText(aFinishST);
187cdf0e10cSrcweir             break;
188cdf0e10cSrcweir         }
189cdf0e10cSrcweir         SetText(sTitle);
190cdf0e10cSrcweir         aPrevPB.Enable(GetCurLevel() != OEM_WELCOME);
191cdf0e10cSrcweir         return 0;
192cdf0e10cSrcweir     }
193cdf0e10cSrcweir /* -----------------------------14.11.2001 11:33------------------------------
194cdf0e10cSrcweir 
195cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
LoadFromLocalFile(const String & rFileName,String & rContent)196cdf0e10cSrcweir     sal_Bool OEMPreloadDialog::LoadFromLocalFile(const String& rFileName, String& rContent)
197cdf0e10cSrcweir     {
198cdf0e10cSrcweir         SvtPathOptions aPathOpt;
199cdf0e10cSrcweir         String sFileName = aPathOpt.GetUserConfigPath();//GetModulePath();
200cdf0e10cSrcweir         INetURLObject aURLObject(sFileName);
201cdf0e10cSrcweir         OSL_ASSERT(aURLObject.getSegmentCount() >= 2);
202cdf0e10cSrcweir         aURLObject.removeSegment(); //remove '/config'
203cdf0e10cSrcweir         aURLObject.removeSegment(); //remove '/user'
204cdf0e10cSrcweir         sFileName = aURLObject.GetMainURL(INetURLObject::DECODE_TO_IURI);
205cdf0e10cSrcweir         sFileName += rFileName;
206cdf0e10cSrcweir 
207cdf0e10cSrcweir         SfxMedium aMedium( sFileName,STREAM_READ, sal_True );
208cdf0e10cSrcweir         SvStream* pInStream = aMedium.GetInStream();
209cdf0e10cSrcweir         if( !pInStream )
210cdf0e10cSrcweir             return sal_False;
211cdf0e10cSrcweir 
212cdf0e10cSrcweir         pInStream->ReadCString( rContent, RTL_TEXTENCODING_UTF8 );
213cdf0e10cSrcweir 
214cdf0e10cSrcweir         xub_StrLen nPos;
215cdf0e10cSrcweir         while ( ( nPos = rContent.Search( 12 )) != STRING_NOTFOUND )
216cdf0e10cSrcweir             rContent.Erase( nPos, 1 );
217cdf0e10cSrcweir         return sal_True;
218cdf0e10cSrcweir     }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 
SetCancelString(const String & rText)221cdf0e10cSrcweir     void OEMPreloadDialog::SetCancelString( const String& rText )
222cdf0e10cSrcweir     {
223cdf0e10cSrcweir         aCancelPB.SetText(rText);
224cdf0e10cSrcweir     }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir /* -----------------------------13.11.2001 12:29------------------------------
227cdf0e10cSrcweir 
228cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
OEMWelcomeTabPage(Window * pParent)229cdf0e10cSrcweir     OEMWelcomeTabPage::OEMWelcomeTabPage(Window* pParent) :
230cdf0e10cSrcweir         TabPage(pParent, ModuleRes(RID_TP_WELCOME)),
231cdf0e10cSrcweir         aInfoFT(this, ModuleRes(FT_INFO))
232cdf0e10cSrcweir     {
233cdf0e10cSrcweir         FreeResource();
234cdf0e10cSrcweir     }
235cdf0e10cSrcweir /* -----------------------------13.11.2001 12:30------------------------------
236cdf0e10cSrcweir 
237cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
~OEMWelcomeTabPage()238cdf0e10cSrcweir     OEMWelcomeTabPage::~OEMWelcomeTabPage()
239cdf0e10cSrcweir     {
240cdf0e10cSrcweir     }
241cdf0e10cSrcweir /* -----------------------------13.11.2001 12:29------------------------------
242cdf0e10cSrcweir 
243cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
OEMLicenseTabPage(OEMPreloadDialog * pParent)244cdf0e10cSrcweir     OEMLicenseTabPage::OEMLicenseTabPage(OEMPreloadDialog* pParent) :
245cdf0e10cSrcweir         TabPage(pParent, ModuleRes(RID_TP_LICENSE)),
246cdf0e10cSrcweir         aLicenseML(this, ModuleRes(ML_LICENSE)),
247cdf0e10cSrcweir         aInfo1FT(this, ModuleRes(FT_INFO1)),
248cdf0e10cSrcweir         aInfo2FT(this, ModuleRes(FT_INFO2)),
249cdf0e10cSrcweir         aInfo3FT(this, ModuleRes(FT_INFO3)),
250cdf0e10cSrcweir         aInfo2_1FT(this, ModuleRes(FT_INFO2_1)),
251cdf0e10cSrcweir         aInfo3_1FT(this, ModuleRes(FT_INFO3_1)),
252cdf0e10cSrcweir         aCBAccept(this, ModuleRes(CB_ACCEPT)),
253cdf0e10cSrcweir         aPBPageDown(this, ModuleRes(PB_PAGEDOWN)),
254cdf0e10cSrcweir         aArrow(this, ModuleRes(IMG_ARROW)),
255cdf0e10cSrcweir         aStrAccept( ModuleRes(LICENCE_ACCEPT) ),
256cdf0e10cSrcweir 	    aStrNotAccept( ModuleRes(LICENCE_NOTACCEPT) ),
257cdf0e10cSrcweir         bEndReached(sal_False),
258cdf0e10cSrcweir         pPreloadDialog(pParent)
259cdf0e10cSrcweir     {
260cdf0e10cSrcweir         FreeResource();
261cdf0e10cSrcweir 
262cdf0e10cSrcweir         aLicenseML.SetEndReachedHdl( LINK(this, OEMLicenseTabPage, EndReachedHdl) );
263cdf0e10cSrcweir         aLicenseML.SetScrolledHdl( LINK(this, OEMLicenseTabPage, ScrolledHdl) );
264cdf0e10cSrcweir 
265cdf0e10cSrcweir         aPBPageDown.SetClickHdl( LINK(this, OEMLicenseTabPage, PageDownHdl) );
266cdf0e10cSrcweir         aCBAccept.SetClickHdl( LINK(this, OEMLicenseTabPage, AcceptHdl) );
267cdf0e10cSrcweir 
268cdf0e10cSrcweir         // We want a automatic repeating page down button
269cdf0e10cSrcweir         WinBits aStyle = aPBPageDown.GetStyle();
270cdf0e10cSrcweir         aStyle |= WB_REPEAT;
271cdf0e10cSrcweir         aPBPageDown.SetStyle( aStyle );
272cdf0e10cSrcweir 
273cdf0e10cSrcweir         aOldCancelText = pPreloadDialog->GetCancelString();
274cdf0e10cSrcweir         pPreloadDialog->SetCancelString( aStrNotAccept );
275cdf0e10cSrcweir 
276cdf0e10cSrcweir         String aText = aInfo2FT.GetText();
277cdf0e10cSrcweir         aText.SearchAndReplaceAll( UniString::CreateFromAscii("%PAGEDOWN"), aPBPageDown.GetText() );
278cdf0e10cSrcweir         aInfo2FT.SetText( aText );
279cdf0e10cSrcweir     }
280cdf0e10cSrcweir /* -----------------------------13.11.2001 12:30------------------------------
281cdf0e10cSrcweir 
282cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
~OEMLicenseTabPage()283cdf0e10cSrcweir     OEMLicenseTabPage::~OEMLicenseTabPage()
284cdf0e10cSrcweir     {
285cdf0e10cSrcweir     }
286cdf0e10cSrcweir /* ---------------------------14.11.2001 11:24----------------------------
287cdf0e10cSrcweir 
288cdf0e10cSrcweir     -----------------------------------------------------------------------*/
ActivatePage()289cdf0e10cSrcweir     void OEMLicenseTabPage::ActivatePage()
290cdf0e10cSrcweir     {
291cdf0e10cSrcweir         if(!aLicenseML.GetText().Len())
292cdf0e10cSrcweir         {
293cdf0e10cSrcweir         aLicenseML.SetLeftMargin( 5 );
294cdf0e10cSrcweir         String sLicense;
295cdf0e10cSrcweir #ifdef UNX
296cdf0e10cSrcweir         OEMPreloadDialog::LoadFromLocalFile(String::CreateFromAscii("LICENSE"), sLicense);
297cdf0e10cSrcweir #else
298cdf0e10cSrcweir         OEMPreloadDialog::LoadFromLocalFile(String::CreateFromAscii("license.txt"), sLicense);
299cdf0e10cSrcweir #endif
300cdf0e10cSrcweir         aLicenseML.SetText( sLicense );
301cdf0e10cSrcweir         }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir         EnableControls();
304cdf0e10cSrcweir     }
305cdf0e10cSrcweir 
306cdf0e10cSrcweir     //------------------------------------------------------------------------
IMPL_LINK(OEMLicenseTabPage,AcceptHdl,CheckBox *,EMPTYARG)307cdf0e10cSrcweir     IMPL_LINK( OEMLicenseTabPage, AcceptHdl, CheckBox *, EMPTYARG )
308cdf0e10cSrcweir     {
309cdf0e10cSrcweir         EnableControls();
310cdf0e10cSrcweir         return 0;
311cdf0e10cSrcweir     }
312cdf0e10cSrcweir 
313cdf0e10cSrcweir     //------------------------------------------------------------------------
IMPL_LINK(OEMLicenseTabPage,PageDownHdl,PushButton *,EMPTYARG)314cdf0e10cSrcweir     IMPL_LINK( OEMLicenseTabPage, PageDownHdl, PushButton *, EMPTYARG )
315cdf0e10cSrcweir     {
316cdf0e10cSrcweir         aLicenseML.ScrollDown( SCROLL_PAGEDOWN );
317cdf0e10cSrcweir         return 0;
318cdf0e10cSrcweir     }
319cdf0e10cSrcweir 
320cdf0e10cSrcweir     //------------------------------------------------------------------------
IMPL_LINK(OEMLicenseTabPage,EndReachedHdl,LicenceView *,EMPTYARG)321cdf0e10cSrcweir     IMPL_LINK( OEMLicenseTabPage, EndReachedHdl, LicenceView *, EMPTYARG )
322cdf0e10cSrcweir     {
323cdf0e10cSrcweir         bEndReached = sal_True;
324cdf0e10cSrcweir 
325cdf0e10cSrcweir         EnableControls();
326cdf0e10cSrcweir         aCBAccept.GrabFocus();
327cdf0e10cSrcweir 
328cdf0e10cSrcweir         return 0;
329cdf0e10cSrcweir     }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     //------------------------------------------------------------------------
IMPL_LINK(OEMLicenseTabPage,ScrolledHdl,LicenceView *,EMPTYARG)332cdf0e10cSrcweir     IMPL_LINK( OEMLicenseTabPage, ScrolledHdl, LicenceView *, EMPTYARG )
333cdf0e10cSrcweir     {
334cdf0e10cSrcweir         EnableControls();
335cdf0e10cSrcweir 
336cdf0e10cSrcweir         return 0;
337cdf0e10cSrcweir     }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir     //------------------------------------------------------------------------
EnableControls()340cdf0e10cSrcweir     void OEMLicenseTabPage::EnableControls()
341cdf0e10cSrcweir     {
342cdf0e10cSrcweir         if( !bEndReached &&
343cdf0e10cSrcweir             ( aLicenseML.IsEndReached() || !aLicenseML.GetText().Len() ) )
344cdf0e10cSrcweir             bEndReached = sal_True;
345cdf0e10cSrcweir 
346cdf0e10cSrcweir         if ( bEndReached )
347cdf0e10cSrcweir         {
348cdf0e10cSrcweir             Point aPos( 0, aInfo3_1FT.GetPosPixel().Y() );
349cdf0e10cSrcweir             aArrow.SetPosPixel( aPos );
350cdf0e10cSrcweir             aCBAccept.Enable();
351cdf0e10cSrcweir         }
352cdf0e10cSrcweir         else
353cdf0e10cSrcweir         {
354cdf0e10cSrcweir             Point aPos( 0, aInfo2_1FT.GetPosPixel().Y() );
355cdf0e10cSrcweir             aArrow.SetPosPixel( aPos );
356cdf0e10cSrcweir             aCBAccept.Disable();
357cdf0e10cSrcweir         }
358cdf0e10cSrcweir 
359cdf0e10cSrcweir         if ( aLicenseML.IsEndReached() )
360cdf0e10cSrcweir             aPBPageDown.Disable();
361cdf0e10cSrcweir         else
362cdf0e10cSrcweir             aPBPageDown.Enable();
363cdf0e10cSrcweir 
364cdf0e10cSrcweir         if ( aCBAccept.IsChecked() )
365cdf0e10cSrcweir         {
366cdf0e10cSrcweir             PushButton *pNext = pPreloadDialog->GetNextButton();
367cdf0e10cSrcweir             if ( ! pNext->IsEnabled() )
368cdf0e10cSrcweir             {
369cdf0e10cSrcweir                 pPreloadDialog->SetCancelString( aOldCancelText );
370cdf0e10cSrcweir                 pNext->Enable(sal_True);
371cdf0e10cSrcweir             }
372cdf0e10cSrcweir         }
373cdf0e10cSrcweir         else
374cdf0e10cSrcweir         {
375cdf0e10cSrcweir             PushButton *pNext = pPreloadDialog->GetNextButton();
376cdf0e10cSrcweir             if ( pNext->IsEnabled() )
377cdf0e10cSrcweir             {
378cdf0e10cSrcweir                 pPreloadDialog->SetCancelString( aStrNotAccept );
379cdf0e10cSrcweir                 pNext->Enable(sal_False);
380cdf0e10cSrcweir             }
381cdf0e10cSrcweir         }
382cdf0e10cSrcweir     }
383cdf0e10cSrcweir 
384cdf0e10cSrcweir     //------------------------------------------------------------------------
385cdf0e10cSrcweir     //------------------------------------------------------------------------
386cdf0e10cSrcweir     //------------------------------------------------------------------------
LicenceView(Window * pParent,const ResId & rResId)387cdf0e10cSrcweir     LicenceView::LicenceView( Window* pParent, const ResId& rResId )
388cdf0e10cSrcweir         : MultiLineEdit( pParent, rResId )
389cdf0e10cSrcweir     {
390cdf0e10cSrcweir         SetLeftMargin( 5 );
391cdf0e10cSrcweir 
392cdf0e10cSrcweir         mbEndReached = IsEndReached();
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 	    StartListening( *GetTextEngine() );
395cdf0e10cSrcweir     }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir     //------------------------------------------------------------------------
~LicenceView()398cdf0e10cSrcweir     LicenceView::~LicenceView()
399cdf0e10cSrcweir     {
400cdf0e10cSrcweir         maEndReachedHdl = Link();
401cdf0e10cSrcweir         maScrolledHdl   = Link();
402cdf0e10cSrcweir 
403cdf0e10cSrcweir         EndListeningAll();
404cdf0e10cSrcweir     }
405cdf0e10cSrcweir 
406cdf0e10cSrcweir     //------------------------------------------------------------------------
ScrollDown(ScrollType eScroll)407cdf0e10cSrcweir     void LicenceView::ScrollDown( ScrollType eScroll )
408cdf0e10cSrcweir     {
409cdf0e10cSrcweir         ScrollBar*  pScroll = GetVScrollBar();
410cdf0e10cSrcweir 
411cdf0e10cSrcweir         if ( pScroll )
412cdf0e10cSrcweir             pScroll->DoScrollAction( eScroll );
413cdf0e10cSrcweir     }
414cdf0e10cSrcweir 
415cdf0e10cSrcweir     //------------------------------------------------------------------------
IsEndReached() const416cdf0e10cSrcweir     sal_Bool LicenceView::IsEndReached() const
417cdf0e10cSrcweir     {
418cdf0e10cSrcweir         sal_Bool bEndReached;
419cdf0e10cSrcweir 
420cdf0e10cSrcweir         ExtTextView*    pView = GetTextView();
421cdf0e10cSrcweir         ExtTextEngine*  pEdit = GetTextEngine();
422cdf0e10cSrcweir         sal_uLong           nHeight = pEdit->GetTextHeight();
423cdf0e10cSrcweir         Size            aOutSize = pView->GetWindow()->GetOutputSizePixel();
424cdf0e10cSrcweir         Point           aBottom( 0, aOutSize.Height() );
425cdf0e10cSrcweir 
426cdf0e10cSrcweir         if ( (sal_uLong) pView->GetDocPos( aBottom ).Y() >= nHeight - 1 )
427cdf0e10cSrcweir             bEndReached = sal_True;
428cdf0e10cSrcweir         else
429cdf0e10cSrcweir             bEndReached = sal_False;
430cdf0e10cSrcweir 
431cdf0e10cSrcweir         return bEndReached;
432cdf0e10cSrcweir     }
433cdf0e10cSrcweir 
434cdf0e10cSrcweir     //------------------------------------------------------------------------
Notify(SfxBroadcaster &,const SfxHint & rHint)435cdf0e10cSrcweir     void LicenceView::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
436cdf0e10cSrcweir     {
437cdf0e10cSrcweir         if ( rHint.IsA( TYPE(TextHint) ) )
438cdf0e10cSrcweir         {
439cdf0e10cSrcweir             sal_Bool    bLastVal = EndReached();
440cdf0e10cSrcweir             sal_uLong   nId = ((const TextHint&)rHint).GetId();
441cdf0e10cSrcweir 
442cdf0e10cSrcweir             if ( nId == TEXT_HINT_PARAINSERTED )
443cdf0e10cSrcweir             {
444cdf0e10cSrcweir                 if ( bLastVal )
445cdf0e10cSrcweir                     mbEndReached = IsEndReached();
446cdf0e10cSrcweir             }
447cdf0e10cSrcweir             else if ( nId == TEXT_HINT_VIEWSCROLLED )
448cdf0e10cSrcweir             {
449cdf0e10cSrcweir                 if ( ! mbEndReached )
450cdf0e10cSrcweir                     mbEndReached = IsEndReached();
451cdf0e10cSrcweir                 maScrolledHdl.Call( this );
452cdf0e10cSrcweir             }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir             if ( EndReached() && !bLastVal )
455cdf0e10cSrcweir             {
456cdf0e10cSrcweir                 maEndReachedHdl.Call( this );
457cdf0e10cSrcweir             }
458cdf0e10cSrcweir         }
459cdf0e10cSrcweir     }
460cdf0e10cSrcweir 
461cdf0e10cSrcweir     //------------------------------------------------------------------------
462cdf0e10cSrcweir 
463cdf0e10cSrcweir //.........................................................................
464cdf0e10cSrcweir }   // namespace preload
465cdf0e10cSrcweir //.........................................................................
466cdf0e10cSrcweir 
467cdf0e10cSrcweir 
468