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