about.cxx (23c0a6f8) about.cxx (ca04f111)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 10 unchanged lines hidden (view full) ---

19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_cui.hxx"
26
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 10 unchanged lines hidden (view full) ---

19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_cui.hxx"
26
27// include ---------------------------------------------------------------
28
29#include <vcl/svapp.hxx>
30#include <vcl/msgbox.hxx>
31#include <tools/stream.hxx>
32#include <tools/urlobj.hxx>
33#include <rtl/bootstrap.hxx>
34#include <unotools/configmgr.hxx>
35#include <unotools/bootstrap.hxx>
36#include <com/sun/star/uno/Any.h>
27#include <com/sun/star/uno/Any.h>
37#include <vcl/graph.hxx>
38#include <svtools/filter.hxx>
39#include <sfx2/sfxuno.hxx>
40#include "about.hxx"
41#include <sfx2/sfxdefs.hxx>
28#include <comphelper/processfactory.hxx>
29#include <dialmgr.hxx>
30#include <osl/file.hxx>
31#include <rtl/bootstrap.hxx>
42#include <sfx2/app.hxx>
43#include <sfx2/sfxcommands.h>
32#include <sfx2/app.hxx>
33#include <sfx2/sfxcommands.h>
44#include "about.hrc"
45#include <dialmgr.hxx>
34#include <sfx2/sfxdefs.hxx>
35#include <sfx2/sfxuno.hxx>
36#include <svtools/filter.hxx>
46#include <svtools/svtools.hrc>
37#include <svtools/svtools.hrc>
38#include <tools/stream.hxx>
39#include <tools/urlobj.hxx>
40#include <unotools/bootstrap.hxx>
41#include <unotools/configmgr.hxx>
42#include <vcl/graph.hxx>
43#include <vcl/msgbox.hxx>
44#include <vcl/svapp.hxx>
45#include <vcl/tabctrl.hxx>
46#include <vcl/tabdlg.hxx>
47#include <vcl/tabpage.hxx>
47
48
48#include <comphelper/processfactory.hxx>
49#include <com/sun/star/system/XSystemShellExecute.hpp>
50#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
51
49#include <com/sun/star/system/XSystemShellExecute.hpp>
50#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
51
52// defines ---------------------------------------------------------------
52#include "about.hxx"
53#include "about.hrc"
53
54#define _STRINGIFY(x) #x
55#define STRINGIFY(x) _STRINGIFY(x)
56
54
55#define _STRINGIFY(x) #x
56#define STRINGIFY(x) _STRINGIFY(x)
57
57// -----------------------------------------------------------------------
58
59static void layoutFixedText( FixedText &rControl, const Point& aPos, Size &aSize, const long nTextWidth )
58namespace
60{
59{
61 aSize = rControl.GetSizePixel();
62 // change the width
63 aSize.Width() = nTextWidth;
64 // set Position and Size, to calculate the minimum size
65 // this will update the Height
66 rControl.SetPosSizePixel( aPos, aSize );
67 aSize = rControl.CalcMinimumSize();
68 // update the size with the right Height
69 rControl.SetSizePixel( aSize );
70}
71
60
72static void layoutEdit( Edit &rControl, const Point& aPos, Size &aSize, const long nTextWidth )
73{
74 aSize = rControl.GetSizePixel();
75 // change the width
76 aSize.Width() = nTextWidth;
77 // set Position and Size, to calculate the minimum size
78 // this will update the Height
79 rControl.SetPosSizePixel( aPos, aSize );
80 aSize = rControl.CalcMinimumSize();
81 // update the size with the right Height
82 rControl.SetSizePixel( aSize );
61 static void lcl_layoutFixedText( FixedText &rControl,
62 const Point& aPos,
63 Size &aSize,
64 const long nTextWidth )
65 {
66 aSize = rControl.GetSizePixel();
67 // change the width
68 aSize.Width() = nTextWidth;
69 // set Position and Size, to calculate the minimum size
70 // this will update the Height
71 rControl.SetPosSizePixel( aPos, aSize );
72 aSize = rControl.CalcMinimumSize();
73 // update the size with the right Height
74 rControl.SetSizePixel( aSize );
75 }
76
77 static void lcl_layoutEdit( Edit &rControl,
78 const Point& aPos,
79 Size &aSize,
80 const long nTextWidth )
81 {
82 aSize = rControl.GetSizePixel();
83 // change the width
84 aSize.Width() = nTextWidth;
85 // set Position and Size, to calculate the minimum size
86 // this will update the Height
87 rControl.SetPosSizePixel( aPos, aSize );
88 aSize = rControl.CalcMinimumSize();
89 // update the size with the right Height
90 rControl.SetSizePixel( aSize );
91 }
92
93 static void lcl_readTxtFile( const rtl::OUString &rFile, rtl::OUString &sText )
94 {
95 rtl::OUString sFile( rFile );
96 rtl::Bootstrap::expandMacros( sFile );
97 osl::File aFile(sFile);
98 if ( aFile.open(OpenFlag_Read) == osl::FileBase::E_None )
99 {
100 osl::DirectoryItem aItem;
101 osl::DirectoryItem::get(sFile, aItem);
102
103 osl::FileStatus aStatus(FileStatusMask_FileSize);
104 aItem.getFileStatus(aStatus);
105
106 sal_uInt64 nBytesRead = 0;
107 sal_uInt64 nPosition = 0;
108 sal_uInt32 nBytes = (sal_uInt32)aStatus.getFileSize();
109
110 sal_Char *pBuffer = new sal_Char[nBytes];
111
112 while ( aFile.read( pBuffer + nPosition,
113 nBytes-nPosition,
114 nBytesRead ) == osl::FileBase::E_None
115 && nPosition + nBytesRead < nBytes)
116 {
117 nPosition += nBytesRead;
118 }
119
120 OSL_ENSURE( nBytes < STRING_MAXLEN, "Text file has too much bytes!" );
121 if ( nBytes > STRING_MAXLEN )
122 nBytes = STRING_MAXLEN - 1;
123
124 sText = rtl::OUString( pBuffer,
125 nBytes,
126 RTL_TEXTENCODING_UTF8,
127 OSTRING_TO_OUSTRING_CVTFLAGS
128 | RTL_TEXTTOUNICODE_FLAGS_GLOBAL_SIGNATURE);
129 delete[] pBuffer;
130 }
131 }
132
133 class ReadmeDialog;
134
135 class ReadmeTabPage : public TabPage
136 {
137 private:
138 MultiLineEdit maText;
139 String msText;
140
141 public:
142 ReadmeTabPage(Window *pParent, const String &sText);
143 ~ReadmeTabPage();
144
145 void Adjust(const Size &aSz, const Size &a6Size);
146 };
147
148 ReadmeTabPage::ReadmeTabPage(Window *pParent, const String &sText)
149 : TabPage(pParent, CUI_RES( RID_CUI_README_TBPAGE))
150 ,maText( this, CUI_RES( RID_CUI_README_TBPAGE_EDIT ))
151 ,msText( sText )
152 {
153 FreeResource();
154
155 maText.SetText(msText);
156 maText.Show();
157 }
158
159 ReadmeTabPage::~ReadmeTabPage()
160 {
161 }
162
163 void ReadmeTabPage::Adjust(const Size &aSz, const Size &a6Size)
164 {
165 long nDlgMargin = a6Size.Width() * 2;
166 long nCtrlMargin = a6Size.Height() * 2;
167 maText.SetPosPixel( Point(a6Size.Width(), a6Size.Height()) );
168 maText.SetSizePixel( Size(aSz.Width() - nDlgMargin, aSz.Height() - nCtrlMargin) );
169 }
170
171 class ReadmeDialog : public ModalDialog
172 {
173 private:
174 TabControl maTabCtrl;
175 OKButton maBtnOK;
176
177 ReadmeTabPage *maReadmeTabPage;
178 ReadmeTabPage *maLicenseTabPage;
179 ReadmeTabPage *maNoticeTabPage;
180
181 DECL_LINK( ActivatePageHdl, TabControl * );
182 DECL_LINK( DeactivatePageHdl, TabControl * );
183
184 public:
185 ReadmeDialog( Window* );
186 ~ReadmeDialog();
187 };
188
189 ReadmeDialog::ReadmeDialog( Window * pParent )
190 : ModalDialog( pParent, CUI_RES( RID_CUI_README_DLG ) )
191 , maTabCtrl( this, CUI_RES(RID_CUI_README_TBCTL) )
192 , maBtnOK( this, CUI_RES(RID_CUI_README_OKBTN) )
193 , maReadmeTabPage(0)
194 , maLicenseTabPage(0)
195 , maNoticeTabPage(0)
196 {
197 FreeResource();
198
199 maTabCtrl.Show();
200
201 const rtl::OUString sReadme( RTL_CONSTASCII_USTRINGPARAM( "$BRAND_BASE_DIR/README" ) );
202 const rtl::OUString sLicense( RTL_CONSTASCII_USTRINGPARAM( "$BRAND_BASE_DIR/program/LICENSE" ) );
203 const rtl::OUString sNotice( RTL_CONSTASCII_USTRINGPARAM( "$BRAND_BASE_DIR/program/NOTICE" ) );
204
205 rtl::OUString sReadmeTxt, sLicenseTxt, sNoticeTxt;
206 lcl_readTxtFile( sReadme, sReadmeTxt );
207 lcl_readTxtFile( sLicense, sLicenseTxt );
208 lcl_readTxtFile( sNotice, sNoticeTxt );
209
210 maReadmeTabPage = new ReadmeTabPage( &maTabCtrl, sReadmeTxt );
211 maLicenseTabPage = new ReadmeTabPage( &maTabCtrl, sLicenseTxt );
212 maNoticeTabPage = new ReadmeTabPage( &maTabCtrl, sNoticeTxt );
213
214 maTabCtrl.SetTabPage( RID_CUI_READMEPAGE, maReadmeTabPage );
215 maTabCtrl.SetTabPage( RID_CUI_LICENSEPAGE, maLicenseTabPage );
216 maTabCtrl.SetTabPage( RID_CUI_NOTICEPAGE, maNoticeTabPage );
217
218 maTabCtrl.SelectTabPage( RID_CUI_READMEPAGE );
219
220 Size aTpSz = maReadmeTabPage->GetOutputSizePixel();
221 Size a6Size = maReadmeTabPage->LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
222
223 maReadmeTabPage->Adjust( aTpSz, a6Size );
224 maLicenseTabPage->Adjust( aTpSz, a6Size );
225 maNoticeTabPage->Adjust( aTpSz, a6Size );
226
227 Size aDlgSize = GetOutputSizePixel();
228 Size aOkBtnSz = maBtnOK.GetSizePixel();
229 Point aOKPnt( aDlgSize.Width() / 2 - aOkBtnSz.Width() / 2 , maBtnOK.GetPosPixel().Y() );
230 maBtnOK.SetPosPixel( aOKPnt );
231 }
232
233 ReadmeDialog::~ReadmeDialog()
234 {
235 delete maReadmeTabPage;
236 delete maLicenseTabPage;
237 delete maNoticeTabPage;
238 }
83}
84
85// -----------------------------------------------------------------------
86
87AboutDialog::AboutDialog( Window* pParent, const ResId& rId ) :
88 SfxModalDialog( pParent, rId ),
89 maOKButton( this, ResId( RID_CUI_ABOUT_BTN_OK, *rId.GetResMgr() ) ),
239}
240
241// -----------------------------------------------------------------------
242
243AboutDialog::AboutDialog( Window* pParent, const ResId& rId ) :
244 SfxModalDialog( pParent, rId ),
245 maOKButton( this, ResId( RID_CUI_ABOUT_BTN_OK, *rId.GetResMgr() ) ),
246 maReadmeButton( this, ResId( RID_CUI_ABOUT_BTN_README, *rId.GetResMgr() ) ),
90 maVersionText( this, ResId( RID_CUI_ABOUT_FTXT_VERSION, *rId.GetResMgr() ) ),
91 maBuildInfoEdit( this, ResId( RID_CUI_ABOUT_FTXT_BUILDDATA, *rId.GetResMgr() ) ),
92 maCopyrightEdit( this, ResId( RID_CUI_ABOUT_FTXT_COPYRIGHT, *rId.GetResMgr() ) ),
93 maCreditsLink( this, ResId( RID_CUI_ABOUT_FTXT_WELCOME_LINK, *rId.GetResMgr() ) ),
247 maVersionText( this, ResId( RID_CUI_ABOUT_FTXT_VERSION, *rId.GetResMgr() ) ),
248 maBuildInfoEdit( this, ResId( RID_CUI_ABOUT_FTXT_BUILDDATA, *rId.GetResMgr() ) ),
249 maCopyrightEdit( this, ResId( RID_CUI_ABOUT_FTXT_COPYRIGHT, *rId.GetResMgr() ) ),
250 maCreditsLink( this, ResId( RID_CUI_ABOUT_FTXT_WELCOME_LINK, *rId.GetResMgr() ) ),
251 maMainLogo( ResId( RID_CUI_ABOUT_LOGO, *rId.GetResMgr() ) ),
94 maCopyrightTextStr( ResId( RID_CUI_ABOUT_STR_COPYRIGHT, *rId.GetResMgr() ) )
95{
96 // load image from module path
97 maAppLogo = SfxApplication::GetApplicationLogo();
98
99 InitControls();
100
101 // set links
252 maCopyrightTextStr( ResId( RID_CUI_ABOUT_STR_COPYRIGHT, *rId.GetResMgr() ) )
253{
254 // load image from module path
255 maAppLogo = SfxApplication::GetApplicationLogo();
256
257 InitControls();
258
259 // set links
260 maReadmeButton.SetClickHdl( LINK( this, AboutDialog, ShowReadme_Impl ) );
102 maCreditsLink.SetClickHdl( LINK( this, AboutDialog, OpenLinkHdl_Impl ) );
103
104 FreeResource();
105
106 SetHelpId( CMD_SID_ABOUT );
107}
108
109// -----------------------------------------------------------------------

--- 72 unchanged lines hidden (view full) ---

182 aNewFont.SetSize( aSmaller );
183 maBuildInfoEdit.SetControlFont( aNewFont );
184}
185
186// -----------------------------------------------------------------------
187
188void AboutDialog::LayoutControls( Size& aDlgSize )
189{
261 maCreditsLink.SetClickHdl( LINK( this, AboutDialog, OpenLinkHdl_Impl ) );
262
263 FreeResource();
264
265 SetHelpId( CMD_SID_ABOUT );
266}
267
268// -----------------------------------------------------------------------

--- 72 unchanged lines hidden (view full) ---

341 aNewFont.SetSize( aSmaller );
342 maBuildInfoEdit.SetControlFont( aNewFont );
343}
344
345// -----------------------------------------------------------------------
346
347void AboutDialog::LayoutControls( Size& aDlgSize )
348{
349 Size aMainLogoSz = maMainLogo.GetSizePixel();
190 Size aAppLogoSiz = maAppLogo.GetSizePixel();
191
350 Size aAppLogoSiz = maAppLogo.GetSizePixel();
351
352 long nLeftOffset = aMainLogoSz.Width();
353
192 aDlgSize = GetOutputSizePixel();
354 aDlgSize = GetOutputSizePixel();
193 aDlgSize.Width() = aAppLogoSiz.Width();
194
195 Size a6Size = maVersionText.LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
355
356 Size a6Size = maVersionText.LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
196 long nY = aAppLogoSiz.Height() + ( a6Size.Height() * 2 );
197 long nDlgMargin = a6Size.Width() * 2;
198 long nCtrlMargin = a6Size.Height() * 2;
357 long nDlgMargin = a6Size.Width() * 2;
358 long nCtrlMargin = a6Size.Height() * 2;
199 long nTextWidth = aDlgSize.Width() - ( nDlgMargin * 2 );
359 long nTextWidth = aAppLogoSiz.Width() - nDlgMargin;
360 long nY = aAppLogoSiz.Height() + a6Size.Height();
200
361
201 Point aPos( nDlgMargin, nY );
362 aDlgSize.Width() = nLeftOffset + a6Size.Width() + aAppLogoSiz.Width();
363
364 Point aPos( nLeftOffset + a6Size.Width(), nY );
202 Size aSize;
203 // layout fixed text control
365 Size aSize;
366 // layout fixed text control
204 layoutFixedText( maVersionText, aPos, aSize, nTextWidth );
205 // set the next control closer
206 nY += aSize.Height() + (nCtrlMargin / 2);
367 lcl_layoutFixedText( maVersionText, aPos, aSize, nTextWidth );
368 nY += aSize.Height() + a6Size.Height();
207
208 // Multiline edit with Build info
209 aPos.Y() = nY;
369
370 // Multiline edit with Build info
371 aPos.Y() = nY;
210 layoutEdit( maBuildInfoEdit, aPos, aSize, nTextWidth );
211 nY += aSize.Height() + nCtrlMargin;
372 lcl_layoutEdit( maBuildInfoEdit, aPos, aSize, nTextWidth );
373 nY += aSize.Height() + a6Size.Height();
212
213 // Multiline edit with Copyright-Text
214 aPos.Y() = nY;
374
375 // Multiline edit with Copyright-Text
376 aPos.Y() = nY;
215 layoutEdit( maCopyrightEdit, aPos, aSize, nTextWidth );
216 // set the next control closer
217 nY += aSize.Height() + (nCtrlMargin/2);
377 lcl_layoutEdit( maCopyrightEdit, aPos, aSize, nTextWidth );
378 nY += aSize.Height() + a6Size.Height();
218
219 // Hyperlink
220 aPos.Y() = nY;
379
380 // Hyperlink
381 aPos.Y() = nY;
221 layoutFixedText( maCreditsLink, aPos, aSize, nTextWidth );
222 nY += aSize.Height() + nCtrlMargin;
382 lcl_layoutFixedText( maCreditsLink, aPos, aSize, nTextWidth );
383 nY += aSize.Height();
223
384
385 nY = std::max( nY, aMainLogoSz.Height() );
386 nY += nCtrlMargin;
387
388 // logos position
389 maMainLogoPos = Point( 0, nY / 2 - aMainLogoSz.Height() / 2 );
390 maAppLogoPos = Point( nLeftOffset + a6Size.Width(), 0 );
391
224 // OK-Button-Position (at the bottom and centered)
225 Size aOKSiz = maOKButton.GetSizePixel();
392 // OK-Button-Position (at the bottom and centered)
393 Size aOKSiz = maOKButton.GetSizePixel();
226 Point aOKPnt( ( aDlgSize.Width() - aOKSiz.Width() ) / 2, nY );
394 Point aOKPnt( ( aDlgSize.Width() - aOKSiz.Width() ) - a6Size.Width(), nY );
227 maOKButton.SetPosPixel( aOKPnt );
228
395 maOKButton.SetPosPixel( aOKPnt );
396
229 aDlgSize.Height() = aOKPnt.Y() + aOKSiz.Height() + nCtrlMargin;
397 maReadmeButton.SetPosPixel( Point(a6Size.Width(), nY) );
398
399 aDlgSize.Height() = aOKPnt.Y() + aOKSiz.Height() + a6Size.Width();
230}
231
232// -----------------------------------------------------------------------
233
234const rtl::OUString AboutDialog::GetBuildId() const
235{
236 rtl::OUString sDefault;
237

--- 59 unchanged lines hidden (view full) ---

297 return( sal_False );
298}
299
300// -----------------------------------------------------------------------
301
302void AboutDialog::Paint( const Rectangle& rRect )
303{
304 SetClipRegion( rRect );
400}
401
402// -----------------------------------------------------------------------
403
404const rtl::OUString AboutDialog::GetBuildId() const
405{
406 rtl::OUString sDefault;
407

--- 59 unchanged lines hidden (view full) ---

467 return( sal_False );
468}
469
470// -----------------------------------------------------------------------
471
472void AboutDialog::Paint( const Rectangle& rRect )
473{
474 SetClipRegion( rRect );
305 Point aPos( 0, 0 );
306 DrawImage( aPos, maAppLogo );
475 DrawImage( maMainLogoPos, maMainLogo );
476 DrawImage( maAppLogoPos, maAppLogo );
307
308 return;
309}
310
311// -----------------------------------------------------------------------
312
313IMPL_LINK ( AboutDialog, OpenLinkHdl_Impl, svt::FixedHyperlink*, EMPTYARG )
314{

--- 14 unchanged lines hidden (view full) ---

329 catch( const com::sun::star::uno::Exception& e )
330 {
331 OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
332 rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
333 }
334 }
335 return 0;
336}
477
478 return;
479}
480
481// -----------------------------------------------------------------------
482
483IMPL_LINK ( AboutDialog, OpenLinkHdl_Impl, svt::FixedHyperlink*, EMPTYARG )
484{

--- 14 unchanged lines hidden (view full) ---

499 catch( const com::sun::star::uno::Exception& e )
500 {
501 OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
502 rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
503 }
504 }
505 return 0;
506}
507
508IMPL_LINK ( AboutDialog, ShowReadme_Impl, PushButton*, EMPTYARG )
509{
510 ReadmeDialog aDlg( this );
511 aDlg.Execute();
512
513 return 0;
514}