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