xref: /aoo41x/main/cui/source/dialogs/about.cxx (revision 910823ae)
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 
27ca04f111SAriel Constenla-Haile #include <comphelper/processfactory.hxx>
28ca04f111SAriel Constenla-Haile #include <dialmgr.hxx>
29ca04f111SAriel Constenla-Haile #include <osl/file.hxx>
30ca04f111SAriel Constenla-Haile #include <rtl/bootstrap.hxx>
31cdf0e10cSrcweir #include <sfx2/sfxcommands.h>
32ca04f111SAriel Constenla-Haile #include <sfx2/sfxdefs.hxx>
33ca04f111SAriel Constenla-Haile #include <sfx2/sfxuno.hxx>
34ca04f111SAriel Constenla-Haile #include <svtools/filter.hxx>
35cdf0e10cSrcweir #include <svtools/svtools.hrc>
36ca04f111SAriel Constenla-Haile #include <tools/stream.hxx>
37ca04f111SAriel Constenla-Haile #include <tools/urlobj.hxx>
38ca04f111SAriel Constenla-Haile #include <unotools/bootstrap.hxx>
39ca04f111SAriel Constenla-Haile #include <unotools/configmgr.hxx>
40ca04f111SAriel Constenla-Haile #include <vcl/graph.hxx>
417168672cSAriel Constenla-Haile #include <vcl/imagerepository.hxx>
42ca04f111SAriel Constenla-Haile #include <vcl/msgbox.hxx>
43ca04f111SAriel Constenla-Haile #include <vcl/svapp.hxx>
44ca04f111SAriel Constenla-Haile #include <vcl/tabctrl.hxx>
45ca04f111SAriel Constenla-Haile #include <vcl/tabdlg.hxx>
46ca04f111SAriel Constenla-Haile #include <vcl/tabpage.hxx>
47cdf0e10cSrcweir 
4823c0a6f8SAriel Constenla-Haile #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
499807c9deSAriel Constenla-Haile #include <com/sun/star/system/SystemShellExecute.hpp>
507168672cSAriel Constenla-Haile #include <com/sun/star/uno/Any.h>
5123c0a6f8SAriel Constenla-Haile 
52ca04f111SAriel Constenla-Haile #include "about.hxx"
53ca04f111SAriel Constenla-Haile #include "about.hrc"
54cdf0e10cSrcweir 
5523c0a6f8SAriel Constenla-Haile #define _STRINGIFY(x) #x
5623c0a6f8SAriel Constenla-Haile #define STRINGIFY(x) _STRINGIFY(x)
57cdf0e10cSrcweir 
587168672cSAriel Constenla-Haile /* On Windows/OS2, all the three files have .txt extension
597168672cSAriel Constenla-Haile    and the README file name is in lowercase
607168672cSAriel Constenla-Haile    Readme files are localized and have the locale in their file name:
617168672cSAriel Constenla-Haile    README_de README_en-US
627168672cSAriel Constenla-Haile */
637168672cSAriel Constenla-Haile #if defined(WNT) || defined(OS2)
647168672cSAriel Constenla-Haile #define FILE_EXTENSION  ".txt"
657168672cSAriel Constenla-Haile #define README_FILE     "readme"
667168672cSAriel Constenla-Haile #else
677168672cSAriel Constenla-Haile #define FILE_EXTENSION
687168672cSAriel Constenla-Haile #define README_FILE     "README"
697168672cSAriel Constenla-Haile #endif
707168672cSAriel Constenla-Haile #define LICENSE_FILE    "LICENSE" FILE_EXTENSION
717168672cSAriel Constenla-Haile #define NOTICE_FILE     "NOTICE"  FILE_EXTENSION
727168672cSAriel Constenla-Haile 
737168672cSAriel Constenla-Haile // Dir where the files are located
74*910823aeSJürgen Schmidt #define OOO_DIR_SHARE_README  "${OOO_BASE_DIR}/share/readme/"
757168672cSAriel Constenla-Haile 
767168672cSAriel Constenla-Haile using namespace com::sun::star;
777168672cSAriel Constenla-Haile 
78ca04f111SAriel Constenla-Haile namespace
79cdf0e10cSrcweir {
80cdf0e10cSrcweir 
81ca04f111SAriel Constenla-Haile     static void lcl_layoutFixedText( FixedText &rControl,
82ca04f111SAriel Constenla-Haile                                      const Point& aPos,
83ca04f111SAriel Constenla-Haile                                      Size &aSize,
84ca04f111SAriel Constenla-Haile                                      const long nTextWidth )
85ca04f111SAriel Constenla-Haile     {
86ca04f111SAriel Constenla-Haile         aSize = rControl.GetSizePixel();
87ca04f111SAriel Constenla-Haile         // change the width
88ca04f111SAriel Constenla-Haile         aSize.Width() = nTextWidth;
89ca04f111SAriel Constenla-Haile         // set Position and Size, to calculate the minimum size
90ca04f111SAriel Constenla-Haile         // this will update the Height
91ca04f111SAriel Constenla-Haile         rControl.SetPosSizePixel( aPos, aSize );
92ca04f111SAriel Constenla-Haile         aSize = rControl.CalcMinimumSize();
93ca04f111SAriel Constenla-Haile         // update the size with the right Height
94ca04f111SAriel Constenla-Haile         rControl.SetSizePixel( aSize );
95ca04f111SAriel Constenla-Haile     }
96ca04f111SAriel Constenla-Haile 
97ca04f111SAriel Constenla-Haile     static void lcl_layoutEdit( Edit &rControl,
98ca04f111SAriel Constenla-Haile                                 const Point& aPos,
99ca04f111SAriel Constenla-Haile                                 Size &aSize,
100ca04f111SAriel Constenla-Haile                                 const long nTextWidth )
101ca04f111SAriel Constenla-Haile     {
102ca04f111SAriel Constenla-Haile         aSize = rControl.GetSizePixel();
103ca04f111SAriel Constenla-Haile         // change the width
104ca04f111SAriel Constenla-Haile         aSize.Width() = nTextWidth;
105ca04f111SAriel Constenla-Haile         // set Position and Size, to calculate the minimum size
106ca04f111SAriel Constenla-Haile         // this will update the Height
107ca04f111SAriel Constenla-Haile         rControl.SetPosSizePixel( aPos, aSize );
108ca04f111SAriel Constenla-Haile         aSize = rControl.CalcMinimumSize();
109ca04f111SAriel Constenla-Haile         // update the size with the right Height
110ca04f111SAriel Constenla-Haile         rControl.SetSizePixel( aSize );
111ca04f111SAriel Constenla-Haile     }
112ca04f111SAriel Constenla-Haile 
113ca04f111SAriel Constenla-Haile     static  void lcl_readTxtFile( const rtl::OUString &rFile, rtl::OUString &sText )
114ca04f111SAriel Constenla-Haile     {
115ca04f111SAriel Constenla-Haile         rtl::OUString sFile( rFile );
116ca04f111SAriel Constenla-Haile         rtl::Bootstrap::expandMacros( sFile );
117ca04f111SAriel Constenla-Haile         osl::File aFile(sFile);
118ca04f111SAriel Constenla-Haile         if ( aFile.open(OpenFlag_Read) == osl::FileBase::E_None )
119ca04f111SAriel Constenla-Haile         {
120ca04f111SAriel Constenla-Haile             osl::DirectoryItem aItem;
121ca04f111SAriel Constenla-Haile             osl::DirectoryItem::get(sFile, aItem);
122ca04f111SAriel Constenla-Haile 
123ca04f111SAriel Constenla-Haile             osl::FileStatus aStatus(FileStatusMask_FileSize);
124ca04f111SAriel Constenla-Haile             aItem.getFileStatus(aStatus);
125ca04f111SAriel Constenla-Haile 
126ca04f111SAriel Constenla-Haile             sal_uInt64 nBytesRead = 0;
127ca04f111SAriel Constenla-Haile             sal_uInt64 nPosition = 0;
128ca04f111SAriel Constenla-Haile             sal_uInt32 nBytes = (sal_uInt32)aStatus.getFileSize();
129ca04f111SAriel Constenla-Haile 
130ca04f111SAriel Constenla-Haile             sal_Char *pBuffer = new sal_Char[nBytes];
131ca04f111SAriel Constenla-Haile 
132ca04f111SAriel Constenla-Haile             while ( aFile.read( pBuffer + nPosition,
133ca04f111SAriel Constenla-Haile                                 nBytes-nPosition,
134ca04f111SAriel Constenla-Haile                                 nBytesRead ) == osl::FileBase::E_None
135ca04f111SAriel Constenla-Haile                     && nPosition + nBytesRead < nBytes)
136ca04f111SAriel Constenla-Haile             {
137ca04f111SAriel Constenla-Haile                 nPosition += nBytesRead;
138ca04f111SAriel Constenla-Haile             }
139ca04f111SAriel Constenla-Haile 
140ca04f111SAriel Constenla-Haile             OSL_ENSURE( nBytes < STRING_MAXLEN, "Text file has too much bytes!" );
141ca04f111SAriel Constenla-Haile             if ( nBytes > STRING_MAXLEN )
142ca04f111SAriel Constenla-Haile                 nBytes = STRING_MAXLEN - 1;
143ca04f111SAriel Constenla-Haile 
144ca04f111SAriel Constenla-Haile             sText = rtl::OUString( pBuffer,
145ca04f111SAriel Constenla-Haile                                 nBytes,
146ca04f111SAriel Constenla-Haile                                 RTL_TEXTENCODING_UTF8,
147ca04f111SAriel Constenla-Haile                                 OSTRING_TO_OUSTRING_CVTFLAGS
148ca04f111SAriel Constenla-Haile                                 | RTL_TEXTTOUNICODE_FLAGS_GLOBAL_SIGNATURE);
149ca04f111SAriel Constenla-Haile             delete[] pBuffer;
150ca04f111SAriel Constenla-Haile         }
151ca04f111SAriel Constenla-Haile     }
152ca04f111SAriel Constenla-Haile 
153ca04f111SAriel Constenla-Haile     class ReadmeDialog;
154ca04f111SAriel Constenla-Haile 
155ca04f111SAriel Constenla-Haile     class ReadmeTabPage : public TabPage
156ca04f111SAriel Constenla-Haile     {
157ca04f111SAriel Constenla-Haile     private:
158ca04f111SAriel Constenla-Haile         MultiLineEdit maText;
159ca04f111SAriel Constenla-Haile         String        msText;
160ca04f111SAriel Constenla-Haile 
161ca04f111SAriel Constenla-Haile     public:
162ca04f111SAriel Constenla-Haile         ReadmeTabPage(Window *pParent, const String &sText);
163ca04f111SAriel Constenla-Haile         ~ReadmeTabPage();
164ca04f111SAriel Constenla-Haile 
165ca04f111SAriel Constenla-Haile         void Adjust(const Size &aSz, const Size &a6Size);
166ca04f111SAriel Constenla-Haile     };
167ca04f111SAriel Constenla-Haile 
168ca04f111SAriel Constenla-Haile     ReadmeTabPage::ReadmeTabPage(Window *pParent, const String &sText)
169ca04f111SAriel Constenla-Haile         : TabPage(pParent, CUI_RES( RID_CUI_README_TBPAGE))
170ca04f111SAriel Constenla-Haile         ,maText( this, CUI_RES( RID_CUI_README_TBPAGE_EDIT ))
171ca04f111SAriel Constenla-Haile         ,msText( sText )
172ca04f111SAriel Constenla-Haile     {
173ca04f111SAriel Constenla-Haile         FreeResource();
174ca04f111SAriel Constenla-Haile 
175ca04f111SAriel Constenla-Haile         maText.SetText(msText);
176ca04f111SAriel Constenla-Haile         maText.Show();
177ca04f111SAriel Constenla-Haile     }
178ca04f111SAriel Constenla-Haile 
179ca04f111SAriel Constenla-Haile     ReadmeTabPage::~ReadmeTabPage()
180ca04f111SAriel Constenla-Haile     {
181ca04f111SAriel Constenla-Haile     }
182ca04f111SAriel Constenla-Haile 
183ca04f111SAriel Constenla-Haile     void ReadmeTabPage::Adjust(const Size &aSz, const Size &a6Size)
184ca04f111SAriel Constenla-Haile     {
185ca04f111SAriel Constenla-Haile         long nDlgMargin  = a6Size.Width() * 2;
186ca04f111SAriel Constenla-Haile         long nCtrlMargin = a6Size.Height() * 2;
187ca04f111SAriel Constenla-Haile         maText.SetPosPixel( Point(a6Size.Width(), a6Size.Height()) );
188ca04f111SAriel Constenla-Haile         maText.SetSizePixel( Size(aSz.Width() - nDlgMargin, aSz.Height() - nCtrlMargin) );
189ca04f111SAriel Constenla-Haile     }
190ca04f111SAriel Constenla-Haile 
191ca04f111SAriel Constenla-Haile     class ReadmeDialog : public ModalDialog
192ca04f111SAriel Constenla-Haile     {
193ca04f111SAriel Constenla-Haile     private:
194ca04f111SAriel Constenla-Haile         TabControl      maTabCtrl;
195ca04f111SAriel Constenla-Haile         OKButton        maBtnOK;
196ca04f111SAriel Constenla-Haile 
197ca04f111SAriel Constenla-Haile         ReadmeTabPage  *maReadmeTabPage;
198ca04f111SAriel Constenla-Haile         ReadmeTabPage  *maLicenseTabPage;
199ca04f111SAriel Constenla-Haile         ReadmeTabPage  *maNoticeTabPage;
200ca04f111SAriel Constenla-Haile 
201ca04f111SAriel Constenla-Haile         DECL_LINK( ActivatePageHdl, TabControl * );
202ca04f111SAriel Constenla-Haile         DECL_LINK( DeactivatePageHdl, TabControl * );
203ca04f111SAriel Constenla-Haile 
204ca04f111SAriel Constenla-Haile     public:
205ca04f111SAriel Constenla-Haile         ReadmeDialog( Window* );
206ca04f111SAriel Constenla-Haile         ~ReadmeDialog();
207ca04f111SAriel Constenla-Haile     };
208ca04f111SAriel Constenla-Haile 
209ca04f111SAriel Constenla-Haile     ReadmeDialog::ReadmeDialog( Window * pParent )
210ca04f111SAriel Constenla-Haile         : ModalDialog( pParent, CUI_RES( RID_CUI_README_DLG ) )
211ca04f111SAriel Constenla-Haile         , maTabCtrl( this, CUI_RES(RID_CUI_README_TBCTL) )
212ca04f111SAriel Constenla-Haile         , maBtnOK( this, CUI_RES(RID_CUI_README_OKBTN) )
213ca04f111SAriel Constenla-Haile         , maReadmeTabPage(0)
214ca04f111SAriel Constenla-Haile         , maLicenseTabPage(0)
215ca04f111SAriel Constenla-Haile         , maNoticeTabPage(0)
216ca04f111SAriel Constenla-Haile     {
217ca04f111SAriel Constenla-Haile         FreeResource();
218ca04f111SAriel Constenla-Haile 
219ca04f111SAriel Constenla-Haile         maTabCtrl.Show();
220ca04f111SAriel Constenla-Haile 
2217168672cSAriel Constenla-Haile         // Notice and License are not localized
222*910823aeSJürgen Schmidt         const rtl::OUString sLicense( RTL_CONSTASCII_USTRINGPARAM( OOO_DIR_SHARE_README LICENSE_FILE ) );
223*910823aeSJürgen Schmidt         const rtl::OUString sNotice( RTL_CONSTASCII_USTRINGPARAM(  OOO_DIR_SHARE_README NOTICE_FILE ) );
2247168672cSAriel Constenla-Haile 
2257168672cSAriel Constenla-Haile         // get localized README
2267168672cSAriel Constenla-Haile         rtl::OUStringBuffer aBuff;
2277168672cSAriel Constenla-Haile         lang::Locale aLocale = Application::GetSettings().GetUILocale();
228*910823aeSJürgen Schmidt         aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( OOO_DIR_SHARE_README README_FILE "_" ) );
2297168672cSAriel Constenla-Haile         aBuff.append( aLocale.Language );
2307168672cSAriel Constenla-Haile         if ( aLocale.Country.getLength() )
2317168672cSAriel Constenla-Haile         {
2327168672cSAriel Constenla-Haile             aBuff.append( sal_Unicode( '-') );
2337168672cSAriel Constenla-Haile             aBuff.append( aLocale.Country );
2347168672cSAriel Constenla-Haile             if ( aLocale.Variant.getLength() )
2357168672cSAriel Constenla-Haile             {
2367168672cSAriel Constenla-Haile                 aBuff.append( sal_Unicode( '-' ) );
2377168672cSAriel Constenla-Haile                 aBuff.append( aLocale.Variant );
2387168672cSAriel Constenla-Haile             }
2397168672cSAriel Constenla-Haile         }
2407168672cSAriel Constenla-Haile #if defined(WNT) || defined(OS2)
2417168672cSAriel Constenla-Haile         aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( FILE_EXTENSION ) );
2427168672cSAriel Constenla-Haile #endif
243ca04f111SAriel Constenla-Haile 
244ca04f111SAriel Constenla-Haile         rtl::OUString sReadmeTxt, sLicenseTxt, sNoticeTxt;
2457168672cSAriel Constenla-Haile         lcl_readTxtFile( aBuff.makeStringAndClear(), sReadmeTxt );
246ca04f111SAriel Constenla-Haile         lcl_readTxtFile( sLicense, sLicenseTxt );
247ca04f111SAriel Constenla-Haile         lcl_readTxtFile( sNotice, sNoticeTxt );
248ca04f111SAriel Constenla-Haile 
249ca04f111SAriel Constenla-Haile         maReadmeTabPage = new ReadmeTabPage( &maTabCtrl, sReadmeTxt );
250ca04f111SAriel Constenla-Haile         maLicenseTabPage = new ReadmeTabPage( &maTabCtrl, sLicenseTxt );
251ca04f111SAriel Constenla-Haile         maNoticeTabPage = new ReadmeTabPage( &maTabCtrl, sNoticeTxt );
252ca04f111SAriel Constenla-Haile 
253ca04f111SAriel Constenla-Haile         maTabCtrl.SetTabPage( RID_CUI_READMEPAGE, maReadmeTabPage );
254ca04f111SAriel Constenla-Haile         maTabCtrl.SetTabPage( RID_CUI_LICENSEPAGE, maLicenseTabPage );
255ca04f111SAriel Constenla-Haile         maTabCtrl.SetTabPage( RID_CUI_NOTICEPAGE, maNoticeTabPage );
256ca04f111SAriel Constenla-Haile 
257ca04f111SAriel Constenla-Haile         maTabCtrl.SelectTabPage( RID_CUI_READMEPAGE );
258ca04f111SAriel Constenla-Haile 
259ca04f111SAriel Constenla-Haile         Size aTpSz  = maReadmeTabPage->GetOutputSizePixel();
260ca04f111SAriel Constenla-Haile         Size a6Size = maReadmeTabPage->LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
261ca04f111SAriel Constenla-Haile 
262ca04f111SAriel Constenla-Haile         maReadmeTabPage->Adjust( aTpSz, a6Size );
263ca04f111SAriel Constenla-Haile         maLicenseTabPage->Adjust( aTpSz, a6Size );
264ca04f111SAriel Constenla-Haile         maNoticeTabPage->Adjust( aTpSz, a6Size );
265ca04f111SAriel Constenla-Haile 
266ca04f111SAriel Constenla-Haile         Size aDlgSize = GetOutputSizePixel();
267ca04f111SAriel Constenla-Haile         Size aOkBtnSz = maBtnOK.GetSizePixel();
268ca04f111SAriel Constenla-Haile         Point aOKPnt( aDlgSize.Width() / 2 - aOkBtnSz.Width() / 2 , maBtnOK.GetPosPixel().Y() );
269ca04f111SAriel Constenla-Haile         maBtnOK.SetPosPixel( aOKPnt );
270ca04f111SAriel Constenla-Haile     }
271ca04f111SAriel Constenla-Haile 
272ca04f111SAriel Constenla-Haile     ReadmeDialog::~ReadmeDialog()
273ca04f111SAriel Constenla-Haile     {
274ca04f111SAriel Constenla-Haile         delete maReadmeTabPage;
275ca04f111SAriel Constenla-Haile         delete maLicenseTabPage;
276ca04f111SAriel Constenla-Haile         delete maNoticeTabPage;
277ca04f111SAriel Constenla-Haile     }
27823c0a6f8SAriel Constenla-Haile }
279cdf0e10cSrcweir 
28023c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
281cdf0e10cSrcweir 
28223c0a6f8SAriel Constenla-Haile AboutDialog::AboutDialog( Window* pParent, const ResId& rId ) :
28323c0a6f8SAriel Constenla-Haile     SfxModalDialog( pParent, rId ),
28423c0a6f8SAriel Constenla-Haile     maOKButton( this, ResId( RID_CUI_ABOUT_BTN_OK, *rId.GetResMgr() ) ),
285ca04f111SAriel Constenla-Haile     maReadmeButton( this, ResId( RID_CUI_ABOUT_BTN_README, *rId.GetResMgr() ) ),
28623c0a6f8SAriel Constenla-Haile     maVersionText( this, ResId( RID_CUI_ABOUT_FTXT_VERSION, *rId.GetResMgr() ) ),
28723c0a6f8SAriel Constenla-Haile     maBuildInfoEdit( this, ResId( RID_CUI_ABOUT_FTXT_BUILDDATA, *rId.GetResMgr() ) ),
28823c0a6f8SAriel Constenla-Haile     maCopyrightEdit( this, ResId( RID_CUI_ABOUT_FTXT_COPYRIGHT, *rId.GetResMgr() ) ),
28923c0a6f8SAriel Constenla-Haile     maCreditsLink( this, ResId( RID_CUI_ABOUT_FTXT_WELCOME_LINK, *rId.GetResMgr() )  ),
29023c0a6f8SAriel Constenla-Haile     maCopyrightTextStr( ResId( RID_CUI_ABOUT_STR_COPYRIGHT, *rId.GetResMgr() ) )
29123c0a6f8SAriel Constenla-Haile {
2927168672cSAriel Constenla-Haile     bool bLoad = vcl::ImageRepository::loadBrandingImage(
2937168672cSAriel Constenla-Haile             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("about")),
2947168672cSAriel Constenla-Haile             maAppLogo );
2957168672cSAriel Constenla-Haile     OSL_ENSURE( bLoad, "Can't load about image");
2967168672cSAriel Constenla-Haile 
2977168672cSAriel Constenla-Haile     bLoad = vcl::ImageRepository::loadBrandingImage(
2987168672cSAriel Constenla-Haile             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("logo")),
2997168672cSAriel Constenla-Haile             maMainLogo );
3007168672cSAriel Constenla-Haile     OSL_ENSURE( bLoad, "Can't load logo image");
301cdf0e10cSrcweir 
30223c0a6f8SAriel Constenla-Haile     InitControls();
30323c0a6f8SAriel Constenla-Haile 
30423c0a6f8SAriel Constenla-Haile     // set links
305ca04f111SAriel Constenla-Haile     maReadmeButton.SetClickHdl( LINK( this, AboutDialog, ShowReadme_Impl ) );
30623c0a6f8SAriel Constenla-Haile     maCreditsLink.SetClickHdl( LINK( this, AboutDialog, OpenLinkHdl_Impl ) );
30723c0a6f8SAriel Constenla-Haile 
30823c0a6f8SAriel Constenla-Haile     FreeResource();
30923c0a6f8SAriel Constenla-Haile 
31023c0a6f8SAriel Constenla-Haile     SetHelpId( CMD_SID_ABOUT );
311cdf0e10cSrcweir }
312cdf0e10cSrcweir 
31323c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
314cdf0e10cSrcweir 
31523c0a6f8SAriel Constenla-Haile AboutDialog::~AboutDialog()
316cdf0e10cSrcweir {
31723c0a6f8SAriel Constenla-Haile }
318cdf0e10cSrcweir 
31923c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
320cdf0e10cSrcweir 
32123c0a6f8SAriel Constenla-Haile void AboutDialog::InitControls()
32223c0a6f8SAriel Constenla-Haile {
32323c0a6f8SAriel Constenla-Haile     // apply font, background et al.
32423c0a6f8SAriel Constenla-Haile     ApplyStyleSettings();
325cdf0e10cSrcweir 
32623c0a6f8SAriel Constenla-Haile     // set strings
32723c0a6f8SAriel Constenla-Haile     maCopyrightEdit.SetText( maCopyrightTextStr );
32823c0a6f8SAriel Constenla-Haile     maBuildInfoEdit.SetText( GetBuildVersionString() );
32923c0a6f8SAriel Constenla-Haile     maCreditsLink.SetURL( maCreditsLink.GetText() );
330cdf0e10cSrcweir 
33123c0a6f8SAriel Constenla-Haile     // determine size and position of the dialog & elements
33223c0a6f8SAriel Constenla-Haile     Size aDlgSize;
33323c0a6f8SAriel Constenla-Haile     LayoutControls( aDlgSize );
33423c0a6f8SAriel Constenla-Haile 
33523c0a6f8SAriel Constenla-Haile     // Change the width of the dialog
33623c0a6f8SAriel Constenla-Haile     SetOutputSizePixel( aDlgSize );
33723c0a6f8SAriel Constenla-Haile }
33823c0a6f8SAriel Constenla-Haile 
33923c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
34023c0a6f8SAriel Constenla-Haile 
34123c0a6f8SAriel Constenla-Haile void AboutDialog::ApplyStyleSettings()
34223c0a6f8SAriel Constenla-Haile {
34323c0a6f8SAriel Constenla-Haile     // Transparenter Font
34423c0a6f8SAriel Constenla-Haile     Font aFont = GetFont();
345cdf0e10cSrcweir     aFont.SetTransparent( sal_True );
34623c0a6f8SAriel Constenla-Haile     SetFont( aFont );
34723c0a6f8SAriel Constenla-Haile 
34823c0a6f8SAriel Constenla-Haile     // set for background and text the correct system color
34923c0a6f8SAriel Constenla-Haile     const StyleSettings& rSettings = GetSettings().GetStyleSettings();
3507168672cSAriel Constenla-Haile     Color aWindowColor( rSettings.GetWindowColor() );
3517168672cSAriel Constenla-Haile     Wallpaper aWall( aWindowColor );
35223c0a6f8SAriel Constenla-Haile     SetBackground( aWall );
353*910823aeSJürgen Schmidt 
35423c0a6f8SAriel Constenla-Haile     Font aNewFont( maCopyrightEdit.GetFont() );
35523c0a6f8SAriel Constenla-Haile     aNewFont.SetTransparent( sal_True );
35623c0a6f8SAriel Constenla-Haile 
35723c0a6f8SAriel Constenla-Haile     maVersionText.SetFont( aNewFont );
35823c0a6f8SAriel Constenla-Haile     maCopyrightEdit.SetFont( aNewFont );
35923c0a6f8SAriel Constenla-Haile 
3607168672cSAriel Constenla-Haile     maVersionText.SetBackground(aWall);
3617168672cSAriel Constenla-Haile     maCopyrightEdit.SetBackground(aWall);
3627168672cSAriel Constenla-Haile     maBuildInfoEdit.SetBackground(aWall);
3637168672cSAriel Constenla-Haile     maCreditsLink.SetBackground(aWall);
36423c0a6f8SAriel Constenla-Haile 
36523c0a6f8SAriel Constenla-Haile     Color aTextColor( rSettings.GetWindowTextColor() );
36623c0a6f8SAriel Constenla-Haile     maVersionText.SetControlForeground( aTextColor );
36723c0a6f8SAriel Constenla-Haile     maCopyrightEdit.SetControlForeground( aTextColor );
36823c0a6f8SAriel Constenla-Haile     maBuildInfoEdit.SetControlForeground( aTextColor );
36923c0a6f8SAriel Constenla-Haile     maCreditsLink.SetControlForeground();
37023c0a6f8SAriel Constenla-Haile 
37123c0a6f8SAriel Constenla-Haile     Size aSmaller = aNewFont.GetSize();
37223c0a6f8SAriel Constenla-Haile     aSmaller.Width() = (long) (aSmaller.Width() * 0.75);
37323c0a6f8SAriel Constenla-Haile     aSmaller.Height() = (long) (aSmaller.Height() * 0.75);
37423c0a6f8SAriel Constenla-Haile     aNewFont.SetSize( aSmaller );
37523c0a6f8SAriel Constenla-Haile 
37623c0a6f8SAriel Constenla-Haile     maBuildInfoEdit.SetFont( aNewFont );
37723c0a6f8SAriel Constenla-Haile 
37823c0a6f8SAriel Constenla-Haile     // the following is a hack to force the MultiLineEdit update its settings
37923c0a6f8SAriel Constenla-Haile     // in order to reflect the Font
38023c0a6f8SAriel Constenla-Haile     // See
38123c0a6f8SAriel Constenla-Haile     //      Window::SetControlFont
38223c0a6f8SAriel Constenla-Haile     //      MultiLineEdit::StateChanged
38323c0a6f8SAriel Constenla-Haile     //      MultiLineEdit::ImplInitSettings
38423c0a6f8SAriel Constenla-Haile     // TODO Override SetFont in MultiLineEdit and do the following,
38523c0a6f8SAriel Constenla-Haile     // otherwise SetFont has no effect at all!
38623c0a6f8SAriel Constenla-Haile     aSmaller = PixelToLogic( aSmaller, MAP_POINT );
38723c0a6f8SAriel Constenla-Haile     aNewFont.SetSize( aSmaller );
38823c0a6f8SAriel Constenla-Haile     maBuildInfoEdit.SetControlFont( aNewFont );
38923c0a6f8SAriel Constenla-Haile }
3908bd5297cSJürgen Schmidt 
39123c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
392cdf0e10cSrcweir 
39323c0a6f8SAriel Constenla-Haile void AboutDialog::LayoutControls( Size& aDlgSize )
39423c0a6f8SAriel Constenla-Haile {
395ca04f111SAriel Constenla-Haile     Size aMainLogoSz = maMainLogo.GetSizePixel();
39623c0a6f8SAriel Constenla-Haile     Size aAppLogoSiz = maAppLogo.GetSizePixel();
39723c0a6f8SAriel Constenla-Haile 
39823c0a6f8SAriel Constenla-Haile     aDlgSize = GetOutputSizePixel();
399325547baSAriel Constenla-Haile     long nCol1 = aMainLogoSz.Width();
400325547baSAriel Constenla-Haile     long nCol2 = aAppLogoSiz.Width() ? aAppLogoSiz.Width() : aDlgSize.Width();
401cdf0e10cSrcweir 
40223c0a6f8SAriel Constenla-Haile     Size a6Size      = maVersionText.LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
40323c0a6f8SAriel Constenla-Haile     long nDlgMargin  = a6Size.Width() * 2;
404cdf0e10cSrcweir     long nCtrlMargin = a6Size.Height() * 2;
405325547baSAriel Constenla-Haile     long nTextWidth  = nCol2 - nDlgMargin;
406ca04f111SAriel Constenla-Haile     long nY          = aAppLogoSiz.Height() + a6Size.Height();
407ca04f111SAriel Constenla-Haile 
408325547baSAriel Constenla-Haile     aDlgSize.Width() = nCol1 + a6Size.Width() + nCol2;
409cdf0e10cSrcweir 
410325547baSAriel Constenla-Haile     Point aPos( nCol1 + a6Size.Width(), nY );
41123c0a6f8SAriel Constenla-Haile     Size aSize;
41223c0a6f8SAriel Constenla-Haile     // layout fixed text control
413ca04f111SAriel Constenla-Haile     lcl_layoutFixedText( maVersionText, aPos, aSize, nTextWidth );
414ca04f111SAriel Constenla-Haile     nY += aSize.Height() + a6Size.Height();
415a392ac37SAriel Constenla-Haile 
41623c0a6f8SAriel Constenla-Haile     // Multiline edit with Build info
41723c0a6f8SAriel Constenla-Haile     aPos.Y() = nY;
418ca04f111SAriel Constenla-Haile     lcl_layoutEdit( maBuildInfoEdit, aPos, aSize, nTextWidth );
419ca04f111SAriel Constenla-Haile     nY += aSize.Height() + a6Size.Height();
420a392ac37SAriel Constenla-Haile 
421cdf0e10cSrcweir     // Multiline edit with Copyright-Text
42223c0a6f8SAriel Constenla-Haile     aPos.Y() = nY;
423ca04f111SAriel Constenla-Haile     lcl_layoutEdit( maCopyrightEdit, aPos, aSize, nTextWidth );
424ca04f111SAriel Constenla-Haile     nY += aSize.Height() + a6Size.Height();
42523c0a6f8SAriel Constenla-Haile 
42623c0a6f8SAriel Constenla-Haile     // Hyperlink
42723c0a6f8SAriel Constenla-Haile     aPos.Y() = nY;
428ca04f111SAriel Constenla-Haile     lcl_layoutFixedText( maCreditsLink, aPos, aSize, nTextWidth );
429ca04f111SAriel Constenla-Haile     nY += aSize.Height();
430ca04f111SAriel Constenla-Haile 
431ca04f111SAriel Constenla-Haile     nY = std::max( nY, aMainLogoSz.Height() );
432ca04f111SAriel Constenla-Haile     nY += nCtrlMargin;
433ca04f111SAriel Constenla-Haile 
434ca04f111SAriel Constenla-Haile     // logos position
435ca04f111SAriel Constenla-Haile     maMainLogoPos = Point( 0, nY / 2 - aMainLogoSz.Height() / 2 );
436325547baSAriel Constenla-Haile     maAppLogoPos = Point( nCol1 + a6Size.Width(), 0 );
43723c0a6f8SAriel Constenla-Haile 
43823c0a6f8SAriel Constenla-Haile     // OK-Button-Position (at the bottom and centered)
43923c0a6f8SAriel Constenla-Haile     Size aOKSiz = maOKButton.GetSizePixel();
440ca04f111SAriel Constenla-Haile     Point aOKPnt( ( aDlgSize.Width() - aOKSiz.Width() ) - a6Size.Width(), nY );
44123c0a6f8SAriel Constenla-Haile     maOKButton.SetPosPixel( aOKPnt );
44223c0a6f8SAriel Constenla-Haile 
443ca04f111SAriel Constenla-Haile     maReadmeButton.SetPosPixel( Point(a6Size.Width(), nY) );
444ca04f111SAriel Constenla-Haile 
445ca04f111SAriel Constenla-Haile     aDlgSize.Height() = aOKPnt.Y() + aOKSiz.Height() + a6Size.Width();
44623c0a6f8SAriel Constenla-Haile }
447cdf0e10cSrcweir 
44823c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
449cdf0e10cSrcweir 
45023c0a6f8SAriel Constenla-Haile const rtl::OUString AboutDialog::GetBuildId() const
45123c0a6f8SAriel Constenla-Haile {
45223c0a6f8SAriel Constenla-Haile     rtl::OUString sDefault;
453cdf0e10cSrcweir 
45423c0a6f8SAriel Constenla-Haile     // Get buildid from version[rc|.ini]
45523c0a6f8SAriel Constenla-Haile     rtl::OUString sBuildId( utl::Bootstrap::getBuildIdData( sDefault ) );
45623c0a6f8SAriel Constenla-Haile     OSL_ENSURE( sBuildId.getLength() > 0, "No BUILDID in bootstrap file" );
45723c0a6f8SAriel Constenla-Haile     rtl::OUStringBuffer sBuildIdBuff( sBuildId );
458cdf0e10cSrcweir 
45923c0a6f8SAriel Constenla-Haile     // Get ProductSource from version[rc|.ini]
46023c0a6f8SAriel Constenla-Haile     rtl::OUString sProductSource( utl::Bootstrap::getProductSource( sDefault ) );
46123c0a6f8SAriel Constenla-Haile     OSL_ENSURE( sProductSource.getLength() > 0, "No ProductSource in bootstrap file" );
462cdf0e10cSrcweir 
46323c0a6f8SAriel Constenla-Haile     // the product source is something like "AOO340",
46423c0a6f8SAriel Constenla-Haile     // while the build id is something like "340m1(Build:9590)"
46523c0a6f8SAriel Constenla-Haile     // For better readability, strip the duplicate ProductMajor ("340").
46623c0a6f8SAriel Constenla-Haile     if ( sProductSource.getLength() )
46723c0a6f8SAriel Constenla-Haile     {
46823c0a6f8SAriel Constenla-Haile         bool bMatchingUPD =
46923c0a6f8SAriel Constenla-Haile                 ( sProductSource.getLength() >= 3 )
47023c0a6f8SAriel Constenla-Haile             &&  ( sBuildId.getLength() >= 3 )
47123c0a6f8SAriel Constenla-Haile             &&  ( sProductSource.copy( sProductSource.getLength() - 3 ) == sBuildId.copy( 0, 3 ) );
47223c0a6f8SAriel Constenla-Haile         OSL_ENSURE( bMatchingUPD, "BUILDID and ProductSource do not match in their UPD" );
47323c0a6f8SAriel Constenla-Haile         if ( bMatchingUPD )
47423c0a6f8SAriel Constenla-Haile             sProductSource = sProductSource.copy( 0, sProductSource.getLength() - 3 );
475cdf0e10cSrcweir 
47623c0a6f8SAriel Constenla-Haile         // prepend the product source
47723c0a6f8SAriel Constenla-Haile         sBuildIdBuff.insert( 0, sProductSource );
47823c0a6f8SAriel Constenla-Haile     }
479cdf0e10cSrcweir 
48023c0a6f8SAriel Constenla-Haile     return sBuildIdBuff.makeStringAndClear();
481cdf0e10cSrcweir }
482cdf0e10cSrcweir 
483cdf0e10cSrcweir // -----------------------------------------------------------------------
484cdf0e10cSrcweir 
48523c0a6f8SAriel Constenla-Haile const rtl::OUString AboutDialog::GetBuildVersionString() const
486cdf0e10cSrcweir {
48723c0a6f8SAriel Constenla-Haile     rtl::OUStringBuffer aBuildString( GetBuildId() );
48823c0a6f8SAriel Constenla-Haile     rtl::OUString sRevision( utl::Bootstrap::getRevisionInfo() );
489cdf0e10cSrcweir 
49023c0a6f8SAriel Constenla-Haile     if ( sRevision.getLength() > 0 )
49123c0a6f8SAriel Constenla-Haile     {
49223c0a6f8SAriel Constenla-Haile         aBuildString.appendAscii( RTL_CONSTASCII_STRINGPARAM( "  -  Rev. " ) );
49323c0a6f8SAriel Constenla-Haile         aBuildString.append( sRevision );
49423c0a6f8SAriel Constenla-Haile     }
495cdf0e10cSrcweir 
49623c0a6f8SAriel Constenla-Haile #ifdef BUILD_VER_STRING
49723c0a6f8SAriel Constenla-Haile     rtl::OUString sBuildVer( RTL_CONSTASCII_USTRINGPARAM( STRINGIFY( BUILD_VER_STRING ) ) );
49823c0a6f8SAriel Constenla-Haile     if ( sBuildVer.getLength() > 0 )
49923c0a6f8SAriel Constenla-Haile     {
50023c0a6f8SAriel Constenla-Haile         aBuildString.append( sal_Unicode( '\n' ) );
50123c0a6f8SAriel Constenla-Haile         aBuildString.append( sBuildVer );
50223c0a6f8SAriel Constenla-Haile     }
503cdf0e10cSrcweir #endif
504cdf0e10cSrcweir 
50523c0a6f8SAriel Constenla-Haile     return aBuildString.makeStringAndClear();
506cdf0e10cSrcweir }
507cdf0e10cSrcweir 
508cdf0e10cSrcweir // -----------------------------------------------------------------------
509cdf0e10cSrcweir 
510cdf0e10cSrcweir sal_Bool AboutDialog::Close()
511cdf0e10cSrcweir {
51223c0a6f8SAriel Constenla-Haile     EndDialog( RET_OK );
51323c0a6f8SAriel Constenla-Haile     return( sal_False );
514cdf0e10cSrcweir }
515cdf0e10cSrcweir 
516cdf0e10cSrcweir // -----------------------------------------------------------------------
517cdf0e10cSrcweir 
518cdf0e10cSrcweir void AboutDialog::Paint( const Rectangle& rRect )
519cdf0e10cSrcweir {
52023c0a6f8SAriel Constenla-Haile     SetClipRegion( rRect );
521*910823aeSJürgen Schmidt 
522*910823aeSJürgen Schmidt     // workaround to ensure that the background is painted correct
523*910823aeSJürgen Schmidt     // on MacOS for exmaple the background was grey and the image and other controls white
524*910823aeSJürgen Schmidt     SetFillColor(GetSettings().GetStyleSettings().GetWindowColor());
525*910823aeSJürgen Schmidt     SetLineColor();
526*910823aeSJürgen Schmidt     DrawRect(rRect);
527*910823aeSJürgen Schmidt 
528ca04f111SAriel Constenla-Haile     DrawImage( maMainLogoPos, maMainLogo );
529ca04f111SAriel Constenla-Haile     DrawImage( maAppLogoPos, maAppLogo );
53023c0a6f8SAriel Constenla-Haile 
53123c0a6f8SAriel Constenla-Haile     return;
53223c0a6f8SAriel Constenla-Haile }
53323c0a6f8SAriel Constenla-Haile 
53423c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
53523c0a6f8SAriel Constenla-Haile 
53623c0a6f8SAriel Constenla-Haile IMPL_LINK ( AboutDialog, OpenLinkHdl_Impl, svt::FixedHyperlink*, EMPTYARG )
53723c0a6f8SAriel Constenla-Haile {
53823c0a6f8SAriel Constenla-Haile     ::rtl::OUString sURL( maCreditsLink.GetURL() );
53923c0a6f8SAriel Constenla-Haile     if ( sURL.getLength() > 0 )
54023c0a6f8SAriel Constenla-Haile     {
54123c0a6f8SAriel Constenla-Haile         try
54223c0a6f8SAriel Constenla-Haile         {
5434ad1da77SJian Fang Zhang             uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShell(
5449807c9deSAriel Constenla-Haile                 com::sun::star::system::SystemShellExecute::create(
5459807c9deSAriel Constenla-Haile                     ::comphelper::getProcessComponentContext() ) );
54623c0a6f8SAriel Constenla-Haile             if ( xSystemShell.is() )
5474ad1da77SJian Fang Zhang                 xSystemShell->execute( sURL, rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::DEFAULTS );
54823c0a6f8SAriel Constenla-Haile         }
5497168672cSAriel Constenla-Haile         catch( const uno::Exception& e )
55023c0a6f8SAriel Constenla-Haile         {
55123c0a6f8SAriel Constenla-Haile              OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
55223c0a6f8SAriel Constenla-Haile                 rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
55323c0a6f8SAriel Constenla-Haile         }
55423c0a6f8SAriel Constenla-Haile     }
5557168672cSAriel Constenla-Haile 
55623c0a6f8SAriel Constenla-Haile     return 0;
557cdf0e10cSrcweir }
558ca04f111SAriel Constenla-Haile 
559ca04f111SAriel Constenla-Haile IMPL_LINK ( AboutDialog, ShowReadme_Impl, PushButton*, EMPTYARG )
560ca04f111SAriel Constenla-Haile {
561ca04f111SAriel Constenla-Haile     ReadmeDialog aDlg( this );
562ca04f111SAriel Constenla-Haile     aDlg.Execute();
563ca04f111SAriel Constenla-Haile 
564ca04f111SAriel Constenla-Haile     return 0;
565ca04f111SAriel Constenla-Haile }
566