2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: hldocntp.cxx,v $
|
|
|
|
*
|
2001-05-29 13:56:53 +00:00
|
|
|
* $Revision: 1.10 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2001-05-29 13:56:53 +00:00
|
|
|
* last change: $Author: sj $ $Date: 2001-05-29 14:56:53 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2000-09-26 08:29:01 +00:00
|
|
|
#include "hldocntp.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#ifndef _SFXVIEWFRM_HXX
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFX_OBJFAC_HXX
|
|
|
|
#include <sfx2/docfac.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
|
|
|
|
#include <com/sun/star/uno/Reference.h>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
|
|
|
|
#include <com/sun/star/uno/Sequence.h>
|
|
|
|
#endif
|
2001-05-29 13:56:53 +00:00
|
|
|
#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/uno/Exception.hpp>
|
|
|
|
#endif
|
2001-02-12 14:12:27 +00:00
|
|
|
#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
|
|
|
|
#include <unotools/localfilehelper.hxx>
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifndef _SV_CONFIG_HXX
|
|
|
|
#include <vcl/config.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_SYSTEM_HXX
|
|
|
|
#include <vcl/system.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_IMAGE_HXX
|
|
|
|
#include <vcl/image.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _URLOBJ_HXX
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#endif
|
2000-09-26 08:29:01 +00:00
|
|
|
#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
|
|
|
|
#include <svtools/pathoptions.hxx>
|
|
|
|
#endif
|
2001-05-29 13:56:53 +00:00
|
|
|
#ifndef INCLUDED_SVTOOLS_DYNAMICMENUOPTIONS_HXX
|
|
|
|
#include <svtools/dynamicmenuoptions.hxx>
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include "hyperdlg.hrc"
|
|
|
|
|
|
|
|
using namespace ::rtl;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Data-struct for documenttypes in listbox
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
struct DocumentTypeData
|
|
|
|
{
|
|
|
|
String aStrURL;
|
|
|
|
String aStrExt;
|
|
|
|
DocumentTypeData (String aURL, String aExt) : aStrURL(aURL), aStrExt(aExt)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Contructor / Destructor
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
SvxHyperlinkNewDocTp::SvxHyperlinkNewDocTp ( Window *pParent, const SfxItemSet& rItemSet)
|
|
|
|
: maGrpNewDoc ( this, ResId (GRP_NEWDOCUMENT) ),
|
|
|
|
maRbtEditNow ( this, ResId (RB_EDITNOW) ),
|
|
|
|
maRbtEditLater ( this, ResId (RB_EDITLATER) ),
|
|
|
|
maFtPath ( this, ResId (FT_PATH_NEWDOC) ),
|
2001-02-12 14:12:27 +00:00
|
|
|
maCbbPath ( this, INET_PROT_FILE ),
|
2000-09-18 16:07:07 +00:00
|
|
|
maFtDocTypes ( this, ResId (FT_DOCUMENT_TYPES) ),
|
|
|
|
maLbDocTypes ( this, ResId (LB_DOCUMENT_TYPES) ),
|
|
|
|
maBtCreate ( this, ResId (BTN_CREATE) ),
|
|
|
|
SvxHyperlinkTabPageBase ( pParent, SVX_RES( RID_SVXPAGE_HYPERLINK_NEWDOCUMENT ),
|
|
|
|
rItemSet )
|
|
|
|
{
|
|
|
|
InitStdControls();
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
SetExchangeSupport ();
|
|
|
|
|
2001-02-12 14:12:27 +00:00
|
|
|
maCbbPath.SetPosSizePixel ( LogicToPixel( Point( 54 , 25 ), MAP_APPFONT ),
|
|
|
|
LogicToPixel( Size ( 176, 60), MAP_APPFONT ) );
|
|
|
|
maCbbPath.Show();
|
|
|
|
maCbbPath.SetBaseURL(SvtPathOptions().GetWorkPath());
|
|
|
|
// maCbbPath.SetHelpId( HID_HYPERDLG_DOC_PATH );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// set defaults
|
|
|
|
maRbtEditNow.Check();
|
|
|
|
|
|
|
|
maBtCreate.SetClickHdl ( LINK ( this, SvxHyperlinkNewDocTp, ClickNewHdl_Impl ) );
|
2001-02-12 14:12:27 +00:00
|
|
|
maCbbPath.SetLoseFocusHdl ( LINK ( this, SvxHyperlinkNewDocTp, LostFocusTargetHdl_Impl ) );
|
|
|
|
maCbbPath.SetModifyHdl ( LINK ( this, SvxHyperlinkNewDocTp, ModifiedPathHdl_Impl ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
maLbDocTypes.SetDoubleClickHdl( LINK ( this, SvxHyperlinkNewDocTp, DClickDocTypeHdl_Impl ) );
|
2001-02-12 14:12:27 +00:00
|
|
|
maLbDocTypes.SetSelectHdl( LINK ( this, SvxHyperlinkNewDocTp, SelectDocTypeHdl_Impl ) );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
FillDocumentList ();
|
|
|
|
}
|
|
|
|
|
|
|
|
SvxHyperlinkNewDocTp::~SvxHyperlinkNewDocTp ()
|
|
|
|
{
|
|
|
|
for ( int n=0; n<maLbDocTypes.GetEntryCount(); n++ )
|
|
|
|
{
|
|
|
|
DocumentTypeData* pTypeData = (DocumentTypeData*)
|
|
|
|
maLbDocTypes.GetEntryData ( n );
|
|
|
|
delete pTypeData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Fill the all dialog-controls except controls in groupbox "more..."
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
void SvxHyperlinkNewDocTp::FillDlgFields ( String& aStrURL )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#define INTERNETSHORTCUT_ID_TAG "InternetShortcut"
|
|
|
|
#define INTERNETSHORTCUT_TITLE_TAG "Title"
|
|
|
|
#define INTERNETSHORTCUT_TARGET_TAG "Target"
|
|
|
|
#define INTERNETSHORTCUT_FOLDER_TAG "Folder"
|
|
|
|
#define INTERNETSHORTCUT_URL_TAG "URL"
|
|
|
|
#define INTERNETSHORTCUT_ICONID_TAG "IconIndex"
|
|
|
|
|
|
|
|
void SvxHyperlinkNewDocTp::ReadURLFile( const String& rFile, String& rTitle, String& rURL, sal_Int32& rIconId, BOOL* pShowAsFolder )
|
|
|
|
{
|
|
|
|
// Open file
|
|
|
|
Config aCfg( rFile );
|
|
|
|
aCfg.SetGroup( INTERNETSHORTCUT_ID_TAG );
|
|
|
|
|
|
|
|
// read URL
|
|
|
|
rURL = aCfg.ReadKey( ByteString( RTL_CONSTASCII_STRINGPARAM( INTERNETSHORTCUT_URL_TAG) ), RTL_TEXTENCODING_ASCII_US );
|
2000-09-26 08:29:01 +00:00
|
|
|
SvtPathOptions aPathOpt;
|
|
|
|
rURL = aPathOpt.SubstituteVariable( rURL );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// read target
|
|
|
|
if ( pShowAsFolder )
|
|
|
|
{
|
|
|
|
String aTemp( aCfg.ReadKey( ByteString( RTL_CONSTASCII_STRINGPARAM( INTERNETSHORTCUT_TARGET_TAG ) ), RTL_TEXTENCODING_ASCII_US ) );
|
|
|
|
*pShowAsFolder = aTemp == String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( INTERNETSHORTCUT_FOLDER_TAG ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// read image-ID
|
|
|
|
String aStrIconId( aCfg.ReadKey( ByteString( RTL_CONSTASCII_STRINGPARAM( INTERNETSHORTCUT_ICONID_TAG ) ), RTL_TEXTENCODING_ASCII_US ) );
|
|
|
|
rIconId = aStrIconId.ToInt32();
|
|
|
|
|
|
|
|
// read title
|
2000-09-26 08:29:01 +00:00
|
|
|
String aLangStr = aPathOpt.SubstituteVariable( DEFINE_CONST_UNICODE("$(vlang)") );
|
2000-09-18 16:07:07 +00:00
|
|
|
ByteString aLang( aLangStr, RTL_TEXTENCODING_UTF8 );
|
|
|
|
ByteString aGroup = INTERNETSHORTCUT_ID_TAG;
|
|
|
|
( ( aGroup += '-' ) += aLang ) += ".W";
|
|
|
|
aCfg.SetGroup( aGroup );
|
|
|
|
rTitle = String( aCfg.ReadKey( INTERNETSHORTCUT_TITLE_TAG ), RTL_TEXTENCODING_UTF7 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvxHyperlinkNewDocTp::FillDocumentList ()
|
|
|
|
{
|
|
|
|
EnterWait();
|
2001-05-29 13:56:53 +00:00
|
|
|
|
|
|
|
uno::Sequence< uno::Sequence< beans::PropertyValue > >
|
|
|
|
aDynamicMenuEntries( SvtDynamicMenuOptions().GetMenu( E_NEWMENU ) );
|
|
|
|
|
|
|
|
sal_uInt32 i, nCount = aDynamicMenuEntries.getLength();
|
|
|
|
for ( i = 0; i < nCount; i++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-05-29 13:56:53 +00:00
|
|
|
uno::Sequence< beans::PropertyValue >& rDynamicMenuEntry = aDynamicMenuEntries[ i ];
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-05-29 13:56:53 +00:00
|
|
|
rtl::OUString aDocumentUrl, aTitle, aImageId, aTargetName;
|
|
|
|
|
|
|
|
for ( int i = 0; i < rDynamicMenuEntry.getLength(); i++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-05-29 13:56:53 +00:00
|
|
|
if ( rDynamicMenuEntry[ i ].Name == DYNAMICMENU_PROPERTYNAME_URL )
|
|
|
|
rDynamicMenuEntry[ i ].Value >>= aDocumentUrl;
|
|
|
|
else if ( rDynamicMenuEntry[i].Name == DYNAMICMENU_PROPERTYNAME_TITLE )
|
|
|
|
rDynamicMenuEntry[i].Value >>= aTitle;
|
|
|
|
else if ( rDynamicMenuEntry[i].Name == DYNAMICMENU_PROPERTYNAME_IMAGEIDENTIFIER )
|
|
|
|
rDynamicMenuEntry[i].Value >>= aImageId;
|
|
|
|
else if ( rDynamicMenuEntry[i].Name == DYNAMICMENU_PROPERTYNAME_TARGETNAME )
|
|
|
|
rDynamicMenuEntry[i].Value >>= aTargetName;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-05-29 13:56:53 +00:00
|
|
|
// Insert into listbox
|
|
|
|
if ( aDocumentUrl.getLength() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-05-29 13:56:53 +00:00
|
|
|
const SfxObjectFactory* pFactory = SfxObjectFactory::GetFactory ( aDocumentUrl );
|
|
|
|
if ( pFactory )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-05-29 13:56:53 +00:00
|
|
|
// insert doc-name and image
|
|
|
|
|
|
|
|
String aTitleName( aTitle );
|
|
|
|
aTitleName.Erase( aTitleName.Search( (sal_Unicode)'~' ), 1 );
|
|
|
|
|
|
|
|
sal_Int16 nPos = maLbDocTypes.InsertEntry ( aTitleName );
|
|
|
|
|
|
|
|
// insert private-url and default-extension as user-data
|
|
|
|
String aStrDefExt( pFactory->GetFilter ( 0 )->GetDefaultExtension () );
|
|
|
|
DocumentTypeData *pTypeData = new DocumentTypeData ( aDocumentUrl,
|
|
|
|
aStrDefExt.Copy( 2, aStrDefExt.Len() ) );
|
|
|
|
maLbDocTypes.SetEntryData ( nPos, pTypeData );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
maLbDocTypes.SelectEntryPos ( 0 );
|
|
|
|
|
|
|
|
LeaveWait();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* retrieve and prepare data from dialog-fields
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
void SvxHyperlinkNewDocTp::GetCurentItemData ( String& aStrURL, String& aStrName,
|
|
|
|
String& aStrIntName, String& aStrFrame,
|
|
|
|
SvxLinkInsertMode& eMode )
|
|
|
|
{
|
|
|
|
// get data from dialog-controls
|
2001-02-12 14:12:27 +00:00
|
|
|
aStrURL = maCbbPath.GetText();
|
|
|
|
if( aStrURL.Len() )
|
|
|
|
{
|
|
|
|
utl::LocalFileHelper::ConvertSystemPathToURL( aStrURL, maCbbPath.GetBaseURL(), aStrURL );
|
|
|
|
if( aStrURL.Len() == 0 )
|
|
|
|
{
|
|
|
|
INetURLObject aTmpURL( SvtPathOptions().GetWorkPath(), INET_PROT_FILE );
|
|
|
|
if( !aTmpURL.hasFinalSlash() )
|
|
|
|
aTmpURL.setFinalSlash();
|
|
|
|
aTmpURL.Append( maCbbPath.GetText() );
|
|
|
|
aStrURL = aTmpURL.GetMainURL();
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// does the filename have got a valid extension ?
|
2001-02-12 14:12:27 +00:00
|
|
|
INetURLObject aURL( aStrURL );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-02-12 14:12:27 +00:00
|
|
|
if ( GetName( aStrURL ) != aEmptyStr &&
|
2000-09-18 16:07:07 +00:00
|
|
|
maLbDocTypes.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
{
|
|
|
|
// get private-url
|
|
|
|
int nPos = maLbDocTypes.GetSelectEntryPos();
|
|
|
|
aURL.setExtension ( ( ( DocumentTypeData* )
|
|
|
|
maLbDocTypes.GetEntryData( nPos ) )->aStrExt );
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Char const sSep[] = ".";
|
|
|
|
|
|
|
|
if( aURL.getFSysPath( INetURLObject::FSYS_DETECT ).Len() - aURL.getName().Len() <= 1 ||
|
|
|
|
aURL.getFSysPath( INetURLObject::FSYS_DETECT ).Search( '.' ) == 0 )
|
|
|
|
{
|
2000-09-26 08:29:01 +00:00
|
|
|
INetURLObject aTmpURL( SvtPathOptions().GetWorkPath(), INET_PROT_FILE );
|
2000-09-18 16:07:07 +00:00
|
|
|
if( !aTmpURL.hasFinalSlash() )
|
|
|
|
aTmpURL.setFinalSlash();
|
|
|
|
aTmpURL.Append( aURL.getName() );
|
|
|
|
aURL = aTmpURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get data from standard-fields
|
|
|
|
aStrIntName = mpEdText->GetText();
|
|
|
|
aStrName = mpEdIndication->GetText();
|
|
|
|
aStrFrame = mpCbbFrame->GetText();
|
|
|
|
eMode = (SvxLinkInsertMode) (mpLbForm->GetSelectEntryPos()+1);
|
|
|
|
if( IsHTMLDoc() )
|
|
|
|
eMode = (SvxLinkInsertMode) ( UINT16(eMode) | HLINK_HTMLMODE );
|
|
|
|
|
|
|
|
if ( aStrURL != aEmptyStr )
|
|
|
|
aStrURL = aURL.GetMainURL( INetURLObject::DECODE_WITH_CHARSET );
|
|
|
|
|
|
|
|
if ( aStrName == aEmptyStr )
|
|
|
|
aStrName = aStrURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* static method to create Tabpage
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
IconChoicePage* SvxHyperlinkNewDocTp::Create( Window* pWindow, const SfxItemSet& rItemSet )
|
|
|
|
{
|
|
|
|
return( new SvxHyperlinkNewDocTp( pWindow, rItemSet ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Activate / Deactivate Tabpage
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
void SvxHyperlinkNewDocTp::ActivatePage( const SfxItemSet& rItemSet )
|
|
|
|
{
|
|
|
|
///////////////////////////////////////
|
|
|
|
// Set dialog-fields from input-itemset
|
|
|
|
SvxHyperlinkItem *pHyperlinkItem = (SvxHyperlinkItem *)
|
|
|
|
rItemSet.GetItem (SID_HYPERLINK_GETLINK);
|
|
|
|
|
|
|
|
if ( pHyperlinkItem )
|
|
|
|
{
|
|
|
|
// standard-fields
|
|
|
|
FillStandardDlgFields (pHyperlinkItem);
|
|
|
|
|
|
|
|
mbNewName = ( pHyperlinkItem->GetName() == aEmptyStr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int SvxHyperlinkNewDocTp::DeactivatePage( SfxItemSet* pSet )
|
|
|
|
{
|
|
|
|
String aStrURL, aStrName, aStrIntName, aStrFrame;
|
|
|
|
SvxLinkInsertMode eMode;
|
|
|
|
|
|
|
|
GetCurentItemData ( aStrURL, aStrName, aStrIntName, aStrFrame, eMode);
|
|
|
|
|
|
|
|
USHORT nEvents = GetMacroEvents();
|
|
|
|
SvxMacroTableDtor* pTable = GetMacroTable();
|
|
|
|
|
|
|
|
SvxHyperlinkItem aItem( SID_HYPERLINK_GETLINK, aStrName, aStrURL, aStrFrame,
|
|
|
|
aStrIntName, eMode, nEvents, pTable );
|
|
|
|
pSet->Put (aItem);
|
|
|
|
|
|
|
|
return( LEAVE_PAGE );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Fill output-ItemSet
|
|
|
|
|*
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
BOOL SvxHyperlinkNewDocTp::FillItemSet( SfxItemSet& rOut)
|
|
|
|
{
|
|
|
|
String aStrURL, aStrName, aStrIntName, aStrFrame;
|
|
|
|
SvxLinkInsertMode eMode;
|
|
|
|
|
|
|
|
GetCurentItemData ( aStrURL, aStrName, aStrIntName, aStrFrame, eMode);
|
|
|
|
|
|
|
|
// put data into itemset
|
|
|
|
USHORT nEvents = GetMacroEvents();
|
|
|
|
SvxMacroTableDtor* pTable = GetMacroTable();
|
|
|
|
|
|
|
|
SvxHyperlinkItem aItem( SID_HYPERLINK_SETLINK, aStrName, aStrURL, aStrFrame,
|
|
|
|
aStrIntName, eMode, nEvents, pTable );
|
|
|
|
rOut.Put (aItem);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Set initial focus
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
void SvxHyperlinkNewDocTp::SetInitFocus()
|
|
|
|
{
|
2001-02-12 14:12:27 +00:00
|
|
|
maCbbPath.GrabFocus();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Ask page whether an insert is possible
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
BOOL SvxHyperlinkNewDocTp::AskApply ()
|
|
|
|
{
|
2001-02-12 14:12:27 +00:00
|
|
|
if( GetName( maCbbPath.GetText() ) != aEmptyStr )
|
2000-09-18 16:07:07 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
WarningBox aWarning( this, WB_OK, SVX_RESSTR(RID_SVXSTR_HYPDLG_NOVALIDFILENAME) );
|
|
|
|
aWarning.Execute();
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Any action to do after apply-button is pressed
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
void SvxHyperlinkNewDocTp::DoApply ()
|
|
|
|
{
|
|
|
|
EnterWait();
|
|
|
|
|
|
|
|
// get data from dialog-controls
|
2001-02-12 14:12:27 +00:00
|
|
|
String aStrNewName = maCbbPath.GetText();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( aStrNewName == aEmptyStr )
|
|
|
|
aStrNewName = maStrInitURL;
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////
|
|
|
|
// create a real URL-String
|
2001-02-12 14:12:27 +00:00
|
|
|
|
|
|
|
if( aStrNewName.Len() )
|
|
|
|
{
|
|
|
|
String aTempName;
|
|
|
|
utl::LocalFileHelper::ConvertSystemPathToURL( aStrNewName, maBaseURL, aTempName );
|
|
|
|
if( aTempName.Len() == 0 )
|
|
|
|
{
|
|
|
|
INetURLObject aTmpURL( SvtPathOptions().GetWorkPath() );
|
|
|
|
if( !aTmpURL.hasFinalSlash() )
|
|
|
|
aTmpURL.setFinalSlash();
|
|
|
|
aTmpURL.Append( aStrNewName );
|
|
|
|
aTempName = aTmpURL.GetMainURL();
|
|
|
|
}
|
|
|
|
|
|
|
|
aStrNewName = aTempName;
|
|
|
|
}
|
|
|
|
|
|
|
|
INetURLObject aURL( aStrNewName );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
int nPos = maLbDocTypes.GetSelectEntryPos();
|
|
|
|
if( nPos == LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
nPos=0;
|
|
|
|
aURL.setExtension ( ( ( DocumentTypeData* )
|
|
|
|
maLbDocTypes.GetEntryData( nPos ) )->aStrExt );
|
|
|
|
|
|
|
|
if( aURL.getFSysPath( INetURLObject::FSYS_DETECT ).Len() - aURL.getName().Len() <= 1 ||
|
|
|
|
aURL.getFSysPath( INetURLObject::FSYS_DETECT ).Search( '.' ) == 0 )
|
|
|
|
{
|
2001-02-12 14:12:27 +00:00
|
|
|
INetURLObject aTmpURL( SvtPathOptions().GetWorkPath() );
|
2000-09-18 16:07:07 +00:00
|
|
|
if( !aTmpURL.hasFinalSlash() )
|
|
|
|
aTmpURL.setFinalSlash();
|
|
|
|
aTmpURL.Append( aURL.getName() );
|
|
|
|
aURL = aTmpURL;
|
|
|
|
}
|
|
|
|
///////////////////////////////////////////////////////
|
|
|
|
// create Document
|
|
|
|
aStrNewName = aURL.GetURLPath( INetURLObject::DECODE_WITH_CHARSET );//INetURLObject::FSYS_DETECT );
|
|
|
|
sal_Char const sSlash[] = "/";
|
|
|
|
if( aStrNewName.SearchAscii( sSlash ) == 0 )
|
|
|
|
aStrNewName.Erase( 0, 1 );
|
|
|
|
|
2001-02-12 14:12:27 +00:00
|
|
|
SfxViewFrame *pViewFrame = NULL;
|
|
|
|
try
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-02-12 14:12:27 +00:00
|
|
|
// current document
|
|
|
|
SfxViewFrame* pCurrentDocFrame = SFX_APP()->GetViewFrame();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-02-12 14:12:27 +00:00
|
|
|
if ( aStrNewName != aEmptyStr )
|
|
|
|
{
|
|
|
|
// get private-url
|
|
|
|
int nPos = maLbDocTypes.GetSelectEntryPos();
|
|
|
|
if( nPos == LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
nPos=0;
|
|
|
|
String aStrDocName ( ( ( DocumentTypeData* )
|
|
|
|
maLbDocTypes.GetEntryData( nPos ) )->aStrURL );
|
|
|
|
|
|
|
|
// create items
|
|
|
|
SfxStringItem aName( SID_FILE_NAME, aStrDocName );
|
|
|
|
SfxStringItem aReferer( SID_REFERER, UniString::CreateFromAscii(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM( "private:user" ) ) );
|
|
|
|
SfxStringItem aFrame( SID_TARGETNAME, UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "_blank" ) ) );
|
|
|
|
//SfxBoolItem aFrame( SID_OPEN_NEW_VIEW, TRUE );
|
|
|
|
|
|
|
|
String aStrFlags ( sal_Unicode('S') );
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( maRbtEditLater.IsChecked() )
|
|
|
|
{
|
2001-02-12 14:12:27 +00:00
|
|
|
aStrFlags += sal_Unicode('H');
|
|
|
|
}
|
|
|
|
SfxStringItem aFlags (SID_OPTIONS, aStrFlags);
|
|
|
|
|
|
|
|
// open url
|
|
|
|
const SfxPoolItem* pReturn = GetDispatcher()->Execute( SID_OPENDOC,
|
|
|
|
SFX_CALLMODE_SYNCHRON,
|
|
|
|
&aName, &aFlags,
|
|
|
|
&aFrame, &aReferer, 0L );
|
|
|
|
|
|
|
|
// save new doc
|
|
|
|
const SfxViewFrameItem *pItem = PTR_CAST( SfxViewFrameItem, pReturn );
|
|
|
|
pViewFrame = pItem->GetFrame();
|
|
|
|
if (pViewFrame)
|
|
|
|
{
|
|
|
|
//SfxViewFrame *pViewFrame = pFrame->GetCurrentViewFrame();
|
|
|
|
SfxStringItem aNewName( SID_FILE_NAME, aURL.GetMainURL() );
|
|
|
|
|
|
|
|
pViewFrame->GetDispatcher()->Execute( SID_SAVEASDOC,
|
|
|
|
SFX_CALLMODE_SYNCHRON,
|
|
|
|
&aNewName, 0L );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
2001-02-12 14:12:27 +00:00
|
|
|
|
|
|
|
if ( maRbtEditNow.IsChecked() )
|
|
|
|
{
|
|
|
|
pCurrentDocFrame->ToTop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception )
|
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-02-12 14:12:27 +00:00
|
|
|
if ( pViewFrame && maRbtEditLater.IsChecked() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-03-14 08:55:52 +00:00
|
|
|
SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
|
|
|
|
BOOL bResult = pObjShell->DoClose();
|
2001-03-20 08:42:34 +00:00
|
|
|
pObjShell->OwnerLock(FALSE);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LeaveWait();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* reset dialog-fields
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
void SvxHyperlinkNewDocTp::Reset( const SfxItemSet& rItemSet)
|
|
|
|
{
|
|
|
|
///////////////////////////////////////
|
|
|
|
// Set dialog-fields from create-itemset
|
|
|
|
maStrInitURL = aEmptyStr;
|
|
|
|
|
|
|
|
SvxHyperlinkItem *pHyperlinkItem = (SvxHyperlinkItem *)
|
|
|
|
rItemSet.GetItem (SID_HYPERLINK_GETLINK);
|
|
|
|
|
|
|
|
if ( pHyperlinkItem )
|
|
|
|
{
|
|
|
|
// set dialog-fields
|
|
|
|
FillStandardDlgFields (pHyperlinkItem);
|
|
|
|
|
|
|
|
// set all other fields
|
|
|
|
FillDlgFields ( (String&)pHyperlinkItem->GetURL() );
|
|
|
|
|
|
|
|
// Store initial URL
|
|
|
|
maStrInitURL = pHyperlinkItem->GetURL();
|
2001-02-12 14:12:27 +00:00
|
|
|
maBaseURL = pHyperlinkItem->GetURL();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
mbNewName = ( pHyperlinkItem->GetName() == aEmptyStr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Click on imagebutton : new
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
IMPL_LINK ( SvxHyperlinkNewDocTp, ClickNewHdl_Impl, void *, EMPTYARG )
|
|
|
|
{
|
|
|
|
SfxFileDialog aDlg( SFX_APP()->GetTopWindow(), WB_3DLOOK | WB_OPEN |
|
|
|
|
SFXWB_PATHDIALOG );
|
|
|
|
|
2001-02-12 14:12:27 +00:00
|
|
|
String aStrURL( maCbbPath.GetText() );
|
|
|
|
utl::LocalFileHelper::ConvertSystemPathToURL( aStrURL, maCbbPath.GetBaseURL(), aStrURL );
|
|
|
|
|
|
|
|
String aStrPath = GetPath ( aStrURL );
|
|
|
|
String aStrName = GetName ( aStrURL );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( aStrPath == aEmptyStr )
|
2000-09-26 08:29:01 +00:00
|
|
|
aStrPath = SvtPathOptions().GetWorkPath();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
aDlg.SetPath ( aStrPath );
|
|
|
|
|
|
|
|
if ( aDlg.Execute() == RET_OK )
|
|
|
|
{
|
2001-02-12 14:12:27 +00:00
|
|
|
sal_Char const sSlash[] = "/";
|
|
|
|
|
|
|
|
maCbbPath.SetBaseURL( aDlg.GetPath() );
|
2000-09-18 16:07:07 +00:00
|
|
|
String aStrTmp( aDlg.GetPath() );
|
2001-02-12 14:12:27 +00:00
|
|
|
|
|
|
|
if( aStrTmp.GetChar( aStrTmp.Len() - 1 ) != sSlash[0] )
|
|
|
|
aStrTmp.AppendAscii( sSlash );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
aStrTmp += aStrName;
|
2001-02-12 14:12:27 +00:00
|
|
|
INetURLObject aNewURL( aStrTmp );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( aStrName != aEmptyStr && aNewURL.getExtension() != aEmptyStr &&
|
|
|
|
maLbDocTypes.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
{
|
|
|
|
// get private-url
|
|
|
|
int nPos = maLbDocTypes.GetSelectEntryPos();
|
|
|
|
aNewURL.setExtension ( ( ( DocumentTypeData* )
|
|
|
|
maLbDocTypes.GetEntryData( nPos ) )->aStrExt );
|
|
|
|
}
|
|
|
|
|
|
|
|
aStrTmp = aNewURL.GetURLPath( INetURLObject::DECODE_WITH_CHARSET );
|
|
|
|
if( aStrTmp.SearchAscii( sSlash ) == 0 )
|
|
|
|
aStrTmp.Erase( 0, 1 );
|
|
|
|
|
2001-02-12 14:12:27 +00:00
|
|
|
maCbbPath.SetText ( aStrTmp );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return( 0L );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Contens of combobox "Path" modified
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
IMPL_LINK ( SvxHyperlinkNewDocTp, ModifiedPathHdl_Impl, void *, EMPTYARG )
|
|
|
|
{
|
|
|
|
if ( mbNewName )
|
2001-02-12 14:12:27 +00:00
|
|
|
mpEdIndication->SetText ( maCbbPath.GetText() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
return( 0L );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Combobox Target lost the focus
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
IMPL_LINK ( SvxHyperlinkNewDocTp, LostFocusTargetHdl_Impl, void *, EMPTYARG )
|
|
|
|
{
|
2001-02-12 14:12:27 +00:00
|
|
|
UpdateExtension();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
return (0L);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Double-Click in Listbox
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
IMPL_LINK ( SvxHyperlinkNewDocTp, DClickDocTypeHdl_Impl, void *, EMPTYARG )
|
|
|
|
{
|
2001-02-12 14:12:27 +00:00
|
|
|
if (maCbbPath.GetText().Len() )
|
2000-09-18 16:07:07 +00:00
|
|
|
LostFocusTargetHdl_Impl (NULL);
|
|
|
|
|
|
|
|
return (0L);
|
|
|
|
}
|
|
|
|
|
2001-02-12 14:12:27 +00:00
|
|
|
IMPL_LINK ( SvxHyperlinkNewDocTp, SelectDocTypeHdl_Impl, void *, EMPTYARG )
|
|
|
|
{
|
|
|
|
|
|
|
|
UpdateExtension();
|
|
|
|
|
|
|
|
return (0L);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Sets the extension according to the selected doc type
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
void SvxHyperlinkNewDocTp::UpdateExtension()
|
|
|
|
{
|
|
|
|
String aStrURL( maCbbPath.GetText() );
|
|
|
|
|
|
|
|
const int nDocTypePos = maLbDocTypes.GetSelectEntryPos();
|
|
|
|
|
|
|
|
// no file? no doctype? no extension!
|
|
|
|
if( aStrURL.Len() == 0 || nDocTypePos == LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
return;
|
|
|
|
|
|
|
|
utl::LocalFileHelper::ConvertSystemPathToURL( aStrURL, maCbbPath.GetBaseURL(), aStrURL );
|
|
|
|
|
|
|
|
// if we have a valid url, use the INetURLObject way
|
|
|
|
if( aStrURL.Len() )
|
|
|
|
{
|
|
|
|
// check for file name
|
|
|
|
if ( GetName ( aStrURL ) != aEmptyStr )
|
|
|
|
{
|
|
|
|
INetURLObject aURL( aStrURL );
|
|
|
|
|
|
|
|
// get private-url
|
|
|
|
aURL.setExtension(((DocumentTypeData*)maLbDocTypes.GetEntryData( nDocTypePos ) )->aStrExt);
|
|
|
|
|
|
|
|
String aStrTmp( aURL.GetURLPath( INetURLObject::DECODE_WITH_CHARSET ) );
|
|
|
|
sal_Char const sSlash[] = "/";
|
|
|
|
if( aStrTmp.SearchAscii( sSlash ) == 0 )
|
|
|
|
aStrTmp.Erase( 0, 1 );
|
|
|
|
maCbbPath.SetText ( aStrTmp );
|
|
|
|
|
|
|
|
ModifiedPathHdl_Impl ( NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aStrURL = maCbbPath.GetText();
|
|
|
|
// since we have no valid url yet, maybe just a file name
|
|
|
|
// we must add the extensions ourselfs
|
|
|
|
|
|
|
|
xub_StrLen nIndex = aStrURL.SearchBackward( sal_Unicode('.') );
|
|
|
|
if( nIndex != -1 )
|
|
|
|
aStrURL = aStrURL.Copy( 0, nIndex );
|
|
|
|
|
|
|
|
aStrURL += sal_Unicode( '.' );
|
|
|
|
aStrURL += ((DocumentTypeData*)maLbDocTypes.GetEntryData( nDocTypePos ) )->aStrExt;
|
|
|
|
maCbbPath.SetText( aStrURL );
|
|
|
|
|
|
|
|
ModifiedPathHdl_Impl ( NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* retrieve path
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
2001-02-12 14:12:27 +00:00
|
|
|
String SvxHyperlinkNewDocTp::GetPath ( const String& aStrFull ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
String aStrPath;
|
|
|
|
aStrPath = aStrFull;
|
|
|
|
return aStrPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* retrieve filename
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
2001-02-12 14:12:27 +00:00
|
|
|
String SvxHyperlinkNewDocTp::GetName ( const String& aStrFull ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
String aStrName;
|
|
|
|
INetURLObject aURL( aStrFull, INET_PROT_FILE );
|
|
|
|
aStrName = aURL.getName();
|
|
|
|
|
|
|
|
return aStrName;
|
|
|
|
}
|
|
|
|
|