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