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