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