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 27cdf0e10cSrcweir // include --------------------------------------------------------------- 28cdf0e10cSrcweir 29cdf0e10cSrcweir #define _SVX_OPTIMPROVE_CXX 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <optimprove.hxx> 32cdf0e10cSrcweir #include <dialmgr.hxx> 33cdf0e10cSrcweir #include <vcl/msgbox.hxx> 34cdf0e10cSrcweir #include <svx/dialogs.hrc> 35cdf0e10cSrcweir #include "optimprove.hrc" 36cdf0e10cSrcweir #include "helpid.hrc" 37cdf0e10cSrcweir #include <cuires.hrc> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 40cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 41*9807c9deSAriel Constenla-Haile #include <com/sun/star/system/SystemShellExecute.hpp> 42cdf0e10cSrcweir #include <com/sun/star/system/SystemShellExecuteFlags.hpp> 43cdf0e10cSrcweir #include <com/sun/star/oooimprovement/XCoreController.hpp> 44cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx> 45cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 46cdf0e10cSrcweir #include <comphelper/uieventslogger.hxx> 47cdf0e10cSrcweir #include <tools/testtoolloader.hxx> 48cdf0e10cSrcweir 49cdf0e10cSrcweir namespace lang = ::com::sun::star::lang; 50cdf0e10cSrcweir namespace uno = ::com::sun::star::uno; 51cdf0e10cSrcweir using namespace com::sun::star::system; 52cdf0e10cSrcweir 53cdf0e10cSrcweir // class SvxImprovementPage ---------------------------------------------- 54cdf0e10cSrcweir 55cdf0e10cSrcweir SvxImprovementPage::SvxImprovementPage( Window* pParent ) : 56cdf0e10cSrcweir 57cdf0e10cSrcweir TabPage( pParent, CUI_RES( RID_SVXPAGE_IMPROVEMENT ) ), 58cdf0e10cSrcweir 59cdf0e10cSrcweir m_aImproveFL ( this, CUI_RES( FL_IMPROVE ) ), 60cdf0e10cSrcweir m_aInvitationFT ( this, CUI_RES( FT_INVITATION ) ), 61cdf0e10cSrcweir m_aYesRB ( this, CUI_RES( RB_YES ) ), 62cdf0e10cSrcweir m_aNoRB ( this, CUI_RES( RB_NO ) ), 63cdf0e10cSrcweir m_aDataFL ( this, CUI_RES( FL_DATA ) ), 64cdf0e10cSrcweir m_aNumberOfReportsFT ( this, CUI_RES( FT_NR_REPORTS ) ), 65cdf0e10cSrcweir m_aNumberOfReportsValueFT ( this, CUI_RES( FT_NR_REPORTS_VALUE ) ), 66cdf0e10cSrcweir m_aNumberOfActionsFT ( this, CUI_RES( FT_NR_ACTIONS ) ), 67cdf0e10cSrcweir m_aNumberOfActionsValueFT ( this, CUI_RES( FT_NR_ACTIONS_VALUE ) ), 68cdf0e10cSrcweir m_aShowDataPB ( this, CUI_RES( PB_SHOWDATA ) ), 69cdf0e10cSrcweir 70cdf0e10cSrcweir m_sInfo ( CUI_RES( STR_INFO ) ), 71cdf0e10cSrcweir m_sMoreInfo ( CUI_RES( STR_MOREINFO ) ) 72cdf0e10cSrcweir 73cdf0e10cSrcweir { 74cdf0e10cSrcweir FreeResource(); 75cdf0e10cSrcweir 76cdf0e10cSrcweir m_aInvitationFT.Show(); 77cdf0e10cSrcweir m_aDataFL.Hide(); 78cdf0e10cSrcweir m_aNumberOfReportsFT.Hide(); 79cdf0e10cSrcweir m_aNumberOfReportsValueFT.Hide(); 80cdf0e10cSrcweir m_aNumberOfActionsFT.Hide(); 81cdf0e10cSrcweir m_aNumberOfActionsValueFT.Hide(); 82cdf0e10cSrcweir m_aShowDataPB.Hide(); 83cdf0e10cSrcweir 84cdf0e10cSrcweir Size aNewSize = m_aInvitationFT.GetSizePixel(); 85cdf0e10cSrcweir const long nMinWidth = m_aYesRB.CalcMinimumSize().Width(); 86cdf0e10cSrcweir const long nNewWidth = std::max( aNewSize.Width() * 4 / 5, nMinWidth ); 87cdf0e10cSrcweir const long nWDelta = aNewSize.Width() - nNewWidth; 88cdf0e10cSrcweir aNewSize.Width() = nNewWidth; 89cdf0e10cSrcweir const Size aCalcSize = m_aInvitationFT.CalcMinimumSize( nNewWidth ); 90cdf0e10cSrcweir const long nHDelta = aCalcSize.Height() - aNewSize.Height(); 91cdf0e10cSrcweir aNewSize.Height() = aCalcSize.Height(); 92cdf0e10cSrcweir m_aInvitationFT.SetSizePixel( aNewSize ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir aNewSize = m_aYesRB.GetSizePixel(); 95cdf0e10cSrcweir aNewSize.Width() = nNewWidth; 96cdf0e10cSrcweir Point aNewPos = m_aYesRB.GetPosPixel(); 97cdf0e10cSrcweir aNewPos.Y() += nHDelta; 98cdf0e10cSrcweir m_aYesRB.SetPosSizePixel( aNewPos, aNewSize ); 99cdf0e10cSrcweir aNewSize = m_aNoRB.GetSizePixel(); 100cdf0e10cSrcweir aNewSize.Width() = nNewWidth; 101cdf0e10cSrcweir aNewPos = m_aNoRB.GetPosPixel(); 102cdf0e10cSrcweir aNewPos.Y() += nHDelta; 103cdf0e10cSrcweir m_aNoRB.SetPosSizePixel( aNewPos, aNewSize ); 104cdf0e10cSrcweir aNewSize = m_aImproveFL.GetSizePixel(); 105cdf0e10cSrcweir aNewSize.Width() -= nWDelta; 106cdf0e10cSrcweir m_aImproveFL.SetSizePixel( aNewSize ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 109cdf0e10cSrcweir aSize.Width() -= nWDelta; 110cdf0e10cSrcweir aSize.Height() = m_aDataFL.GetPosPixel().Y(); 111cdf0e10cSrcweir aSize.Height() += nHDelta; 112cdf0e10cSrcweir SetSizePixel( aSize ); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir // ----------------------------------------------------------------------- 116cdf0e10cSrcweir 117cdf0e10cSrcweir SvxImprovementPage::~SvxImprovementPage() 118cdf0e10cSrcweir { 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir // class SvxImprovementDialog -------------------------------------------- 122cdf0e10cSrcweir 123cdf0e10cSrcweir SvxImprovementDialog::SvxImprovementDialog( Window* pParent, const String& rInfoURL ) : 124cdf0e10cSrcweir 125cdf0e10cSrcweir SfxSingleTabDialog( pParent, RID_SVXPAGE_IMPROVEMENT, rInfoURL ), 126cdf0e10cSrcweir 127cdf0e10cSrcweir m_pPage( NULL ) 128cdf0e10cSrcweir 129cdf0e10cSrcweir { 130cdf0e10cSrcweir m_pPage = new SvxImprovementPage( this ); 131cdf0e10cSrcweir SetInfoLink( LINK( this, SvxImprovementDialog, HandleHyperlink ) ); 132cdf0e10cSrcweir SetPage( m_pPage ); 133cdf0e10cSrcweir if ( GetOKButton() ) 134cdf0e10cSrcweir GetOKButton()->SetClickHdl( LINK( this, SvxImprovementDialog, HandleOK ) ); 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir IMPL_LINK( SvxImprovementDialog, HandleHyperlink, svt::FixedHyperlinkImage*, pHyperlinkImage ) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir ::rtl::OUString sURL( pHyperlinkImage->GetURL() ); 140cdf0e10cSrcweir 141cdf0e10cSrcweir if ( sURL.getLength() > 0 ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir try 144cdf0e10cSrcweir { 145cdf0e10cSrcweir uno::Reference< XSystemShellExecute > xSystemShell( 146*9807c9deSAriel Constenla-Haile com::sun::star::system::SystemShellExecute::create( 147*9807c9deSAriel Constenla-Haile ::comphelper::getProcessComponentContext() ) ); 148cdf0e10cSrcweir if ( xSystemShell.is() ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir xSystemShell->execute( 151cdf0e10cSrcweir sURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS ); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir } 154cdf0e10cSrcweir catch( const uno::Exception& e ) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir OSL_TRACE( "Caught exception: %s\n thread terminated.\n", 157cdf0e10cSrcweir rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); 158cdf0e10cSrcweir } 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir return 0; 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir IMPL_LINK( SvxImprovementDialog, HandleOK, OKButton*, EMPTYARG ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory(); 167cdf0e10cSrcweir uno::Reference< com::sun::star::oooimprovement::XCoreController > core_c( 168cdf0e10cSrcweir xSMGR->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.oooimprovement.CoreController")), 169cdf0e10cSrcweir uno::UNO_QUERY); 170cdf0e10cSrcweir if(core_c.is()) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir ::comphelper::ConfigurationHelper::writeDirectKey( 173cdf0e10cSrcweir xSMGR, 174cdf0e10cSrcweir ::rtl::OUString::createFromAscii("/org.openoffice.Office.OOoImprovement.Settings"), 175cdf0e10cSrcweir ::rtl::OUString::createFromAscii("Participation"), 176cdf0e10cSrcweir ::rtl::OUString::createFromAscii("ShowedInvitation"), 177cdf0e10cSrcweir uno::makeAny( true ), 178cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_STANDARD ); 179cdf0e10cSrcweir ::comphelper::ConfigurationHelper::writeDirectKey( 180cdf0e10cSrcweir xSMGR, 181cdf0e10cSrcweir ::rtl::OUString::createFromAscii("/org.openoffice.Office.OOoImprovement.Settings"), 182cdf0e10cSrcweir ::rtl::OUString::createFromAscii("Participation"), 183cdf0e10cSrcweir ::rtl::OUString::createFromAscii("InvitationAccepted"), 184cdf0e10cSrcweir uno::makeAny( m_pPage->IsYesChecked() ), 185cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_STANDARD ); 186cdf0e10cSrcweir // TODO: refactor 187cdf0e10cSrcweir ::comphelper::UiEventsLogger::reinit(); 188cdf0e10cSrcweir ::tools::InitTestToolLib(); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir EndDialog( RET_OK ); 191cdf0e10cSrcweir return 0; 192cdf0e10cSrcweir } 193