masterfix DEV300: #i10000# build fix
[LibreOffice.git] / cui / source / options / optimprove.cxx
blobb1eb055e9b1a3c9821d6309b1da9837d886fd25e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
33 #define _SVX_OPTIMPROVE_CXX
35 #include <optimprove.hxx>
36 #include <dialmgr.hxx>
37 #include <vcl/msgbox.hxx>
38 #include <svx/dialogs.hrc>
39 #include "optimprove.hrc"
40 #include "helpid.hrc"
41 #include <cuires.hrc>
43 #include <com/sun/star/uno/Any.hxx>
44 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45 #include <com/sun/star/system/XSystemShellExecute.hpp>
46 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
47 #include <com/sun/star/oooimprovement/XCoreController.hpp>
48 #include <comphelper/configurationhelper.hxx>
49 #include <comphelper/processfactory.hxx>
50 #include <comphelper/uieventslogger.hxx>
51 #include <tools/testtoolloader.hxx>
53 namespace lang = ::com::sun::star::lang;
54 namespace uno = ::com::sun::star::uno;
55 using namespace com::sun::star::system;
57 // class SvxImprovementPage ----------------------------------------------
59 SvxImprovementPage::SvxImprovementPage( Window* pParent ) :
61 TabPage( pParent, CUI_RES( RID_SVXPAGE_IMPROVEMENT ) ),
63 m_aImproveFL ( this, CUI_RES( FL_IMPROVE ) ),
64 m_aInvitationFT ( this, CUI_RES( FT_INVITATION ) ),
65 m_aYesRB ( this, CUI_RES( RB_YES ) ),
66 m_aNoRB ( this, CUI_RES( RB_NO ) ),
67 m_aDataFL ( this, CUI_RES( FL_DATA ) ),
68 m_aNumberOfReportsFT ( this, CUI_RES( FT_NR_REPORTS ) ),
69 m_aNumberOfReportsValueFT ( this, CUI_RES( FT_NR_REPORTS_VALUE ) ),
70 m_aNumberOfActionsFT ( this, CUI_RES( FT_NR_ACTIONS ) ),
71 m_aNumberOfActionsValueFT ( this, CUI_RES( FT_NR_ACTIONS_VALUE ) ),
72 m_aShowDataPB ( this, CUI_RES( PB_SHOWDATA ) ),
74 m_sInfo ( CUI_RES( STR_INFO ) ),
75 m_sMoreInfo ( CUI_RES( STR_MOREINFO ) )
78 FreeResource();
80 m_aInvitationFT.Show();
81 m_aDataFL.Hide();
82 m_aNumberOfReportsFT.Hide();
83 m_aNumberOfReportsValueFT.Hide();
84 m_aNumberOfActionsFT.Hide();
85 m_aNumberOfActionsValueFT.Hide();
86 m_aShowDataPB.Hide();
88 Size aNewSize = m_aInvitationFT.GetSizePixel();
89 const long nMinWidth = m_aYesRB.CalcMinimumSize().Width();
90 const long nNewWidth = std::max( aNewSize.Width() * 4 / 5, nMinWidth );
91 const long nWDelta = aNewSize.Width() - nNewWidth;
92 aNewSize.Width() = nNewWidth;
93 const Size aCalcSize = m_aInvitationFT.CalcMinimumSize( nNewWidth );
94 const long nHDelta = aCalcSize.Height() - aNewSize.Height();
95 aNewSize.Height() = aCalcSize.Height();
96 m_aInvitationFT.SetSizePixel( aNewSize );
98 aNewSize = m_aYesRB.GetSizePixel();
99 aNewSize.Width() = nNewWidth;
100 Point aNewPos = m_aYesRB.GetPosPixel();
101 aNewPos.Y() += nHDelta;
102 m_aYesRB.SetPosSizePixel( aNewPos, aNewSize );
103 aNewSize = m_aNoRB.GetSizePixel();
104 aNewSize.Width() = nNewWidth;
105 aNewPos = m_aNoRB.GetPosPixel();
106 aNewPos.Y() += nHDelta;
107 m_aNoRB.SetPosSizePixel( aNewPos, aNewSize );
108 aNewSize = m_aImproveFL.GetSizePixel();
109 aNewSize.Width() -= nWDelta;
110 m_aImproveFL.SetSizePixel( aNewSize );
112 Size aSize = GetOutputSizePixel();
113 aSize.Width() -= nWDelta;
114 aSize.Height() = m_aDataFL.GetPosPixel().Y();
115 aSize.Height() += nHDelta;
116 SetSizePixel( aSize );
119 // -----------------------------------------------------------------------
121 SvxImprovementPage::~SvxImprovementPage()
125 // class SvxImprovementDialog --------------------------------------------
127 SvxImprovementDialog::SvxImprovementDialog( Window* pParent, const String& rInfoURL ) :
129 SfxSingleTabDialog( pParent, RID_SVXPAGE_IMPROVEMENT, rInfoURL ),
131 m_pPage( NULL )
134 m_pPage = new SvxImprovementPage( this );
135 SetInfoLink( LINK( this, SvxImprovementDialog, HandleHyperlink ) );
136 SetPage( m_pPage );
137 if ( GetOKButton() )
138 GetOKButton()->SetClickHdl( LINK( this, SvxImprovementDialog, HandleOK ) );
141 IMPL_LINK( SvxImprovementDialog, HandleHyperlink, svt::FixedHyperlinkImage*, pHyperlinkImage )
143 ::rtl::OUString sURL( pHyperlinkImage->GetURL() );
145 if ( sURL.getLength() > 0 )
149 uno::Reference< lang::XMultiServiceFactory > xSMGR =
150 ::comphelper::getProcessServiceFactory();
151 uno::Reference< XSystemShellExecute > xSystemShell(
152 xSMGR->createInstance( ::rtl::OUString(
153 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.system.SystemShellExecute" ) ) ),
154 uno::UNO_QUERY_THROW );
155 if ( xSystemShell.is() )
157 xSystemShell->execute(
158 sURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS );
161 catch( const uno::Exception& e )
163 OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
164 rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
168 return 0;
171 IMPL_LINK( SvxImprovementDialog, HandleOK, OKButton*, EMPTYARG )
173 uno::Reference< lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
174 uno::Reference< com::sun::star::oooimprovement::XCoreController > core_c(
175 xSMGR->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.oooimprovement.CoreController")),
176 uno::UNO_QUERY);
177 if(core_c.is())
179 ::comphelper::ConfigurationHelper::writeDirectKey(
180 xSMGR,
181 ::rtl::OUString::createFromAscii("/org.openoffice.Office.OOoImprovement.Settings"),
182 ::rtl::OUString::createFromAscii("Participation"),
183 ::rtl::OUString::createFromAscii("ShowedInvitation"),
184 uno::makeAny( true ),
185 ::comphelper::ConfigurationHelper::E_STANDARD );
186 ::comphelper::ConfigurationHelper::writeDirectKey(
187 xSMGR,
188 ::rtl::OUString::createFromAscii("/org.openoffice.Office.OOoImprovement.Settings"),
189 ::rtl::OUString::createFromAscii("Participation"),
190 ::rtl::OUString::createFromAscii("InvitationAccepted"),
191 uno::makeAny( m_pPage->IsYesChecked() ),
192 ::comphelper::ConfigurationHelper::E_STANDARD );
193 // TODO: refactor
194 ::comphelper::UiEventsLogger::reinit();
195 ::tools::InitTestToolLib();
197 EndDialog( RET_OK );
198 return 0;