16d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
36d739b60SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
46d739b60SAndrew Rist * or more contributor license agreements. See the NOTICE file
56d739b60SAndrew Rist * distributed with this work for additional information
66d739b60SAndrew Rist * regarding copyright ownership. The ASF licenses this file
76d739b60SAndrew Rist * to you under the Apache License, Version 2.0 (the
86d739b60SAndrew Rist * "License"); you may not use this file except in compliance
96d739b60SAndrew Rist * with the License. You may obtain a copy of the License at
106d739b60SAndrew Rist *
116d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
126d739b60SAndrew Rist *
136d739b60SAndrew Rist * Unless required by applicable law or agreed to in writing,
146d739b60SAndrew Rist * software distributed under the License is distributed on an
156d739b60SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166d739b60SAndrew Rist * KIND, either express or implied. See the License for the
176d739b60SAndrew Rist * specific language governing permissions and limitations
186d739b60SAndrew Rist * under the License.
196d739b60SAndrew Rist *
206d739b60SAndrew Rist *************************************************************/
216d739b60SAndrew Rist
226d739b60SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_framework.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "backingwindow.hxx"
28cdf0e10cSrcweir #include "classes/resource.hrc"
29cdf0e10cSrcweir #include "framework.hrc"
30cdf0e10cSrcweir #include "classes/fwkresid.hxx"
31cdf0e10cSrcweir #include <services.h>
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include "vcl/metric.hxx"
34cdf0e10cSrcweir #include "vcl/mnemonic.hxx"
35cdf0e10cSrcweir #include "vcl/menu.hxx"
36cdf0e10cSrcweir #include "vcl/svapp.hxx"
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include "tools/urlobj.hxx"
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include "unotools/dynamicmenuoptions.hxx"
41cdf0e10cSrcweir #include "unotools/historyoptions.hxx"
42cdf0e10cSrcweir #include "svtools/imagemgr.hxx"
43cdf0e10cSrcweir #include "svtools/svtools.hrc"
44cdf0e10cSrcweir
45cdf0e10cSrcweir #include "comphelper/processfactory.hxx"
46cdf0e10cSrcweir #include "comphelper/sequenceashashmap.hxx"
47cdf0e10cSrcweir #include "comphelper/configurationhelper.hxx"
48cdf0e10cSrcweir
49*f7882915SAriel Constenla-Haile #include <toolkit/awt/vclxmenu.hxx>
50*f7882915SAriel Constenla-Haile
51cdf0e10cSrcweir #include "cppuhelper/implbase1.hxx"
52cdf0e10cSrcweir
53cdf0e10cSrcweir #include "rtl/strbuf.hxx"
54cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
55cdf0e10cSrcweir #include "osl/file.h"
56cdf0e10cSrcweir
57cdf0e10cSrcweir #include "com/sun/star/lang/XMultiServiceFactory.hpp"
58cdf0e10cSrcweir #include "com/sun/star/container/XNameAccess.hpp"
599807c9deSAriel Constenla-Haile #include "com/sun/star/system/SystemShellExecute.hpp"
60cdf0e10cSrcweir #include "com/sun/star/system/SystemShellExecuteFlags.hpp"
61cdf0e10cSrcweir #include "com/sun/star/task/XJobExecutor.hpp"
62cdf0e10cSrcweir #include "com/sun/star/util/XStringWidth.hpp"
63*f7882915SAriel Constenla-Haile #include <com/sun/star/frame/PopupMenuControllerFactory.hpp>
64cdf0e10cSrcweir
65cdf0e10cSrcweir using namespace ::com::sun::star::beans;
66cdf0e10cSrcweir using namespace ::com::sun::star::frame;
67cdf0e10cSrcweir using namespace ::com::sun::star::uno;
68cdf0e10cSrcweir using namespace ::com::sun::star;
69cdf0e10cSrcweir using namespace framework;
70cdf0e10cSrcweir
71*f7882915SAriel Constenla-Haile #define RECENT_FILE_LIST ".uno:RecentFileList"
72*f7882915SAriel Constenla-Haile
73cdf0e10cSrcweir #define WRITER_URL "private:factory/swriter"
74cdf0e10cSrcweir #define CALC_URL "private:factory/scalc"
75cdf0e10cSrcweir #define IMPRESS_WIZARD_URL "private:factory/simpress?slot=6686"
76cdf0e10cSrcweir #define DRAW_URL "private:factory/sdraw"
77cdf0e10cSrcweir #define BASE_URL "private:factory/sdatabase?Interactive"
78cdf0e10cSrcweir #define MATH_URL "private:factory/smath"
79cdf0e10cSrcweir #define TEMPLATE_URL "slot:5500"
80cdf0e10cSrcweir #define OPEN_URL ".uno:Open"
81cdf0e10cSrcweir
DecoToolBox(Window * pParent,WinBits nStyle)82cdf0e10cSrcweir DecoToolBox::DecoToolBox( Window* pParent, WinBits nStyle ) :
83cdf0e10cSrcweir ToolBox( pParent, nStyle )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir SetBackground();
86cdf0e10cSrcweir SetPaintTransparent( sal_True );
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
DataChanged(const DataChangedEvent & rDCEvt)89cdf0e10cSrcweir void DecoToolBox::DataChanged( const DataChangedEvent& rDCEvt )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir Window::DataChanged( rDCEvt );
92cdf0e10cSrcweir
93cdf0e10cSrcweir if ( rDCEvt.GetFlags() & SETTINGS_STYLE )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir calcMinSize();
96cdf0e10cSrcweir SetBackground();
97cdf0e10cSrcweir SetPaintTransparent( sal_True );
98cdf0e10cSrcweir }
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
calcMinSize()101cdf0e10cSrcweir void DecoToolBox::calcMinSize()
102cdf0e10cSrcweir {
103cdf0e10cSrcweir ToolBox aTbx( GetParent() );
104cdf0e10cSrcweir sal_uInt16 nItems = GetItemCount();
105cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nItems; i++ )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir sal_uInt16 nId = GetItemId( i );
108cdf0e10cSrcweir aTbx.InsertItem( nId, GetItemImage( nId ) );
109cdf0e10cSrcweir }
110cdf0e10cSrcweir aTbx.SetOutStyle( TOOLBOX_STYLE_FLAT );
111cdf0e10cSrcweir maMinSize = aTbx.CalcWindowSizePixel();
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
getMinSize()114cdf0e10cSrcweir Size DecoToolBox::getMinSize()
115cdf0e10cSrcweir {
116cdf0e10cSrcweir return maMinSize;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
119cdf0e10cSrcweir class RecentFilesStringLength : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XStringWidth >
120cdf0e10cSrcweir {
121cdf0e10cSrcweir public:
RecentFilesStringLength()122cdf0e10cSrcweir RecentFilesStringLength() {}
~RecentFilesStringLength()123cdf0e10cSrcweir virtual ~RecentFilesStringLength() {}
124cdf0e10cSrcweir
125cdf0e10cSrcweir // XStringWidth
queryStringWidth(const::rtl::OUString & aString)126cdf0e10cSrcweir sal_Int32 SAL_CALL queryStringWidth( const ::rtl::OUString& aString )
127cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
128cdf0e10cSrcweir {
129cdf0e10cSrcweir return aString.getLength();
130cdf0e10cSrcweir }
131cdf0e10cSrcweir };
132cdf0e10cSrcweir
133cdf0e10cSrcweir #define STC_BUTTON_STYLE (WB_LEFT | WB_VCENTER | WB_FLATBUTTON | WB_BEVELBUTTON)
134cdf0e10cSrcweir
BackingWindow(Window * i_pParent)135cdf0e10cSrcweir BackingWindow::BackingWindow( Window* i_pParent ) :
136cdf0e10cSrcweir Window( i_pParent, FwkResId( DLG_BACKING ) ),
137cdf0e10cSrcweir maWelcome( this, WB_LEFT ),
138cdf0e10cSrcweir maProduct( this, WB_LEFT ),
139cdf0e10cSrcweir maWriterButton( this, STC_BUTTON_STYLE ),
140cdf0e10cSrcweir maCalcButton( this, STC_BUTTON_STYLE ),
141cdf0e10cSrcweir maImpressButton( this, STC_BUTTON_STYLE ),
142cdf0e10cSrcweir maOpenButton( this, STC_BUTTON_STYLE ),
143cdf0e10cSrcweir maDrawButton( this, STC_BUTTON_STYLE ),
144cdf0e10cSrcweir maDBButton( this, STC_BUTTON_STYLE ),
145cdf0e10cSrcweir maMathButton( this, STC_BUTTON_STYLE ),
146cdf0e10cSrcweir maTemplateButton( this, STC_BUTTON_STYLE ),
147cdf0e10cSrcweir maToolbox( this, WB_DIALOGCONTROL ),
148cdf0e10cSrcweir maWelcomeString( FwkResId( STR_BACKING_WELCOME ) ),
149cdf0e10cSrcweir maProductString( FwkResId( STR_BACKING_WELCOMEPRODUCT ) ),
150cdf0e10cSrcweir maOpenString( FwkResId( STR_BACKING_FILE ) ),
151cdf0e10cSrcweir maTemplateString( FwkResId( STR_BACKING_TEMPLATE ) ),
152cdf0e10cSrcweir maButtonImageSize( 10, 10 ),
153cdf0e10cSrcweir mbInitControls( false ),
154cdf0e10cSrcweir mnLayoutStyle( 0 ),
155cdf0e10cSrcweir mpAccExec( NULL ),
156cdf0e10cSrcweir mnBtnPos( 120 ),
157*f7882915SAriel Constenla-Haile mnBtnTop( 150 )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir mnColumnWidth[0] = mnColumnWidth[1] = 0;
160cdf0e10cSrcweir mnTextColumnWidth[0] = mnTextColumnWidth[1] = 0;
161cdf0e10cSrcweir
162cdf0e10cSrcweir try
163cdf0e10cSrcweir {
164*f7882915SAriel Constenla-Haile mxContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
165*f7882915SAriel Constenla-Haile
166*f7882915SAriel Constenla-Haile Reference<lang::XMultiServiceFactory> xConfig(
167*f7882915SAriel Constenla-Haile mxContext->getServiceManager()->createInstanceWithContext(
168*f7882915SAriel Constenla-Haile SERVICENAME_CFGPROVIDER, mxContext), UNO_QUERY);
169cdf0e10cSrcweir if( xConfig.is() )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir Sequence<Any> args(1);
172cdf0e10cSrcweir PropertyValue val(
173cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("nodepath") ),
174cdf0e10cSrcweir 0,
175cdf0e10cSrcweir Any(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.Common/Help/StartCenter"))),
176cdf0e10cSrcweir PropertyState_DIRECT_VALUE);
177cdf0e10cSrcweir args.getArray()[0] <<= val;
178cdf0e10cSrcweir Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,args), UNO_QUERY);
179cdf0e10cSrcweir if( xNameAccess.is() )
180cdf0e10cSrcweir {
181cdf0e10cSrcweir //throws css::container::NoSuchElementException, css::lang::WrappedTargetException
182cdf0e10cSrcweir Any value( xNameAccess->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartCenterLayoutStyle"))) );
183cdf0e10cSrcweir mnLayoutStyle = value.get<sal_Int32>();
184cdf0e10cSrcweir }
185cdf0e10cSrcweir }
186*f7882915SAriel Constenla-Haile
187*f7882915SAriel Constenla-Haile mxPopupMenuFactory.set(
188*f7882915SAriel Constenla-Haile frame::PopupMenuControllerFactory::create( mxContext ) );
189*f7882915SAriel Constenla-Haile // TODO If there is no PopupMenuController, the button should be a nomral one not a MenuButton
190*f7882915SAriel Constenla-Haile if ( mxPopupMenuFactory->hasController(
191*f7882915SAriel Constenla-Haile DECLARE_ASCII( RECENT_FILE_LIST ) , SERVICENAME_STARTMODULE ) )
192*f7882915SAriel Constenla-Haile {
193*f7882915SAriel Constenla-Haile mxPopupMenu.set( mxContext->getServiceManager()->createInstanceWithContext(
194*f7882915SAriel Constenla-Haile DECLARE_ASCII( "com.sun.star.awt.PopupMenu" ), mxContext ), uno::UNO_QUERY_THROW );
195*f7882915SAriel Constenla-Haile }
196cdf0e10cSrcweir }
197*f7882915SAriel Constenla-Haile catch (const Exception& e)
198cdf0e10cSrcweir {
199*f7882915SAriel Constenla-Haile OSL_TRACE( "BackingWindow - caught an exception! %s",
200*f7882915SAriel Constenla-Haile rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
201*f7882915SAriel Constenla-Haile (void) e;
202cdf0e10cSrcweir }
203cdf0e10cSrcweir
204cdf0e10cSrcweir String aExtHelpText( FwkResId( STR_BACKING_EXTHELP ) );
205cdf0e10cSrcweir String aRegHelpText( FwkResId( STR_BACKING_REGHELP ) );
206cdf0e10cSrcweir String aInfoHelpText( FwkResId( STR_BACKING_INFOHELP ) );
207cdf0e10cSrcweir String aTplRepHelpText( FwkResId( STR_BACKING_TPLREP ) );
208cdf0e10cSrcweir
209cdf0e10cSrcweir // clean up resource stack
210cdf0e10cSrcweir FreeResource();
211cdf0e10cSrcweir
212cdf0e10cSrcweir maWelcome.SetPaintTransparent( sal_True );
213cdf0e10cSrcweir maProduct.SetPaintTransparent( sal_True );
214cdf0e10cSrcweir EnableChildTransparentMode();
215cdf0e10cSrcweir
216cdf0e10cSrcweir SetStyle( GetStyle() | WB_DIALOGCONTROL );
217cdf0e10cSrcweir
218cdf0e10cSrcweir // force tab cycling in toolbox
219cdf0e10cSrcweir maToolbox.SetStyle( maToolbox.GetStyle() | WB_FORCETABCYCLE );
220cdf0e10cSrcweir
221cdf0e10cSrcweir // insert toolbox items
222cdf0e10cSrcweir maToolbox.InsertItem( nItemId_TplRep, Image() );
223cdf0e10cSrcweir maToolbox.SetItemText( nItemId_TplRep, aTplRepHelpText );
224cdf0e10cSrcweir maToolbox.SetQuickHelpText( nItemId_TplRep, aTplRepHelpText );
225cdf0e10cSrcweir maToolbox.SetItemCommand( nItemId_TplRep, String( RTL_CONSTASCII_USTRINGPARAM( ".HelpId:StartCenter:TemplateRepository" ) ) );
226cdf0e10cSrcweir maToolbox.ShowItem( nItemId_TplRep );
227cdf0e10cSrcweir
228cdf0e10cSrcweir maToolbox.InsertItem( nItemId_Extensions, Image() );
229cdf0e10cSrcweir maToolbox.SetQuickHelpText( nItemId_Extensions, aExtHelpText );
230cdf0e10cSrcweir maToolbox.SetItemText( nItemId_Extensions, aExtHelpText );
231cdf0e10cSrcweir maToolbox.SetItemCommand( nItemId_Extensions, String( RTL_CONSTASCII_USTRINGPARAM( ".HelpId:StartCenter:Extensions" ) ) );
232cdf0e10cSrcweir maToolbox.ShowItem( nItemId_Extensions );
233cdf0e10cSrcweir
234cdf0e10cSrcweir maToolbox.InsertItem( nItemId_Info, Image() );
235cdf0e10cSrcweir maToolbox.SetItemText( nItemId_Info, aInfoHelpText );
236cdf0e10cSrcweir maToolbox.SetQuickHelpText( nItemId_Info, aInfoHelpText );
237cdf0e10cSrcweir maToolbox.SetItemCommand( nItemId_Info, String( RTL_CONSTASCII_USTRINGPARAM( ".HelpId:StartCenter:Info" ) ) );
238cdf0e10cSrcweir maToolbox.ShowItem( nItemId_Info );
239cdf0e10cSrcweir
240cdf0e10cSrcweir // get dispatch provider
241cdf0e10cSrcweir mxDesktop = Reference<XDesktop>( comphelper::getProcessServiceFactory()->createInstance(SERVICENAME_DESKTOP ),UNO_QUERY );
242cdf0e10cSrcweir if( mxDesktop.is() )
243cdf0e10cSrcweir mxDesktopDispatchProvider = Reference< XDispatchProvider >( mxDesktop, UNO_QUERY );
244cdf0e10cSrcweir
245cdf0e10cSrcweir maWriterButton.SetHelpId( ".HelpId:StartCenter:WriterButton" );
246cdf0e10cSrcweir maCalcButton.SetHelpId( ".HelpId:StartCenter:CalcButton" );
247cdf0e10cSrcweir maImpressButton.SetHelpId( ".HelpId:StartCenter:ImpressButton" );
248cdf0e10cSrcweir maDrawButton.SetHelpId( ".HelpId:StartCenter:DrawButton" );
249cdf0e10cSrcweir maDBButton.SetHelpId( ".HelpId:StartCenter:DBButton" );
250cdf0e10cSrcweir maMathButton.SetHelpId( ".HelpId:StartCenter:MathButton" );
251cdf0e10cSrcweir maTemplateButton.SetHelpId( ".HelpId:StartCenter:TemplateButton" );
252cdf0e10cSrcweir maOpenButton.SetHelpId( ".HelpId:StartCenter:OpenButton" );
253cdf0e10cSrcweir maToolbox.SetHelpId( ".HelpId:StartCenter:Toolbox" );
254cdf0e10cSrcweir
255cdf0e10cSrcweir // init background
256cdf0e10cSrcweir initBackground();
257cdf0e10cSrcweir
258cdf0e10cSrcweir // add some breathing space for the images
259cdf0e10cSrcweir maButtonImageSize.Width() += 12;
260cdf0e10cSrcweir maButtonImageSize.Height() += 12;
261cdf0e10cSrcweir
262cdf0e10cSrcweir }
263cdf0e10cSrcweir
264cdf0e10cSrcweir
~BackingWindow()265cdf0e10cSrcweir BackingWindow::~BackingWindow()
266cdf0e10cSrcweir {
267cdf0e10cSrcweir delete mpAccExec;
268*f7882915SAriel Constenla-Haile
269*f7882915SAriel Constenla-Haile if( mxPopupMenuController.is() )
270*f7882915SAriel Constenla-Haile {
271*f7882915SAriel Constenla-Haile Reference< lang::XComponent > xComponent( mxPopupMenuController, UNO_QUERY );
272*f7882915SAriel Constenla-Haile if( xComponent.is() )
273*f7882915SAriel Constenla-Haile {
274*f7882915SAriel Constenla-Haile try
275*f7882915SAriel Constenla-Haile {
276*f7882915SAriel Constenla-Haile xComponent->dispose();
277*f7882915SAriel Constenla-Haile }
278*f7882915SAriel Constenla-Haile catch (...)
279*f7882915SAriel Constenla-Haile {}
280*f7882915SAriel Constenla-Haile }
281*f7882915SAriel Constenla-Haile mxPopupMenuController.clear();
282*f7882915SAriel Constenla-Haile }
283*f7882915SAriel Constenla-Haile mxPopupMenuFactory.clear();
284*f7882915SAriel Constenla-Haile mxPopupMenu.clear();
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
GetFocus()287cdf0e10cSrcweir void BackingWindow::GetFocus()
288cdf0e10cSrcweir {
289cdf0e10cSrcweir if( IsVisible() )
290cdf0e10cSrcweir maWriterButton.GrabFocus();
291cdf0e10cSrcweir Window::GetFocus();
292cdf0e10cSrcweir }
293cdf0e10cSrcweir
294cdf0e10cSrcweir class ImageContainerRes : public Resource
295cdf0e10cSrcweir {
296cdf0e10cSrcweir public:
ImageContainerRes(const ResId & i_rId)297cdf0e10cSrcweir ImageContainerRes( const ResId& i_rId ) : Resource( i_rId ) {}
~ImageContainerRes()298cdf0e10cSrcweir ~ImageContainerRes() { FreeResource(); }
299cdf0e10cSrcweir };
300cdf0e10cSrcweir
DataChanged(const DataChangedEvent & rDCEvt)301cdf0e10cSrcweir void BackingWindow::DataChanged( const DataChangedEvent& rDCEvt )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir Window::DataChanged( rDCEvt );
304cdf0e10cSrcweir
305cdf0e10cSrcweir if ( rDCEvt.GetFlags() & SETTINGS_STYLE )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir initBackground();
308cdf0e10cSrcweir Invalidate();
309cdf0e10cSrcweir }
310cdf0e10cSrcweir }
311cdf0e10cSrcweir
prepareRecentFileMenu()312cdf0e10cSrcweir void BackingWindow::prepareRecentFileMenu()
313cdf0e10cSrcweir {
314*f7882915SAriel Constenla-Haile if( ! mxPopupMenu.is() )
315*f7882915SAriel Constenla-Haile return;
316cdf0e10cSrcweir
317*f7882915SAriel Constenla-Haile if ( !mxPopupMenuController.is() )
318cdf0e10cSrcweir {
319*f7882915SAriel Constenla-Haile uno::Sequence< uno::Any > aArgs( 2 );
320*f7882915SAriel Constenla-Haile beans::PropertyValue aProp;
321cdf0e10cSrcweir
322*f7882915SAriel Constenla-Haile aProp.Name = DECLARE_ASCII( "Frame" );
323*f7882915SAriel Constenla-Haile aProp.Value <<= mxFrame;
324*f7882915SAriel Constenla-Haile aArgs[0] <<= aProp;
325*f7882915SAriel Constenla-Haile
326*f7882915SAriel Constenla-Haile aProp.Name = DECLARE_ASCII( "ModuleIdentifier" );
327*f7882915SAriel Constenla-Haile aProp.Value <<= SERVICENAME_STARTMODULE;
328*f7882915SAriel Constenla-Haile aArgs[1] <<= aProp;
329*f7882915SAriel Constenla-Haile try
330*f7882915SAriel Constenla-Haile {
331*f7882915SAriel Constenla-Haile mxPopupMenuController.set(
332*f7882915SAriel Constenla-Haile mxPopupMenuFactory->createInstanceWithArgumentsAndContext(
333*f7882915SAriel Constenla-Haile DECLARE_ASCII( RECENT_FILE_LIST ), aArgs, mxContext),
334*f7882915SAriel Constenla-Haile uno::UNO_QUERY_THROW );
335*f7882915SAriel Constenla-Haile mxPopupMenuController->setPopupMenu( mxPopupMenu );
336cdf0e10cSrcweir }
337*f7882915SAriel Constenla-Haile catch ( const Exception &e )
338*f7882915SAriel Constenla-Haile {
339*f7882915SAriel Constenla-Haile OSL_TRACE( "BackingWindow - caught an exception! %s",
340*f7882915SAriel Constenla-Haile rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
341*f7882915SAriel Constenla-Haile (void) e;
342*f7882915SAriel Constenla-Haile }
343*f7882915SAriel Constenla-Haile
344*f7882915SAriel Constenla-Haile PopupMenu *pRecentMenu = NULL;
345*f7882915SAriel Constenla-Haile VCLXMenu* pTKMenu = VCLXMenu::GetImplementation( mxPopupMenu );
346*f7882915SAriel Constenla-Haile if ( pTKMenu )
347*f7882915SAriel Constenla-Haile pRecentMenu = dynamic_cast< PopupMenu * >( pTKMenu->GetMenu() );
348*f7882915SAriel Constenla-Haile maOpenButton.SetPopupMenu( pRecentMenu );
349cdf0e10cSrcweir }
350cdf0e10cSrcweir }
351cdf0e10cSrcweir
initBackground()352cdf0e10cSrcweir void BackingWindow::initBackground()
353cdf0e10cSrcweir {
354cdf0e10cSrcweir SetBackground();
355cdf0e10cSrcweir
356cdf0e10cSrcweir bool bDark = GetSettings().GetStyleSettings().GetHighContrastMode();
357cdf0e10cSrcweir if( bDark )
358cdf0e10cSrcweir maWelcomeTextColor = maLabelTextColor = Color( COL_WHITE );
359cdf0e10cSrcweir else if( mnLayoutStyle == 1 )
360cdf0e10cSrcweir maWelcomeTextColor = maLabelTextColor = Color( COL_BLACK );
361cdf0e10cSrcweir else
362cdf0e10cSrcweir maWelcomeTextColor = maLabelTextColor = Color( 0x26, 0x35, 0x42 );
363cdf0e10cSrcweir
364cdf0e10cSrcweir Color aTextBGColor( bDark ? COL_BLACK : COL_WHITE );
365cdf0e10cSrcweir
366cdf0e10cSrcweir // select image set
367cdf0e10cSrcweir ImageContainerRes aRes( FwkResId( bDark ? RES_BACKING_IMAGES_HC : RES_BACKING_IMAGES ) );
368cdf0e10cSrcweir
369cdf0e10cSrcweir // scale middle segment
370cdf0e10cSrcweir Size aMiddleSize;
371cdf0e10cSrcweir if( !! maBackgroundMiddle )
372cdf0e10cSrcweir aMiddleSize = maBackgroundMiddle.GetSizePixel();
373cdf0e10cSrcweir // load middle segment
374cdf0e10cSrcweir maBackgroundMiddle = BitmapEx( FwkResId( BMP_BACKING_BACKGROUND_MIDDLE ) );
375cdf0e10cSrcweir // and scale it to previous size
376cdf0e10cSrcweir if( aMiddleSize.Width() && aMiddleSize.Height() )
377cdf0e10cSrcweir maBackgroundMiddle.Scale( aMiddleSize );
378cdf0e10cSrcweir
379cdf0e10cSrcweir if( GetSettings().GetLayoutRTL() )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir // replace images by RTL versions
382cdf0e10cSrcweir maBackgroundLeft = BitmapEx( FwkResId( BMP_BACKING_BACKGROUND_RTL_RIGHT ) );
383cdf0e10cSrcweir maBackgroundRight = BitmapEx( FwkResId( BMP_BACKING_BACKGROUND_RTL_LEFT) );
384cdf0e10cSrcweir }
385cdf0e10cSrcweir else
386cdf0e10cSrcweir {
387cdf0e10cSrcweir maBackgroundLeft = BitmapEx( FwkResId( BMP_BACKING_BACKGROUND_LEFT ) );
388cdf0e10cSrcweir maBackgroundRight = BitmapEx( FwkResId( BMP_BACKING_BACKGROUND_RIGHT ) );
389cdf0e10cSrcweir }
390cdf0e10cSrcweir maToolbox.SetItemImage( nItemId_Extensions, BitmapEx( FwkResId( BMP_BACKING_EXT ) ) );
391288ab9e2SHerbert Dürr //### maToolbox.SetItemImage( nItemId_Reg, BitmapEx( FwkResId( BMP_BACKING_REG ) ) );
392cdf0e10cSrcweir maToolbox.SetItemImage( nItemId_Info, BitmapEx( FwkResId( BMP_BACKING_INFO ) ) );
393cdf0e10cSrcweir maToolbox.SetItemImage( nItemId_TplRep, BitmapEx( FwkResId( BMP_BACKING_TPLREP ) ) );
394cdf0e10cSrcweir
395cdf0e10cSrcweir maWelcome.SetControlForeground( maWelcomeTextColor );
396cdf0e10cSrcweir maWelcome.SetBackground();
397cdf0e10cSrcweir maProduct.SetControlForeground( maWelcomeTextColor );
398cdf0e10cSrcweir maProduct.SetBackground();
399cdf0e10cSrcweir
400cdf0e10cSrcweir if( mnLayoutStyle == 1 )
401cdf0e10cSrcweir {
402cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() )
403cdf0e10cSrcweir mnBtnPos = maBackgroundRight.GetSizePixel().Width() + 40;
404cdf0e10cSrcweir else
405cdf0e10cSrcweir mnBtnPos = maBackgroundLeft.GetSizePixel().Width() + 40;
406cdf0e10cSrcweir }
407cdf0e10cSrcweir
408cdf0e10cSrcweir // get icon images from fwk resource and set them on the appropriate buttons
409cdf0e10cSrcweir loadImage( FwkResId( BMP_BACKING_WRITER ), maWriterButton );
410cdf0e10cSrcweir loadImage( FwkResId( BMP_BACKING_CALC ), maCalcButton );
411cdf0e10cSrcweir loadImage( FwkResId( BMP_BACKING_IMPRESS ), maImpressButton );
412cdf0e10cSrcweir loadImage( FwkResId( BMP_BACKING_DRAW ), maDrawButton );
413cdf0e10cSrcweir loadImage( FwkResId( BMP_BACKING_DATABASE ), maDBButton );
414cdf0e10cSrcweir loadImage( FwkResId( BMP_BACKING_FORMULA ), maMathButton );
415cdf0e10cSrcweir loadImage( FwkResId( BMP_BACKING_OPENFILE ), maOpenButton );
416cdf0e10cSrcweir loadImage( FwkResId( BMP_BACKING_OPENTEMPLATE ), maTemplateButton );
417cdf0e10cSrcweir
418cdf0e10cSrcweir maOpenButton.SetMenuMode( MENUBUTTON_MENUMODE_TIMED );
419cdf0e10cSrcweir maOpenButton.SetActivateHdl( LINK( this, BackingWindow, ActivateHdl ) );
420cdf0e10cSrcweir }
421cdf0e10cSrcweir
initControls()422cdf0e10cSrcweir void BackingWindow::initControls()
423cdf0e10cSrcweir {
424cdf0e10cSrcweir if( mbInitControls )
425cdf0e10cSrcweir return;
426cdf0e10cSrcweir
427cdf0e10cSrcweir mbInitControls = true;
428cdf0e10cSrcweir
429cdf0e10cSrcweir // calculate dialog size
430cdf0e10cSrcweir // begin with background bitmap
431cdf0e10cSrcweir maControlRect = Rectangle( Point(), maBackgroundLeft.GetSizePixel() );
432cdf0e10cSrcweir maControlRect.Left() += nShadowLeft;
433cdf0e10cSrcweir maControlRect.Right() -= nShadowRight;
434cdf0e10cSrcweir maControlRect.Top() += nShadowTop;
435cdf0e10cSrcweir maControlRect.Bottom() -= nShadowBottom;
436cdf0e10cSrcweir
437cdf0e10cSrcweir long nYPos = 0;
438cdf0e10cSrcweir // set bigger welcome string
439cdf0e10cSrcweir maWelcome.SetText( maWelcomeString );
440cdf0e10cSrcweir maTextFont = GetSettings().GetStyleSettings().GetLabelFont();
441cdf0e10cSrcweir maTextFont.SetSize( Size( 0, 18 ) );
442cdf0e10cSrcweir maTextFont.SetWeight( WEIGHT_BOLD );
443cdf0e10cSrcweir maWelcome.SetFont( maTextFont );
444cdf0e10cSrcweir // get metric to get correct width factor and adjust
445cdf0e10cSrcweir long nW = (maWelcome.GetFontMetric().GetWidth()*95)/100;
446cdf0e10cSrcweir maTextFont.SetSize( Size( nW, 18 ) );
447cdf0e10cSrcweir
448cdf0e10cSrcweir maWelcome.SetFont( maTextFont );
449cdf0e10cSrcweir maWelcome.SetControlFont( maTextFont );
450cdf0e10cSrcweir maWelcomeSize = Size( maWelcome.GetTextWidth( maWelcomeString ), maWelcome.GetTextHeight() );
451cdf0e10cSrcweir maWelcomeSize.Width() = (maWelcomeSize.Width() * 20)/19;
452cdf0e10cSrcweir
453cdf0e10cSrcweir nYPos += (maWelcomeSize.Height()*3)/2;
454cdf0e10cSrcweir
455cdf0e10cSrcweir if( maControlRect.GetWidth() < mnBtnPos + maWelcomeSize.Width() + 20 )
456cdf0e10cSrcweir maControlRect.Right() = maControlRect.Left() + maWelcomeSize.Width() + mnBtnPos + 20;
457cdf0e10cSrcweir
458cdf0e10cSrcweir nYPos += maWelcomeSize.Height();
459cdf0e10cSrcweir
460cdf0e10cSrcweir // set product string
461cdf0e10cSrcweir maTextFont.SetSize( Size( 0, 30 ) );
462cdf0e10cSrcweir maProduct.SetFont( maTextFont );
463cdf0e10cSrcweir
464cdf0e10cSrcweir // get metric to get correct width factor and adjust
465cdf0e10cSrcweir nW = (maProduct.GetFontMetric().GetWidth()*95)/100;
466cdf0e10cSrcweir maTextFont.SetSize( Size( nW, 28 ) );
467cdf0e10cSrcweir
468cdf0e10cSrcweir maProduct.SetFont( maTextFont );
469cdf0e10cSrcweir maProduct.SetControlFont( maTextFont );
470cdf0e10cSrcweir maProduct.SetText( maProductString );
471cdf0e10cSrcweir maProductSize = Size( maProduct.GetTextWidth( maProductString ), maProduct.GetTextHeight() );
472cdf0e10cSrcweir maProductSize.Width() = (maProductSize.Width() * 20)/19;
473cdf0e10cSrcweir
474cdf0e10cSrcweir if( maControlRect.GetWidth() < maProductSize.Width() + mnBtnPos + 10 )
475cdf0e10cSrcweir maControlRect.Right() = maControlRect.Left() + maProductSize.Width() + mnBtnPos + 10;
476cdf0e10cSrcweir
477cdf0e10cSrcweir if( mnLayoutStyle == 1 )
478cdf0e10cSrcweir {
479cdf0e10cSrcweir maWelcome.Show();
480cdf0e10cSrcweir maProduct.Show();
481cdf0e10cSrcweir }
482cdf0e10cSrcweir
483cdf0e10cSrcweir nYPos += (maProductSize.Height()*3)/2;
484cdf0e10cSrcweir
485cdf0e10cSrcweir // set a slighly larger font than normal labels on the texts
486cdf0e10cSrcweir maTextFont.SetSize( Size( 0, 11 ) );
487cdf0e10cSrcweir maTextFont.SetWeight( WEIGHT_NORMAL );
488cdf0e10cSrcweir
489cdf0e10cSrcweir // collect the URLs of the entries in the File/New menu
490cdf0e10cSrcweir SvtModuleOptions aModuleOptions;
491cdf0e10cSrcweir std::set< rtl::OUString > aFileNewAppsAvailable;
492cdf0e10cSrcweir SvtDynamicMenuOptions aOpt;
493cdf0e10cSrcweir Sequence < Sequence < PropertyValue > > aNewMenu = aOpt.GetMenu( E_NEWMENU );
494cdf0e10cSrcweir const rtl::OUString sURLKey( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
495cdf0e10cSrcweir
496cdf0e10cSrcweir const Sequence< PropertyValue >* pNewMenu = aNewMenu.getConstArray();
497cdf0e10cSrcweir const Sequence< PropertyValue >* pNewMenuEnd = aNewMenu.getConstArray() + aNewMenu.getLength();
498cdf0e10cSrcweir for ( ; pNewMenu != pNewMenuEnd; ++pNewMenu )
499cdf0e10cSrcweir {
500cdf0e10cSrcweir comphelper::SequenceAsHashMap aEntryItems( *pNewMenu );
501cdf0e10cSrcweir rtl::OUString sURL( aEntryItems.getUnpackedValueOrDefault( sURLKey, rtl::OUString() ) );
502cdf0e10cSrcweir if ( sURL.getLength() )
503cdf0e10cSrcweir aFileNewAppsAvailable.insert( sURL );
504cdf0e10cSrcweir }
505cdf0e10cSrcweir
506cdf0e10cSrcweir // create mnemonics on the fly, preregister the mnemonics of the menu
507cdf0e10cSrcweir MnemonicGenerator aMnemns;
508cdf0e10cSrcweir maTemplateString = MnemonicGenerator::EraseAllMnemonicChars( maTemplateString );
509cdf0e10cSrcweir maOpenString = MnemonicGenerator::EraseAllMnemonicChars( maOpenString );
510cdf0e10cSrcweir
511cdf0e10cSrcweir SystemWindow* pSysWin = GetSystemWindow();
512cdf0e10cSrcweir if( pSysWin )
513cdf0e10cSrcweir {
514cdf0e10cSrcweir MenuBar* pMBar = pSysWin->GetMenuBar();
515cdf0e10cSrcweir if( pMBar )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir for( sal_uInt16 i = 0; i < pMBar->GetItemCount(); i++ )
518cdf0e10cSrcweir {
519cdf0e10cSrcweir sal_uInt16 nItemId = pMBar->GetItemId( i );
520cdf0e10cSrcweir String aItemText( pMBar->GetItemText( nItemId ) );
521cdf0e10cSrcweir if( aItemText.Len() )
522cdf0e10cSrcweir aMnemns.RegisterMnemonic( aItemText );
523cdf0e10cSrcweir }
524cdf0e10cSrcweir }
525cdf0e10cSrcweir }
526cdf0e10cSrcweir
527cdf0e10cSrcweir // layout the buttons
528cdf0e10cSrcweir layoutButton( WRITER_URL, 0, aFileNewAppsAvailable,
529cdf0e10cSrcweir aModuleOptions, SvtModuleOptions::E_SWRITER,
530cdf0e10cSrcweir maWriterButton, aMnemns );
531cdf0e10cSrcweir layoutButton( DRAW_URL, 1, aFileNewAppsAvailable,
532cdf0e10cSrcweir aModuleOptions, SvtModuleOptions::E_SDRAW,
533cdf0e10cSrcweir maDrawButton, aMnemns );
534cdf0e10cSrcweir nYPos += maButtonImageSize.Height() + 10;
535cdf0e10cSrcweir layoutButton( CALC_URL, 0, aFileNewAppsAvailable,
536cdf0e10cSrcweir aModuleOptions, SvtModuleOptions::E_SCALC,
537cdf0e10cSrcweir maCalcButton, aMnemns );
538cdf0e10cSrcweir layoutButton( BASE_URL, 1, aFileNewAppsAvailable,
539cdf0e10cSrcweir aModuleOptions, SvtModuleOptions::E_SDATABASE,
540cdf0e10cSrcweir maDBButton, aMnemns );
541cdf0e10cSrcweir nYPos += maButtonImageSize.Height() + 10;
542cdf0e10cSrcweir layoutButton( IMPRESS_WIZARD_URL, 0, aFileNewAppsAvailable,
543cdf0e10cSrcweir aModuleOptions, SvtModuleOptions::E_SIMPRESS,
544cdf0e10cSrcweir maImpressButton, aMnemns );
545cdf0e10cSrcweir layoutButton( MATH_URL, 1, aFileNewAppsAvailable,
546cdf0e10cSrcweir aModuleOptions, SvtModuleOptions::E_SMATH,
547cdf0e10cSrcweir maMathButton, aMnemns );
548cdf0e10cSrcweir
549cdf0e10cSrcweir nYPos += 3*maButtonImageSize.Height() / 2;
550cdf0e10cSrcweir
551cdf0e10cSrcweir layoutButton( NULL, 0, aFileNewAppsAvailable,
552cdf0e10cSrcweir aModuleOptions, SvtModuleOptions::E_SWRITER,
553cdf0e10cSrcweir maOpenButton, aMnemns, maOpenString );
554cdf0e10cSrcweir layoutButton( NULL, 1, aFileNewAppsAvailable,
555cdf0e10cSrcweir aModuleOptions, SvtModuleOptions::E_SWRITER,
556cdf0e10cSrcweir maTemplateButton, aMnemns, maTemplateString );
557cdf0e10cSrcweir nYPos += 10;
558cdf0e10cSrcweir
559cdf0e10cSrcweir DBG_ASSERT( nYPos < maControlRect.GetHeight(), "misformatting !" );
560cdf0e10cSrcweir if( mnColumnWidth[0] + mnColumnWidth[1] + mnBtnPos + 20 > maControlRect.GetWidth() )
561cdf0e10cSrcweir maControlRect.Right() = maControlRect.Left() + mnColumnWidth[0] + mnColumnWidth[1] + mnBtnPos + 20;
562cdf0e10cSrcweir
563cdf0e10cSrcweir mnTextColumnWidth[0] = mnColumnWidth[0];
564cdf0e10cSrcweir mnTextColumnWidth[1] = mnColumnWidth[1];
565cdf0e10cSrcweir
566cdf0e10cSrcweir if( mnTextColumnWidth[1] > mnTextColumnWidth[0] )
567cdf0e10cSrcweir {
568cdf0e10cSrcweir mnColumnWidth[0] = mnColumnWidth[1];
569cdf0e10cSrcweir mnTextColumnWidth[0] = mnTextColumnWidth[1];
570cdf0e10cSrcweir }
571cdf0e10cSrcweir else
572cdf0e10cSrcweir {
573cdf0e10cSrcweir mnColumnWidth[1] = mnColumnWidth[0];
574cdf0e10cSrcweir mnTextColumnWidth[1] = mnTextColumnWidth[0];
575cdf0e10cSrcweir }
576cdf0e10cSrcweir if( maControlRect.GetWidth() < maControlRect.GetHeight() * 3 / 2 )
577cdf0e10cSrcweir {
578cdf0e10cSrcweir maControlRect.Right() = maControlRect.Left() + maControlRect.GetHeight() * 3 / 2;
579cdf0e10cSrcweir long nDelta = (maControlRect.GetWidth() - mnBtnPos - mnColumnWidth[1] - mnColumnWidth[0] - 20);
580cdf0e10cSrcweir mnColumnWidth[0] += nDelta/2;
581cdf0e10cSrcweir mnColumnWidth[1] += nDelta/2;
582cdf0e10cSrcweir }
583cdf0e10cSrcweir
584cdf0e10cSrcweir maToolbox.SetSelectHdl( LINK( this, BackingWindow, ToolboxHdl ) );
585cdf0e10cSrcweir if( mnLayoutStyle == 0 )
586cdf0e10cSrcweir maToolbox.Show();
587cdf0e10cSrcweir
588cdf0e10cSrcweir // scale middle map to formatted width
589cdf0e10cSrcweir Size aMiddleSegmentSize( maControlRect.GetSize().Width() + nShadowLeft + nShadowRight,
590cdf0e10cSrcweir maBackgroundMiddle.GetSizePixel().Height() );
591cdf0e10cSrcweir
592cdf0e10cSrcweir long nLW = maBackgroundLeft.GetSizePixel().Width();
593cdf0e10cSrcweir long nRW = maBackgroundRight.GetSizePixel().Width();
594cdf0e10cSrcweir if( aMiddleSegmentSize.Width() > nLW + nRW )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir aMiddleSegmentSize.Width() -= nLW;
597cdf0e10cSrcweir aMiddleSegmentSize.Width() -= nRW;
598cdf0e10cSrcweir maBackgroundMiddle.Scale( aMiddleSegmentSize );
599cdf0e10cSrcweir }
600cdf0e10cSrcweir else
601cdf0e10cSrcweir maBackgroundMiddle = BitmapEx();
602cdf0e10cSrcweir
603cdf0e10cSrcweir Resize();
604cdf0e10cSrcweir
605cdf0e10cSrcweir maWriterButton.GrabFocus();
606cdf0e10cSrcweir }
607cdf0e10cSrcweir
loadImage(const ResId & i_rId,PushButton & i_rButton)608cdf0e10cSrcweir void BackingWindow::loadImage( const ResId& i_rId, PushButton& i_rButton )
609cdf0e10cSrcweir {
610cdf0e10cSrcweir BitmapEx aBmp( i_rId );
611cdf0e10cSrcweir Size aImgSize( aBmp.GetSizePixel() );
612cdf0e10cSrcweir if( aImgSize.Width() > maButtonImageSize.Width() )
613cdf0e10cSrcweir maButtonImageSize.Width() = aImgSize.Width();
614cdf0e10cSrcweir if( aImgSize.Height() > maButtonImageSize.Height() )
615cdf0e10cSrcweir maButtonImageSize.Height() = aImgSize.Height();
616cdf0e10cSrcweir i_rButton.SetModeImage( aBmp );
617cdf0e10cSrcweir }
618cdf0e10cSrcweir
layoutButton(const char * i_pURL,int nColumn,const std::set<rtl::OUString> & i_rURLS,SvtModuleOptions & i_rOpt,SvtModuleOptions::EModule i_eMod,PushButton & i_rBtn,MnemonicGenerator & i_rMnemns,const String & i_rStr)619cdf0e10cSrcweir void BackingWindow::layoutButton(
620cdf0e10cSrcweir const char* i_pURL, int nColumn,
621cdf0e10cSrcweir const std::set<rtl::OUString>& i_rURLS,
622cdf0e10cSrcweir SvtModuleOptions& i_rOpt, SvtModuleOptions::EModule i_eMod,
623cdf0e10cSrcweir PushButton& i_rBtn,
624cdf0e10cSrcweir MnemonicGenerator& i_rMnemns,
625cdf0e10cSrcweir const String& i_rStr
626cdf0e10cSrcweir )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir rtl::OUString aURL( rtl::OUString::createFromAscii( i_pURL ? i_pURL : "" ) );
629cdf0e10cSrcweir // setup button
630cdf0e10cSrcweir i_rBtn.SetPaintTransparent( sal_True );
631cdf0e10cSrcweir i_rBtn.SetClickHdl( LINK( this, BackingWindow, ClickHdl ) );
632cdf0e10cSrcweir if( i_pURL && (! i_rOpt.IsModuleInstalled( i_eMod ) || i_rURLS.find( aURL ) == i_rURLS.end()) )
633cdf0e10cSrcweir {
634cdf0e10cSrcweir i_rBtn.Enable( sal_False );
635cdf0e10cSrcweir }
636cdf0e10cSrcweir
637cdf0e10cSrcweir // setup text
638cdf0e10cSrcweir i_rBtn.SetFont( maTextFont );
639cdf0e10cSrcweir i_rBtn.SetControlFont( maTextFont );
640cdf0e10cSrcweir String aText( i_rStr.Len() ? i_rStr : SvFileInformationManager::GetDescription( INetURLObject( aURL ) ) );
641cdf0e10cSrcweir i_rMnemns.CreateMnemonic( aText );
642cdf0e10cSrcweir i_rBtn.SetText( aText );
643cdf0e10cSrcweir
644cdf0e10cSrcweir long nTextWidth = i_rBtn.GetTextWidth( i_rBtn.GetText() );
645cdf0e10cSrcweir
646cdf0e10cSrcweir nTextWidth += maButtonImageSize.Width() + 8; // add some fuzz to be on the safe side
647cdf0e10cSrcweir if( nColumn >= 0 && nColumn < static_cast<int>(sizeof(mnColumnWidth)/sizeof(mnColumnWidth[0])) )
648cdf0e10cSrcweir {
649cdf0e10cSrcweir if( nTextWidth > mnColumnWidth[nColumn] )
650cdf0e10cSrcweir mnColumnWidth[nColumn] = nTextWidth;
651cdf0e10cSrcweir }
652cdf0e10cSrcweir
653cdf0e10cSrcweir i_rBtn.SetImageAlign( IMAGEALIGN_LEFT );
654cdf0e10cSrcweir // show the controls
655cdf0e10cSrcweir i_rBtn.Show();
656cdf0e10cSrcweir }
657cdf0e10cSrcweir
Paint(const Rectangle &)658cdf0e10cSrcweir void BackingWindow::Paint( const Rectangle& )
659cdf0e10cSrcweir {
6606e2074bdSHerbert Dürr Resize();
6616e2074bdSHerbert Dürr
662cdf0e10cSrcweir Wallpaper aBack( GetSettings().GetStyleSettings().GetWorkspaceGradient() );
663cdf0e10cSrcweir Region aClip( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
664cdf0e10cSrcweir Rectangle aBmpRect(maControlRect);
665cdf0e10cSrcweir aBmpRect.Left() -= nShadowLeft;
666cdf0e10cSrcweir aBmpRect.Top() -= nShadowTop;
667cdf0e10cSrcweir aBmpRect.Right() += nShadowRight;
668cdf0e10cSrcweir aBmpRect.Bottom() += nShadowBottom;
669cdf0e10cSrcweir aClip.Exclude( aBmpRect );
670cdf0e10cSrcweir Push( PUSH_CLIPREGION );
671cdf0e10cSrcweir IntersectClipRegion( aClip );
672cdf0e10cSrcweir DrawWallpaper( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ), aBack );
673cdf0e10cSrcweir Pop();
674cdf0e10cSrcweir
675cdf0e10cSrcweir VirtualDevice aDev( *this );
676cdf0e10cSrcweir aDev.EnableRTL( IsRTLEnabled() );
677cdf0e10cSrcweir aDev.SetOutputSizePixel( aBmpRect.GetSize() );
678cdf0e10cSrcweir Point aOffset( Point( 0, 0 ) - aBmpRect.TopLeft() );
679cdf0e10cSrcweir aDev.DrawWallpaper( Rectangle( aOffset, GetOutputSizePixel() ), aBack );
680cdf0e10cSrcweir
681cdf0e10cSrcweir // draw bitmap
682cdf0e10cSrcweir Point aTL( 0, 0 );
683cdf0e10cSrcweir aDev.DrawBitmapEx( aTL, maBackgroundLeft );
684cdf0e10cSrcweir aTL.X() += maBackgroundLeft.GetSizePixel().Width();
685cdf0e10cSrcweir if( !!maBackgroundMiddle )
686cdf0e10cSrcweir {
687cdf0e10cSrcweir aDev.DrawBitmapEx( aTL, maBackgroundMiddle );
688cdf0e10cSrcweir aTL.X() += maBackgroundMiddle.GetSizePixel().Width();
689cdf0e10cSrcweir }
690cdf0e10cSrcweir aDev.DrawBitmapEx( aTL, maBackgroundRight );
691cdf0e10cSrcweir
692cdf0e10cSrcweir DrawOutDev( aBmpRect.TopLeft(), aBmpRect.GetSize(),
693cdf0e10cSrcweir Point( 0, 0 ), aBmpRect.GetSize(),
694cdf0e10cSrcweir aDev );
695cdf0e10cSrcweir }
696cdf0e10cSrcweir
Notify(NotifyEvent & rNEvt)697cdf0e10cSrcweir long BackingWindow::Notify( NotifyEvent& rNEvt )
698cdf0e10cSrcweir {
699cdf0e10cSrcweir if( rNEvt.GetType() == EVENT_KEYINPUT )
700cdf0e10cSrcweir {
701cdf0e10cSrcweir if( ! mpAccExec )
702cdf0e10cSrcweir {
703cdf0e10cSrcweir mpAccExec = svt::AcceleratorExecute::createAcceleratorHelper();
704cdf0e10cSrcweir mpAccExec->init( comphelper::getProcessServiceFactory(), mxFrame);
705cdf0e10cSrcweir }
706cdf0e10cSrcweir
707cdf0e10cSrcweir const KeyEvent* pEvt = rNEvt.GetKeyEvent();
708cdf0e10cSrcweir const KeyCode& rKeyCode(pEvt->GetKeyCode());
709cdf0e10cSrcweir if( pEvt && mpAccExec->execute(rKeyCode) )
710cdf0e10cSrcweir return 1;
711cdf0e10cSrcweir // #i110344# extrawurst: specialized arrow key control
712cdf0e10cSrcweir if( rKeyCode.GetModifier() == 0 )
713cdf0e10cSrcweir {
714cdf0e10cSrcweir if( rKeyCode.GetCode() == KEY_RIGHT )
715cdf0e10cSrcweir {
716cdf0e10cSrcweir if( maWriterButton.HasFocus() )
717cdf0e10cSrcweir maDrawButton.GrabFocus();
718cdf0e10cSrcweir else if( maCalcButton.HasFocus() )
719cdf0e10cSrcweir maDBButton.GrabFocus();
720cdf0e10cSrcweir else if( maImpressButton.HasFocus() )
721cdf0e10cSrcweir maMathButton.GrabFocus();
722cdf0e10cSrcweir else if( maOpenButton.HasFocus() )
723cdf0e10cSrcweir maTemplateButton.GrabFocus();
724cdf0e10cSrcweir return 1;
725cdf0e10cSrcweir }
726cdf0e10cSrcweir else if( rKeyCode.GetCode() == KEY_LEFT )
727cdf0e10cSrcweir {
728cdf0e10cSrcweir if( maDrawButton.HasFocus() )
729cdf0e10cSrcweir maWriterButton.GrabFocus();
730cdf0e10cSrcweir else if( maDBButton.HasFocus() )
731cdf0e10cSrcweir maCalcButton.GrabFocus();
732cdf0e10cSrcweir else if( maMathButton.HasFocus() )
733cdf0e10cSrcweir maImpressButton.GrabFocus();
734cdf0e10cSrcweir else if( maTemplateButton.HasFocus() )
735cdf0e10cSrcweir maOpenButton.GrabFocus();
736cdf0e10cSrcweir return 1;
737cdf0e10cSrcweir }
738cdf0e10cSrcweir else if( rKeyCode.GetCode() == KEY_UP )
739cdf0e10cSrcweir {
740cdf0e10cSrcweir // first column
741cdf0e10cSrcweir if( maOpenButton.HasFocus() )
742cdf0e10cSrcweir maImpressButton.GrabFocus();
743cdf0e10cSrcweir else if( maImpressButton.HasFocus() )
744cdf0e10cSrcweir maCalcButton.GrabFocus();
745cdf0e10cSrcweir else if( maCalcButton.HasFocus() )
746cdf0e10cSrcweir maWriterButton.GrabFocus();
747cdf0e10cSrcweir // second column
748cdf0e10cSrcweir else if( maTemplateButton.HasFocus() )
749cdf0e10cSrcweir maMathButton.GrabFocus();
750cdf0e10cSrcweir else if( maMathButton.HasFocus() )
751cdf0e10cSrcweir maDBButton.GrabFocus();
752cdf0e10cSrcweir else if( maDBButton.HasFocus() )
753cdf0e10cSrcweir maDrawButton.GrabFocus();
754cdf0e10cSrcweir return 1;
755cdf0e10cSrcweir }
756cdf0e10cSrcweir else if( rKeyCode.GetCode() == KEY_DOWN )
757cdf0e10cSrcweir {
758cdf0e10cSrcweir // first column
759cdf0e10cSrcweir if( maWriterButton.HasFocus() )
760cdf0e10cSrcweir maCalcButton.GrabFocus();
761cdf0e10cSrcweir else if( maCalcButton.HasFocus() )
762cdf0e10cSrcweir maImpressButton.GrabFocus();
763cdf0e10cSrcweir else if( maImpressButton.HasFocus() )
764cdf0e10cSrcweir maOpenButton.GrabFocus();
765cdf0e10cSrcweir // second column
766cdf0e10cSrcweir else if( maDrawButton.HasFocus() )
767cdf0e10cSrcweir maDBButton.GrabFocus();
768cdf0e10cSrcweir else if( maDBButton.HasFocus() )
769cdf0e10cSrcweir maMathButton.GrabFocus();
770cdf0e10cSrcweir else if( maMathButton.HasFocus() )
771cdf0e10cSrcweir maTemplateButton.GrabFocus();
772cdf0e10cSrcweir return 1;
773cdf0e10cSrcweir }
774cdf0e10cSrcweir }
775cdf0e10cSrcweir }
776cdf0e10cSrcweir return Window::Notify( rNEvt );
777cdf0e10cSrcweir }
778cdf0e10cSrcweir
setOwningFrame(const com::sun::star::uno::Reference<com::sun::star::frame::XFrame> & xFrame)779cdf0e10cSrcweir void BackingWindow::setOwningFrame( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame )
780cdf0e10cSrcweir {
781cdf0e10cSrcweir mxFrame = xFrame;
782cdf0e10cSrcweir if( ! mbInitControls )
783cdf0e10cSrcweir initControls();
784cdf0e10cSrcweir }
785cdf0e10cSrcweir
Resize()786cdf0e10cSrcweir void BackingWindow::Resize()
787cdf0e10cSrcweir {
788cdf0e10cSrcweir Size aWindowSize( GetSizePixel() );
789cdf0e10cSrcweir Size aControlSize = maControlRect.GetSize();
790cdf0e10cSrcweir maControlRect = Rectangle( Point( (aWindowSize.Width() - aControlSize.Width()) / 2,
791cdf0e10cSrcweir (aWindowSize.Height() - aControlSize.Height()) / 2 ),
792cdf0e10cSrcweir aControlSize );
793cdf0e10cSrcweir
794cdf0e10cSrcweir maToolbox.calcMinSize();
795cdf0e10cSrcweir Size aTBSize( maToolbox.getMinSize() );
796cdf0e10cSrcweir Point aTBPos( maControlRect.Left() + mnBtnPos,
797cdf0e10cSrcweir maControlRect.Bottom() - aTBSize.Height() - 10 );
798cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() )
799cdf0e10cSrcweir aTBPos.X() = maControlRect.Right() - aTBSize.Width() - mnBtnPos;
800cdf0e10cSrcweir maToolbox.SetPosSizePixel( aTBPos, aTBSize );
801cdf0e10cSrcweir
802cdf0e10cSrcweir // #i93631# squeeze controls so they fit into the box
803cdf0e10cSrcweir // this can be necessary due to application font height which has small deviations
804cdf0e10cSrcweir // from the size set
805cdf0e10cSrcweir const long nWDelta = maWelcomeSize.Height();
806cdf0e10cSrcweir const long nW2Delta = (maWelcomeSize.Height()*3)/2;
807cdf0e10cSrcweir const long nPDelta = (maProductSize.Height()*3)/2;
808cdf0e10cSrcweir const long nBDelta = maButtonImageSize.Height() + 10;
809cdf0e10cSrcweir const long nB2Delta = 3*maButtonImageSize.Height()/2;
810cdf0e10cSrcweir const long nLastDelta = maButtonImageSize.Height();
811cdf0e10cSrcweir long nDiff = 0;
812cdf0e10cSrcweir while( ( maControlRect.Top() +
813cdf0e10cSrcweir (nWDelta - nDiff) +
814cdf0e10cSrcweir (nW2Delta- nDiff) +
815cdf0e10cSrcweir (nPDelta - nDiff) +
816cdf0e10cSrcweir 3 * (nBDelta - nDiff) +
817cdf0e10cSrcweir (nB2Delta- nDiff) +
818cdf0e10cSrcweir nLastDelta
819cdf0e10cSrcweir ) > aTBPos.Y() )
820cdf0e10cSrcweir {
821cdf0e10cSrcweir nDiff++;
822cdf0e10cSrcweir }
823cdf0e10cSrcweir
824cdf0e10cSrcweir long nYPos = maControlRect.Top();
825cdf0e10cSrcweir nYPos += nW2Delta - nDiff;
826cdf0e10cSrcweir maWelcome.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos, nYPos ),
827cdf0e10cSrcweir Size( maControlRect.GetWidth() - mnBtnPos - 5, (maWelcomeSize.Height()*20)/19 ) );
828cdf0e10cSrcweir nYPos += nWDelta - nDiff;
829cdf0e10cSrcweir maProduct.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos, nYPos ), Size( maControlRect.GetWidth() - mnBtnPos - 5, (maProductSize.Height()*20)/19 ) );
830cdf0e10cSrcweir nYPos += nPDelta - nDiff;
831cdf0e10cSrcweir
832cdf0e10cSrcweir nYPos += nWDelta/2 - nDiff;
833cdf0e10cSrcweir
834cdf0e10cSrcweir if( mnLayoutStyle != 1 )
835cdf0e10cSrcweir nYPos = maControlRect.Top() + mnBtnTop;
836cdf0e10cSrcweir
837cdf0e10cSrcweir maWriterButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos, nYPos ), Size( mnTextColumnWidth[0], maButtonImageSize.Height() ) );
838cdf0e10cSrcweir maDrawButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos + mnColumnWidth[0], nYPos ), Size( mnTextColumnWidth[1], maButtonImageSize.Height() ) );
839cdf0e10cSrcweir nYPos += nBDelta - nDiff;
840cdf0e10cSrcweir maCalcButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos, nYPos ), Size( mnTextColumnWidth[0], maButtonImageSize.Height() ) );
841cdf0e10cSrcweir maDBButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos + mnColumnWidth[0], nYPos ), Size( mnTextColumnWidth[1], maButtonImageSize.Height() ) );
842cdf0e10cSrcweir nYPos += nBDelta - nDiff;
843cdf0e10cSrcweir maImpressButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos, nYPos ), Size( mnTextColumnWidth[0], maButtonImageSize.Height() ) );
844cdf0e10cSrcweir maMathButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos + mnColumnWidth[0], nYPos ), Size( mnTextColumnWidth[1], maButtonImageSize.Height() ) );
845cdf0e10cSrcweir
846cdf0e10cSrcweir nYPos += nB2Delta - nDiff;
847cdf0e10cSrcweir maOpenButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos, nYPos ), Size( mnTextColumnWidth[0], maButtonImageSize.Height() ) );
848cdf0e10cSrcweir maTemplateButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos + mnColumnWidth[0], nYPos ), Size( mnTextColumnWidth[1], maButtonImageSize.Height() ) );
8496e2074bdSHerbert Dürr
8506e2074bdSHerbert Dürr if( !IsInPaint())
8516e2074bdSHerbert Dürr Invalidate();
852cdf0e10cSrcweir }
853cdf0e10cSrcweir
IMPL_LINK(BackingWindow,ToolboxHdl,void *,EMPTYARG)854cdf0e10cSrcweir IMPL_LINK( BackingWindow, ToolboxHdl, void*, EMPTYARG )
855cdf0e10cSrcweir {
856cdf0e10cSrcweir const char* pNodePath = NULL;
857cdf0e10cSrcweir const char* pNode = NULL;
858cdf0e10cSrcweir
859cdf0e10cSrcweir switch( maToolbox.GetCurItemId() )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir case nItemId_Extensions:
862cdf0e10cSrcweir pNodePath = "/org.openoffice.Office.Common/Help/StartCenter";
863cdf0e10cSrcweir pNode = "AddFeatureURL";
864cdf0e10cSrcweir break;
865cdf0e10cSrcweir case nItemId_Info:
866cdf0e10cSrcweir pNodePath = "/org.openoffice.Office.Common/Help/StartCenter";
867cdf0e10cSrcweir pNode = "InfoURL";
868cdf0e10cSrcweir break;
869cdf0e10cSrcweir case nItemId_TplRep:
870cdf0e10cSrcweir pNodePath = "/org.openoffice.Office.Common/Help/StartCenter";
871cdf0e10cSrcweir pNode = "TemplateRepositoryURL";
872cdf0e10cSrcweir break;
873cdf0e10cSrcweir default:
874cdf0e10cSrcweir break;
875cdf0e10cSrcweir }
876cdf0e10cSrcweir if( pNodePath && pNode )
877cdf0e10cSrcweir {
878cdf0e10cSrcweir try
879cdf0e10cSrcweir {
880cdf0e10cSrcweir Reference<lang::XMultiServiceFactory> xConfig( comphelper::getProcessServiceFactory()->createInstance(SERVICENAME_CFGPROVIDER),UNO_QUERY);
881cdf0e10cSrcweir if( xConfig.is() )
882cdf0e10cSrcweir {
883cdf0e10cSrcweir Sequence<Any> args(1);
884cdf0e10cSrcweir PropertyValue val(
885cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("nodepath") ),
886cdf0e10cSrcweir 0,
887cdf0e10cSrcweir Any(rtl::OUString::createFromAscii(pNodePath)),
888cdf0e10cSrcweir PropertyState_DIRECT_VALUE);
889cdf0e10cSrcweir args.getArray()[0] <<= val;
890cdf0e10cSrcweir Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,args), UNO_QUERY);
891cdf0e10cSrcweir if( xNameAccess.is() )
892cdf0e10cSrcweir {
893cdf0e10cSrcweir rtl::OUString sURL;
894cdf0e10cSrcweir //throws css::container::NoSuchElementException, css::lang::WrappedTargetException
895cdf0e10cSrcweir Any value( xNameAccess->getByName(rtl::OUString::createFromAscii(pNode)) );
896cdf0e10cSrcweir sURL = value.get<rtl::OUString> ();
897cdf0e10cSrcweir
898cdf0e10cSrcweir // extend the URLs with Office locale argument
899cdf0e10cSrcweir INetURLObject aURLObj( sURL );
900cdf0e10cSrcweir
901cdf0e10cSrcweir rtl::OUString sParam = aURLObj.GetParam();
902cdf0e10cSrcweir rtl::OUStringBuffer aURLBuf( sParam );
903cdf0e10cSrcweir if ( sParam.getLength() > 0 )
904cdf0e10cSrcweir aURLBuf.appendAscii( "&" );
905cdf0e10cSrcweir aURLBuf.appendAscii( "lang=" );
906cdf0e10cSrcweir
907cdf0e10cSrcweir // read locale from configuration
908cdf0e10cSrcweir ::rtl::OUString sLocale;
909cdf0e10cSrcweir ::rtl::OUString sPackage = ::rtl::OUString::createFromAscii("org.openoffice.Setup");
910cdf0e10cSrcweir ::rtl::OUString sRelPath = ::rtl::OUString::createFromAscii("L10N");
911cdf0e10cSrcweir ::rtl::OUString sKey = ::rtl::OUString::createFromAscii("ooLocale");
912cdf0e10cSrcweir
913cdf0e10cSrcweir try
914cdf0e10cSrcweir {
915cdf0e10cSrcweir ::comphelper::ConfigurationHelper::readDirectKey(comphelper::getProcessServiceFactory(),
916cdf0e10cSrcweir sPackage,
917cdf0e10cSrcweir sRelPath,
918cdf0e10cSrcweir sKey,
919cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_READONLY) >>= sLocale;
920cdf0e10cSrcweir }
921cdf0e10cSrcweir catch(const com::sun::star::uno::RuntimeException& exRun)
922cdf0e10cSrcweir { throw exRun; }
923cdf0e10cSrcweir catch(const com::sun::star::uno::Exception&)
924cdf0e10cSrcweir { sLocale = ::rtl::OUString::createFromAscii("en-US"); }
925cdf0e10cSrcweir
926cdf0e10cSrcweir aURLBuf.append(sLocale);
927cdf0e10cSrcweir
928cdf0e10cSrcweir sParam = aURLBuf.makeStringAndClear();
929cdf0e10cSrcweir
930cdf0e10cSrcweir aURLObj.SetParam( sParam );
931cdf0e10cSrcweir sURL = aURLObj.GetMainURL( INetURLObject::NO_DECODE );
932cdf0e10cSrcweir
933cdf0e10cSrcweir Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
9349807c9deSAriel Constenla-Haile com::sun::star::system::SystemShellExecute::create(
9359807c9deSAriel Constenla-Haile ::comphelper::getProcessComponentContext() ) );
936cdf0e10cSrcweir //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException
937cdf0e10cSrcweir xSystemShellExecute->execute( sURL, rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::DEFAULTS);
938cdf0e10cSrcweir }
939cdf0e10cSrcweir }
940cdf0e10cSrcweir }
941cdf0e10cSrcweir catch (Exception& )
942cdf0e10cSrcweir {
943cdf0e10cSrcweir }
944cdf0e10cSrcweir }
945cdf0e10cSrcweir
946cdf0e10cSrcweir return 0;
947cdf0e10cSrcweir }
948cdf0e10cSrcweir
IMPL_LINK(BackingWindow,ClickHdl,Button *,pButton)949cdf0e10cSrcweir IMPL_LINK( BackingWindow, ClickHdl, Button*, pButton )
950cdf0e10cSrcweir {
951cdf0e10cSrcweir // dispatch the appropriate URL and end the dialog
952cdf0e10cSrcweir if( pButton == &maWriterButton )
953cdf0e10cSrcweir dispatchURL( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(WRITER_URL) ) );
954cdf0e10cSrcweir else if( pButton == &maCalcButton )
955cdf0e10cSrcweir dispatchURL( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(CALC_URL) ) );
956cdf0e10cSrcweir else if( pButton == &maImpressButton )
957cdf0e10cSrcweir dispatchURL( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(IMPRESS_WIZARD_URL) ) );
958cdf0e10cSrcweir else if( pButton == &maDrawButton )
959cdf0e10cSrcweir dispatchURL( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(DRAW_URL) ) );
960cdf0e10cSrcweir else if( pButton == &maDBButton )
961cdf0e10cSrcweir dispatchURL( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(BASE_URL) ) );
962cdf0e10cSrcweir else if( pButton == &maMathButton )
963cdf0e10cSrcweir dispatchURL( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(MATH_URL) ) );
964cdf0e10cSrcweir else if( pButton == &maOpenButton )
965cdf0e10cSrcweir {
966cdf0e10cSrcweir Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
967cdf0e10cSrcweir
968cdf0e10cSrcweir Sequence< com::sun::star::beans::PropertyValue > aArgs(1);
969cdf0e10cSrcweir PropertyValue* pArg = aArgs.getArray();
970cdf0e10cSrcweir pArg[0].Name = rtl::OUString::createFromAscii("Referer");
971cdf0e10cSrcweir pArg[0].Value <<= rtl::OUString::createFromAscii("private:user");
972cdf0e10cSrcweir
973cdf0e10cSrcweir dispatchURL( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(OPEN_URL) ), rtl::OUString(), xFrame, aArgs );
974cdf0e10cSrcweir }
975cdf0e10cSrcweir else if( pButton == &maTemplateButton )
976cdf0e10cSrcweir {
977cdf0e10cSrcweir Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
978cdf0e10cSrcweir
979cdf0e10cSrcweir Sequence< com::sun::star::beans::PropertyValue > aArgs(1);
980cdf0e10cSrcweir PropertyValue* pArg = aArgs.getArray();
981cdf0e10cSrcweir pArg[0].Name = rtl::OUString::createFromAscii("Referer");
982cdf0e10cSrcweir pArg[0].Value <<= rtl::OUString::createFromAscii("private:user");
983cdf0e10cSrcweir
984cdf0e10cSrcweir dispatchURL( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(TEMPLATE_URL) ), rtl::OUString(), xFrame, aArgs );
985cdf0e10cSrcweir }
986cdf0e10cSrcweir return 0;
987cdf0e10cSrcweir }
988cdf0e10cSrcweir
989cdf0e10cSrcweir
IMPL_LINK(BackingWindow,ActivateHdl,Button *,pButton)990cdf0e10cSrcweir IMPL_LINK( BackingWindow, ActivateHdl, Button*, pButton )
991cdf0e10cSrcweir {
992cdf0e10cSrcweir if( pButton == &maOpenButton )
993cdf0e10cSrcweir prepareRecentFileMenu();
994cdf0e10cSrcweir return 0;
995cdf0e10cSrcweir }
996cdf0e10cSrcweir
997cdf0e10cSrcweir struct ImplDelayedDispatch
998cdf0e10cSrcweir {
999cdf0e10cSrcweir Reference< XDispatch > xDispatch;
1000cdf0e10cSrcweir com::sun::star::util::URL aDispatchURL;
1001cdf0e10cSrcweir Sequence< PropertyValue > aArgs;
1002cdf0e10cSrcweir
ImplDelayedDispatchImplDelayedDispatch1003cdf0e10cSrcweir ImplDelayedDispatch( const Reference< XDispatch >& i_xDispatch,
1004cdf0e10cSrcweir const com::sun::star::util::URL& i_rURL,
1005cdf0e10cSrcweir const Sequence< PropertyValue >& i_rArgs )
1006cdf0e10cSrcweir : xDispatch( i_xDispatch ),
1007cdf0e10cSrcweir aDispatchURL( i_rURL ),
1008cdf0e10cSrcweir aArgs( i_rArgs )
1009cdf0e10cSrcweir {
1010cdf0e10cSrcweir }
~ImplDelayedDispatchImplDelayedDispatch1011cdf0e10cSrcweir ~ImplDelayedDispatch() {}
1012cdf0e10cSrcweir };
1013cdf0e10cSrcweir
implDispatchDelayed(void *,void * pArg)1014cdf0e10cSrcweir static long implDispatchDelayed( void*, void* pArg )
1015cdf0e10cSrcweir {
1016cdf0e10cSrcweir struct ImplDelayedDispatch* pDispatch = reinterpret_cast<ImplDelayedDispatch*>(pArg);
1017cdf0e10cSrcweir try
1018cdf0e10cSrcweir {
1019cdf0e10cSrcweir pDispatch->xDispatch->dispatch( pDispatch->aDispatchURL, pDispatch->aArgs );
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir catch( Exception )
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir }
1024cdf0e10cSrcweir
1025cdf0e10cSrcweir // clean up
1026cdf0e10cSrcweir delete pDispatch;
1027cdf0e10cSrcweir
1028cdf0e10cSrcweir return 0;
1029cdf0e10cSrcweir }
1030cdf0e10cSrcweir
dispatchURL(const rtl::OUString & i_rURL,const rtl::OUString & rTarget,const Reference<XDispatchProvider> & i_xProv,const Sequence<PropertyValue> & i_rArgs)1031cdf0e10cSrcweir void BackingWindow::dispatchURL( const rtl::OUString& i_rURL,
1032cdf0e10cSrcweir const rtl::OUString& rTarget,
1033cdf0e10cSrcweir const Reference< XDispatchProvider >& i_xProv,
1034cdf0e10cSrcweir const Sequence< PropertyValue >& i_rArgs )
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir // if no special dispatch provider is given, get the desktop
1037cdf0e10cSrcweir Reference< XDispatchProvider > xProvider( i_xProv.is() ? i_xProv : mxDesktopDispatchProvider );
1038cdf0e10cSrcweir
1039cdf0e10cSrcweir // check for dispatch provider
1040cdf0e10cSrcweir if( !xProvider.is())
1041cdf0e10cSrcweir return;
1042cdf0e10cSrcweir
1043cdf0e10cSrcweir // get an URL transformer to clean up the URL
1044cdf0e10cSrcweir com::sun::star::util::URL aDispatchURL;
1045cdf0e10cSrcweir aDispatchURL.Complete = i_rURL;
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir Reference < com::sun::star::util::XURLTransformer > xURLTransformer(
1048cdf0e10cSrcweir comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer") ),
1049cdf0e10cSrcweir com::sun::star::uno::UNO_QUERY );
1050cdf0e10cSrcweir if ( xURLTransformer.is() )
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir try
1053cdf0e10cSrcweir {
1054cdf0e10cSrcweir // clean up the URL
1055cdf0e10cSrcweir xURLTransformer->parseStrict( aDispatchURL );
1056cdf0e10cSrcweir // get a Dispatch for the URL and target
1057cdf0e10cSrcweir Reference< XDispatch > xDispatch(
1058cdf0e10cSrcweir xProvider->queryDispatch( aDispatchURL, rTarget, 0 )
1059cdf0e10cSrcweir );
1060cdf0e10cSrcweir // dispatch the URL
1061cdf0e10cSrcweir if ( xDispatch.is() )
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir ImplDelayedDispatch* pDisp = new ImplDelayedDispatch( xDispatch, aDispatchURL, i_rArgs );
1064cdf0e10cSrcweir sal_uLong nEventId = 0;
1065cdf0e10cSrcweir if( ! Application::PostUserEvent( nEventId, Link( NULL, implDispatchDelayed ), pDisp ) )
1066cdf0e10cSrcweir delete pDisp; // event could not be posted for unknown reason, at least don't leak
1067cdf0e10cSrcweir }
1068cdf0e10cSrcweir }
1069cdf0e10cSrcweir catch ( com::sun::star::uno::RuntimeException& )
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir throw;
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir catch ( com::sun::star::uno::Exception& )
1074cdf0e10cSrcweir {
1075cdf0e10cSrcweir }
1076cdf0e10cSrcweir }
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir
1079