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
10cdf0e10cSrcweir *
112ee96f1cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
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.
19cdf0e10cSrcweir *
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>
314524451eSJürgen Schmidt //#include <rtl/ustrbuf.hxx>
32cdf0e10cSrcweir #include <sfx2/sfxcommands.h>
33ca04f111SAriel Constenla-Haile #include <sfx2/sfxdefs.hxx>
34ca04f111SAriel Constenla-Haile #include <sfx2/sfxuno.hxx>
35ca04f111SAriel Constenla-Haile #include <svtools/filter.hxx>
36cdf0e10cSrcweir #include <svtools/svtools.hrc>
37ca04f111SAriel Constenla-Haile #include <tools/stream.hxx>
38ca04f111SAriel Constenla-Haile #include <tools/urlobj.hxx>
39ca04f111SAriel Constenla-Haile #include <unotools/bootstrap.hxx>
40ca04f111SAriel Constenla-Haile #include <unotools/configmgr.hxx>
41ca04f111SAriel Constenla-Haile #include <vcl/graph.hxx>
427168672cSAriel Constenla-Haile #include <vcl/imagerepository.hxx>
43ca04f111SAriel Constenla-Haile #include <vcl/msgbox.hxx>
44ca04f111SAriel Constenla-Haile #include <vcl/svapp.hxx>
45ca04f111SAriel Constenla-Haile #include <vcl/tabctrl.hxx>
46ca04f111SAriel Constenla-Haile #include <vcl/tabdlg.hxx>
47ca04f111SAriel Constenla-Haile #include <vcl/tabpage.hxx>
48cdf0e10cSrcweir
4923c0a6f8SAriel Constenla-Haile #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
509807c9deSAriel Constenla-Haile #include <com/sun/star/system/SystemShellExecute.hpp>
517168672cSAriel Constenla-Haile #include <com/sun/star/uno/Any.h>
5223c0a6f8SAriel Constenla-Haile
53ca04f111SAriel Constenla-Haile #include "about.hxx"
54ca04f111SAriel Constenla-Haile #include "about.hrc"
55cdf0e10cSrcweir
56a392ac37SAriel Constenla-Haile #define _STRINGIFY(x) #x
57a392ac37SAriel Constenla-Haile #define STRINGIFY(x) _STRINGIFY(x)
58cdf0e10cSrcweir
597168672cSAriel Constenla-Haile /* On Windows/OS2, all the three files have .txt extension
607168672cSAriel Constenla-Haile and the README file name is in lowercase
617168672cSAriel Constenla-Haile Readme files are localized and have the locale in their file name:
627168672cSAriel Constenla-Haile README_de README_en-US
637168672cSAriel Constenla-Haile */
647168672cSAriel Constenla-Haile #if defined(WNT) || defined(OS2)
657168672cSAriel Constenla-Haile #define FILE_EXTENSION ".txt"
667168672cSAriel Constenla-Haile #define README_FILE "readme"
677168672cSAriel Constenla-Haile #else
687168672cSAriel Constenla-Haile #define FILE_EXTENSION
697168672cSAriel Constenla-Haile #define README_FILE "README"
707168672cSAriel Constenla-Haile #endif
717168672cSAriel Constenla-Haile #define LICENSE_FILE "LICENSE" FILE_EXTENSION
727168672cSAriel Constenla-Haile #define NOTICE_FILE "NOTICE" FILE_EXTENSION
737168672cSAriel Constenla-Haile
747168672cSAriel Constenla-Haile // Dir where the files are located
75910823aeSJürgen Schmidt #define OOO_DIR_SHARE_README "${OOO_BASE_DIR}/share/readme/"
767168672cSAriel Constenla-Haile
777168672cSAriel Constenla-Haile using namespace com::sun::star;
787168672cSAriel Constenla-Haile
79ca04f111SAriel Constenla-Haile namespace
80ca04f111SAriel Constenla-Haile {
81cdf0e10cSrcweir
lcl_layoutFixedText(FixedText & rControl,const Point & aPos,Size & aSize,const long nTextWidth)82ca04f111SAriel Constenla-Haile static void lcl_layoutFixedText( FixedText &rControl,
83ca04f111SAriel Constenla-Haile const Point& aPos,
84ca04f111SAriel Constenla-Haile Size &aSize,
85ca04f111SAriel Constenla-Haile const long nTextWidth )
86a392ac37SAriel Constenla-Haile {
8723c0a6f8SAriel Constenla-Haile aSize = rControl.GetSizePixel();
8823c0a6f8SAriel Constenla-Haile // change the width
8923c0a6f8SAriel Constenla-Haile aSize.Width() = nTextWidth;
9023c0a6f8SAriel Constenla-Haile // set Position and Size, to calculate the minimum size
9123c0a6f8SAriel Constenla-Haile // this will update the Height
9223c0a6f8SAriel Constenla-Haile rControl.SetPosSizePixel( aPos, aSize );
9323c0a6f8SAriel Constenla-Haile aSize = rControl.CalcMinimumSize();
9423c0a6f8SAriel Constenla-Haile // update the size with the right Height
9523c0a6f8SAriel Constenla-Haile rControl.SetSizePixel( aSize );
96a392ac37SAriel Constenla-Haile }
97cdf0e10cSrcweir
lcl_layoutEdit(Edit & rControl,const Point & aPos,Size & aSize,const long nTextWidth)98ca04f111SAriel Constenla-Haile static void lcl_layoutEdit( Edit &rControl,
99ca04f111SAriel Constenla-Haile const Point& aPos,
100ca04f111SAriel Constenla-Haile Size &aSize,
101ca04f111SAriel Constenla-Haile const long nTextWidth )
10223c0a6f8SAriel Constenla-Haile {
10323c0a6f8SAriel Constenla-Haile aSize = rControl.GetSizePixel();
10423c0a6f8SAriel Constenla-Haile // change the width
10523c0a6f8SAriel Constenla-Haile aSize.Width() = nTextWidth;
10623c0a6f8SAriel Constenla-Haile // set Position and Size, to calculate the minimum size
10723c0a6f8SAriel Constenla-Haile // this will update the Height
10823c0a6f8SAriel Constenla-Haile rControl.SetPosSizePixel( aPos, aSize );
10923c0a6f8SAriel Constenla-Haile aSize = rControl.CalcMinimumSize();
11023c0a6f8SAriel Constenla-Haile // update the size with the right Height
11123c0a6f8SAriel Constenla-Haile rControl.SetSizePixel( aSize );
11223c0a6f8SAriel Constenla-Haile }
113cdf0e10cSrcweir
lcl_readTxtFile(const rtl::OUString & rFile,rtl::OUString & sText)114ca04f111SAriel Constenla-Haile static void lcl_readTxtFile( const rtl::OUString &rFile, rtl::OUString &sText )
115ca04f111SAriel Constenla-Haile {
116ca04f111SAriel Constenla-Haile rtl::OUString sFile( rFile );
117ca04f111SAriel Constenla-Haile rtl::Bootstrap::expandMacros( sFile );
118ca04f111SAriel Constenla-Haile osl::File aFile(sFile);
119ca04f111SAriel Constenla-Haile if ( aFile.open(OpenFlag_Read) == osl::FileBase::E_None )
120ca04f111SAriel Constenla-Haile {
121ca04f111SAriel Constenla-Haile osl::DirectoryItem aItem;
122ca04f111SAriel Constenla-Haile osl::DirectoryItem::get(sFile, aItem);
123ca04f111SAriel Constenla-Haile
124ca04f111SAriel Constenla-Haile osl::FileStatus aStatus(FileStatusMask_FileSize);
125ca04f111SAriel Constenla-Haile aItem.getFileStatus(aStatus);
126ca04f111SAriel Constenla-Haile
127ca04f111SAriel Constenla-Haile sal_uInt64 nBytesRead = 0;
128ca04f111SAriel Constenla-Haile sal_uInt64 nPosition = 0;
129ca04f111SAriel Constenla-Haile sal_uInt32 nBytes = (sal_uInt32)aStatus.getFileSize();
130ca04f111SAriel Constenla-Haile
131ca04f111SAriel Constenla-Haile sal_Char *pBuffer = new sal_Char[nBytes];
132ca04f111SAriel Constenla-Haile
133ca04f111SAriel Constenla-Haile while ( aFile.read( pBuffer + nPosition,
134ca04f111SAriel Constenla-Haile nBytes-nPosition,
135ca04f111SAriel Constenla-Haile nBytesRead ) == osl::FileBase::E_None
136ca04f111SAriel Constenla-Haile && nPosition + nBytesRead < nBytes)
137ca04f111SAriel Constenla-Haile {
138ca04f111SAriel Constenla-Haile nPosition += nBytesRead;
139ca04f111SAriel Constenla-Haile }
140ca04f111SAriel Constenla-Haile
141ca04f111SAriel Constenla-Haile OSL_ENSURE( nBytes < STRING_MAXLEN, "Text file has too much bytes!" );
142ca04f111SAriel Constenla-Haile if ( nBytes > STRING_MAXLEN )
143ca04f111SAriel Constenla-Haile nBytes = STRING_MAXLEN - 1;
144ca04f111SAriel Constenla-Haile
145ca04f111SAriel Constenla-Haile sText = rtl::OUString( pBuffer,
146ca04f111SAriel Constenla-Haile nBytes,
147ca04f111SAriel Constenla-Haile RTL_TEXTENCODING_UTF8,
148ca04f111SAriel Constenla-Haile OSTRING_TO_OUSTRING_CVTFLAGS
149ca04f111SAriel Constenla-Haile | RTL_TEXTTOUNICODE_FLAGS_GLOBAL_SIGNATURE);
150ca04f111SAriel Constenla-Haile delete[] pBuffer;
151ca04f111SAriel Constenla-Haile }
152ca04f111SAriel Constenla-Haile }
153ca04f111SAriel Constenla-Haile
154ca04f111SAriel Constenla-Haile class ReadmeDialog;
155ca04f111SAriel Constenla-Haile
156ca04f111SAriel Constenla-Haile class ReadmeTabPage : public TabPage
157ca04f111SAriel Constenla-Haile {
158ca04f111SAriel Constenla-Haile private:
159ca04f111SAriel Constenla-Haile MultiLineEdit maText;
160ca04f111SAriel Constenla-Haile String msText;
161ca04f111SAriel Constenla-Haile
162ca04f111SAriel Constenla-Haile public:
163ca04f111SAriel Constenla-Haile ReadmeTabPage(Window *pParent, const String &sText);
164ca04f111SAriel Constenla-Haile ~ReadmeTabPage();
165ca04f111SAriel Constenla-Haile
166ca04f111SAriel Constenla-Haile void Adjust(const Size &aSz, const Size &a6Size);
167ca04f111SAriel Constenla-Haile };
168ca04f111SAriel Constenla-Haile
ReadmeTabPage(Window * pParent,const String & sText)169ca04f111SAriel Constenla-Haile ReadmeTabPage::ReadmeTabPage(Window *pParent, const String &sText)
170ca04f111SAriel Constenla-Haile : TabPage(pParent, CUI_RES( RID_CUI_README_TBPAGE))
171ca04f111SAriel Constenla-Haile ,maText( this, CUI_RES( RID_CUI_README_TBPAGE_EDIT ))
172ca04f111SAriel Constenla-Haile ,msText( sText )
173ca04f111SAriel Constenla-Haile {
174ca04f111SAriel Constenla-Haile FreeResource();
175ca04f111SAriel Constenla-Haile
176ca04f111SAriel Constenla-Haile maText.SetText(msText);
177ca04f111SAriel Constenla-Haile maText.Show();
178ca04f111SAriel Constenla-Haile }
179ca04f111SAriel Constenla-Haile
~ReadmeTabPage()180ca04f111SAriel Constenla-Haile ReadmeTabPage::~ReadmeTabPage()
181ca04f111SAriel Constenla-Haile {
182ca04f111SAriel Constenla-Haile }
183ca04f111SAriel Constenla-Haile
Adjust(const Size & aSz,const Size & a6Size)184ca04f111SAriel Constenla-Haile void ReadmeTabPage::Adjust(const Size &aSz, const Size &a6Size)
185ca04f111SAriel Constenla-Haile {
186ca04f111SAriel Constenla-Haile long nDlgMargin = a6Size.Width() * 2;
187ca04f111SAriel Constenla-Haile long nCtrlMargin = a6Size.Height() * 2;
188ca04f111SAriel Constenla-Haile maText.SetPosPixel( Point(a6Size.Width(), a6Size.Height()) );
189ca04f111SAriel Constenla-Haile maText.SetSizePixel( Size(aSz.Width() - nDlgMargin, aSz.Height() - nCtrlMargin) );
190ca04f111SAriel Constenla-Haile }
191ca04f111SAriel Constenla-Haile
192ca04f111SAriel Constenla-Haile class ReadmeDialog : public ModalDialog
193ca04f111SAriel Constenla-Haile {
194ca04f111SAriel Constenla-Haile private:
195ca04f111SAriel Constenla-Haile TabControl maTabCtrl;
196ca04f111SAriel Constenla-Haile OKButton maBtnOK;
197ca04f111SAriel Constenla-Haile
198ca04f111SAriel Constenla-Haile ReadmeTabPage *maReadmeTabPage;
199ca04f111SAriel Constenla-Haile ReadmeTabPage *maLicenseTabPage;
200ca04f111SAriel Constenla-Haile ReadmeTabPage *maNoticeTabPage;
201ca04f111SAriel Constenla-Haile
202ca04f111SAriel Constenla-Haile DECL_LINK( ActivatePageHdl, TabControl * );
203ca04f111SAriel Constenla-Haile DECL_LINK( DeactivatePageHdl, TabControl * );
204ca04f111SAriel Constenla-Haile
205ca04f111SAriel Constenla-Haile public:
206ca04f111SAriel Constenla-Haile ReadmeDialog( Window* );
207ca04f111SAriel Constenla-Haile ~ReadmeDialog();
208ca04f111SAriel Constenla-Haile };
209ca04f111SAriel Constenla-Haile
ReadmeDialog(Window * pParent)210ca04f111SAriel Constenla-Haile ReadmeDialog::ReadmeDialog( Window * pParent )
211ca04f111SAriel Constenla-Haile : ModalDialog( pParent, CUI_RES( RID_CUI_README_DLG ) )
212ca04f111SAriel Constenla-Haile , maTabCtrl( this, CUI_RES(RID_CUI_README_TBCTL) )
213ca04f111SAriel Constenla-Haile , maBtnOK( this, CUI_RES(RID_CUI_README_OKBTN) )
214ca04f111SAriel Constenla-Haile , maReadmeTabPage(0)
215ca04f111SAriel Constenla-Haile , maLicenseTabPage(0)
216ca04f111SAriel Constenla-Haile , maNoticeTabPage(0)
217ca04f111SAriel Constenla-Haile {
218ca04f111SAriel Constenla-Haile FreeResource();
219ca04f111SAriel Constenla-Haile
220ca04f111SAriel Constenla-Haile maTabCtrl.Show();
221ca04f111SAriel Constenla-Haile
2227168672cSAriel Constenla-Haile // Notice and License are not localized
223910823aeSJürgen Schmidt const rtl::OUString sLicense( RTL_CONSTASCII_USTRINGPARAM( OOO_DIR_SHARE_README LICENSE_FILE ) );
224910823aeSJürgen Schmidt const rtl::OUString sNotice( RTL_CONSTASCII_USTRINGPARAM( OOO_DIR_SHARE_README NOTICE_FILE ) );
2257168672cSAriel Constenla-Haile
2267168672cSAriel Constenla-Haile // get localized README
2277168672cSAriel Constenla-Haile rtl::OUStringBuffer aBuff;
2287168672cSAriel Constenla-Haile lang::Locale aLocale = Application::GetSettings().GetUILocale();
229910823aeSJürgen Schmidt aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( OOO_DIR_SHARE_README README_FILE "_" ) );
2307168672cSAriel Constenla-Haile aBuff.append( aLocale.Language );
2317168672cSAriel Constenla-Haile if ( aLocale.Country.getLength() )
2327168672cSAriel Constenla-Haile {
2337168672cSAriel Constenla-Haile aBuff.append( sal_Unicode( '-') );
2347168672cSAriel Constenla-Haile aBuff.append( aLocale.Country );
2357168672cSAriel Constenla-Haile if ( aLocale.Variant.getLength() )
2367168672cSAriel Constenla-Haile {
2377168672cSAriel Constenla-Haile aBuff.append( sal_Unicode( '-' ) );
2387168672cSAriel Constenla-Haile aBuff.append( aLocale.Variant );
2397168672cSAriel Constenla-Haile }
2407168672cSAriel Constenla-Haile }
2417168672cSAriel Constenla-Haile #if defined(WNT) || defined(OS2)
2427168672cSAriel Constenla-Haile aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( FILE_EXTENSION ) );
2437168672cSAriel Constenla-Haile #endif
244ca04f111SAriel Constenla-Haile
245ca04f111SAriel Constenla-Haile rtl::OUString sReadmeTxt, sLicenseTxt, sNoticeTxt;
2467168672cSAriel Constenla-Haile lcl_readTxtFile( aBuff.makeStringAndClear(), sReadmeTxt );
247ca04f111SAriel Constenla-Haile lcl_readTxtFile( sLicense, sLicenseTxt );
248ca04f111SAriel Constenla-Haile lcl_readTxtFile( sNotice, sNoticeTxt );
249ca04f111SAriel Constenla-Haile
250ca04f111SAriel Constenla-Haile maReadmeTabPage = new ReadmeTabPage( &maTabCtrl, sReadmeTxt );
251ca04f111SAriel Constenla-Haile maLicenseTabPage = new ReadmeTabPage( &maTabCtrl, sLicenseTxt );
252ca04f111SAriel Constenla-Haile maNoticeTabPage = new ReadmeTabPage( &maTabCtrl, sNoticeTxt );
253ca04f111SAriel Constenla-Haile
254ca04f111SAriel Constenla-Haile maTabCtrl.SetTabPage( RID_CUI_READMEPAGE, maReadmeTabPage );
255ca04f111SAriel Constenla-Haile maTabCtrl.SetTabPage( RID_CUI_LICENSEPAGE, maLicenseTabPage );
256ca04f111SAriel Constenla-Haile maTabCtrl.SetTabPage( RID_CUI_NOTICEPAGE, maNoticeTabPage );
257ca04f111SAriel Constenla-Haile
258ca04f111SAriel Constenla-Haile maTabCtrl.SelectTabPage( RID_CUI_READMEPAGE );
259ca04f111SAriel Constenla-Haile
260ca04f111SAriel Constenla-Haile Size aTpSz = maReadmeTabPage->GetOutputSizePixel();
261ca04f111SAriel Constenla-Haile Size a6Size = maReadmeTabPage->LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
262ca04f111SAriel Constenla-Haile
263ca04f111SAriel Constenla-Haile maReadmeTabPage->Adjust( aTpSz, a6Size );
264ca04f111SAriel Constenla-Haile maLicenseTabPage->Adjust( aTpSz, a6Size );
265ca04f111SAriel Constenla-Haile maNoticeTabPage->Adjust( aTpSz, a6Size );
266ca04f111SAriel Constenla-Haile
267ca04f111SAriel Constenla-Haile Size aDlgSize = GetOutputSizePixel();
268ca04f111SAriel Constenla-Haile Size aOkBtnSz = maBtnOK.GetSizePixel();
269ca04f111SAriel Constenla-Haile Point aOKPnt( aDlgSize.Width() / 2 - aOkBtnSz.Width() / 2 , maBtnOK.GetPosPixel().Y() );
270ca04f111SAriel Constenla-Haile maBtnOK.SetPosPixel( aOKPnt );
271ca04f111SAriel Constenla-Haile }
272ca04f111SAriel Constenla-Haile
~ReadmeDialog()273ca04f111SAriel Constenla-Haile ReadmeDialog::~ReadmeDialog()
274ca04f111SAriel Constenla-Haile {
275ca04f111SAriel Constenla-Haile delete maReadmeTabPage;
276ca04f111SAriel Constenla-Haile delete maLicenseTabPage;
277ca04f111SAriel Constenla-Haile delete maNoticeTabPage;
278ca04f111SAriel Constenla-Haile }
279ca04f111SAriel Constenla-Haile }
280ca04f111SAriel Constenla-Haile
28123c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
282cdf0e10cSrcweir
AboutDialog(Window * pParent,const ResId & rId)28323c0a6f8SAriel Constenla-Haile AboutDialog::AboutDialog( Window* pParent, const ResId & rId ) :
28423c0a6f8SAriel Constenla-Haile SfxModalDialog( pParent, rId ),
28523c0a6f8SAriel Constenla-Haile maOKButton( this, ResId( RID_CUI_ABOUT_BTN_OK, *rId.GetResMgr() ) ),
286ca04f111SAriel Constenla-Haile maReadmeButton( this, ResId( RID_CUI_ABOUT_BTN_README, *rId.GetResMgr() ) ),
28723c0a6f8SAriel Constenla-Haile maVersionText( this, ResId( RID_CUI_ABOUT_FTXT_VERSION, *rId.GetResMgr() ) ),
28823c0a6f8SAriel Constenla-Haile maBuildInfoEdit( this, ResId( RID_CUI_ABOUT_FTXT_BUILDDATA, *rId.GetResMgr() ) ),
28923c0a6f8SAriel Constenla-Haile maCopyrightEdit( this, ResId( RID_CUI_ABOUT_FTXT_COPYRIGHT, *rId.GetResMgr() ) ),
2904524451eSJürgen Schmidt maCreditsLink( this, ResId( RID_CUI_ABOUT_FTXT_WELCOME_LINK, *rId.GetResMgr() ) )
2914524451eSJürgen Schmidt // maCopyrightTextStr( ResId( RID_CUI_ABOUT_STR_COPYRIGHT, *rId.GetResMgr() ) )
29223c0a6f8SAriel Constenla-Haile {
2937168672cSAriel Constenla-Haile bool bLoad = vcl::ImageRepository::loadBrandingImage(
2947168672cSAriel Constenla-Haile rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("about")),
2957168672cSAriel Constenla-Haile maAppLogo );
2967168672cSAriel Constenla-Haile OSL_ENSURE( bLoad, "Can't load about image");
2977168672cSAriel Constenla-Haile
2987168672cSAriel Constenla-Haile bLoad = vcl::ImageRepository::loadBrandingImage(
2997168672cSAriel Constenla-Haile rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("logo")),
3007168672cSAriel Constenla-Haile maMainLogo );
3017168672cSAriel Constenla-Haile OSL_ENSURE( bLoad, "Can't load logo image");
302cdf0e10cSrcweir
3034524451eSJürgen Schmidt const String vendor( ResId( RID_CUI_ABOUT_STR_COPYRIGHT_VENDOR, *rId.GetResMgr() ) );
3044524451eSJürgen Schmidt String createdRes( ResId( RID_CUI_ABOUT_STR_CREATED, *rId.GetResMgr() ) );
3054524451eSJürgen Schmidt if ( !vendor.EqualsAscii("Apache Software Foundation") ) {
3064524451eSJürgen Schmidt createdRes = String( ResId( RID_CUI_ABOUT_STR_CREATED_VENDOR, *rId.GetResMgr() ));
3074524451eSJürgen Schmidt }
3084524451eSJürgen Schmidt const String copyrightAcknowledge( ResId( RID_CUI_ABOUT_STR_ACKNOWLEDGE, *rId.GetResMgr() ) );
3094524451eSJürgen Schmidt
3104524451eSJürgen Schmidt rtl::OUStringBuffer sbcopyright(250);
3114524451eSJürgen Schmidt sbcopyright.appendAscii("Copyright ");
3124524451eSJürgen Schmidt sbcopyright.append((sal_Unicode)0x00a9);
3134524451eSJürgen Schmidt sbcopyright.appendAscii(" ");
31484aec320SJim Jagielski // TODO:
31584aec320SJim Jagielski // This date needs to be updated each year... do this automagically
31684aec320SJim Jagielski //
317*ee3ee635Smseidel rtl::OUString sYear( RTL_CONSTASCII_USTRINGPARAM("2025") );
3184524451eSJürgen Schmidt if (vendor.EqualsAscii("Apache Software Foundation")) {
3194524451eSJürgen Schmidt sbcopyright.append(sYear);
3204524451eSJürgen Schmidt sbcopyright.appendAscii(" The Apache Software Foundation.\n\n");
3214524451eSJürgen Schmidt } else {
3224524451eSJürgen Schmidt #ifdef COPYRIGHT_YEAR
3234524451eSJürgen Schmidt const rtl::OUString sDefYear( RTL_CONSTASCII_USTRINGPARAM( STRINGIFY( COPYRIGHT_YEAR ) ) );
3244524451eSJürgen Schmidt if ( sDefYear.getLength() > 0 )
3254524451eSJürgen Schmidt {
3264524451eSJürgen Schmidt sYear = sDefYear;
3274524451eSJürgen Schmidt }
3284524451eSJürgen Schmidt #endif
3294524451eSJürgen Schmidt sbcopyright.append(sYear);
3304524451eSJürgen Schmidt sbcopyright.appendAscii(" ");
3314524451eSJürgen Schmidt sbcopyright.append(vendor);
3324524451eSJürgen Schmidt sbcopyright.appendAscii(".\nPortion copyright The Apache Software Foundation.\n\n");
3334524451eSJürgen Schmidt }
3344524451eSJürgen Schmidt sbcopyright.append( createdRes );
3354524451eSJürgen Schmidt sbcopyright.appendAscii("\n\n");
3364524451eSJürgen Schmidt sbcopyright.append( copyrightAcknowledge );
3374524451eSJürgen Schmidt maCopyrightTextStr = sbcopyright.makeStringAndClear();
3384524451eSJürgen Schmidt
33923c0a6f8SAriel Constenla-Haile InitControls();
340cdf0e10cSrcweir
34123c0a6f8SAriel Constenla-Haile // set links
342ca04f111SAriel Constenla-Haile maReadmeButton.SetClickHdl( LINK( this, AboutDialog, ShowReadme_Impl ) );
34323c0a6f8SAriel Constenla-Haile maCreditsLink.SetClickHdl( LINK( this, AboutDialog, OpenLinkHdl_Impl ) );
344cdf0e10cSrcweir
345cdf0e10cSrcweir FreeResource();
346cdf0e10cSrcweir
347cdf0e10cSrcweir SetHelpId( CMD_SID_ABOUT );
348cdf0e10cSrcweir }
349cdf0e10cSrcweir
350cdf0e10cSrcweir // -----------------------------------------------------------------------
351cdf0e10cSrcweir
~AboutDialog()352cdf0e10cSrcweir AboutDialog::~AboutDialog()
353cdf0e10cSrcweir {
354cdf0e10cSrcweir }
355cdf0e10cSrcweir
356cdf0e10cSrcweir // -----------------------------------------------------------------------
357cdf0e10cSrcweir
InitControls()35823c0a6f8SAriel Constenla-Haile void AboutDialog::InitControls()
359cdf0e10cSrcweir {
36023c0a6f8SAriel Constenla-Haile // apply font, background et al.
36123c0a6f8SAriel Constenla-Haile ApplyStyleSettings();
36223c0a6f8SAriel Constenla-Haile
36323c0a6f8SAriel Constenla-Haile // set strings
36423c0a6f8SAriel Constenla-Haile maCopyrightEdit.SetText( maCopyrightTextStr );
36523c0a6f8SAriel Constenla-Haile maBuildInfoEdit.SetText( GetBuildVersionString() );
36623c0a6f8SAriel Constenla-Haile maCreditsLink.SetURL( maCreditsLink.GetText() );
36723c0a6f8SAriel Constenla-Haile
36823c0a6f8SAriel Constenla-Haile // determine size and position of the dialog & elements
36923c0a6f8SAriel Constenla-Haile Size aDlgSize;
37023c0a6f8SAriel Constenla-Haile LayoutControls( aDlgSize );
37123c0a6f8SAriel Constenla-Haile
37223c0a6f8SAriel Constenla-Haile // Change the width of the dialog
37323c0a6f8SAriel Constenla-Haile SetOutputSizePixel( aDlgSize );
374cdf0e10cSrcweir }
375cdf0e10cSrcweir
376cdf0e10cSrcweir // -----------------------------------------------------------------------
377cdf0e10cSrcweir
ApplyStyleSettings()37823c0a6f8SAriel Constenla-Haile void AboutDialog::ApplyStyleSettings()
379cdf0e10cSrcweir {
38023c0a6f8SAriel Constenla-Haile // Transparenter Font
38123c0a6f8SAriel Constenla-Haile Font aFont = GetFont();
38223c0a6f8SAriel Constenla-Haile aFont.SetTransparent( sal_True );
38323c0a6f8SAriel Constenla-Haile SetFont( aFont );
38423c0a6f8SAriel Constenla-Haile
38523c0a6f8SAriel Constenla-Haile // set for background and text the correct system color
38623c0a6f8SAriel Constenla-Haile const StyleSettings& rSettings = GetSettings().GetStyleSettings();
3877168672cSAriel Constenla-Haile Color aWindowColor( rSettings.GetWindowColor() );
3887168672cSAriel Constenla-Haile Wallpaper aWall( aWindowColor );
38923c0a6f8SAriel Constenla-Haile SetBackground( aWall );
390910823aeSJürgen Schmidt
39123c0a6f8SAriel Constenla-Haile Font aNewFont( maCopyrightEdit.GetFont() );
39223c0a6f8SAriel Constenla-Haile aNewFont.SetTransparent( sal_True );
39323c0a6f8SAriel Constenla-Haile
39423c0a6f8SAriel Constenla-Haile maVersionText.SetFont( aNewFont );
39523c0a6f8SAriel Constenla-Haile maCopyrightEdit.SetFont( aNewFont );
39623c0a6f8SAriel Constenla-Haile
3977168672cSAriel Constenla-Haile maVersionText.SetBackground(aWall);
3987168672cSAriel Constenla-Haile maCopyrightEdit.SetBackground(aWall);
3997168672cSAriel Constenla-Haile maBuildInfoEdit.SetBackground(aWall);
4007168672cSAriel Constenla-Haile maCreditsLink.SetBackground(aWall);
40123c0a6f8SAriel Constenla-Haile
40223c0a6f8SAriel Constenla-Haile Color aTextColor( rSettings.GetWindowTextColor() );
40323c0a6f8SAriel Constenla-Haile maVersionText.SetControlForeground( aTextColor );
40423c0a6f8SAriel Constenla-Haile maCopyrightEdit.SetControlForeground( aTextColor );
40523c0a6f8SAriel Constenla-Haile maBuildInfoEdit.SetControlForeground( aTextColor );
40623c0a6f8SAriel Constenla-Haile maCreditsLink.SetControlForeground();
40723c0a6f8SAriel Constenla-Haile
40823c0a6f8SAriel Constenla-Haile Size aSmaller = aNewFont.GetSize();
40923c0a6f8SAriel Constenla-Haile aSmaller.Width() = (long) (aSmaller.Width() * 0.75);
41023c0a6f8SAriel Constenla-Haile aSmaller.Height() = (long) (aSmaller.Height() * 0.75);
41123c0a6f8SAriel Constenla-Haile aNewFont.SetSize( aSmaller );
41223c0a6f8SAriel Constenla-Haile
41323c0a6f8SAriel Constenla-Haile maBuildInfoEdit.SetFont( aNewFont );
41423c0a6f8SAriel Constenla-Haile
41523c0a6f8SAriel Constenla-Haile // the following is a hack to force the MultiLineEdit update its settings
41623c0a6f8SAriel Constenla-Haile // in order to reflect the Font
41723c0a6f8SAriel Constenla-Haile // See
41823c0a6f8SAriel Constenla-Haile // Window::SetControlFont
41923c0a6f8SAriel Constenla-Haile // MultiLineEdit::StateChanged
42023c0a6f8SAriel Constenla-Haile // MultiLineEdit::ImplInitSettings
42123c0a6f8SAriel Constenla-Haile // TODO Override SetFont in MultiLineEdit and do the following,
42223c0a6f8SAriel Constenla-Haile // otherwise SetFont has no effect at all!
42323c0a6f8SAriel Constenla-Haile aSmaller = PixelToLogic( aSmaller, MAP_POINT );
42423c0a6f8SAriel Constenla-Haile aNewFont.SetSize( aSmaller );
42523c0a6f8SAriel Constenla-Haile maBuildInfoEdit.SetControlFont( aNewFont );
42623c0a6f8SAriel Constenla-Haile }
42723c0a6f8SAriel Constenla-Haile
42823c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
42923c0a6f8SAriel Constenla-Haile
LayoutControls(Size & aDlgSize)43023c0a6f8SAriel Constenla-Haile void AboutDialog::LayoutControls( Size& aDlgSize )
43123c0a6f8SAriel Constenla-Haile {
432ca04f111SAriel Constenla-Haile Size aMainLogoSz = maMainLogo.GetSizePixel();
43323c0a6f8SAriel Constenla-Haile Size aAppLogoSiz = maAppLogo.GetSizePixel();
43423c0a6f8SAriel Constenla-Haile
43523c0a6f8SAriel Constenla-Haile aDlgSize = GetOutputSizePixel();
436325547baSAriel Constenla-Haile long nCol1 = aMainLogoSz.Width();
437325547baSAriel Constenla-Haile long nCol2 = aAppLogoSiz.Width() ? aAppLogoSiz.Width() : aDlgSize.Width();
43823c0a6f8SAriel Constenla-Haile
43923c0a6f8SAriel Constenla-Haile Size a6Size = maVersionText.LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
44023c0a6f8SAriel Constenla-Haile long nDlgMargin = a6Size.Width() * 2;
44123c0a6f8SAriel Constenla-Haile long nCtrlMargin = a6Size.Height() * 2;
442325547baSAriel Constenla-Haile long nTextWidth = nCol2 - nDlgMargin;
443ca04f111SAriel Constenla-Haile long nY = aAppLogoSiz.Height() + a6Size.Height();
44423c0a6f8SAriel Constenla-Haile
445325547baSAriel Constenla-Haile aDlgSize.Width() = nCol1 + a6Size.Width() + nCol2;
446ca04f111SAriel Constenla-Haile
447325547baSAriel Constenla-Haile Point aPos( nCol1 + a6Size.Width(), nY );
44823c0a6f8SAriel Constenla-Haile Size aSize;
44923c0a6f8SAriel Constenla-Haile // layout fixed text control
450ca04f111SAriel Constenla-Haile lcl_layoutFixedText( maVersionText, aPos, aSize, nTextWidth );
451ca04f111SAriel Constenla-Haile nY += aSize.Height() + a6Size.Height();
45223c0a6f8SAriel Constenla-Haile
45323c0a6f8SAriel Constenla-Haile // Multiline edit with Build info
45423c0a6f8SAriel Constenla-Haile aPos.Y() = nY;
455ca04f111SAriel Constenla-Haile lcl_layoutEdit( maBuildInfoEdit, aPos, aSize, nTextWidth );
456ca04f111SAriel Constenla-Haile nY += aSize.Height() + a6Size.Height();
45723c0a6f8SAriel Constenla-Haile
45823c0a6f8SAriel Constenla-Haile // Multiline edit with Copyright-Text
45923c0a6f8SAriel Constenla-Haile aPos.Y() = nY;
460ca04f111SAriel Constenla-Haile lcl_layoutEdit( maCopyrightEdit, aPos, aSize, nTextWidth );
461ca04f111SAriel Constenla-Haile nY += aSize.Height() + a6Size.Height();
46223c0a6f8SAriel Constenla-Haile
46323c0a6f8SAriel Constenla-Haile // Hyperlink
46423c0a6f8SAriel Constenla-Haile aPos.Y() = nY;
465ca04f111SAriel Constenla-Haile lcl_layoutFixedText( maCreditsLink, aPos, aSize, nTextWidth );
466ca04f111SAriel Constenla-Haile nY += aSize.Height();
467ca04f111SAriel Constenla-Haile
468ca04f111SAriel Constenla-Haile nY = std::max( nY, aMainLogoSz.Height() );
469ca04f111SAriel Constenla-Haile nY += nCtrlMargin;
470ca04f111SAriel Constenla-Haile
471ca04f111SAriel Constenla-Haile // logos position
472ca04f111SAriel Constenla-Haile maMainLogoPos = Point( 0, nY / 2 - aMainLogoSz.Height() / 2 );
473325547baSAriel Constenla-Haile maAppLogoPos = Point( nCol1 + a6Size.Width(), 0 );
47423c0a6f8SAriel Constenla-Haile
47523c0a6f8SAriel Constenla-Haile // OK-Button-Position (at the bottom and centered)
47623c0a6f8SAriel Constenla-Haile Size aOKSiz = maOKButton.GetSizePixel();
477ca04f111SAriel Constenla-Haile Point aOKPnt( ( aDlgSize.Width() - aOKSiz.Width() ) - a6Size.Width(), nY );
47823c0a6f8SAriel Constenla-Haile maOKButton.SetPosPixel( aOKPnt );
47923c0a6f8SAriel Constenla-Haile
480ca04f111SAriel Constenla-Haile maReadmeButton.SetPosPixel( Point(a6Size.Width(), nY) );
481ca04f111SAriel Constenla-Haile
482ca04f111SAriel Constenla-Haile aDlgSize.Height() = aOKPnt.Y() + aOKSiz.Height() + a6Size.Width();
48323c0a6f8SAriel Constenla-Haile }
48423c0a6f8SAriel Constenla-Haile
48523c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
48623c0a6f8SAriel Constenla-Haile
GetBuildId() const48723c0a6f8SAriel Constenla-Haile const rtl::OUString AboutDialog::GetBuildId() const
48823c0a6f8SAriel Constenla-Haile {
48923c0a6f8SAriel Constenla-Haile rtl::OUString sDefault;
49023c0a6f8SAriel Constenla-Haile
49123c0a6f8SAriel Constenla-Haile // Get buildid from version[rc|.ini]
49223c0a6f8SAriel Constenla-Haile rtl::OUString sBuildId( utl::Bootstrap::getBuildIdData( sDefault ) );
49323c0a6f8SAriel Constenla-Haile OSL_ENSURE( sBuildId.getLength() > 0, "No BUILDID in bootstrap file" );
49423c0a6f8SAriel Constenla-Haile rtl::OUStringBuffer sBuildIdBuff( sBuildId );
49523c0a6f8SAriel Constenla-Haile
49623c0a6f8SAriel Constenla-Haile // Get ProductSource from version[rc|.ini]
49723c0a6f8SAriel Constenla-Haile rtl::OUString sProductSource( utl::Bootstrap::getProductSource( sDefault ) );
49823c0a6f8SAriel Constenla-Haile OSL_ENSURE( sProductSource.getLength() > 0, "No ProductSource in bootstrap file" );
49923c0a6f8SAriel Constenla-Haile
50023c0a6f8SAriel Constenla-Haile // the product source is something like "AOO340",
50123c0a6f8SAriel Constenla-Haile // while the build id is something like "340m1(Build:9590)"
50223c0a6f8SAriel Constenla-Haile // For better readability, strip the duplicate ProductMajor ("340").
50323c0a6f8SAriel Constenla-Haile if ( sProductSource.getLength() )
50423c0a6f8SAriel Constenla-Haile {
505a524e3b9SArrigo Marchiori sal_Int32 nMajorLength = sProductSource.getLength() - 3;
50623c0a6f8SAriel Constenla-Haile bool bMatchingUPD =
50723c0a6f8SAriel Constenla-Haile ( sProductSource.getLength() >= 3 )
508a524e3b9SArrigo Marchiori && ( sBuildId.getLength() >= nMajorLength )
509a524e3b9SArrigo Marchiori && ( sProductSource.copy( 3 ) == sBuildId.copy( 0, nMajorLength ) );
51023c0a6f8SAriel Constenla-Haile OSL_ENSURE( bMatchingUPD, "BUILDID and ProductSource do not match in their UPD" );
51123c0a6f8SAriel Constenla-Haile if ( bMatchingUPD )
512a524e3b9SArrigo Marchiori sProductSource = sProductSource.copy( 0, sProductSource.getLength() - nMajorLength );
51323c0a6f8SAriel Constenla-Haile
51423c0a6f8SAriel Constenla-Haile // prepend the product source
51523c0a6f8SAriel Constenla-Haile sBuildIdBuff.insert( 0, sProductSource );
51623c0a6f8SAriel Constenla-Haile }
51723c0a6f8SAriel Constenla-Haile
51823c0a6f8SAriel Constenla-Haile return sBuildIdBuff.makeStringAndClear();
51923c0a6f8SAriel Constenla-Haile }
52023c0a6f8SAriel Constenla-Haile
52123c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
52223c0a6f8SAriel Constenla-Haile
GetBuildVersionString() const52323c0a6f8SAriel Constenla-Haile const rtl::OUString AboutDialog::GetBuildVersionString() const
52423c0a6f8SAriel Constenla-Haile {
52523c0a6f8SAriel Constenla-Haile rtl::OUStringBuffer aBuildString( GetBuildId() );
52623c0a6f8SAriel Constenla-Haile rtl::OUString sRevision( utl::Bootstrap::getRevisionInfo() );
52723c0a6f8SAriel Constenla-Haile
52823c0a6f8SAriel Constenla-Haile if ( sRevision.getLength() > 0 )
52923c0a6f8SAriel Constenla-Haile {
53023c0a6f8SAriel Constenla-Haile aBuildString.appendAscii( RTL_CONSTASCII_STRINGPARAM( " - Rev. " ) );
53123c0a6f8SAriel Constenla-Haile aBuildString.append( sRevision );
53223c0a6f8SAriel Constenla-Haile }
53323c0a6f8SAriel Constenla-Haile
53423c0a6f8SAriel Constenla-Haile #ifdef BUILD_VER_STRING
53523c0a6f8SAriel Constenla-Haile rtl::OUString sBuildVer( RTL_CONSTASCII_USTRINGPARAM( STRINGIFY( BUILD_VER_STRING ) ) );
53623c0a6f8SAriel Constenla-Haile if ( sBuildVer.getLength() > 0 )
53723c0a6f8SAriel Constenla-Haile {
53823c0a6f8SAriel Constenla-Haile aBuildString.append( sal_Unicode( '\n' ) );
53923c0a6f8SAriel Constenla-Haile aBuildString.append( sBuildVer );
54023c0a6f8SAriel Constenla-Haile }
541cdf0e10cSrcweir #endif
542cdf0e10cSrcweir
54323c0a6f8SAriel Constenla-Haile return aBuildString.makeStringAndClear();
544cdf0e10cSrcweir }
545cdf0e10cSrcweir
546cdf0e10cSrcweir // -----------------------------------------------------------------------
547cdf0e10cSrcweir
Close()548cdf0e10cSrcweir sal_Bool AboutDialog::Close()
549cdf0e10cSrcweir {
550cdf0e10cSrcweir EndDialog( RET_OK );
551cdf0e10cSrcweir return( sal_False );
552cdf0e10cSrcweir }
553cdf0e10cSrcweir
554cdf0e10cSrcweir // -----------------------------------------------------------------------
555cdf0e10cSrcweir
Paint(const Rectangle & rRect)556cdf0e10cSrcweir void AboutDialog::Paint( const Rectangle& rRect )
557cdf0e10cSrcweir {
558cdf0e10cSrcweir SetClipRegion( rRect );
559910823aeSJürgen Schmidt
560910823aeSJürgen Schmidt // workaround to ensure that the background is painted correct
561910823aeSJürgen Schmidt // on MacOS for exmaple the background was grey and the image and other controls white
562910823aeSJürgen Schmidt SetFillColor(GetSettings().GetStyleSettings().GetWindowColor());
563910823aeSJürgen Schmidt SetLineColor();
564910823aeSJürgen Schmidt DrawRect(rRect);
565910823aeSJürgen Schmidt
566ca04f111SAriel Constenla-Haile DrawImage( maMainLogoPos, maMainLogo );
567ca04f111SAriel Constenla-Haile DrawImage( maAppLogoPos, maAppLogo );
568cdf0e10cSrcweir
569cdf0e10cSrcweir return;
570cdf0e10cSrcweir }
571cdf0e10cSrcweir
57223c0a6f8SAriel Constenla-Haile // -----------------------------------------------------------------------
573cdf0e10cSrcweir
IMPL_LINK(AboutDialog,OpenLinkHdl_Impl,svt::FixedHyperlink *,EMPTYARG)57423c0a6f8SAriel Constenla-Haile IMPL_LINK ( AboutDialog, OpenLinkHdl_Impl, svt::FixedHyperlink*, EMPTYARG )
575cdf0e10cSrcweir {
57623c0a6f8SAriel Constenla-Haile ::rtl::OUString sURL( maCreditsLink.GetURL() );
57723c0a6f8SAriel Constenla-Haile if ( sURL.getLength() > 0 )
578cdf0e10cSrcweir {
57923c0a6f8SAriel Constenla-Haile try
580cdf0e10cSrcweir {
5814ad1da77SJian Fang Zhang uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShell(
5829807c9deSAriel Constenla-Haile com::sun::star::system::SystemShellExecute::create(
5839807c9deSAriel Constenla-Haile ::comphelper::getProcessComponentContext() ) );
58423c0a6f8SAriel Constenla-Haile if ( xSystemShell.is() )
5854ad1da77SJian Fang Zhang xSystemShell->execute( sURL, rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::DEFAULTS );
586cdf0e10cSrcweir }
5877168672cSAriel Constenla-Haile catch( const uno::Exception& e )
588cdf0e10cSrcweir {
58923c0a6f8SAriel Constenla-Haile OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
59023c0a6f8SAriel Constenla-Haile rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
591cdf0e10cSrcweir }
592cdf0e10cSrcweir }
5937168672cSAriel Constenla-Haile
59423c0a6f8SAriel Constenla-Haile return 0;
59523c0a6f8SAriel Constenla-Haile }
596ca04f111SAriel Constenla-Haile
IMPL_LINK(AboutDialog,ShowReadme_Impl,PushButton *,EMPTYARG)597ca04f111SAriel Constenla-Haile IMPL_LINK ( AboutDialog, ShowReadme_Impl, PushButton*, EMPTYARG )
598ca04f111SAriel Constenla-Haile {
599ca04f111SAriel Constenla-Haile ReadmeDialog aDlg( this );
600ca04f111SAriel Constenla-Haile aDlg.Execute();
601ca04f111SAriel Constenla-Haile
602ca04f111SAriel Constenla-Haile return 0;
603ca04f111SAriel Constenla-Haile }
604