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