xref: /aoo41x/main/cui/source/dialogs/about.cxx (revision ca04f111)
12ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
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
102ee96f1cSAndrew Rist  *
112ee96f1cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
122ee96f1cSAndrew Rist  *
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.
192ee96f1cSAndrew Rist  *
202ee96f1cSAndrew Rist  *************************************************************/
212ee96f1cSAndrew Rist 
222ee96f1cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cui.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/uno/Any.h>
28*ca04f111SAriel Constenla-Haile #include <comphelper/processfactory.hxx>
29*ca04f111SAriel Constenla-Haile #include <dialmgr.hxx>
30*ca04f111SAriel Constenla-Haile #include <osl/file.hxx>
31*ca04f111SAriel Constenla-Haile #include <rtl/bootstrap.hxx>
32cdf0e10cSrcweir #include <sfx2/app.hxx>
33cdf0e10cSrcweir #include <sfx2/sfxcommands.h>
34*ca04f111SAriel Constenla-Haile #include <sfx2/sfxdefs.hxx>
35*ca04f111SAriel Constenla-Haile #include <sfx2/sfxuno.hxx>
36*ca04f111SAriel Constenla-Haile #include <svtools/filter.hxx>
37cdf0e10cSrcweir #include <svtools/svtools.hrc>
38*ca04f111SAriel Constenla-Haile #include <tools/stream.hxx>
39*ca04f111SAriel Constenla-Haile #include <tools/urlobj.hxx>
40*ca04f111SAriel Constenla-Haile #include <unotools/bootstrap.hxx>
41*ca04f111SAriel Constenla-Haile #include <unotools/configmgr.hxx>
42*ca04f111SAriel Constenla-Haile #include <vcl/graph.hxx>
43*ca04f111SAriel Constenla-Haile #include <vcl/msgbox.hxx>
44*ca04f111SAriel Constenla-Haile #include <vcl/svapp.hxx>
45*ca04f111SAriel Constenla-Haile #include <vcl/tabctrl.hxx>
46*ca04f111SAriel Constenla-Haile #include <vcl/tabdlg.hxx>
47*ca04f111SAriel Constenla-Haile #include <vcl/tabpage.hxx>
48cdf0e10cSrcweir 
4923c0a6f8SAriel Constenla-Haile #include <com/sun/star/system/XSystemShellExecute.hpp>
5023c0a6f8SAriel Constenla-Haile #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
5123c0a6f8SAriel Constenla-Haile 
52*ca04f111SAriel Constenla-Haile #include "about.hxx"
53*ca04f111SAriel Constenla-Haile #include "about.hrc"
54cdf0e10cSrcweir 
5523c0a6f8SAriel Constenla-Haile #define _STRINGIFY(x) #x
5623c0a6f8SAriel Constenla-Haile #define STRINGIFY(x) _STRINGIFY(x)
57cdf0e10cSrcweir 
58*ca04f111SAriel Constenla-Haile namespace
59cdf0e10cSrcweir {
60cdf0e10cSrcweir 
61*ca04f111SAriel Constenla-Haile     static void lcl_layoutFixedText( FixedText &rControl,
62*ca04f111SAriel Constenla-Haile                                      const Point& aPos,
63*ca04f111SAriel Constenla-Haile                                      Size &aSize,
64*ca04f111SAriel Constenla-Haile                                      const long nTextWidth )
65*ca04f111SAriel Constenla-Haile     {
66*ca04f111SAriel Constenla-Haile         aSize = rControl.GetSizePixel();
67*ca04f111SAriel Constenla-Haile         // change the width
68*ca04f111SAriel Constenla-Haile         aSize.Width() = nTextWidth;
69*ca04f111SAriel Constenla-Haile         // set Position and Size, to calculate the minimum size
70*ca04f111SAriel Constenla-Haile         // this will update the Height
71*ca04f111SAriel Constenla-Haile         rControl.SetPosSizePixel( aPos, aSize );
72*ca04f111SAriel Constenla-Haile         aSize = rControl.CalcMinimumSize();
73*ca04f111SAriel Constenla-Haile         // update the size with the right Height
74*ca04f111SAriel Constenla-Haile         rControl.SetSizePixel( aSize );
75*ca04f111SAriel Constenla-Haile     }
76*ca04f111SAriel Constenla-Haile 
77*ca04f111SAriel Constenla-Haile     static void lcl_layoutEdit( Edit &rControl,
78*ca04f111SAriel Constenla-Haile                                 const Point& aPos,
79*ca04f111SAriel Constenla-Haile                                 Size &aSize,
80*ca04f111SAriel Constenla-Haile                                 const long nTextWidth )
81*ca04f111SAriel Constenla-Haile     {
82*ca04f111SAriel Constenla-Haile         aSize = rControl.GetSizePixel();
83*ca04f111SAriel Constenla-Haile         // change the width
84*ca04f111SAriel Constenla-Haile         aSize.Width() = nTextWidth;
85*ca04f111SAriel Constenla-Haile         // set Position and Size, to calculate the minimum size
86*ca04f111SAriel Constenla-Haile         // this will update the Height
87*ca04f111SAriel Constenla-Haile         rControl.SetPosSizePixel( aPos, aSize );
88*ca04f111SAriel Constenla-Haile         aSize = rControl.CalcMinimumSize();
89*ca04f111SAriel Constenla-Haile         // update the size with the right Height
90*ca04f111SAriel Constenla-Haile         rControl.SetSizePixel( aSize );
91*ca04f111SAriel Constenla-Haile     }
92*ca04f111SAriel Constenla-Haile 
93*ca04f111SAriel Constenla-Haile     static  void lcl_readTxtFile( const rtl::OUString &rFile, rtl::OUString &sText )
94*ca04f111SAriel Constenla-Haile     {
95*ca04f111SAriel Constenla-Haile         rtl::OUString sFile( rFile );
96*ca04f111SAriel Constenla-Haile         rtl::Bootstrap::expandMacros( sFile );
97*ca04f111SAriel Constenla-Haile         osl::File aFile(sFile);
98*ca04f111SAriel Constenla-Haile         if ( aFile.open(OpenFlag_Read) == osl::FileBase::E_None )
99*ca04f111SAriel Constenla-Haile         {
100*ca04f111SAriel Constenla-Haile             osl::DirectoryItem aItem;
101*ca04f111SAriel Constenla-Haile             osl::DirectoryItem::get(sFile, aItem);
102*ca04f111SAriel Constenla-Haile 
103*ca04f111SAriel Constenla-Haile             osl::FileStatus aStatus(FileStatusMask_FileSize);
104*ca04f111SAriel Constenla-Haile             aItem.getFileStatus(aStatus);
105*ca04f111SAriel Constenla-Haile 
106*ca04f111SAriel Constenla-Haile             sal_uInt64 nBytesRead = 0;
107*ca04f111SAriel Constenla-Haile             sal_uInt64 nPosition = 0;
108*ca04f111SAriel Constenla-Haile             sal_uInt32 nBytes = (sal_uInt32)aStatus.getFileSize();
109*ca04f111SAriel Constenla-Haile 
110*ca04f111SAriel Constenla-Haile             sal_Char *pBuffer = new sal_Char[nBytes];
111*ca04f111SAriel Constenla-Haile 
112*ca04f111SAriel Constenla-Haile             while ( aFile.read( pBuffer + nPosition,
113*ca04f111SAriel Constenla-Haile                                 nBytes-nPosition,
114*ca04f111SAriel Constenla-Haile                                 nBytesRead ) == osl::FileBase::E_None
115*ca04f111SAriel Constenla-Haile                     && nPosition + nBytesRead < nBytes)
116*ca04f111SAriel Constenla-Haile             {
117*ca04f111SAriel Constenla-Haile                 nPosition += nBytesRead;
118*ca04f111SAriel Constenla-Haile             }
119*ca04f111SAriel Constenla-Haile 
120*ca04f111SAriel Constenla-Haile             OSL_ENSURE( nBytes < STRING_MAXLEN, "Text file has too much bytes!" );
121*ca04f111SAriel Constenla-Haile             if ( nBytes > STRING_MAXLEN )
122*ca04f111SAriel Constenla-Haile                 nBytes = STRING_MAXLEN - 1;
123*ca04f111SAriel Constenla-Haile 
124*ca04f111SAriel Constenla-Haile             sText = rtl::OUString( pBuffer,
125*ca04f111SAriel Constenla-Haile                                 nBytes,
126*ca04f111SAriel Constenla-Haile                                 RTL_TEXTENCODING_UTF8,
127*ca04f111SAriel Constenla-Haile                                 OSTRING_TO_OUSTRING_CVTFLAGS
128*ca04f111SAriel Constenla-Haile                                 | RTL_TEXTTOUNICODE_FLAGS_GLOBAL_SIGNATURE);
129*ca04f111SAriel Constenla-Haile             delete[] pBuffer;
130*ca04f111SAriel Constenla-Haile         }
131*ca04f111SAriel Constenla-Haile     }
132*ca04f111SAriel Constenla-Haile 
133*ca04f111SAriel Constenla-Haile     class ReadmeDialog;
134*ca04f111SAriel Constenla-Haile 
135*ca04f111SAriel Constenla-Haile     class ReadmeTabPage : public TabPage
136*ca04f111SAriel Constenla-Haile     {
137*ca04f111SAriel Constenla-Haile     private:
138*ca04f111SAriel Constenla-Haile         MultiLineEdit maText;
139*ca04f111SAriel Constenla-Haile         String        msText;
140*ca04f111SAriel Constenla-Haile 
141*ca04f111SAriel Constenla-Haile     public:
142*ca04f111SAriel Constenla-Haile         ReadmeTabPage(Window *pParent, const String &sText);
143*ca04f111SAriel Constenla-Haile         ~ReadmeTabPage();
144*ca04f111SAriel Constenla-Haile 
145*ca04f111SAriel Constenla-Haile         void Adjust(const Size &aSz, const Size &a6Size);
146*ca04f111SAriel Constenla-Haile     };
147*ca04f111SAriel Constenla-Haile 
148*ca04f111SAriel Constenla-Haile     ReadmeTabPage::ReadmeTabPage(Window *pParent, const String &sText)
149*ca04f111SAriel Constenla-Haile         : TabPage(pParent, CUI_RES( RID_CUI_README_TBPAGE))
150*ca04f111SAriel Constenla-Haile         ,maText( this, CUI_RES( RID_CUI_README_TBPAGE_EDIT ))
151*ca04f111SAriel Constenla-Haile         ,msText( sText )
152*ca04f111SAriel Constenla-Haile     {
153*ca04f111SAriel Constenla-Haile         FreeResource();
154*ca04f111SAriel Constenla-Haile 
155*ca04f111SAriel Constenla-Haile         maText.SetText(msText);
156*ca04f111SAriel Constenla-Haile         maText.Show();
157*ca04f111SAriel Constenla-Haile     }
158*ca04f111SAriel Constenla-Haile 
159*ca04f111SAriel Constenla-Haile     ReadmeTabPage::~ReadmeTabPage()
160*ca04f111SAriel Constenla-Haile     {
161*ca04f111SAriel Constenla-Haile     }
162*ca04f111SAriel Constenla-Haile 
163*ca04f111SAriel Constenla-Haile     void ReadmeTabPage::Adjust(const Size &aSz, const Size &a6Size)
164*ca04f111SAriel Constenla-Haile     {
165*ca04f111SAriel Constenla-Haile         long nDlgMargin  = a6Size.Width() * 2;
166*ca04f111SAriel Constenla-Haile         long nCtrlMargin = a6Size.Height() * 2;
167*ca04f111SAriel Constenla-Haile         maText.SetPosPixel( Point(a6Size.Width(), a6Size.Height()) );
168*ca04f111SAriel Constenla-Haile         maText.SetSizePixel( Size(aSz.Width() - nDlgMargin, aSz.Height() - nCtrlMargin) );
169*ca04f111SAriel Constenla-Haile     }
170*ca04f111SAriel Constenla-Haile 
171*ca04f111SAriel Constenla-Haile     class ReadmeDialog : public ModalDialog
172*ca04f111SAriel Constenla-Haile     {
173*ca04f111SAriel Constenla-Haile     private:
174*ca04f111SAriel Constenla-Haile         TabControl      maTabCtrl;
175*ca04f111SAriel Constenla-Haile         OKButton        maBtnOK;
176*ca04f111SAriel Constenla-Haile 
177*ca04f111SAriel Constenla-Haile         ReadmeTabPage  *maReadmeTabPage;
178*ca04f111SAriel Constenla-Haile         ReadmeTabPage  *maLicenseTabPage;
179*ca04f111SAriel Constenla-Haile         ReadmeTabPage  *maNoticeTabPage;
180*ca04f111SAriel Constenla-Haile 
181*ca04f111SAriel Constenla-Haile         DECL_LINK( ActivatePageHdl, TabControl * );
182*ca04f111SAriel Constenla-Haile         DECL_LINK( DeactivatePageHdl, TabControl * );
183*ca04f111SAriel Constenla-Haile 
184*ca04f111SAriel Constenla-Haile     public:
185*ca04f111SAriel Constenla-Haile         ReadmeDialog( Window* );
186*ca04f111SAriel Constenla-Haile         ~ReadmeDialog();
187*ca04f111SAriel Constenla-Haile     };
188*ca04f111SAriel Constenla-Haile 
189*ca04f111SAriel Constenla-Haile     ReadmeDialog::ReadmeDialog( Window * pParent )
190*ca04f111SAriel Constenla-Haile         : ModalDialog( pParent, CUI_RES( RID_CUI_README_DLG ) )
191*ca04f111SAriel Constenla-Haile         , maTabCtrl( this, CUI_RES(RID_CUI_README_TBCTL) )
192*ca04f111SAriel Constenla-Haile         , maBtnOK( this, CUI_RES(RID_CUI_README_OKBTN) )
193*ca04f111SAriel Constenla-Haile         , maReadmeTabPage(0)
194*ca04f111SAriel Constenla-Haile         , maLicenseTabPage(0)
195*ca04f111SAriel Constenla-Haile         , maNoticeTabPage(0)
196*ca04f111SAriel Constenla-Haile     {
197*ca04f111SAriel Constenla-Haile         FreeResource();
198*ca04f111SAriel Constenla-Haile 
199*ca04f111SAriel Constenla-Haile         maTabCtrl.Show();
200*ca04f111SAriel Constenla-Haile 
201*ca04f111SAriel Constenla-Haile         const rtl::OUString sReadme( RTL_CONSTASCII_USTRINGPARAM( "$BRAND_BASE_DIR/README" ) );
202*ca04f111SAriel Constenla-Haile         const rtl::OUString sLicense( RTL_CONSTASCII_USTRINGPARAM( "$BRAND_BASE_DIR/program/LICENSE" ) );
203*ca04f111SAriel Constenla-Haile         const rtl::OUString sNotice( RTL_CONSTASCII_USTRINGPARAM( "$BRAND_BASE_DIR/program/NOTICE" ) );
204*ca04f111SAriel Constenla-Haile 
205*ca04f111SAriel Constenla-Haile         rtl::OUString sReadmeTxt, sLicenseTxt, sNoticeTxt;
206*ca04f111SAriel Constenla-Haile         lcl_readTxtFile( sReadme, sReadmeTxt );
207*ca04f111SAriel Constenla-Haile         lcl_readTxtFile( sLicense, sLicenseTxt );
208*ca04f111SAriel Constenla-Haile         lcl_readTxtFile( sNotice, sNoticeTxt );
209*ca04f111SAriel Constenla-Haile 
210*ca04f111SAriel Constenla-Haile         maReadmeTabPage = new ReadmeTabPage( &maTabCtrl, sReadmeTxt );
211*ca04f111SAriel Constenla-Haile         maLicenseTabPage = new ReadmeTabPage( &maTabCtrl, sLicenseTxt );
212*ca04f111SAriel Constenla-Haile         maNoticeTabPage = new ReadmeTabPage( &maTabCtrl, sNoticeTxt );
213*ca04f111SAriel Constenla-Haile 
214*ca04f111SAriel Constenla-Haile         maTabCtrl.SetTabPage( RID_CUI_READMEPAGE, maReadmeTabPage );
215*ca04f111SAriel Constenla-Haile         maTabCtrl.SetTabPage( RID_CUI_LICENSEPAGE, maLicenseTabPage );
216*ca04f111SAriel Constenla-Haile         maTabCtrl.SetTabPage( RID_CUI_NOTICEPAGE, maNoticeTabPage );
217*ca04f111SAriel Constenla-Haile 
218*ca04f111SAriel Constenla-Haile         maTabCtrl.SelectTabPage( RID_CUI_READMEPAGE );
219*ca04f111SAriel Constenla-Haile 
220*ca04f111SAriel Constenla-Haile         Size aTpSz  = maReadmeTabPage->GetOutputSizePixel();
221*ca04f111SAriel Constenla-Haile         Size a6Size = maReadmeTabPage->LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
222*ca04f111SAriel Constenla-Haile 
223*ca04f111SAriel Constenla-Haile         maReadmeTabPage->Adjust( aTpSz, a6Size );
224*ca04f111SAriel Constenla-Haile         maLicenseTabPage->Adjust( aTpSz, a6Size );
225*ca04f111SAriel Constenla-Haile         maNoticeTabPage->Adjust( aTpSz, a6Size );
226*ca04f111SAriel Constenla-Haile 
227*ca04f111SAriel Constenla-Haile         Size aDlgSize = GetOutputSizePixel();
228*ca04f111SAriel Constenla-Haile         Size aOkBtnSz = maBtnOK.GetSizePixel();
229*ca04f111SAriel Constenla-Haile         Point aOKPnt( aDlgSize.Width() / 2 - aOkBtnSz.Width() / 2 , maBtnOK.GetPosPixel().Y() );
230*ca04f111SAriel Constenla-Haile         maBtnOK.SetPosPixel( aOKPnt );
231*ca04f111SAriel Constenla-Haile     }
232*ca04f111SAriel Constenla-Haile 
233*ca04f111SAriel Constenla-Haile     ReadmeDialog::~ReadmeDialog()
234*ca04f111SAriel Constenla-Haile     {
235*ca04f111SAriel Constenla-Haile         delete maReadmeTabPage;
236*ca04f111SAriel Constenla-Haile         delete maLicenseTabPage;
237*ca04f111SAriel Constenla-Haile         delete maNoticeTabPage;
238*ca04f111SAriel Constenla-Haile     }
23923c0a6f8SAriel Constenla-Haile }
240cdf0e10cSrcweir 
24123c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
242cdf0e10cSrcweir 
24323c0a6f8SAriel Constenla-Haile AboutDialog::AboutDialog( Window* pParent, const ResId& rId ) :
24423c0a6f8SAriel Constenla-Haile     SfxModalDialog( pParent, rId ),
24523c0a6f8SAriel Constenla-Haile     maOKButton( this, ResId( RID_CUI_ABOUT_BTN_OK, *rId.GetResMgr() ) ),
246*ca04f111SAriel Constenla-Haile     maReadmeButton( this, ResId( RID_CUI_ABOUT_BTN_README, *rId.GetResMgr() ) ),
24723c0a6f8SAriel Constenla-Haile     maVersionText( this, ResId( RID_CUI_ABOUT_FTXT_VERSION, *rId.GetResMgr() ) ),
24823c0a6f8SAriel Constenla-Haile     maBuildInfoEdit( this, ResId( RID_CUI_ABOUT_FTXT_BUILDDATA, *rId.GetResMgr() ) ),
24923c0a6f8SAriel Constenla-Haile     maCopyrightEdit( this, ResId( RID_CUI_ABOUT_FTXT_COPYRIGHT, *rId.GetResMgr() ) ),
25023c0a6f8SAriel Constenla-Haile     maCreditsLink( this, ResId( RID_CUI_ABOUT_FTXT_WELCOME_LINK, *rId.GetResMgr() )  ),
251*ca04f111SAriel Constenla-Haile     maMainLogo( ResId( RID_CUI_ABOUT_LOGO, *rId.GetResMgr() ) ),
25223c0a6f8SAriel Constenla-Haile     maCopyrightTextStr( ResId( RID_CUI_ABOUT_STR_COPYRIGHT, *rId.GetResMgr() ) )
25323c0a6f8SAriel Constenla-Haile {
25423c0a6f8SAriel Constenla-Haile     // load image from module path
25523c0a6f8SAriel Constenla-Haile     maAppLogo = SfxApplication::GetApplicationLogo();
256cdf0e10cSrcweir 
25723c0a6f8SAriel Constenla-Haile     InitControls();
25823c0a6f8SAriel Constenla-Haile 
25923c0a6f8SAriel Constenla-Haile     // set links
260*ca04f111SAriel Constenla-Haile     maReadmeButton.SetClickHdl( LINK( this, AboutDialog, ShowReadme_Impl ) );
26123c0a6f8SAriel Constenla-Haile     maCreditsLink.SetClickHdl( LINK( this, AboutDialog, OpenLinkHdl_Impl ) );
26223c0a6f8SAriel Constenla-Haile 
26323c0a6f8SAriel Constenla-Haile     FreeResource();
26423c0a6f8SAriel Constenla-Haile 
26523c0a6f8SAriel Constenla-Haile     SetHelpId( CMD_SID_ABOUT );
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
26823c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
269cdf0e10cSrcweir 
27023c0a6f8SAriel Constenla-Haile AboutDialog::~AboutDialog()
271cdf0e10cSrcweir {
27223c0a6f8SAriel Constenla-Haile }
273cdf0e10cSrcweir 
27423c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
275cdf0e10cSrcweir 
27623c0a6f8SAriel Constenla-Haile void AboutDialog::InitControls()
27723c0a6f8SAriel Constenla-Haile {
27823c0a6f8SAriel Constenla-Haile     // apply font, background et al.
27923c0a6f8SAriel Constenla-Haile     ApplyStyleSettings();
280cdf0e10cSrcweir 
28123c0a6f8SAriel Constenla-Haile     // set strings
28223c0a6f8SAriel Constenla-Haile     maCopyrightEdit.SetText( maCopyrightTextStr );
28323c0a6f8SAriel Constenla-Haile     maBuildInfoEdit.SetText( GetBuildVersionString() );
28423c0a6f8SAriel Constenla-Haile     maCreditsLink.SetURL( maCreditsLink.GetText() );
285cdf0e10cSrcweir 
28623c0a6f8SAriel Constenla-Haile     // determine size and position of the dialog & elements
28723c0a6f8SAriel Constenla-Haile     Size aDlgSize;
28823c0a6f8SAriel Constenla-Haile     LayoutControls( aDlgSize );
28923c0a6f8SAriel Constenla-Haile 
29023c0a6f8SAriel Constenla-Haile     // Change the width of the dialog
29123c0a6f8SAriel Constenla-Haile     SetOutputSizePixel( aDlgSize );
29223c0a6f8SAriel Constenla-Haile }
29323c0a6f8SAriel Constenla-Haile 
29423c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
29523c0a6f8SAriel Constenla-Haile 
29623c0a6f8SAriel Constenla-Haile void AboutDialog::ApplyStyleSettings()
29723c0a6f8SAriel Constenla-Haile {
29823c0a6f8SAriel Constenla-Haile     // Transparenter Font
29923c0a6f8SAriel Constenla-Haile     Font aFont = GetFont();
300cdf0e10cSrcweir     aFont.SetTransparent( sal_True );
30123c0a6f8SAriel Constenla-Haile     SetFont( aFont );
30223c0a6f8SAriel Constenla-Haile 
30323c0a6f8SAriel Constenla-Haile     // set for background and text the correct system color
30423c0a6f8SAriel Constenla-Haile     const StyleSettings& rSettings = GetSettings().GetStyleSettings();
30523c0a6f8SAriel Constenla-Haile     Color aWhiteCol( rSettings.GetWindowColor() );
30623c0a6f8SAriel Constenla-Haile     Wallpaper aWall( aWhiteCol );
30723c0a6f8SAriel Constenla-Haile     SetBackground( aWall );
30823c0a6f8SAriel Constenla-Haile     Font aNewFont( maCopyrightEdit.GetFont() );
30923c0a6f8SAriel Constenla-Haile     aNewFont.SetTransparent( sal_True );
31023c0a6f8SAriel Constenla-Haile 
31123c0a6f8SAriel Constenla-Haile     maVersionText.SetFont( aNewFont );
31223c0a6f8SAriel Constenla-Haile     maCopyrightEdit.SetFont( aNewFont );
31323c0a6f8SAriel Constenla-Haile 
31423c0a6f8SAriel Constenla-Haile     maVersionText.SetBackground();
31523c0a6f8SAriel Constenla-Haile     maCopyrightEdit.SetBackground();
31623c0a6f8SAriel Constenla-Haile     maBuildInfoEdit.SetBackground();
31723c0a6f8SAriel Constenla-Haile     maCreditsLink.SetBackground();
31823c0a6f8SAriel Constenla-Haile 
31923c0a6f8SAriel Constenla-Haile     Color aTextColor( rSettings.GetWindowTextColor() );
32023c0a6f8SAriel Constenla-Haile     maVersionText.SetControlForeground( aTextColor );
32123c0a6f8SAriel Constenla-Haile     maCopyrightEdit.SetControlForeground( aTextColor );
32223c0a6f8SAriel Constenla-Haile     maBuildInfoEdit.SetControlForeground( aTextColor );
32323c0a6f8SAriel Constenla-Haile     maCreditsLink.SetControlForeground();
32423c0a6f8SAriel Constenla-Haile 
32523c0a6f8SAriel Constenla-Haile     Size aSmaller = aNewFont.GetSize();
32623c0a6f8SAriel Constenla-Haile     aSmaller.Width() = (long) (aSmaller.Width() * 0.75);
32723c0a6f8SAriel Constenla-Haile     aSmaller.Height() = (long) (aSmaller.Height() * 0.75);
32823c0a6f8SAriel Constenla-Haile     aNewFont.SetSize( aSmaller );
32923c0a6f8SAriel Constenla-Haile 
33023c0a6f8SAriel Constenla-Haile     maBuildInfoEdit.SetFont( aNewFont );
33123c0a6f8SAriel Constenla-Haile 
33223c0a6f8SAriel Constenla-Haile     // the following is a hack to force the MultiLineEdit update its settings
33323c0a6f8SAriel Constenla-Haile     // in order to reflect the Font
33423c0a6f8SAriel Constenla-Haile     // See
33523c0a6f8SAriel Constenla-Haile     //      Window::SetControlFont
33623c0a6f8SAriel Constenla-Haile     //      MultiLineEdit::StateChanged
33723c0a6f8SAriel Constenla-Haile     //      MultiLineEdit::ImplInitSettings
33823c0a6f8SAriel Constenla-Haile     // TODO Override SetFont in MultiLineEdit and do the following,
33923c0a6f8SAriel Constenla-Haile     // otherwise SetFont has no effect at all!
34023c0a6f8SAriel Constenla-Haile     aSmaller = PixelToLogic( aSmaller, MAP_POINT );
34123c0a6f8SAriel Constenla-Haile     aNewFont.SetSize( aSmaller );
34223c0a6f8SAriel Constenla-Haile     maBuildInfoEdit.SetControlFont( aNewFont );
34323c0a6f8SAriel Constenla-Haile }
3448bd5297cSJürgen Schmidt 
34523c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
346cdf0e10cSrcweir 
34723c0a6f8SAriel Constenla-Haile void AboutDialog::LayoutControls( Size& aDlgSize )
34823c0a6f8SAriel Constenla-Haile {
349*ca04f111SAriel Constenla-Haile     Size aMainLogoSz = maMainLogo.GetSizePixel();
35023c0a6f8SAriel Constenla-Haile     Size aAppLogoSiz = maAppLogo.GetSizePixel();
35123c0a6f8SAriel Constenla-Haile 
352*ca04f111SAriel Constenla-Haile     long nLeftOffset = aMainLogoSz.Width();
353*ca04f111SAriel Constenla-Haile 
35423c0a6f8SAriel Constenla-Haile     aDlgSize = GetOutputSizePixel();
355cdf0e10cSrcweir 
35623c0a6f8SAriel Constenla-Haile     Size a6Size      = maVersionText.LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
35723c0a6f8SAriel Constenla-Haile     long nDlgMargin  = a6Size.Width() * 2;
358cdf0e10cSrcweir     long nCtrlMargin = a6Size.Height() * 2;
359*ca04f111SAriel Constenla-Haile     long nTextWidth  = aAppLogoSiz.Width() - nDlgMargin;
360*ca04f111SAriel Constenla-Haile     long nY          = aAppLogoSiz.Height() + a6Size.Height();
361*ca04f111SAriel Constenla-Haile 
362*ca04f111SAriel Constenla-Haile     aDlgSize.Width() = nLeftOffset + a6Size.Width() + aAppLogoSiz.Width();
363cdf0e10cSrcweir 
364*ca04f111SAriel Constenla-Haile     Point aPos( nLeftOffset + a6Size.Width(), nY );
36523c0a6f8SAriel Constenla-Haile     Size aSize;
36623c0a6f8SAriel Constenla-Haile     // layout fixed text control
367*ca04f111SAriel Constenla-Haile     lcl_layoutFixedText( maVersionText, aPos, aSize, nTextWidth );
368*ca04f111SAriel Constenla-Haile     nY += aSize.Height() + a6Size.Height();
369a392ac37SAriel Constenla-Haile 
37023c0a6f8SAriel Constenla-Haile     // Multiline edit with Build info
37123c0a6f8SAriel Constenla-Haile     aPos.Y() = nY;
372*ca04f111SAriel Constenla-Haile     lcl_layoutEdit( maBuildInfoEdit, aPos, aSize, nTextWidth );
373*ca04f111SAriel Constenla-Haile     nY += aSize.Height() + a6Size.Height();
374a392ac37SAriel Constenla-Haile 
375cdf0e10cSrcweir     // Multiline edit with Copyright-Text
37623c0a6f8SAriel Constenla-Haile     aPos.Y() = nY;
377*ca04f111SAriel Constenla-Haile     lcl_layoutEdit( maCopyrightEdit, aPos, aSize, nTextWidth );
378*ca04f111SAriel Constenla-Haile     nY += aSize.Height() + a6Size.Height();
37923c0a6f8SAriel Constenla-Haile 
38023c0a6f8SAriel Constenla-Haile     // Hyperlink
38123c0a6f8SAriel Constenla-Haile     aPos.Y() = nY;
382*ca04f111SAriel Constenla-Haile     lcl_layoutFixedText( maCreditsLink, aPos, aSize, nTextWidth );
383*ca04f111SAriel Constenla-Haile     nY += aSize.Height();
384*ca04f111SAriel Constenla-Haile 
385*ca04f111SAriel Constenla-Haile     nY = std::max( nY, aMainLogoSz.Height() );
386*ca04f111SAriel Constenla-Haile     nY += nCtrlMargin;
387*ca04f111SAriel Constenla-Haile 
388*ca04f111SAriel Constenla-Haile     // logos position
389*ca04f111SAriel Constenla-Haile     maMainLogoPos = Point( 0, nY / 2 - aMainLogoSz.Height() / 2 );
390*ca04f111SAriel Constenla-Haile     maAppLogoPos = Point( nLeftOffset + a6Size.Width(), 0 );
39123c0a6f8SAriel Constenla-Haile 
39223c0a6f8SAriel Constenla-Haile     // OK-Button-Position (at the bottom and centered)
39323c0a6f8SAriel Constenla-Haile     Size aOKSiz = maOKButton.GetSizePixel();
394*ca04f111SAriel Constenla-Haile     Point aOKPnt( ( aDlgSize.Width() - aOKSiz.Width() ) - a6Size.Width(), nY );
39523c0a6f8SAriel Constenla-Haile     maOKButton.SetPosPixel( aOKPnt );
39623c0a6f8SAriel Constenla-Haile 
397*ca04f111SAriel Constenla-Haile     maReadmeButton.SetPosPixel( Point(a6Size.Width(), nY) );
398*ca04f111SAriel Constenla-Haile 
399*ca04f111SAriel Constenla-Haile     aDlgSize.Height() = aOKPnt.Y() + aOKSiz.Height() + a6Size.Width();
40023c0a6f8SAriel Constenla-Haile }
401cdf0e10cSrcweir 
40223c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
403cdf0e10cSrcweir 
40423c0a6f8SAriel Constenla-Haile const rtl::OUString AboutDialog::GetBuildId() const
40523c0a6f8SAriel Constenla-Haile {
40623c0a6f8SAriel Constenla-Haile     rtl::OUString sDefault;
407cdf0e10cSrcweir 
40823c0a6f8SAriel Constenla-Haile     // Get buildid from version[rc|.ini]
40923c0a6f8SAriel Constenla-Haile     rtl::OUString sBuildId( utl::Bootstrap::getBuildIdData( sDefault ) );
41023c0a6f8SAriel Constenla-Haile     OSL_ENSURE( sBuildId.getLength() > 0, "No BUILDID in bootstrap file" );
41123c0a6f8SAriel Constenla-Haile     rtl::OUStringBuffer sBuildIdBuff( sBuildId );
412cdf0e10cSrcweir 
41323c0a6f8SAriel Constenla-Haile     // Get ProductSource from version[rc|.ini]
41423c0a6f8SAriel Constenla-Haile     rtl::OUString sProductSource( utl::Bootstrap::getProductSource( sDefault ) );
41523c0a6f8SAriel Constenla-Haile     OSL_ENSURE( sProductSource.getLength() > 0, "No ProductSource in bootstrap file" );
416cdf0e10cSrcweir 
41723c0a6f8SAriel Constenla-Haile     // the product source is something like "AOO340",
41823c0a6f8SAriel Constenla-Haile     // while the build id is something like "340m1(Build:9590)"
41923c0a6f8SAriel Constenla-Haile     // For better readability, strip the duplicate ProductMajor ("340").
42023c0a6f8SAriel Constenla-Haile     if ( sProductSource.getLength() )
42123c0a6f8SAriel Constenla-Haile     {
42223c0a6f8SAriel Constenla-Haile         bool bMatchingUPD =
42323c0a6f8SAriel Constenla-Haile                 ( sProductSource.getLength() >= 3 )
42423c0a6f8SAriel Constenla-Haile             &&  ( sBuildId.getLength() >= 3 )
42523c0a6f8SAriel Constenla-Haile             &&  ( sProductSource.copy( sProductSource.getLength() - 3 ) == sBuildId.copy( 0, 3 ) );
42623c0a6f8SAriel Constenla-Haile         OSL_ENSURE( bMatchingUPD, "BUILDID and ProductSource do not match in their UPD" );
42723c0a6f8SAriel Constenla-Haile         if ( bMatchingUPD )
42823c0a6f8SAriel Constenla-Haile             sProductSource = sProductSource.copy( 0, sProductSource.getLength() - 3 );
429cdf0e10cSrcweir 
43023c0a6f8SAriel Constenla-Haile         // prepend the product source
43123c0a6f8SAriel Constenla-Haile         sBuildIdBuff.insert( 0, sProductSource );
43223c0a6f8SAriel Constenla-Haile     }
433cdf0e10cSrcweir 
43423c0a6f8SAriel Constenla-Haile     return sBuildIdBuff.makeStringAndClear();
435cdf0e10cSrcweir }
436cdf0e10cSrcweir 
437cdf0e10cSrcweir // -----------------------------------------------------------------------
438cdf0e10cSrcweir 
43923c0a6f8SAriel Constenla-Haile const rtl::OUString AboutDialog::GetBuildVersionString() const
440cdf0e10cSrcweir {
44123c0a6f8SAriel Constenla-Haile     rtl::OUStringBuffer aBuildString( GetBuildId() );
44223c0a6f8SAriel Constenla-Haile     rtl::OUString sRevision( utl::Bootstrap::getRevisionInfo() );
443cdf0e10cSrcweir 
44423c0a6f8SAriel Constenla-Haile     if ( sRevision.getLength() > 0 )
44523c0a6f8SAriel Constenla-Haile     {
44623c0a6f8SAriel Constenla-Haile         aBuildString.appendAscii( RTL_CONSTASCII_STRINGPARAM( "  -  Rev. " ) );
44723c0a6f8SAriel Constenla-Haile         aBuildString.append( sRevision );
44823c0a6f8SAriel Constenla-Haile     }
449cdf0e10cSrcweir 
45023c0a6f8SAriel Constenla-Haile #ifdef BUILD_VER_STRING
45123c0a6f8SAriel Constenla-Haile     rtl::OUString sBuildVer( RTL_CONSTASCII_USTRINGPARAM( STRINGIFY( BUILD_VER_STRING ) ) );
45223c0a6f8SAriel Constenla-Haile     if ( sBuildVer.getLength() > 0 )
45323c0a6f8SAriel Constenla-Haile     {
45423c0a6f8SAriel Constenla-Haile         aBuildString.append( sal_Unicode( '\n' ) );
45523c0a6f8SAriel Constenla-Haile         aBuildString.append( sBuildVer );
45623c0a6f8SAriel Constenla-Haile     }
457cdf0e10cSrcweir #endif
458cdf0e10cSrcweir 
45923c0a6f8SAriel Constenla-Haile     return aBuildString.makeStringAndClear();
460cdf0e10cSrcweir }
461cdf0e10cSrcweir 
462cdf0e10cSrcweir // -----------------------------------------------------------------------
463cdf0e10cSrcweir 
464cdf0e10cSrcweir sal_Bool AboutDialog::Close()
465cdf0e10cSrcweir {
46623c0a6f8SAriel Constenla-Haile     EndDialog( RET_OK );
46723c0a6f8SAriel Constenla-Haile     return( sal_False );
468cdf0e10cSrcweir }
469cdf0e10cSrcweir 
470cdf0e10cSrcweir // -----------------------------------------------------------------------
471cdf0e10cSrcweir 
472cdf0e10cSrcweir void AboutDialog::Paint( const Rectangle& rRect )
473cdf0e10cSrcweir {
47423c0a6f8SAriel Constenla-Haile     SetClipRegion( rRect );
475*ca04f111SAriel Constenla-Haile     DrawImage( maMainLogoPos, maMainLogo );
476*ca04f111SAriel Constenla-Haile     DrawImage( maAppLogoPos, maAppLogo );
47723c0a6f8SAriel Constenla-Haile 
47823c0a6f8SAriel Constenla-Haile     return;
47923c0a6f8SAriel Constenla-Haile }
48023c0a6f8SAriel Constenla-Haile 
48123c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
48223c0a6f8SAriel Constenla-Haile 
48323c0a6f8SAriel Constenla-Haile IMPL_LINK ( AboutDialog, OpenLinkHdl_Impl, svt::FixedHyperlink*, EMPTYARG )
48423c0a6f8SAriel Constenla-Haile {
48523c0a6f8SAriel Constenla-Haile     ::rtl::OUString sURL( maCreditsLink.GetURL() );
48623c0a6f8SAriel Constenla-Haile     if ( sURL.getLength() > 0 )
48723c0a6f8SAriel Constenla-Haile     {
48823c0a6f8SAriel Constenla-Haile         try
48923c0a6f8SAriel Constenla-Haile         {
49023c0a6f8SAriel Constenla-Haile             com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xSMGR =
49123c0a6f8SAriel Constenla-Haile                 ::comphelper::getProcessServiceFactory();
49223c0a6f8SAriel Constenla-Haile             com::sun::star::uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShell(
49323c0a6f8SAriel Constenla-Haile                 xSMGR->createInstance( ::rtl::OUString(
49423c0a6f8SAriel Constenla-Haile                     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.system.SystemShellExecute" ) ) ),
49523c0a6f8SAriel Constenla-Haile                 com::sun::star::uno::UNO_QUERY_THROW );
49623c0a6f8SAriel Constenla-Haile             if ( xSystemShell.is() )
49723c0a6f8SAriel Constenla-Haile                 xSystemShell->execute( sURL, ::rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::DEFAULTS );
49823c0a6f8SAriel Constenla-Haile         }
49923c0a6f8SAriel Constenla-Haile         catch( const com::sun::star::uno::Exception& e )
50023c0a6f8SAriel Constenla-Haile         {
50123c0a6f8SAriel Constenla-Haile              OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
50223c0a6f8SAriel Constenla-Haile                 rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
50323c0a6f8SAriel Constenla-Haile         }
50423c0a6f8SAriel Constenla-Haile     }
50523c0a6f8SAriel Constenla-Haile     return 0;
506cdf0e10cSrcweir }
507*ca04f111SAriel Constenla-Haile 
508*ca04f111SAriel Constenla-Haile IMPL_LINK ( AboutDialog, ShowReadme_Impl, PushButton*, EMPTYARG )
509*ca04f111SAriel Constenla-Haile {
510*ca04f111SAriel Constenla-Haile     ReadmeDialog aDlg( this );
511*ca04f111SAriel Constenla-Haile     aDlg.Execute();
512*ca04f111SAriel Constenla-Haile 
513*ca04f111SAriel Constenla-Haile     return 0;
514*ca04f111SAriel Constenla-Haile }
515