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 : : #include "templwin.hxx"
30 : : #include <svtools/templdlg.hxx>
31 : : #include <svtools/svtresid.hxx>
32 : : #include <svtools/langhelp.hxx>
33 : : #include <unotools/pathoptions.hxx>
34 : : #include <unotools/dynamicmenuoptions.hxx>
35 : : #include <unotools/extendedsecurityoptions.hxx>
36 : : #include <vcl/xtextedt.hxx>
37 : : #include <svl/inettype.hxx>
38 : : #include <svtools/imagemgr.hxx>
39 : : #include <svtools/miscopt.hxx>
40 : : #include <svtools/templatefoldercache.hxx>
41 : : #include <svtools/imgdef.hxx>
42 : : #include <vcl/txtattr.hxx>
43 : : #include <svtools/svtools.hrc>
44 : : #include "templwin.hrc"
45 : : #include <svtools/helpid.hrc>
46 : : #include <unotools/viewoptions.hxx>
47 : : #include <unotools/ucbhelper.hxx>
48 : : #include "unotools/configmgr.hxx"
49 : : #include <com/sun/star/awt/XWindow.hpp>
50 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 : : #include <com/sun/star/frame/XFrame.hpp>
52 : : #include <toolkit/helper/vclunohelper.hxx>
53 : : #include <com/sun/star/util/URL.hpp>
54 : : #include <com/sun/star/util/URLTransformer.hpp>
55 : : #include <com/sun/star/util/XURLTransformer.hpp>
56 : : #include <com/sun/star/util/XOfficeInstallationDirectories.hpp>
57 : : #include <com/sun/star/frame/XDispatchProvider.hpp>
58 : : #include <com/sun/star/frame/DocumentTemplates.hpp>
59 : : #include <com/sun/star/frame/XDocumentTemplates.hpp>
60 : : #include <com/sun/star/frame/XComponentLoader.hpp>
61 : : #include <com/sun/star/beans/PropertyValue.hpp>
62 : : #include <com/sun/star/ucb/XContent.hpp>
63 : : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
64 : : #include <com/sun/star/view/XPrintable.hpp>
65 : : #include <com/sun/star/document/XDocumentProperties.hpp>
66 : : #include <com/sun/star/beans/XPropertySet.hpp>
67 : : #include <com/sun/star/beans/XMultiPropertySet.hpp>
68 : : #include <com/sun/star/beans/XPropertySetInfo.hpp>
69 : : #include <com/sun/star/io/IOException.hpp>
70 : : #include <com/sun/star/util/DateTime.hpp>
71 : : #include <com/sun/star/script/XTypeConverter.hpp>
72 : : #include <com/sun/star/system/XSystemShellExecute.hpp>
73 : : #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
74 : : #include <unotools/localedatawrapper.hxx>
75 : : #include <com/sun/star/container/XNameContainer.hpp>
76 : : #include <vcl/waitobj.hxx>
77 : : #include <comphelper/processfactory.hxx>
78 : : #include <tools/urlobj.hxx>
79 : : #include <tools/datetime.hxx>
80 : : #include <vcl/svapp.hxx>
81 : : #include <vcl/split.hxx>
82 : : #include <vcl/msgbox.hxx>
83 : : #include <svtools/DocumentInfoPreview.hxx>
84 : : #include <vcl/mnemonic.hxx>
85 : :
86 : : #include <ucbhelper/content.hxx>
87 : : #include <comphelper/string.hxx>
88 : :
89 : : using namespace ::com::sun::star;
90 : : using namespace ::com::sun::star::beans;
91 : : using namespace ::com::sun::star::container;
92 : : using namespace ::com::sun::star::frame;
93 : : using namespace ::com::sun::star::document;
94 : : using namespace ::com::sun::star::lang;
95 : : using namespace ::com::sun::star::ucb;
96 : : using namespace ::com::sun::star::uno;
97 : : using namespace ::com::sun::star::view;
98 : : using namespace svtools;
99 : :
100 : : #define aSeparatorStr "----------------------------------"
101 : :
102 : : #define SPLITSET_ID 0
103 : : #define COLSET_ID 1
104 : : #define ICONWIN_ID 2
105 : : #define FILEWIN_ID 3
106 : : #define FRAMEWIN_ID 4
107 : :
108 : : #define ICON_POS_NEWDOC 0
109 : : #define ICON_POS_TEMPLATES 1
110 : : #define ICON_POS_MYDOCS 2
111 : : #define ICON_POS_SAMPLES 3
112 : :
113 : : #define ASCII_STR(s) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
114 : : #define VIEWSETTING_NEWFROMTEMPLATE ASCII_STR("NewFromTemplate")
115 : : #define VIEWSETTING_SELECTEDGROUP ASCII_STR("SelectedGroup")
116 : : #define VIEWSETTING_SELECTEDVIEW ASCII_STR("SelectedView")
117 : : #define VIEWSETTING_SPLITRATIO ASCII_STR("SplitRatio")
118 : : #define VIEWSETTING_LASTFOLDER ASCII_STR("LastFolder")
119 : :
120 : 0 : struct FolderHistory
121 : : {
122 : : String m_sURL;
123 : : sal_uLong m_nGroup;
124 : :
125 : 0 : FolderHistory( const String& _rURL, sal_Int32 _nGroup ) :
126 : 0 : m_sURL( _rURL ), m_nGroup( _nGroup ) {}
127 : : };
128 : :
129 : : typedef ::std::vector< ::rtl::OUString* > NewDocList_Impl;
130 : :
131 : : // class SvtDummyHeaderBar_Impl ------------------------------------------
132 : :
133 : 0 : void SvtDummyHeaderBar_Impl::UpdateBackgroundColor()
134 : : {
135 [ # # ]: 0 : SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetWindowColor() ) );
136 : 0 : }
137 : :
138 : 0 : SvtDummyHeaderBar_Impl::SvtDummyHeaderBar_Impl( Window* pPar ) : Window( pPar )
139 : : {
140 [ # # ][ # # ]: 0 : SetSizePixel( HeaderBar( this, 0 ).CalcWindowSizePixel() ); // HeaderBar used only to calculate size
[ # # ][ # # ]
141 : :
142 [ # # ]: 0 : UpdateBackgroundColor();
143 : 0 : }
144 : :
145 : 0 : SvtDummyHeaderBar_Impl::~SvtDummyHeaderBar_Impl()
146 : : {
147 [ # # ]: 0 : }
148 : :
149 : 0 : void SvtDummyHeaderBar_Impl::DataChanged( const DataChangedEvent& r )
150 : : {
151 : 0 : Window::DataChanged( r );
152 [ # # ]: 0 : if( r.GetType() == DATACHANGED_SETTINGS )
153 : 0 : UpdateBackgroundColor();
154 : 0 : }
155 : :
156 : : // class SvtIconWindow_Impl ----------------------------------------------
157 : :
158 : 0 : SvtIconWindow_Impl::SvtIconWindow_Impl( Window* pParent ) :
159 : :
160 : : Window( pParent, WB_DIALOGCONTROL | WB_BORDER | WB_3DLOOK ),
161 : :
162 : : aDummyHeaderBar( this ),
163 : : aIconCtrl( this, WB_ICON | WB_NOCOLUMNHEADER | WB_HIGHLIGHTFRAME | /*!WB_NOSELECTION |*/
164 : : WB_NODRAGSELECTION | WB_TABSTOP | WB_CLIPCHILDREN ),
165 : : aNewDocumentRootURL( ASCII_STR("private:newdoc") ),
166 [ # # ][ # # ]: 0 : aMyDocumentsRootURL( SvtPathOptions().GetWorkPath() ),
[ # # ]
167 : : aSamplesFolderRootURL( SvtPathOptions().
168 : : SubstituteVariable( String( ASCII_STR("$(insturl)/share/samples/$(vlang)") ) ) ),
169 [ # # ][ # # ]: 0 : nMaxTextLength( 0 )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
170 : :
171 : : {
172 [ # # ]: 0 : aDummyHeaderBar.Show();
173 : :
174 [ # # ][ # # ]: 0 : aIconCtrl.SetAccessibleName( String( RTL_CONSTASCII_USTRINGPARAM("Groups") ) );
[ # # ]
175 [ # # ]: 0 : aIconCtrl.SetHelpId( HID_TEMPLATEDLG_ICONCTRL );
176 [ # # ]: 0 : aIconCtrl.SetChoiceWithCursor( sal_True );
177 [ # # ]: 0 : aIconCtrl.SetSelectionMode( SINGLE_SELECTION );
178 [ # # ]: 0 : aIconCtrl.Show();
179 : :
180 : : // detect the root URL of templates
181 [ # # ][ # # ]: 0 : Reference< XDocumentTemplates > xTemplates( frame::DocumentTemplates::create(::comphelper::getProcessComponentContext()) );
182 : :
183 [ # # ][ # # ]: 0 : Reference < XContent > aRootContent = xTemplates->getContent();
184 : 0 : Reference < XCommandEnvironment > aCmdEnv;
185 : :
186 [ # # ]: 0 : if ( aRootContent.is() )
187 [ # # ][ # # ]: 0 : aTemplateRootURL = aRootContent->getIdentifier()->getContentIdentifier();
[ # # ][ # # ]
[ # # ]
188 : :
189 : : // insert the categories
190 : : // "New Document"
191 [ # # ][ # # ]: 0 : Image aImage( SvtResId( IMG_SVT_NEWDOC ) );
192 [ # # ]: 0 : nMaxTextLength = aImage.GetSizePixel().Width();
193 [ # # ][ # # ]: 0 : String aEntryStr = SVT_RESSTR(STR_SVT_NEWDOC);
[ # # ]
194 : : SvxIconChoiceCtrlEntry* pEntry =
195 [ # # ]: 0 : aIconCtrl.InsertEntry( aEntryStr, aImage, ICON_POS_NEWDOC );
196 [ # # ][ # # ]: 0 : pEntry->SetUserData( new String( aNewDocumentRootURL ) );
197 [ # # ][ # # ]: 0 : pEntry->SetQuickHelpText( SVT_RESSTR(STR_SVT_NEWDOC_HELP) );
[ # # ][ # # ]
[ # # ]
198 : : DBG_ASSERT( !pEntry->GetBoundRect().IsEmpty(), "empty rectangle" );
199 [ # # ]: 0 : long nTemp = pEntry->GetBoundRect().GetSize().Width();
200 [ # # ]: 0 : if (nTemp > nMaxTextLength)
201 : 0 : nMaxTextLength = nTemp;
202 : :
203 : : // "Templates"
204 [ # # ]: 0 : if( aTemplateRootURL.Len() > 0 )
205 : : {
206 [ # # ][ # # ]: 0 : aEntryStr = SVT_RESSTR(STR_SVT_TEMPLATES);
[ # # ]
207 : : pEntry = aIconCtrl.InsertEntry(
208 [ # # ][ # # ]: 0 : aEntryStr, Image( SvtResId( IMG_SVT_TEMPLATES ) ), ICON_POS_TEMPLATES );
[ # # ][ # # ]
209 [ # # ][ # # ]: 0 : pEntry->SetUserData( new String( aTemplateRootURL ) );
210 [ # # ][ # # ]: 0 : pEntry->SetQuickHelpText(SVT_RESSTR(STR_SVT_TEMPLATES_HELP));
[ # # ][ # # ]
[ # # ]
211 : : DBG_ASSERT( !pEntry->GetBoundRect().IsEmpty(), "empty rectangle" );
212 [ # # ]: 0 : nTemp = pEntry->GetBoundRect().GetSize().Width();
213 [ # # ]: 0 : if (nTemp > nMaxTextLength)
214 : 0 : nMaxTextLength = nTemp;
215 : : }
216 : :
217 : : // "My Documents"
218 [ # # ][ # # ]: 0 : aEntryStr = SVT_RESSTR(STR_SVT_MYDOCS);
[ # # ]
219 : : pEntry = aIconCtrl.InsertEntry(
220 [ # # ][ # # ]: 0 : aEntryStr, Image( SvtResId( IMG_SVT_MYDOCS ) ), ICON_POS_MYDOCS );
[ # # ][ # # ]
221 [ # # ][ # # ]: 0 : pEntry->SetUserData( new String( aMyDocumentsRootURL ) );
222 [ # # ][ # # ]: 0 : pEntry->SetQuickHelpText( SVT_RESSTR(STR_SVT_MYDOCS_HELP) );
[ # # ][ # # ]
[ # # ]
223 : : DBG_ASSERT( !pEntry->GetBoundRect().IsEmpty(), "empty rectangle" );
224 [ # # ]: 0 : nTemp = pEntry->GetBoundRect().GetSize().Width();
225 [ # # ]: 0 : if( nTemp > nMaxTextLength )
226 : 0 : nMaxTextLength = nTemp;
227 : :
228 : : // "Samples"
229 [ # # ][ # # ]: 0 : aEntryStr = SVT_RESSTR(STR_SVT_SAMPLES);
[ # # ]
230 : : pEntry = aIconCtrl.InsertEntry(
231 [ # # ][ # # ]: 0 : aEntryStr, Image( SvtResId( IMG_SVT_SAMPLES ) ), ICON_POS_SAMPLES );
[ # # ][ # # ]
232 [ # # ][ # # ]: 0 : pEntry->SetUserData( new String( aSamplesFolderRootURL ) );
233 [ # # ][ # # ]: 0 : pEntry->SetQuickHelpText( SVT_RESSTR(STR_SVT_SAMPLES_HELP));
[ # # ][ # # ]
[ # # ]
234 : : DBG_ASSERT( !pEntry->GetBoundRect().IsEmpty(), "empty rectangle" );
235 [ # # ]: 0 : nTemp = pEntry->GetBoundRect().GetSize().Width();
236 [ # # ]: 0 : if (nTemp > nMaxTextLength)
237 : 0 : nMaxTextLength = nTemp;
238 : :
239 [ # # ][ # # ]: 0 : aIconCtrl.CreateAutoMnemonics();
[ # # ]
240 : 0 : }
241 : :
242 [ # # ][ # # ]: 0 : SvtIconWindow_Impl::~SvtIconWindow_Impl()
[ # # ][ # # ]
[ # # ][ # # ]
243 : : {
244 [ # # ][ # # ]: 0 : for ( sal_uLong i = 0; i < aIconCtrl.GetEntryCount(); ++i )
245 : : {
246 [ # # ]: 0 : SvxIconChoiceCtrlEntry* pEntry = aIconCtrl.GetEntry( i );
247 [ # # ][ # # ]: 0 : delete (String*)pEntry->GetUserData();
248 : : }
249 [ # # ]: 0 : }
250 : :
251 : 0 : SvxIconChoiceCtrlEntry* SvtIconWindow_Impl::GetEntry( const String& rURL ) const
252 : : {
253 : 0 : SvxIconChoiceCtrlEntry* pEntry = NULL;
254 [ # # ]: 0 : for ( sal_uLong i = 0; i < aIconCtrl.GetEntryCount(); ++i )
255 : : {
256 [ # # ]: 0 : SvxIconChoiceCtrlEntry* pTemp = aIconCtrl.GetEntry( i );
257 [ # # ]: 0 : String aURL( *( (String*)pTemp->GetUserData() ) );
258 [ # # ][ # # ]: 0 : if ( aURL == rURL )
259 : : {
260 : 0 : pEntry = pTemp;
261 : : break;
262 : : }
263 [ # # ][ # # ]: 0 : }
264 : :
265 : 0 : return pEntry;
266 : : }
267 : :
268 : 0 : void SvtIconWindow_Impl::Resize()
269 : : {
270 : 0 : Size aWinSize = GetOutputSizePixel();
271 [ # # ]: 0 : Size aHeaderSize = aDummyHeaderBar.GetSizePixel();
272 : 0 : aHeaderSize.Width() = aWinSize.Width();
273 [ # # ]: 0 : aDummyHeaderBar.SetSizePixel( aHeaderSize );
274 : 0 : long nHeaderHeight = aHeaderSize.Height();
275 : 0 : aWinSize.Height() -= nHeaderHeight;
276 [ # # ]: 0 : aIconCtrl.SetPosSizePixel( Point( 0, nHeaderHeight ), aWinSize );
277 [ # # ]: 0 : aIconCtrl.ArrangeIcons();
278 : 0 : }
279 : :
280 : 0 : String SvtIconWindow_Impl::GetCursorPosIconURL() const
281 : : {
282 : 0 : String aURL;
283 [ # # ]: 0 : SvxIconChoiceCtrlEntry* pEntry = aIconCtrl.GetCursor( );
284 [ # # ]: 0 : if ( pEntry )
285 [ # # ]: 0 : aURL = *static_cast<String*>(pEntry->GetUserData());
286 : 0 : return aURL;
287 : :
288 : : }
289 : :
290 : 0 : String SvtIconWindow_Impl::GetSelectedIconURL() const
291 : : {
292 : : sal_uLong nPos;
293 [ # # ]: 0 : SvxIconChoiceCtrlEntry* pEntry = aIconCtrl.GetSelectedEntry( nPos );
294 [ # # ]: 0 : String aURL;
295 [ # # ]: 0 : if ( pEntry )
296 [ # # ]: 0 : aURL = *static_cast<String*>(pEntry->GetUserData());
297 : 0 : return aURL;
298 : : }
299 : :
300 : 0 : String SvtIconWindow_Impl::GetIconText( const String& rURL ) const
301 : : {
302 : 0 : String aText;
303 [ # # ]: 0 : SvxIconChoiceCtrlEntry* pEntry = GetEntry( rURL );
304 [ # # ]: 0 : if ( pEntry )
305 [ # # ][ # # ]: 0 : aText = MnemonicGenerator::EraseAllMnemonicChars( pEntry->GetText() );
[ # # ][ # # ]
[ # # ]
306 : 0 : return aText;
307 : : }
308 : :
309 : 0 : void SvtIconWindow_Impl::InvalidateIconControl()
310 : : {
311 : 0 : aIconCtrl.Invalidate();
312 : 0 : }
313 : :
314 : 0 : sal_uLong SvtIconWindow_Impl::GetCursorPos() const
315 : : {
316 : 0 : sal_uLong nPos = ~sal_uLong(0);
317 : :
318 : 0 : SvxIconChoiceCtrlEntry* pCursorEntry = aIconCtrl.GetCursor( );
319 [ # # ]: 0 : if ( pCursorEntry )
320 : 0 : nPos = aIconCtrl.GetEntryListPos( pCursorEntry );
321 : :
322 : 0 : return nPos;
323 : : }
324 : :
325 : 0 : sal_uLong SvtIconWindow_Impl::GetSelectEntryPos() const
326 : : {
327 : : sal_uLong nPos;
328 [ # # ][ # # ]: 0 : if ( !aIconCtrl.GetSelectedEntry( nPos ) )
329 : 0 : nPos = ~sal_uLong(0);
330 : 0 : return nPos;
331 : : }
332 : :
333 : 0 : void SvtIconWindow_Impl::SetCursorPos( sal_uLong nPos )
334 : : {
335 : 0 : SvxIconChoiceCtrlEntry* pEntry = aIconCtrl.GetEntry( nPos );
336 : 0 : aIconCtrl.SetCursor( pEntry );
337 : 0 : aIconCtrl.Invalidate();
338 : 0 : aIconCtrl.Update();
339 : 0 : }
340 : :
341 : 0 : void SvtIconWindow_Impl::SetFocus()
342 : : {
343 : 0 : aIconCtrl.GrabFocus();
344 : 0 : }
345 : :
346 : 0 : long SvtIconWindow_Impl::CalcHeight() const
347 : : {
348 : : // calculate the required height of the IconControl
349 : 0 : long nHeight = 0;
350 : 0 : sal_uLong nCount = aIconCtrl.GetEntryCount();
351 [ # # ]: 0 : if ( nCount > 0 )
352 : : // bottom of the last icon
353 : 0 : nHeight = aIconCtrl.GetEntry(nCount-1)->GetBoundRect().Bottom();
354 : :
355 : : // + headerbar height
356 : 0 : nHeight += aDummyHeaderBar.GetSizePixel().Height();
357 : :
358 : 0 : return nHeight;
359 : : }
360 : :
361 : 0 : sal_Bool SvtIconWindow_Impl::IsRootURL( const String& rURL ) const
362 : : {
363 : 0 : return rURL == aNewDocumentRootURL ||
364 : 0 : rURL == aTemplateRootURL ||
365 : 0 : rURL == aMyDocumentsRootURL ||
366 [ # # ][ # # : 0 : rURL == aSamplesFolderRootURL;
# # # # ]
367 : : }
368 : :
369 : 0 : sal_uLong SvtIconWindow_Impl::GetRootPos( const String& rURL ) const
370 : : {
371 : 0 : sal_uLong nPos = ~sal_uLong(0);
372 [ # # ]: 0 : if ( aNewDocumentRootURL.Match( rURL ) == STRING_MATCH )
373 : 0 : nPos = 0;
374 [ # # ]: 0 : else if ( aTemplateRootURL.Match( rURL ) == STRING_MATCH )
375 : 0 : nPos = 1;
376 [ # # ]: 0 : else if ( aMyDocumentsRootURL.Match( rURL ) == STRING_MATCH )
377 : 0 : nPos = 2;
378 [ # # ]: 0 : else if ( aSamplesFolderRootURL.Match( rURL ) == STRING_MATCH )
379 : 0 : nPos = 3;
380 [ # # ]: 0 : else if ( rURL.Match( aMyDocumentsRootURL ) == STRING_MATCH )
381 : 0 : nPos = 2;
382 : : else
383 : : {
384 : : DBG_WARNING( "SvtIconWindow_Impl::GetRootPos(): invalid position" );
385 : 0 : nPos = 2;
386 : : }
387 : :
388 : 0 : return nPos;
389 : : }
390 : :
391 : 0 : void SvtIconWindow_Impl::UpdateIcons()
392 : : {
393 : : aIconCtrl.GetEntry( ICON_POS_NEWDOC )->SetImage(
394 [ # # ][ # # ]: 0 : Image( SvtResId( IMG_SVT_NEWDOC ) ) );
[ # # ][ # # ]
395 : : aIconCtrl.GetEntry( ICON_POS_TEMPLATES )->SetImage(
396 [ # # ][ # # ]: 0 : Image( SvtResId( IMG_SVT_TEMPLATES ) ) );
[ # # ][ # # ]
397 : : aIconCtrl.GetEntry( ICON_POS_MYDOCS )->SetImage(
398 [ # # ][ # # ]: 0 : Image( SvtResId( IMG_SVT_MYDOCS ) ) );
[ # # ][ # # ]
399 : : aIconCtrl.GetEntry( ICON_POS_SAMPLES )->SetImage(
400 [ # # ][ # # ]: 0 : Image( SvtResId( IMG_SVT_SAMPLES ) ) );
[ # # ][ # # ]
401 : 0 : }
402 : :
403 : 0 : void SvtIconWindow_Impl::SelectFolder(sal_Int32 nFolderPosition)
404 : : {
405 : 0 : SvxIconChoiceCtrlEntry* pEntry = aIconCtrl.GetEntry( nFolderPosition );
406 [ # # ]: 0 : if(pEntry)
407 : : {
408 : 0 : aIconCtrl.SetCursor( pEntry );
409 : 0 : aIconCtrl.GetClickHdl().Call(&aIconCtrl);
410 : : }
411 : 0 : }
412 : :
413 : : // class SvtFileViewWindow_Impl -----------------------------------------_
414 : :
415 : 0 : SvtFileViewWindow_Impl::SvtFileViewWindow_Impl( SvtTemplateWindow* pParent ) :
416 : :
417 : : Window( pParent, WB_DIALOGCONTROL | WB_TABSTOP | WB_BORDER | WB_3DLOOK ),
418 : :
419 : : rParent ( *pParent ),
420 : : aFileView ( this, SvtResId( CTRL_FILEVIEW ), FILEVIEW_SHOW_NONE | FILEVIEW_SHOW_ONLYTITLE ),
421 [ # # ][ # # ]: 0 : bIsTemplateFolder ( sal_False )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
422 : :
423 : : {
424 [ # # ][ # # ]: 0 : aFileView.SetStyle( aFileView.GetStyle() | WB_DIALOGCONTROL | WB_TABSTOP );
425 [ # # ]: 0 : aFileView.SetHelpId( HID_TEMPLATEDLG_FILEVIEW );
426 [ # # ]: 0 : aFileView.Show();
427 [ # # ]: 0 : aFileView.EnableAutoResize();
428 [ # # ]: 0 : aFileView.EnableContextMenu( sal_False );
429 [ # # ]: 0 : aFileView.EnableDelete( sal_False );
430 : 0 : }
431 : :
432 [ # # ][ # # ]: 0 : SvtFileViewWindow_Impl::~SvtFileViewWindow_Impl()
[ # # ][ # # ]
[ # # ][ # # ]
433 : : {
434 [ # # ]: 0 : }
435 : :
436 : 0 : void GetMenuEntry_Impl
437 : : (
438 : : Sequence< PropertyValue >& aDynamicMenuEntry,
439 : : ::rtl::OUString& rTitle,
440 : : ::rtl::OUString& rURL,
441 : : ::rtl::OUString& rFrame,
442 : : ::rtl::OUString& rImageId
443 : : )
444 : : {
445 [ # # ]: 0 : for ( int i = 0; i < aDynamicMenuEntry.getLength(); i++ )
446 : : {
447 [ # # ][ # # ]: 0 : if ( aDynamicMenuEntry[i].Name == DYNAMICMENU_PROPERTYNAME_URL )
448 : 0 : aDynamicMenuEntry[i].Value >>= rURL;
449 [ # # ][ # # ]: 0 : else if ( aDynamicMenuEntry[i].Name == DYNAMICMENU_PROPERTYNAME_TITLE )
450 : 0 : aDynamicMenuEntry[i].Value >>= rTitle;
451 [ # # ][ # # ]: 0 : else if ( aDynamicMenuEntry[i].Name == DYNAMICMENU_PROPERTYNAME_IMAGEIDENTIFIER )
452 : 0 : aDynamicMenuEntry[i].Value >>= rImageId;
453 [ # # ][ # # ]: 0 : else if ( aDynamicMenuEntry[i].Name == DYNAMICMENU_PROPERTYNAME_TARGETNAME )
454 : 0 : aDynamicMenuEntry[i].Value >>= rFrame;
455 : : }
456 : 0 : }
457 : :
458 : 0 : Sequence< ::rtl::OUString > SvtFileViewWindow_Impl::GetNewDocContents() const
459 : : {
460 [ # # ]: 0 : NewDocList_Impl aNewDocs;
461 [ # # ]: 0 : Sequence< Sequence< PropertyValue > > aDynamicMenuEntries;
462 [ # # ][ # # ]: 0 : aDynamicMenuEntries = SvtDynamicMenuOptions().GetMenu( E_NEWMENU );
[ # # ][ # # ]
[ # # ]
463 : :
464 : 0 : ::rtl::OUString aTitle;
465 : 0 : ::rtl::OUString aURL;
466 : 0 : ::rtl::OUString aImageURL;
467 : 0 : ::rtl::OUString aTargetFrame;
468 : :
469 : 0 : sal_uInt32 i, nCount = aDynamicMenuEntries.getLength();
470 [ # # ]: 0 : ::rtl::OUString sSeparator( ASCII_STR("private:separator") );
471 [ # # ]: 0 : ::rtl::OUString sSlotURL( ASCII_STR("slot:5500") );
472 : :
473 [ # # ]: 0 : for ( i = 0; i < nCount; ++i )
474 : : {
475 [ # # ][ # # ]: 0 : GetMenuEntry_Impl( aDynamicMenuEntries[i], aTitle, aURL, aTargetFrame, aImageURL );
476 [ # # ]: 0 : if( aURL == sSlotURL )
477 : 0 : continue;
478 [ # # ]: 0 : if( aURL == sSeparator )
479 : : {
480 [ # # ][ # # ]: 0 : String aSeparator( ASCII_STR( aSeparatorStr ) );
481 [ # # ][ # # ]: 0 : ::rtl::OUString* pSeparator = new ::rtl::OUString( aSeparator );
482 [ # # ][ # # ]: 0 : aNewDocs.push_back( pSeparator );
483 : : }
484 : : else
485 : : {
486 : : // title
487 [ # # ][ # # ]: 0 : String aRow = MnemonicGenerator::EraseAllMnemonicChars( String( aTitle ) );
[ # # ]
488 [ # # ]: 0 : aRow += '\t';
489 : : // no type
490 [ # # ]: 0 : aRow += '\t';
491 : : // no size
492 [ # # ]: 0 : aRow += '\t';
493 : : // no date
494 [ # # ]: 0 : aRow += '\t';
495 : : // url
496 [ # # ][ # # ]: 0 : aRow += String( aURL );
[ # # ]
497 [ # # ]: 0 : aRow += '\t';
498 : : // folder == false
499 [ # # ]: 0 : aRow += '0';
500 : : // image url?
501 [ # # ]: 0 : if ( !aImageURL.isEmpty() )
502 : : {
503 [ # # ]: 0 : aRow += '\t';
504 [ # # ][ # # ]: 0 : aRow += String( aImageURL );
[ # # ]
505 : : }
506 : :
507 [ # # ][ # # ]: 0 : ::rtl::OUString* pRow = new ::rtl::OUString( aRow );
508 [ # # ][ # # ]: 0 : aNewDocs.push_back( pRow );
509 : : }
510 : : }
511 : :
512 : 0 : nCount = aNewDocs.size();
513 [ # # ]: 0 : Sequence < ::rtl::OUString > aRet( nCount );
514 [ # # ]: 0 : ::rtl::OUString* pRet = aRet.getArray();
515 [ # # ]: 0 : for ( i = 0; i < nCount; ++i )
516 : : {
517 : 0 : ::rtl::OUString* pNewDoc = aNewDocs[i];
518 : 0 : pRet[i] = *( pNewDoc );
519 [ # # ]: 0 : delete pNewDoc;
520 : : }
521 : :
522 [ # # ]: 0 : return aRet;
523 : : }
524 : :
525 : 0 : void SvtFileViewWindow_Impl::Resize()
526 : : {
527 [ # # ]: 0 : aFileView.SetSizePixel(GetOutputSizePixel());
528 : 0 : }
529 : :
530 : 0 : String SvtFileViewWindow_Impl::GetSelectedFile() const
531 : : {
532 : 0 : return aFileView.GetCurrentURL();
533 : : }
534 : :
535 : 0 : void SvtFileViewWindow_Impl::OpenFolder( const String& rURL )
536 : : {
537 : 0 : aFolderURL = rURL;
538 : :
539 : 0 : rParent.SetPrevLevelButtonState( rURL );
540 : :
541 : 0 : aFileView.SetUrlFilter( &aURLFilter );
542 : :
543 [ # # ][ # # ]: 0 : INetProtocol eProt = INetURLObject( rURL ).GetProtocol();
544 : 0 : bIsTemplateFolder = ( eProt == INET_PROT_VND_SUN_STAR_HIER );
545 : 0 : bool isNewDocumentFolder = ( eProt == INET_PROT_PRIVATE );
546 : :
547 [ # # ][ # # ]: 0 : aURLFilter.enableFilter( !bIsTemplateFolder && !isNewDocumentFolder );
548 : :
549 [ # # ]: 0 : if ( isNewDocumentFolder )
550 : : {
551 : 0 : aFileView.EnableNameReplacing( sal_False );
552 [ # # ]: 0 : aFileView.Initialize( GetNewDocContents() );
553 : : }
554 : : else
555 : : {
556 : 0 : xub_StrLen nSampFoldLen = aSamplesFolderURL.Len();
557 : : aFileView.EnableNameReplacing(
558 [ # # ][ # # ]: 0 : nSampFoldLen && rURL.CompareTo( aSamplesFolderURL, nSampFoldLen ) == COMPARE_EQUAL );
559 [ # # ]: 0 : aFileView.Initialize( rURL, String(), NULL );
560 : : }
561 : 0 : aNewFolderLink.Call( this );
562 : 0 : }
563 : :
564 : 0 : sal_Bool SvtFileViewWindow_Impl::HasPreviousLevel( String& rURL ) const
565 : : {
566 [ # # ][ # # ]: 0 : INetURLObject aViewObj( aFileView.GetViewURL() );
[ # # ]
567 [ # # ][ # # ]: 0 : INetURLObject aRootObj( aCurrentRootURL );
568 [ # # ][ # # ]: 0 : INetURLObject aMyDocObj( aMyDocumentsURL );
569 : :
570 [ # # ][ # # ]: 0 : return ( ( aViewObj != aRootObj || aRootObj == aMyDocObj ) && aFileView.GetParentURL( rURL ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
571 : : }
572 : :
573 : 0 : String SvtFileViewWindow_Impl::GetFolderTitle() const
574 : : {
575 : 0 : rtl::OUString aTitle;
576 [ # # ][ # # ]: 0 : ::utl::UCBContentHelper::GetTitle( aFolderURL, &aTitle );
577 [ # # ]: 0 : return aTitle;
578 : : }
579 : :
580 : 0 : void SvtFileViewWindow_Impl::SetFocus()
581 : : {
582 : 0 : aFileView.SetFocus();
583 : 0 : }
584 : :
585 : : // class SvtDocInfoTable_Impl --------------------------------------------
586 : :
587 : 0 : SvtDocInfoTable_Impl::SvtDocInfoTable_Impl() :
588 : :
589 [ # # ]: 0 : ResStringArray( SvtResId( STRARY_SVT_DOCINFO ) )
590 : :
591 : : {
592 : 0 : }
593 : : // -----------------------------------------------------------------------
594 : :
595 : 0 : rtl::OUString SvtDocInfoTable_Impl::GetString( long nId ) const
596 : : {
597 : 0 : sal_uInt32 nPos( FindIndex( nId ) );
598 : :
599 [ # # ]: 0 : if ( RESARRAY_INDEX_NOTFOUND != nPos )
600 : 0 : return ResStringArray::GetString( nPos );
601 : :
602 : 0 : return rtl::OUString();
603 : : }
604 : :
605 : : // class SvtFrameWindow_Impl ---------------------------------------------
606 : :
607 : 0 : SvtFrameWindow_Impl::SvtFrameWindow_Impl( Window* pParent ) :
608 : :
609 [ # # ][ # # ]: 0 : Window( pParent )
610 : :
611 : : {
612 : : // detect application language
613 [ # # ][ # # ]: 0 : aLocale= SvtPathOptions().GetLocale();
[ # # ]
614 : :
615 : : // create windows and frame
616 [ # # ][ # # ]: 0 : pEditWin = new ODocumentInfoPreview( this ,WB_LEFT | WB_VSCROLL | WB_READONLY | WB_BORDER | WB_3DLOOK);
617 [ # # ][ # # ]: 0 : pTextWin = new Window( this );
618 [ # # ][ # # ]: 0 : xFrame = Reference < XFrame > ( ::comphelper::getProcessServiceFactory()->
619 [ # # ][ # # ]: 0 : createInstance( ASCII_STR("com.sun.star.frame.Frame") ), UNO_QUERY );
[ # # ][ # # ]
620 [ # # ][ # # ]: 0 : xWindow = VCLUnoHelper::GetInterface( pTextWin );
621 [ # # ][ # # ]: 0 : xFrame->initialize( xWindow );
622 : :
623 : : // create docinfo instance
624 [ # # ][ # # ]: 0 : m_xDocProps.set( ::comphelper::getProcessServiceFactory()->createInstance(
625 : 0 : ASCII_STR("com.sun.star.document.DocumentProperties") ),
626 [ # # ][ # # ]: 0 : UNO_QUERY );
[ # # ]
627 : :
628 [ # # ][ # # ]: 0 : pEmptyWin = new Window( this, WB_BORDER | WB_3DLOOK );
629 : 0 : }
630 : :
631 [ # # ][ # # ]: 0 : SvtFrameWindow_Impl::~SvtFrameWindow_Impl()
632 : : {
633 [ # # ][ # # ]: 0 : delete pEditWin;
634 [ # # ][ # # ]: 0 : delete pEmptyWin;
635 [ # # ][ # # ]: 0 : xFrame->dispose();
636 [ # # ]: 0 : }
637 : :
638 : 0 : void SvtFrameWindow_Impl::ViewEditWin()
639 : : {
640 : 0 : pEmptyWin->Hide();
641 : 0 : xWindow->setVisible( sal_False );
642 : 0 : pTextWin->Hide();
643 : 0 : pEditWin->Show();
644 : 0 : }
645 : :
646 : 0 : void SvtFrameWindow_Impl::ViewTextWin()
647 : : {
648 : 0 : pEmptyWin->Hide();
649 : 0 : pEditWin->Hide();
650 : 0 : xWindow->setVisible( sal_True );
651 : 0 : pTextWin->Show();
652 : 0 : }
653 : :
654 : 0 : void SvtFrameWindow_Impl::ViewEmptyWin()
655 : : {
656 : 0 : xWindow->setVisible( sal_False );
657 : 0 : pTextWin->Hide();
658 : 0 : pEditWin->Hide();
659 : 0 : pEmptyWin->Show();
660 : 0 : }
661 : :
662 : 0 : void SvtFrameWindow_Impl::ViewNonEmptyWin()
663 : : {
664 [ # # ]: 0 : if( bDocInfo )
665 : 0 : ViewEditWin();
666 : : else
667 : 0 : ViewTextWin();
668 : 0 : }
669 : :
670 : 0 : void SvtFrameWindow_Impl::ShowDocInfo( const String& rURL )
671 : : {
672 : : try
673 : : {
674 [ # # ][ # # ]: 0 : uno::Reference < task::XInteractionHandler > xInteractionHandler( ::comphelper::getProcessServiceFactory()->createInstance(
675 [ # # ][ # # ]: 0 : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler" )) ), uno::UNO_QUERY );
[ # # ]
676 [ # # ]: 0 : uno::Sequence < beans::PropertyValue> aProps(1);
677 [ # # ][ # # ]: 0 : aProps[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ));
678 [ # # ][ # # ]: 0 : aProps[0].Value <<= xInteractionHandler;
679 [ # # ][ # # ]: 0 : m_xDocProps->loadFromMedium( rURL, aProps );
[ # # ]
680 [ # # ][ # # ]: 0 : pEditWin->fill( m_xDocProps, rURL );
[ # # # ]
[ # # ]
681 : : }
682 : 0 : catch ( UnknownPropertyException& ) {}
683 : 0 : catch ( Exception& ) {}
684 : 0 : }
685 : :
686 : 0 : void SvtFrameWindow_Impl::Resize()
687 : : {
688 : 0 : Size aWinSize = GetOutputSizePixel();
689 [ # # ]: 0 : pEditWin->SetSizePixel( aWinSize );
690 [ # # ]: 0 : pTextWin->SetSizePixel( aWinSize );
691 [ # # ]: 0 : pEmptyWin->SetSizePixel( aWinSize );
692 : 0 : }
693 : :
694 : 0 : void SvtFrameWindow_Impl::OpenFile( const String& rURL, sal_Bool bPreview, sal_Bool bIsTemplate, sal_Bool bAsTemplate )
695 : : {
696 [ # # ]: 0 : if ( bPreview )
697 : 0 : aCurrentURL = rURL;
698 : :
699 : 0 : ViewNonEmptyWin();
700 : 0 : pEditWin->clear();
701 : :
702 [ # # ][ # # ]: 0 : if ( rURL.Len() > 0 && bPreview && m_xDocProps.is() )
[ # # ][ # # ]
703 : 0 : ShowDocInfo( rURL );
704 : :
705 [ # # ]: 0 : if ( rURL.Len() == 0 )
706 : : {
707 [ # # ]: 0 : xFrame->setComponent( Reference < com::sun::star::awt::XWindow >(), Reference < XController >() );
708 : 0 : ViewEmptyWin();
709 : : }
710 [ # # ][ # # ]: 0 : else if ( !::utl::UCBContentHelper::IsFolder( rURL ) )
711 : : {
712 : 0 : com::sun::star::util::URL aURL;
713 [ # # ]: 0 : aURL.Complete = rURL;
714 : : Reference< com::sun::star::util::XURLTransformer > xTrans(
715 [ # # ][ # # ]: 0 : com::sun::star::util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
716 [ # # ][ # # ]: 0 : xTrans->parseStrict( aURL );
717 : :
718 [ # # ]: 0 : String aTarget;
719 [ # # ]: 0 : Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY );
720 [ # # ]: 0 : if ( bPreview )
721 [ # # ][ # # ]: 0 : aTarget = ASCII_STR("_self");
722 : : else
723 : : {
724 : : // can be removed if the database application change its URL
725 [ # # ]: 0 : String sServiceScheme( RTL_CONSTASCII_USTRINGPARAM( "service:" ) );
726 [ # # ][ # # ]: 0 : if ( rURL.Match( sServiceScheme ) != sServiceScheme.Len() )
727 : : // service URL has no default target
728 [ # # ][ # # ]: 0 : aTarget = ASCII_STR("_default");
729 [ # # ][ # # ]: 0 : xProv = Reference < XDispatchProvider >( ::comphelper::getProcessServiceFactory()->
730 [ # # ][ # # ]: 0 : createInstance( ASCII_STR("com.sun.star.frame.Desktop") ), UNO_QUERY );
[ # # ][ # # ]
[ # # ]
731 : : }
732 : :
733 : 0 : Reference < XDispatch > xDisp = xProv.is() ?
734 [ # # ][ # # ]: 0 : xProv->queryDispatch( aURL, aTarget, 0 ) : Reference < XDispatch >();
[ # # ][ # # ]
[ # # ][ # # ]
735 : :
736 [ # # ]: 0 : if ( xDisp.is() )
737 : : {
738 [ # # ]: 0 : if ( bPreview )
739 : : {
740 [ # # ]: 0 : if ( m_aOpenURL != aURL.Complete )
741 : : {
742 [ # # ][ # # ]: 0 : WaitObject aWaitCursor( GetParent() );
743 : : // disabling must be done here, does not work in ctor because
744 : : // execute of the dialog will overwrite it
745 : : // ( own execute method would help )
746 [ # # ]: 0 : pTextWin->EnableInput( sal_False, sal_True );
747 [ # # ][ # # ]: 0 : if ( pTextWin->IsReallyVisible() )
748 : : {
749 : 0 : sal_Bool b = sal_True;
750 [ # # ]: 0 : Sequence < PropertyValue > aArgs( 4 );
751 [ # # ][ # # ]: 0 : aArgs[0].Name = ASCII_STR("Preview");
752 [ # # ][ # # ]: 0 : aArgs[0].Value.setValue( &b, ::getBooleanCppuType() );
753 [ # # ][ # # ]: 0 : aArgs[1].Name = ASCII_STR("ReadOnly");
754 [ # # ][ # # ]: 0 : aArgs[1].Value.setValue( &b, ::getBooleanCppuType() );
755 [ # # ][ # # ]: 0 : aArgs[2].Name = ASCII_STR("AsTemplate"); // prevents getting an empty URL with getURL()!
756 : :
757 [ # # ][ # # ]: 0 : uno::Reference < task::XInteractionHandler > xInteractionHandler( ::comphelper::getProcessServiceFactory()->createInstance(
758 [ # # ][ # # ]: 0 : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler" )) ), uno::UNO_QUERY );
[ # # ]
759 [ # # ][ # # ]: 0 : aArgs[3].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ));
760 [ # # ][ # # ]: 0 : aArgs[3].Value <<= xInteractionHandler;
761 : :
762 : 0 : b = sal_False;
763 [ # # ][ # # ]: 0 : aArgs[2].Value.setValue( &b, ::getBooleanCppuType() );
764 [ # # ][ # # ]: 0 : xDisp->dispatch( aURL, aArgs );
765 : :
766 : 0 : ::rtl::OUString aDispURL;
767 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::frame::XController > xCtrl = xFrame->getController();
768 [ # # ]: 0 : if( xCtrl.is() )
769 : : {
770 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::frame::XModel > xMdl = xCtrl->getModel();
771 [ # # ]: 0 : if( xMdl.is() )
772 [ # # ][ # # ]: 0 : aDispURL = xMdl->getURL();
773 : : }
774 : :
775 [ # # ]: 0 : if( aDispURL != aURL.Complete )
776 : : {
777 [ # # ][ # # ]: 0 : xFrame->setComponent( Reference < com::sun::star::awt::XWindow >(), Reference < XController >() );
778 [ # # ]: 0 : ViewEmptyWin();
779 : 0 : m_aOpenURL = rtl::OUString();
780 : : }
781 : : else
782 [ # # ]: 0 : m_aOpenURL = aDispURL;
783 [ # # ]: 0 : }
784 : : }
785 : : }
786 [ # # ]: 0 : else if ( bIsTemplate )
787 : : {
788 [ # # ]: 0 : Sequence < PropertyValue > aArgs( 1 );
789 [ # # ][ # # ]: 0 : aArgs[0].Name = ASCII_STR("AsTemplate");
790 [ # # ][ # # ]: 0 : aArgs[0].Value <<= bAsTemplate;
791 [ # # ][ # # ]: 0 : xDisp->dispatch( aURL, aArgs );
792 [ # # ]: 0 : m_aOpenURL = rtl::OUString();
793 : : }
794 : : else
795 : : {
796 [ # # ]: 0 : Sequence < PropertyValue > aArgs;
797 [ # # ][ # # ]: 0 : xDisp->dispatch( aURL, aArgs );
798 [ # # ]: 0 : m_aOpenURL = rtl::OUString();
799 : : }
800 [ # # ]: 0 : }
801 : : }
802 : 0 : }
803 : :
804 : 0 : void SvtFrameWindow_Impl::ToggleView( sal_Bool bDI )
805 : : {
806 : 0 : bDocInfo = bDI;
807 : :
808 : : // view is set properly in OpenFile()
809 : :
810 : 0 : OpenFile( aCurrentURL, sal_True, sal_False, sal_False );
811 : 0 : }
812 : :
813 : : // class SvtTemplateWindow -----------------------------------------------
814 : :
815 : 0 : SvtTemplateWindow::SvtTemplateWindow( Window* pParent ) :
816 : :
817 : : Window( pParent, WB_DIALOGCONTROL ),
818 : :
819 : : aFileViewTB ( this, SvtResId( TB_SVT_FILEVIEW ) ),
820 : : aFrameWinTB ( this, SvtResId( TB_SVT_FRAMEWIN ) ),
821 : : aSplitWin ( this, WB_DIALOGCONTROL | WB_NOSPLITDRAW ),
822 [ # # ][ # # ]: 0 : pHistoryList ( NULL )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
823 : :
824 : : {
825 : : // create windows
826 [ # # ][ # # ]: 0 : pIconWin = new SvtIconWindow_Impl( this );
827 [ # # ][ # # ]: 0 : pFileWin = new SvtFileViewWindow_Impl( this );
828 [ # # ]: 0 : pFileWin->SetMyDocumentsURL( pIconWin->GetMyDocumentsRootURL() );
829 [ # # ]: 0 : pFileWin->SetSamplesFolderURL( pIconWin->GetSamplesFolderURL() );
830 [ # # ][ # # ]: 0 : pFrameWin = new SvtFrameWindow_Impl( this );
831 : :
832 : : // set handlers
833 [ # # ]: 0 : pIconWin->SetClickHdl( LINK( this, SvtTemplateWindow, IconClickHdl_Impl ) );
834 [ # # ][ # # ]: 0 : pFileWin->SetSelectHdl( LINK( this, SvtTemplateWindow, FileSelectHdl_Impl ) );
835 [ # # ][ # # ]: 0 : pFileWin->SetDoubleClickHdl( LINK( this, SvtTemplateWindow, FileDblClickHdl_Impl ) );
836 [ # # ]: 0 : pFileWin->SetNewFolderHdl( LINK( this, SvtTemplateWindow, NewFolderHdl_Impl ) );
837 : :
838 : : // create the split items
839 [ # # ]: 0 : aSplitWin.SetAlign( WINDOWALIGN_LEFT );
840 : 0 : long nWidth = pIconWin->GetMaxTextLength() * 8 / 7 + 1; // extra space for border
841 [ # # ]: 0 : aSplitWin.InsertItem( ICONWIN_ID, pIconWin, nWidth, SPLITWINDOW_APPEND, 0, SWIB_FIXED );
842 [ # # ]: 0 : aSplitWin.InsertItem( FILEWIN_ID, pFileWin, 50, SPLITWINDOW_APPEND, 0, SWIB_PERCENTSIZE );
843 [ # # ]: 0 : aSplitWin.InsertItem( FRAMEWIN_ID, pFrameWin, 50, SPLITWINDOW_APPEND, 0, SWIB_PERCENTSIZE );
844 [ # # ]: 0 : aSplitWin.SetSplitHdl( LINK( this, SvtTemplateWindow, ResizeHdl_Impl ) );
845 : :
846 : : // show the windows
847 [ # # ]: 0 : pIconWin->Show();
848 [ # # ]: 0 : pFileWin->Show();
849 [ # # ]: 0 : pFrameWin->Show();
850 [ # # ]: 0 : aSplitWin.Show();
851 : :
852 : : // initialize the timers
853 [ # # ]: 0 : aSelectTimer.SetTimeout( 200 );
854 [ # # ]: 0 : aSelectTimer.SetTimeoutHdl( LINK( this, SvtTemplateWindow, TimeoutHdl_Impl ) );
855 : :
856 : : // initialize the toolboxes and then show them
857 [ # # ]: 0 : InitToolBoxes();
858 [ # # ]: 0 : aFileViewTB.Show();
859 [ # # ]: 0 : aFrameWinTB.Show();
860 : :
861 [ # # ]: 0 : ReadViewSettings( );
862 : :
863 [ # # ][ # # ]: 0 : Application::PostUserEvent( LINK( this, SvtTemplateWindow, ResizeHdl_Impl ) );
864 : 0 : }
865 : :
866 : : // ------------------------------------------------------------------------
867 : :
868 [ # # ][ # # ]: 0 : SvtTemplateWindow::~SvtTemplateWindow()
[ # # ][ # # ]
[ # # ]
869 : : {
870 [ # # ]: 0 : WriteViewSettings( );
871 : :
872 [ # # ][ # # ]: 0 : delete pIconWin;
873 [ # # ][ # # ]: 0 : delete pFileWin;
874 [ # # ][ # # ]: 0 : delete pFrameWin;
875 [ # # ]: 0 : if ( pHistoryList )
876 : : {
877 [ # # ]: 0 : for ( size_t i = 0, n = pHistoryList->size(); i < n; ++i )
878 [ # # ][ # # ]: 0 : delete (*pHistoryList)[ i ];
879 : 0 : pHistoryList->clear();
880 [ # # ]: 0 : delete pHistoryList;
881 : : }
882 [ # # ]: 0 : }
883 : :
884 : : // ------------------------------------------------------------------------
885 : :
886 : 0 : IMPL_LINK_NOARG(SvtTemplateWindow , IconClickHdl_Impl)
887 : : {
888 [ # # ]: 0 : String aURL = pIconWin->GetSelectedIconURL();
889 [ # # ]: 0 : if ( !aURL.Len() )
890 [ # # ][ # # ]: 0 : aURL = pIconWin->GetCursorPosIconURL();
[ # # ]
891 [ # # ][ # # ]: 0 : if ( pFileWin->GetRootURL() != aURL )
[ # # ][ # # ]
892 : : {
893 [ # # ]: 0 : pFileWin->OpenRoot( aURL );
894 [ # # ]: 0 : pIconWin->InvalidateIconControl();
895 [ # # ]: 0 : aFileViewTB.EnableItem( TI_DOCTEMPLATE_PRINT, sal_False );
896 : : }
897 [ # # ]: 0 : return 0;
898 : : }
899 : :
900 : : // ------------------------------------------------------------------------
901 : :
902 : 0 : IMPL_LINK_NOARG(SvtTemplateWindow , FileSelectHdl_Impl)
903 : : {
904 : 0 : aSelectTimer.Start();
905 : 0 : return 0;
906 : : }
907 : :
908 : : // ------------------------------------------------------------------------
909 : :
910 : 0 : IMPL_LINK_NOARG(SvtTemplateWindow , FileDblClickHdl_Impl)
911 : : {
912 [ # # ]: 0 : if ( aSelectTimer.IsActive() )
913 [ # # ]: 0 : aSelectTimer.Stop();
914 : :
915 [ # # ]: 0 : String aURL = pFileWin->GetSelectedFile();
916 [ # # ]: 0 : if ( aURL.Len() > 0 )
917 : : {
918 [ # # ][ # # ]: 0 : if ( ::utl::UCBContentHelper::IsFolder( aURL ) )
[ # # ]
919 [ # # ]: 0 : pFileWin->OpenFolder( aURL );
920 : : else
921 [ # # ]: 0 : aDoubleClickHdl.Call( this );
922 : : }
923 : :
924 [ # # ]: 0 : return 0;
925 : : }
926 : :
927 : : // ------------------------------------------------------------------------
928 : :
929 : 0 : IMPL_LINK_NOARG(SvtTemplateWindow , NewFolderHdl_Impl)
930 : : {
931 [ # # ][ # # ]: 0 : pFrameWin->OpenFile( String(), sal_True, sal_False, sal_False );
[ # # ]
932 [ # # ]: 0 : aFileViewTB.EnableItem( TI_DOCTEMPLATE_PRINT, sal_False );
933 : :
934 [ # # ]: 0 : String sURL = pFileWin->GetFolderURL();
935 [ # # ]: 0 : sal_uLong nPos = pIconWin->GetRootPos( sURL );
936 [ # # ]: 0 : AppendHistoryURL( sURL, nPos );
937 : :
938 [ # # ]: 0 : aNewFolderHdl.Call( this );
939 [ # # ]: 0 : return 0;
940 : : }
941 : :
942 : : // ------------------------------------------------------------------------
943 : :
944 : 0 : IMPL_LINK_NOARG(SvtTemplateWindow , TimeoutHdl_Impl)
945 : : {
946 [ # # ]: 0 : aSelectHdl.Call( this );
947 [ # # ]: 0 : String sURL = pFileWin->GetSelectedFile();
948 [ # # ]: 0 : sal_Bool bIsNewDoc = ( pIconWin->GetSelectEntryPos() == ICON_POS_NEWDOC );
949 [ # # ][ # # ]: 0 : sal_Bool bIsFile = ( sURL.Len() != 0 && !::utl::UCBContentHelper::IsFolder( sURL ) &&
[ # # ][ # # ]
950 [ # # ][ # # ]: 0 : INetURLObject( sURL ).GetProtocol() != INET_PROT_PRIVATE && !bIsNewDoc );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
[ # # ]
951 [ # # ]: 0 : aFileViewTB.EnableItem( TI_DOCTEMPLATE_PRINT, bIsFile );
952 [ # # ]: 0 : aFrameWinTB.EnableItem( TI_DOCTEMPLATE_PREVIEW, !bIsNewDoc );
953 : :
954 [ # # ]: 0 : if ( bIsFile )
955 [ # # ]: 0 : pFrameWin->OpenFile( sURL, sal_True, sal_False, sal_False );
956 [ # # ][ # # ]: 0 : else if ( bIsNewDoc && aFrameWinTB.IsItemChecked( TI_DOCTEMPLATE_PREVIEW ) )
[ # # ][ # # ]
957 : : {
958 [ # # ]: 0 : aFrameWinTB.CheckItem( TI_DOCTEMPLATE_DOCINFO );
959 [ # # ]: 0 : DoAction( TI_DOCTEMPLATE_DOCINFO );
960 : : }
961 [ # # ]: 0 : return 0;
962 : : }
963 : :
964 : : // ------------------------------------------------------------------------
965 : :
966 : 0 : IMPL_LINK ( SvtTemplateWindow , ClickHdl_Impl, ToolBox *, pToolBox )
967 : : {
968 : 0 : DoAction( pToolBox->GetCurItemId() );
969 : 0 : return 0;
970 : : }
971 : :
972 : : // ------------------------------------------------------------------------
973 : :
974 : 0 : IMPL_LINK_NOARG(SvtTemplateWindow , ResizeHdl_Impl)
975 : : {
976 : 0 : Resize();
977 : 0 : return 0;
978 : : }
979 : :
980 : : // ------------------------------------------------------------------------
981 : :
982 : 0 : void SvtTemplateWindow::PrintFile( const String& rURL )
983 : : {
984 : : // open the file readonly and hidden
985 [ # # ]: 0 : Sequence < PropertyValue > aArgs( 2 );
986 [ # # ][ # # ]: 0 : aArgs[0].Name = ASCII_STR("ReadOnly");
987 [ # # ][ # # ]: 0 : aArgs[0].Value <<= sal_True;
988 [ # # ][ # # ]: 0 : aArgs[1].Name = ASCII_STR("Hidden");
989 [ # # ][ # # ]: 0 : aArgs[1].Value <<= sal_True;
990 : :
991 [ # # ][ # # ]: 0 : Reference < XComponentLoader > xDesktop( ::comphelper::getProcessServiceFactory()->
992 [ # # ][ # # ]: 0 : createInstance( ASCII_STR("com.sun.star.frame.Desktop") ), UNO_QUERY );
[ # # ]
993 [ # # ]: 0 : Reference < XModel > xModel( xDesktop->loadComponentFromURL(
994 [ # # ][ # # ]: 0 : rURL, ASCII_STR("_blank"), 0, aArgs ), UNO_QUERY );
[ # # ][ # # ]
995 [ # # ]: 0 : if ( xModel.is() )
996 : : {
997 : : // print
998 [ # # ]: 0 : Reference < XPrintable > xPrintable( xModel, UNO_QUERY );
999 [ # # ]: 0 : if ( xPrintable.is() )
1000 [ # # ][ # # ]: 0 : xPrintable->print( Sequence < PropertyValue >() );
[ # # ][ # # ]
1001 [ # # ]: 0 : }
1002 : 0 : }
1003 : :
1004 : : // ------------------------------------------------------------------------
1005 : :
1006 : 0 : void SvtTemplateWindow::AppendHistoryURL( const String& rURL, sal_uLong nGroup )
1007 : : {
1008 : 0 : sal_Bool bInsert = sal_True;
1009 [ # # ]: 0 : if ( !pHistoryList )
1010 [ # # ]: 0 : pHistoryList = new HistoryList_Impl;
1011 [ # # ]: 0 : else if ( pHistoryList->size() > 0 )
1012 : : {
1013 : 0 : FolderHistory* pLastEntry = pHistoryList->back();
1014 : 0 : bInsert = ( rURL != pLastEntry->m_sURL);
1015 : : }
1016 : :
1017 [ # # ]: 0 : if ( bInsert )
1018 : : {
1019 [ # # ][ # # ]: 0 : FolderHistory* pEntry = new FolderHistory( rURL, nGroup );
1020 [ # # ]: 0 : pHistoryList->push_back( pEntry );
1021 [ # # ]: 0 : aFileViewTB.EnableItem( TI_DOCTEMPLATE_BACK, pHistoryList->size() > 1 );
1022 : : }
1023 : 0 : }
1024 : :
1025 : : // ------------------------------------------------------------------------
1026 : :
1027 : 0 : void SvtTemplateWindow::OpenHistory()
1028 : : {
1029 [ # # ]: 0 : delete pHistoryList->back();
1030 : 0 : pHistoryList->pop_back();
1031 : 0 : FolderHistory* pEntry = pHistoryList->back();
1032 : 0 : pHistoryList->pop_back();
1033 : 0 : aFileViewTB.EnableItem( TI_DOCTEMPLATE_BACK, pHistoryList->size() > 1 );
1034 : 0 : pFileWin->OpenFolder( pEntry->m_sURL );
1035 : 0 : pIconWin->SetCursorPos( pEntry->m_nGroup );
1036 [ # # ]: 0 : delete pEntry;
1037 : 0 : }
1038 : :
1039 : : // ------------------------------------------------------------------------
1040 : :
1041 : 0 : void SvtTemplateWindow::DoAction( sal_uInt16 nAction )
1042 : : {
1043 [ # # # # : 0 : switch( nAction )
# ]
1044 : : {
1045 : : case TI_DOCTEMPLATE_BACK :
1046 : : {
1047 [ # # ][ # # ]: 0 : if ( pHistoryList && pHistoryList->size() > 1 )
[ # # ]
1048 : 0 : OpenHistory();
1049 : 0 : break;
1050 : : }
1051 : :
1052 : : case TI_DOCTEMPLATE_PREV :
1053 : : {
1054 [ # # ]: 0 : String aURL;
1055 [ # # ][ # # ]: 0 : if ( pFileWin->HasPreviousLevel( aURL ) )
1056 [ # # ]: 0 : pFileWin->OpenFolder( aURL );
1057 [ # # ]: 0 : break;
1058 : : }
1059 : :
1060 : : case TI_DOCTEMPLATE_PRINT :
1061 : : {
1062 [ # # ]: 0 : String sPrintFile( pFileWin->GetSelectedFile() );
1063 [ # # ]: 0 : if ( sPrintFile.Len() > 0 )
1064 [ # # ]: 0 : PrintFile( sPrintFile );
1065 [ # # ]: 0 : break;
1066 : : }
1067 : :
1068 : : case TI_DOCTEMPLATE_DOCINFO :
1069 : : case TI_DOCTEMPLATE_PREVIEW :
1070 : : {
1071 : 0 : pFrameWin->ToggleView( TI_DOCTEMPLATE_DOCINFO == nAction );
1072 : 0 : break;
1073 : : }
1074 : : }
1075 : 0 : }
1076 : :
1077 : : // ------------------------------------------------------------------------
1078 : :
1079 : 0 : void SvtTemplateWindow::InitToolBoxes()
1080 : : {
1081 [ # # ]: 0 : InitToolBoxImages();
1082 : :
1083 [ # # ]: 0 : Size aSize = aFileViewTB.CalcWindowSizePixel();
1084 : 0 : aSize.Height() += 4;
1085 [ # # ]: 0 : aFileViewTB.SetPosSizePixel( Point( 0, 2 ), aSize );
1086 [ # # ]: 0 : aSize = aFrameWinTB.CalcWindowSizePixel();
1087 : 0 : aSize.Height() += 4;
1088 [ # # ][ # # ]: 0 : aFrameWinTB.SetPosSizePixel( Point( pFrameWin->GetPosPixel().X() + 2, 2 ), aSize );
1089 : :
1090 [ # # ][ # # ]: 0 : sal_Bool bFlat = ( SvtMiscOptions().GetToolboxStyle() == TOOLBOX_STYLE_FLAT );
[ # # ]
1091 [ # # ]: 0 : if ( bFlat )
1092 : : {
1093 [ # # ]: 0 : aFileViewTB.SetOutStyle( TOOLBOX_STYLE_FLAT );
1094 [ # # ]: 0 : aFrameWinTB.SetOutStyle( TOOLBOX_STYLE_FLAT );
1095 : : }
1096 : :
1097 [ # # ]: 0 : aFileViewTB.EnableItem( TI_DOCTEMPLATE_BACK, sal_False );
1098 [ # # ]: 0 : aFileViewTB.EnableItem( TI_DOCTEMPLATE_PREV, sal_False );
1099 [ # # ]: 0 : aFileViewTB.EnableItem( TI_DOCTEMPLATE_PRINT, sal_False );
1100 : :
1101 [ # # ]: 0 : Link aLink = LINK( this, SvtTemplateWindow, ClickHdl_Impl );
1102 : 0 : aFileViewTB.SetClickHdl( aLink );
1103 : 0 : aFrameWinTB.SetClickHdl( aLink );
1104 : 0 : }
1105 : :
1106 : : // ------------------------------------------------------------------------
1107 : :
1108 : 0 : void SvtTemplateWindow::InitToolBoxImages()
1109 : : {
1110 [ # # ]: 0 : SvtMiscOptions aMiscOpt;
1111 [ # # ]: 0 : sal_Bool bLarge = aMiscOpt.AreCurrentSymbolsLarge();
1112 : :
1113 : : aFileViewTB.SetItemImage( TI_DOCTEMPLATE_BACK, Image( SvtResId(
1114 : : bLarge ? IMG_SVT_DOCTEMPLATE_BACK_LARGE
1115 [ # # ][ # # ]: 0 : : IMG_SVT_DOCTEMPLATE_BACK_SMALL ) ) );
[ # # ][ # # ]
[ # # ]
1116 : : aFileViewTB.SetItemImage( TI_DOCTEMPLATE_PREV, Image( SvtResId(
1117 : : bLarge ? IMG_SVT_DOCTEMPLATE_PREV_LARGE
1118 [ # # ][ # # ]: 0 : : IMG_SVT_DOCTEMPLATE_PREV_SMALL ) ) );
[ # # ][ # # ]
[ # # ]
1119 : : aFileViewTB.SetItemImage( TI_DOCTEMPLATE_PRINT, Image( SvtResId(
1120 : : bLarge ? IMG_SVT_DOCTEMPLATE_PRINT_LARGE
1121 [ # # ][ # # ]: 0 : : IMG_SVT_DOCTEMPLATE_PRINT_SMALL ) ) );
[ # # ][ # # ]
[ # # ]
1122 : :
1123 : : aFrameWinTB.SetItemImage( TI_DOCTEMPLATE_DOCINFO, Image( SvtResId(
1124 : : bLarge ? IMG_SVT_DOCTEMPLATE_DOCINFO_LARGE
1125 [ # # ][ # # ]: 0 : : IMG_SVT_DOCTEMPLATE_DOCINFO_SMALL ) ) );
[ # # ][ # # ]
[ # # ]
1126 : : aFrameWinTB.SetItemImage( TI_DOCTEMPLATE_PREVIEW, Image( SvtResId(
1127 : : bLarge ? IMG_SVT_DOCTEMPLATE_PREVIEW_LARGE
1128 [ # # ][ # # ]: 0 : : IMG_SVT_DOCTEMPLATE_PREVIEW_SMALL ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
1129 : 0 : }
1130 : :
1131 : : // ------------------------------------------------------------------------
1132 : :
1133 : 0 : void SvtTemplateWindow::UpdateIcons()
1134 : : {
1135 : 0 : pIconWin->UpdateIcons();
1136 : 0 : }
1137 : :
1138 : : // ------------------------------------------------------------------------
1139 : :
1140 : 0 : long SvtTemplateWindow::PreNotify( NotifyEvent& rNEvt )
1141 : : {
1142 : 0 : sal_uInt16 nType = rNEvt.GetType();
1143 : 0 : long nRet = 0;
1144 : :
1145 [ # # ][ # # ]: 0 : if ( EVENT_KEYINPUT == nType && rNEvt.GetKeyEvent() )
[ # # ]
1146 : : {
1147 : 0 : const KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
1148 : 0 : sal_uInt16 nCode = rKeyCode.GetCode();
1149 : :
1150 [ # # ][ # # ]: 0 : if ( KEY_BACKSPACE == nCode && !rKeyCode.GetModifier() && pFileWin->HasChildPathFocus() )
[ # # ][ # # ]
1151 : : {
1152 : 0 : DoAction( TI_DOCTEMPLATE_BACK );
1153 : 0 : nRet = 1;
1154 : : }
1155 [ # # ]: 0 : else if ( pIconWin->ProcessKeyEvent( *rNEvt.GetKeyEvent() ) )
1156 : : {
1157 : 0 : nRet = 1;
1158 : : }
1159 : : }
1160 : :
1161 [ # # ]: 0 : return nRet ? nRet : Window::PreNotify( rNEvt );
1162 : : }
1163 : :
1164 : : // -----------------------------------------------------------------------------
1165 : :
1166 : 0 : void SvtTemplateWindow::DataChanged( const DataChangedEvent& rDCEvt )
1167 : : {
1168 : 0 : Window::DataChanged( rDCEvt );
1169 : :
1170 [ # # ][ # # : 0 : if ( ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) ||
# # # # ]
1171 : 0 : ( rDCEvt.GetType() == DATACHANGED_DISPLAY ) ) &&
1172 : 0 : ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
1173 : : {
1174 : : // update of the background for the area left of the FileView toolbox
1175 [ # # ]: 0 : SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFaceColor() ) );
1176 : : // update of the images of the IconChoiceControl
1177 : 0 : UpdateIcons();
1178 : : // update of the toolbox images
1179 : 0 : InitToolBoxImages();
1180 : : }
1181 : 0 : }
1182 : : // ------------------------------------------------------------------------
1183 : :
1184 : 0 : void SvtTemplateWindow::Resize()
1185 : : {
1186 [ # # ]: 0 : long nItemSize = aSplitWin.GetItemSize( ICONWIN_ID );
1187 [ # # ][ # # ]: 0 : long nSplitterWidth = Splitter( this, 0 ).GetSizePixel().Width();
[ # # ]
1188 : :
1189 [ # # ]: 0 : Point aPos = aFileViewTB.GetPosPixel();
1190 : 0 : aPos.X() = nItemSize + nSplitterWidth / 2;
1191 [ # # ]: 0 : aFileViewTB.SetPosPixel( aPos );
1192 : :
1193 : 0 : Size aWinSize = GetOutputSizePixel();
1194 : 0 : long nWidth = aWinSize.Width() - aPos.X();
1195 : :
1196 [ # # ]: 0 : nItemSize = nWidth * aSplitWin.GetItemSize( FILEWIN_ID ) / 100;
1197 [ # # ]: 0 : aPos.X() = pFrameWin->GetPosPixel().X() + 2;
1198 [ # # ]: 0 : aFrameWinTB.SetPosPixel( aPos );
1199 : :
1200 [ # # ]: 0 : Size aSize = aFileViewTB.GetSizePixel();
1201 : 0 : aSize.Width() = nItemSize;
1202 [ # # ]: 0 : aFileViewTB.SetSizePixel( aSize );
1203 : :
1204 [ # # ]: 0 : aSize = aFrameWinTB.GetSizePixel();
1205 : 0 : aSize.Width() = nWidth - nItemSize;
1206 [ # # ]: 0 : aFrameWinTB.SetSizePixel( aSize );
1207 : :
1208 [ # # ]: 0 : long nToolBoxHeight = aSize.Height() + aFrameWinTB.GetPosPixel().Y();
1209 : 0 : aSize = aWinSize;
1210 : 0 : aSize.Height() -= nToolBoxHeight;
1211 [ # # ]: 0 : aSplitWin.SetPosSizePixel( Point( 0, nToolBoxHeight ), aSize );
1212 : 0 : }
1213 : :
1214 : : // ------------------------------------------------------------------------
1215 : :
1216 : 0 : String SvtTemplateWindow::GetSelectedFile() const
1217 : : {
1218 : 0 : return pFileWin->GetSelectedFile();
1219 : : }
1220 : :
1221 : : // ------------------------------------------------------------------------
1222 : :
1223 : 0 : sal_Bool SvtTemplateWindow::IsFileSelected() const
1224 : : {
1225 [ # # ]: 0 : String aURL = pFileWin->GetSelectedFile();
1226 [ # # ][ # # ]: 0 : sal_Bool bRet = ( aURL.Len() > 0 && !::utl::UCBContentHelper::IsFolder( aURL ) );
[ # # ][ # # ]
[ # # ][ # # ]
1227 [ # # ]: 0 : return bRet;
1228 : : }
1229 : :
1230 : : // ------------------------------------------------------------------------
1231 : :
1232 : 0 : void SvtTemplateWindow::OpenFile( sal_Bool bNotAsTemplate )
1233 : : {
1234 [ # # ]: 0 : String aURL = pFileWin->GetSelectedFile();
1235 [ # # ][ # # ]: 0 : if ( aURL.Len() > 0 && !::utl::UCBContentHelper::IsFolder( aURL ) )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
1236 [ # # ][ # # ]: 0 : pFrameWin->OpenFile( aURL, sal_False, pFileWin->IsTemplateFolder(), !bNotAsTemplate );
1237 : 0 : }
1238 : :
1239 : : // ------------------------------------------------------------------------
1240 : :
1241 : 0 : String SvtTemplateWindow::GetFolderTitle() const
1242 : : {
1243 [ # # ]: 0 : String sTitle;
1244 [ # # ]: 0 : String sFolderURL = pFileWin->GetFolderURL();
1245 [ # # ][ # # ]: 0 : if ( pIconWin->IsRootURL( sFolderURL ) )
1246 [ # # ][ # # ]: 0 : sTitle = pIconWin->GetIconText( sFolderURL );
[ # # ]
1247 : : else
1248 [ # # ][ # # ]: 0 : sTitle = pFileWin->GetFolderTitle();
[ # # ]
1249 [ # # ]: 0 : return sTitle;
1250 : : }
1251 : :
1252 : : // ------------------------------------------------------------------------
1253 : :
1254 : 0 : String SvtTemplateWindow::GetFolderURL() const
1255 : : {
1256 : 0 : return pFileWin->GetFolderURL();
1257 : : }
1258 : :
1259 : :
1260 : : // ------------------------------------------------------------------------
1261 : :
1262 : 0 : void SvtTemplateWindow::SetFocus( sal_Bool bIconWin )
1263 : : {
1264 [ # # ]: 0 : if ( bIconWin )
1265 : 0 : pIconWin->SetFocus();
1266 : : else
1267 : 0 : pFileWin->SetFocus();
1268 : 0 : }
1269 : :
1270 : : // ------------------------------------------------------------------------
1271 : :
1272 : 0 : void SvtTemplateWindow::OpenTemplateRoot()
1273 : : {
1274 : 0 : pFileWin->OpenFolder( pIconWin->GetTemplateRootURL() );
1275 : 0 : }
1276 : :
1277 : : // ------------------------------------------------------------------------
1278 : :
1279 : 0 : void SvtTemplateWindow::SetPrevLevelButtonState( const String& rURL )
1280 : : {
1281 : : // disable the prev level button on root folder of the icon pane (except My Documents)
1282 : : // and on the root of all (file:/// -> count == 0)
1283 [ # # ][ # # ]: 0 : INetURLObject aObj( rURL );
1284 [ # # ]: 0 : sal_Int32 nCount = aObj.getSegmentCount();
1285 : : sal_Bool bEnable =
1286 : : ( nCount > 0 &&
1287 [ # # ][ # # ]: 0 : ( !pIconWin->IsRootURL( rURL ) || rURL == pIconWin->GetMyDocumentsRootURL() ) );
[ # # ][ # # ]
[ # # ]
1288 [ # # ][ # # ]: 0 : aFileViewTB.EnableItem( TI_DOCTEMPLATE_PREV, bEnable );
1289 : 0 : }
1290 : :
1291 : : // ------------------------------------------------------------------------
1292 : :
1293 : 0 : void SvtTemplateWindow::ClearHistory()
1294 : : {
1295 [ # # ]: 0 : if( pHistoryList )
1296 : : {
1297 [ # # ]: 0 : for ( size_t i = 0, n = pHistoryList->size(); i < n; ++i )
1298 [ # # ]: 0 : delete (*pHistoryList)[ i ];
1299 : 0 : pHistoryList->clear();
1300 : : }
1301 : 0 : }
1302 : :
1303 : : // ------------------------------------------------------------------------
1304 : :
1305 : 0 : long SvtTemplateWindow::CalcHeight() const
1306 : : {
1307 : : // toolbox height
1308 : 0 : long nHeight = aFileViewTB.GetSizePixel().Height();
1309 : : // + iconwin height
1310 : 0 : nHeight += pIconWin->CalcHeight();
1311 : : // + little offset
1312 : 0 : nHeight += 8;
1313 : 0 : return nHeight;
1314 : : }
1315 : :
1316 : : // ------------------------------------------------------------------------
1317 : :
1318 : 0 : void SvtTemplateWindow::ReadViewSettings()
1319 : : {
1320 : : // defaults
1321 : 0 : sal_Int32 nSelectedGroup = ICON_POS_TEMPLATES;
1322 : 0 : sal_Int32 nSelectedView = TI_DOCTEMPLATE_DOCINFO;
1323 : 0 : double nSplitRatio = 0.5;
1324 : 0 : ::rtl::OUString sLastFolder;
1325 : :
1326 [ # # ][ # # ]: 0 : SvtViewOptions aViewSettings( E_DIALOG, VIEWSETTING_NEWFROMTEMPLATE );
1327 [ # # ][ # # ]: 0 : if ( aViewSettings.Exists() )
1328 : : {
1329 : : // read the settings
1330 [ # # ]: 0 : Sequence< NamedValue > aSettings = aViewSettings.GetUserData( );
1331 : :
1332 [ # # ][ # # ]: 0 : aViewSettings.GetUserItem( VIEWSETTING_SELECTEDGROUP ) >>= nSelectedGroup;
1333 [ # # ][ # # ]: 0 : aViewSettings.GetUserItem( VIEWSETTING_SELECTEDVIEW ) >>= nSelectedView;
1334 [ # # ][ # # ]: 0 : aViewSettings.GetUserItem( VIEWSETTING_SPLITRATIO ) >>= nSplitRatio;
1335 [ # # ][ # # ]: 0 : aViewSettings.GetUserItem( VIEWSETTING_LASTFOLDER ) >>= sLastFolder;
[ # # ]
1336 : : }
1337 : : // normalize
1338 [ # # ]: 0 : if ( nSelectedGroup < ICON_POS_NEWDOC ) nSelectedGroup = ICON_POS_NEWDOC;
1339 [ # # ]: 0 : if ( nSelectedGroup > ICON_POS_SAMPLES ) nSelectedGroup = ICON_POS_SAMPLES;
1340 : :
1341 [ # # ][ # # ]: 0 : if ( ( TI_DOCTEMPLATE_DOCINFO != nSelectedView ) && ( TI_DOCTEMPLATE_PREVIEW != nSelectedView ) )
1342 : 0 : nSelectedView = TI_DOCTEMPLATE_DOCINFO;
1343 : :
1344 [ # # ]: 0 : if ( nSplitRatio < 0.2 ) nSplitRatio = 0.2;
1345 [ # # ]: 0 : if ( nSplitRatio > 0.8 ) nSplitRatio = 0.8;
1346 : :
1347 : : // change our view according to the settings
1348 : :
1349 : : // the selected view (details or preview)
1350 [ # # ]: 0 : pFrameWin->ToggleView( TI_DOCTEMPLATE_DOCINFO == nSelectedView );
1351 [ # # ]: 0 : aFrameWinTB.CheckItem( (sal_uInt16)nSelectedView, sal_True );
1352 : :
1353 : : // the split ratio
1354 [ # # ][ # # ]: 0 : sal_Int32 nSplitFileAndFrameSize = aSplitWin.GetItemSize( FILEWIN_ID ) + aSplitWin.GetItemSize( FRAMEWIN_ID );
1355 : 0 : sal_Int32 nSplitFileSize = (sal_Int32)(nSplitFileAndFrameSize * nSplitRatio);
1356 : 0 : sal_Int32 nSplitFrameSize = nSplitFileAndFrameSize - nSplitFileSize;
1357 [ # # ]: 0 : aSplitWin.SetItemSize( FILEWIN_ID, nSplitFileSize );
1358 [ # # ]: 0 : aSplitWin.SetItemSize( FRAMEWIN_ID, nSplitFrameSize );
1359 [ # # ]: 0 : Resize();
1360 : :
1361 : : // the selected folder
1362 [ # # ]: 0 : pIconWin->SetCursorPos( nSelectedGroup );
1363 : :
1364 : : // open the last folder or the selected group
1365 [ # # ]: 0 : if ( !sLastFolder.isEmpty() )
1366 [ # # ][ # # ]: 0 : pFileWin->OpenFolder( sLastFolder );
[ # # ]
1367 : : else
1368 [ # # ][ # # ]: 0 : IconClickHdl_Impl( NULL );
1369 : 0 : }
1370 : :
1371 : : // ------------------------------------------------------------------------
1372 : :
1373 : 0 : void SvtTemplateWindow::WriteViewSettings()
1374 : : {
1375 : : // collect
1376 [ # # ]: 0 : Sequence< NamedValue > aSettings(4);
1377 : :
1378 : : // the selected group
1379 [ # # ][ # # ]: 0 : aSettings[0].Name = VIEWSETTING_SELECTEDGROUP;
1380 [ # # ]: 0 : pIconWin->SetFocus();
1381 [ # # ][ # # ]: 0 : aSettings[0].Value <<= (sal_Int32)pIconWin->GetCursorPos( );
[ # # ]
1382 : :
1383 : : // the selected view mode
1384 [ # # ][ # # ]: 0 : aSettings[1].Name = VIEWSETTING_SELECTEDVIEW;
1385 [ # # ][ # # ]: 0 : aSettings[1].Value <<= sal_Int32( aFrameWinTB.IsItemChecked( TI_DOCTEMPLATE_DOCINFO ) ? TI_DOCTEMPLATE_DOCINFO : TI_DOCTEMPLATE_PREVIEW );
[ # # ][ # # ]
1386 : :
1387 : : // the split ratio
1388 [ # # ][ # # ]: 0 : aSettings[2].Name = VIEWSETTING_SPLITRATIO;
1389 [ # # ]: 0 : sal_Int32 nSplitFileSize = aSplitWin.GetItemSize( FILEWIN_ID );
1390 [ # # ]: 0 : sal_Int32 nSplitFileAndFrameSize = nSplitFileSize + aSplitWin.GetItemSize( FRAMEWIN_ID );
1391 [ # # ][ # # ]: 0 : aSettings[2].Value <<= double( 1.0 * nSplitFileSize / nSplitFileAndFrameSize );
1392 : :
1393 : : // last folder
1394 [ # # ][ # # ]: 0 : aSettings[3].Name = VIEWSETTING_LASTFOLDER;
1395 [ # # ][ # # ]: 0 : aSettings[3].Value <<= ::rtl::OUString( pFileWin->GetFolderURL() );
[ # # ][ # # ]
[ # # ]
1396 : :
1397 : : // write
1398 [ # # ][ # # ]: 0 : SvtViewOptions aViewSettings( E_DIALOG, VIEWSETTING_NEWFROMTEMPLATE );
1399 [ # # ][ # # ]: 0 : aViewSettings.SetUserData( aSettings );
[ # # ]
1400 : 0 : }
1401 : :
1402 : 0 : void SvtTemplateWindow::SelectFolder(sal_Int32 nFolderPosition)
1403 : : {
1404 : 0 : pIconWin->SelectFolder(nFolderPosition);
1405 : 0 : }
1406 : :
1407 : : struct SvtTmplDlg_Impl
1408 : : {
1409 : : SvtTemplateWindow* pWin;
1410 : : String aTitle;
1411 : : Timer aUpdateTimer;
1412 : : sal_Bool bSelectNoOpen;
1413 : :
1414 : : uno::Reference< util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
1415 : :
1416 : :
1417 [ # # ][ # # ]: 0 : SvtTmplDlg_Impl( Window* pParent ) : pWin( new SvtTemplateWindow( pParent ) ) ,bSelectNoOpen( sal_False ) {}
1418 : :
1419 [ # # ][ # # ]: 0 : ~SvtTmplDlg_Impl() { delete pWin; }
[ # # ]
1420 : : };
1421 : :
1422 : 0 : SvtDocumentTemplateDialog::SvtDocumentTemplateDialog( Window* pParent ) :
1423 : :
1424 : : ModalDialog( pParent, SvtResId( DLG_DOCTEMPLATE ) ),
1425 : :
1426 : : aMoreTemplatesLink ( this, SvtResId( FT_DOCTEMPLATE_LINK ) ),
1427 : : aLine ( this, SvtResId( FL_DOCTEMPLATE ) ),
1428 : : aManageBtn ( this, SvtResId( BTN_DOCTEMPLATE_MANAGE ) ),
1429 : : aEditBtn ( this, SvtResId( BTN_DOCTEMPLATE_EDIT ) ),
1430 : : aOKBtn ( this, SvtResId( BTN_DOCTEMPLATE_OPEN ) ),
1431 : : aCancelBtn ( this, SvtResId( BTN_DOCTEMPLATE_CANCEL ) ),
1432 : : aHelpBtn ( this, SvtResId( BTN_DOCTEMPLATE_HELP ) ),
1433 [ # # ][ # # ]: 0 : pImpl ( NULL )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1434 : : {
1435 [ # # ]: 0 : FreeResource();
1436 [ # # ]: 0 : InitImpl( );
1437 : 0 : }
1438 : :
1439 : : // ------------------------------------------------------------------------
1440 : :
1441 : 0 : void SvtDocumentTemplateDialog::InitImpl( )
1442 : : {
1443 [ # # ][ # # ]: 0 : pImpl = new SvtTmplDlg_Impl( this );
1444 [ # # ][ # # ]: 0 : pImpl->aTitle = GetText();
[ # # ]
1445 : :
1446 [ # # ][ # # ]: 0 : bool bHideLink = ( SvtExtendedSecurityOptions().GetOpenHyperlinkMode()
[ # # ]
1447 : 0 : == SvtExtendedSecurityOptions::OPEN_NEVER );
1448 [ # # ]: 0 : if ( !bHideLink )
1449 : : {
1450 : : aMoreTemplatesLink.SetURL( String(
1451 [ # # ][ # # ]: 0 : RTL_CONSTASCII_USTRINGPARAM( "http://templates.libreoffice.org/" ) ) );
[ # # ]
1452 [ # # ]: 0 : aMoreTemplatesLink.SetClickHdl( LINK( this, SvtDocumentTemplateDialog, OpenLinkHdl_Impl ) );
1453 : : }
1454 : : else
1455 [ # # ]: 0 : aMoreTemplatesLink.Hide();
1456 : :
1457 [ # # ]: 0 : aManageBtn.SetClickHdl( LINK( this, SvtDocumentTemplateDialog, OrganizerHdl_Impl ) );
1458 [ # # ]: 0 : Link aLink = LINK( this, SvtDocumentTemplateDialog, OKHdl_Impl );
1459 : 0 : aEditBtn.SetClickHdl( aLink );
1460 : 0 : aOKBtn.SetClickHdl( aLink );
1461 : :
1462 [ # # ]: 0 : pImpl->pWin->SetSelectHdl( LINK( this, SvtDocumentTemplateDialog, SelectHdl_Impl ) );
1463 [ # # ]: 0 : pImpl->pWin->SetDoubleClickHdl( LINK( this, SvtDocumentTemplateDialog, DoubleClickHdl_Impl ) );
1464 [ # # ]: 0 : pImpl->pWin->SetNewFolderHdl( LINK( this, SvtDocumentTemplateDialog, NewFolderHdl_Impl ) );
1465 [ # # ]: 0 : pImpl->pWin->SetSendFocusHdl( LINK( this, SvtDocumentTemplateDialog, SendFocusHdl_Impl ) );
1466 : :
1467 : : // dynamic height adjustment
1468 [ # # ]: 0 : long nHeight = pImpl->pWin->CalcHeight();
1469 : :
1470 : 0 : Size aSize = GetOutputSizePixel();
1471 [ # # ]: 0 : Point aPos = aMoreTemplatesLink.GetPosPixel();
1472 [ # # ][ # # ]: 0 : Size a6Size = LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
[ # # ]
1473 [ # # ]: 0 : if ( bHideLink )
1474 [ # # ]: 0 : aPos.Y() += aMoreTemplatesLink.GetSizePixel().Height();
1475 : : else
1476 : 0 : aPos.Y() -= a6Size.Height();
1477 : 0 : long nDelta = aPos.Y() - nHeight;
1478 : 0 : aSize.Height() -= nDelta;
1479 [ # # ]: 0 : SetOutputSizePixel( aSize );
1480 : :
1481 : 0 : aSize.Height() = nHeight;
1482 : 0 : aSize.Width() -= ( a6Size.Width() * 2 );
1483 [ # # ]: 0 : pImpl->pWin->SetPosSizePixel( Point( a6Size.Width(), 0 ), aSize );
1484 : :
1485 [ # # ]: 0 : aPos = aMoreTemplatesLink.GetPosPixel();
1486 : 0 : aPos.Y() -= nDelta;
1487 [ # # ]: 0 : aMoreTemplatesLink.SetPosPixel( aPos );
1488 [ # # ]: 0 : aPos = aLine.GetPosPixel();
1489 : 0 : aPos.Y() -= nDelta;
1490 [ # # ]: 0 : aLine.SetPosPixel( aPos );
1491 [ # # ]: 0 : aPos = aManageBtn.GetPosPixel();
1492 : 0 : aPos.Y() -= nDelta;
1493 [ # # ]: 0 : aManageBtn.SetPosPixel( aPos );
1494 [ # # ]: 0 : aPos = aEditBtn.GetPosPixel();
1495 : 0 : aPos.Y() -= nDelta;
1496 [ # # ]: 0 : aEditBtn.SetPosPixel( aPos );
1497 [ # # ]: 0 : aPos = aOKBtn.GetPosPixel();
1498 : 0 : aPos.Y() -= nDelta;
1499 [ # # ]: 0 : aOKBtn.SetPosPixel( aPos );
1500 [ # # ]: 0 : aPos = aCancelBtn.GetPosPixel();
1501 : 0 : aPos.Y() -= nDelta;
1502 [ # # ]: 0 : aCancelBtn.SetPosPixel( aPos );
1503 [ # # ]: 0 : aPos = aHelpBtn.GetPosPixel();
1504 : 0 : aPos.Y() -= nDelta;
1505 [ # # ]: 0 : aHelpBtn.SetPosPixel( aPos );
1506 : :
1507 [ # # ]: 0 : pImpl->pWin->Show();
1508 : :
1509 [ # # ]: 0 : SelectHdl_Impl( NULL );
1510 [ # # ]: 0 : NewFolderHdl_Impl( NULL );
1511 : :
1512 [ # # ]: 0 : UpdateHdl_Impl( NULL );
1513 : 0 : }
1514 : :
1515 : : // ------------------------------------------------------------------------
1516 : :
1517 [ # # ][ # # ]: 0 : SvtDocumentTemplateDialog::~SvtDocumentTemplateDialog()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1518 : : {
1519 [ # # ][ # # ]: 0 : delete pImpl;
1520 [ # # ]: 0 : }
1521 : :
1522 : : // ------------------------------------------------------------------------
1523 : :
1524 : 0 : sal_Bool SvtDocumentTemplateDialog::CanEnableEditBtn() const
1525 : : {
1526 : 0 : sal_Bool bEnable = sal_False;
1527 : :
1528 [ # # ][ # # ]: 0 : ::rtl::OUString aFolderURL = pImpl->pWin->GetFolderURL();
[ # # ]
1529 [ # # ][ # # ]: 0 : if ( pImpl->pWin->IsFileSelected() && !aFolderURL.isEmpty() )
[ # # ][ # # ]
1530 : : {
1531 [ # # ][ # # ]: 0 : ::rtl::OUString aFileTargetURL = pImpl->pWin->GetSelectedFile();
[ # # ]
1532 : 0 : bEnable = !aFileTargetURL.isEmpty();
1533 : : }
1534 : :
1535 : 0 : return bEnable;
1536 : : }
1537 : :
1538 : : // ------------------------------------------------------------------------
1539 : :
1540 : 0 : IMPL_LINK_NOARG(SvtDocumentTemplateDialog , SelectHdl_Impl)
1541 : : {
1542 [ # # ][ # # ]: 0 : aEditBtn.Enable( pImpl->pWin->IsTemplateFolderOpen() && CanEnableEditBtn() );
1543 : 0 : aOKBtn.Enable( pImpl->pWin->IsFileSelected() );
1544 : 0 : return 0;
1545 : : }
1546 : :
1547 : : // ------------------------------------------------------------------------
1548 : :
1549 : 0 : IMPL_LINK_NOARG(SvtDocumentTemplateDialog , DoubleClickHdl_Impl)
1550 : : {
1551 : 0 : EndDialog( RET_OK );
1552 : :
1553 [ # # ]: 0 : if ( !pImpl->bSelectNoOpen )
1554 : 0 : pImpl->pWin->OpenFile( !pImpl->pWin->IsTemplateFolderOpen() );
1555 : 0 : return 0;
1556 : : }
1557 : :
1558 : : // ------------------------------------------------------------------------
1559 : :
1560 : 0 : IMPL_LINK_NOARG(SvtDocumentTemplateDialog , NewFolderHdl_Impl)
1561 : : {
1562 [ # # ]: 0 : String aNewTitle( pImpl->aTitle );
1563 [ # # ][ # # ]: 0 : aNewTitle += String( ASCII_STR(" - ") );
[ # # ][ # # ]
1564 [ # # ][ # # ]: 0 : aNewTitle += pImpl->pWin->GetFolderTitle();
[ # # ]
1565 [ # # ]: 0 : SetText( aNewTitle );
1566 : :
1567 [ # # ]: 0 : SelectHdl_Impl( NULL );
1568 [ # # ]: 0 : return 0;
1569 : : }
1570 : :
1571 : : // ------------------------------------------------------------------------
1572 : :
1573 : 0 : IMPL_LINK_NOARG(SvtDocumentTemplateDialog , SendFocusHdl_Impl)
1574 : : {
1575 [ # # ]: 0 : if ( pImpl->pWin->HasIconWinFocus() )
1576 : 0 : aHelpBtn.GrabFocus();
1577 : : else
1578 : : {
1579 [ # # ]: 0 : if ( aEditBtn.IsEnabled() )
1580 : 0 : aEditBtn.GrabFocus();
1581 [ # # ]: 0 : else if ( aOKBtn.IsEnabled() )
1582 : 0 : aOKBtn.GrabFocus();
1583 : : else
1584 : 0 : aCancelBtn.GrabFocus();
1585 : : }
1586 : :
1587 : 0 : return 0;
1588 : : }
1589 : :
1590 : : // ------------------------------------------------------------------------
1591 : :
1592 : 0 : IMPL_LINK ( SvtDocumentTemplateDialog , OKHdl_Impl, PushButton *, pBtn )
1593 : : {
1594 [ # # ]: 0 : if ( pImpl->pWin->IsFileSelected() )
1595 : : {
1596 : 0 : EndDialog( RET_OK );
1597 : :
1598 [ # # ]: 0 : if ( !pImpl->bSelectNoOpen )
1599 : 0 : pImpl->pWin->OpenFile( &aEditBtn == pBtn );
1600 : : }
1601 : 0 : return 0;
1602 : : }
1603 : :
1604 : : // ------------------------------------------------------------------------
1605 : :
1606 : 0 : IMPL_LINK_NOARG(SvtDocumentTemplateDialog , OrganizerHdl_Impl)
1607 : : {
1608 [ # # ]: 0 : Window* pOldDefWin = Application::GetDefDialogParent();
1609 [ # # ]: 0 : Application::SetDefDialogParent( this );
1610 : : Reference < XFramesSupplier > xDesktop = Reference < XFramesSupplier >(
1611 [ # # ][ # # ]: 0 : ::comphelper::getProcessServiceFactory()->
1612 [ # # ][ # # ]: 0 : createInstance( ASCII_STR("com.sun.star.frame.Desktop") ), UNO_QUERY );
[ # # ]
1613 [ # # ][ # # ]: 0 : Reference < XFrame > xFrame( xDesktop->getActiveFrame() );
1614 [ # # ]: 0 : if ( !xFrame.is() )
1615 [ # # ][ # # ]: 0 : xFrame = Reference < XFrame >( xDesktop, UNO_QUERY );
1616 : :
1617 : 0 : com::sun::star::util::URL aTargetURL;
1618 [ # # ]: 0 : aTargetURL.Complete = ASCII_STR("slot:5540");
1619 : : Reference< com::sun::star::util::XURLTransformer > xTrans(
1620 [ # # ][ # # ]: 0 : com::sun::star::util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
1621 [ # # ][ # # ]: 0 : xTrans->parseStrict( aTargetURL );
1622 : :
1623 [ # # ]: 0 : Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY );
1624 : 0 : Reference < XDispatch > xDisp;
1625 [ # # ][ # # ]: 0 : xDisp = xProv->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
[ # # ]
1626 : :
1627 [ # # ]: 0 : if ( xDisp.is() )
1628 : : {
1629 [ # # ]: 0 : Sequence<PropertyValue> aArgs(1);
1630 [ # # ]: 0 : PropertyValue* pArg = aArgs.getArray();
1631 [ # # ]: 0 : pArg[0].Name = ASCII_STR("Referer");
1632 [ # # ][ # # ]: 0 : pArg[0].Value <<= ASCII_STR("private:user");
1633 [ # # ][ # # ]: 0 : xDisp->dispatch( aTargetURL, aArgs );
[ # # ]
1634 : : }
1635 : :
1636 [ # # ]: 0 : Application::SetDefDialogParent( pOldDefWin );
1637 : 0 : return 0;
1638 : : }
1639 : :
1640 : : // ------------------------------------------------------------------------
1641 : :
1642 : 0 : IMPL_LINK ( SvtDocumentTemplateDialog, UpdateHdl_Impl, Timer*, _pEventSource )
1643 : : {
1644 [ # # ]: 0 : pImpl->pWin->SetFocus( sal_False );
1645 [ # # ][ # # ]: 0 : Reference< XDocumentTemplates > xTemplates( frame::DocumentTemplates::create(::comphelper::getProcessComponentContext()) );
1646 [ # # ]: 0 : if ( _pEventSource )
1647 : : { // it was no direct call, which means it was triggered by the timer, which means we alread checked the necessity
1648 [ # # ]: 0 : WaitObject aWaitCursor( this );
1649 [ # # ][ # # ]: 0 : xTemplates->update();
1650 [ # # ]: 0 : if ( pImpl->pWin->IsTemplateFolderOpen() )
1651 : : {
1652 [ # # ]: 0 : pImpl->pWin->ClearHistory();
1653 [ # # ]: 0 : pImpl->pWin->OpenTemplateRoot();
1654 [ # # ]: 0 : }
1655 : : }
1656 : : else
1657 : : {
1658 : : // check if we really need to do the update
1659 [ # # ]: 0 : ::svt::TemplateFolderCache aCache;
1660 [ # # ][ # # ]: 0 : if ( aCache.needsUpdate() )
1661 : : { // yes -> do it asynchronous (it will take a noticeable time)
1662 : :
1663 : : // (but first store the current state)
1664 [ # # ]: 0 : aCache.storeState();
1665 : :
1666 : : // start the timer for the async update
1667 [ # # ]: 0 : pImpl->aUpdateTimer.SetTimeout( 300 );
1668 [ # # ]: 0 : pImpl->aUpdateTimer.SetTimeoutHdl( LINK( this, SvtDocumentTemplateDialog, UpdateHdl_Impl ) );
1669 [ # # ]: 0 : pImpl->aUpdateTimer.Start();
1670 [ # # ]: 0 : }
1671 : : }
1672 : 0 : return 0;
1673 : : }
1674 : :
1675 : : // ------------------------------------------------------------------------
1676 : :
1677 : 0 : IMPL_LINK_NOARG(SvtDocumentTemplateDialog, OpenLinkHdl_Impl)
1678 : : {
1679 [ # # ][ # # ]: 0 : ::rtl::OUString sURL( aMoreTemplatesLink.GetURL() );
[ # # ]
1680 [ # # ]: 0 : if ( !sURL.isEmpty() )
1681 : : {
1682 [ # # ]: 0 : localizeWebserviceURI(sURL);
1683 : : try
1684 : : {
1685 : : uno::Reference< lang::XMultiServiceFactory > xSMGR =
1686 [ # # ]: 0 : ::comphelper::getProcessServiceFactory();
1687 : : uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShell(
1688 [ # # ]: 0 : xSMGR->createInstance( ::rtl::OUString(
1689 : 0 : RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.system.SystemShellExecute" ) ) ),
1690 [ # # ][ # # ]: 0 : uno::UNO_QUERY_THROW );
[ # # ]
1691 [ # # ]: 0 : if ( xSystemShell.is() )
1692 [ # # ][ # # ]: 0 : xSystemShell->execute( sURL, ::rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY );
1693 [ # # ][ # # ]: 0 : EndDialog( RET_CANCEL );
1694 : : }
1695 [ # # ]: 0 : catch( const uno::Exception& e )
1696 : : {
1697 : : OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
1698 : : rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
1699 : : }
1700 : : }
1701 : 0 : return 0;
1702 : : }
1703 : :
1704 : 0 : void SvtDocumentTemplateDialog::SelectTemplateFolder()
1705 : : {
1706 : 0 : pImpl->pWin->SelectFolder(ICON_POS_TEMPLATES);
1707 : 0 : }
1708 : :
1709 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|