2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: fuinsfil.cxx,v $
|
|
|
|
*
|
2004-11-03 15:45:04 +00:00
|
|
|
* $Revision: 1.31 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2004-11-03 15:45:04 +00:00
|
|
|
* last change: $Author: rt $ $Date: 2004-11-03 16:45:04 $
|
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): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2004-01-20 10:03:33 +00:00
|
|
|
#include "fuinsfil.hxx"
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifndef _SV_WRKWIN_HXX
|
|
|
|
#include <vcl/wrkwin.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFX_PROGRESS_HXX
|
|
|
|
#include <sfx2/progress.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _OUTLINER_HXX
|
|
|
|
#include <svx/outliner.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _EDITENG_HXX
|
|
|
|
#include <svx/editeng.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXSTRITEM_HXX //autogen
|
|
|
|
#include <svtools/stritem.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXREQUEST_HXX //autogen
|
|
|
|
#include <sfx2/request.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXAPP_HXX //autogen
|
|
|
|
#include <sfx2/app.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_MSGBOX_HXX //autogen
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFX_PRINTER_HXX //autogen
|
|
|
|
#include <sfx2/printer.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVDORECT_HXX //autogen
|
|
|
|
#include <svx/svdorect.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVDUNDO_HXX //autogen
|
|
|
|
#include <svx/svdundo.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVDOUTL_HXX //autogen
|
|
|
|
#include <svx/svdoutl.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXSTBMGR_HXX //autogen
|
|
|
|
#include <sfx2/stbmgr.hxx>
|
|
|
|
#endif
|
2001-05-28 06:40:41 +00:00
|
|
|
#ifndef _FILEDLGHELPER_HXX
|
|
|
|
#include <sfx2/filedlghelper.hxx>
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifndef _SOT_FORMATS_HXX //autogen
|
|
|
|
#include <sot/formats.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef SVTOOLS_URIHELPER_HXX
|
|
|
|
#include <svtools/urihelper.hxx>
|
|
|
|
#endif
|
2001-04-06 13:17:19 +00:00
|
|
|
#ifndef _FORBIDDENCHARACTERSTABLE_HXX
|
|
|
|
#include <svx/forbiddencharacterstable.hxx>
|
|
|
|
#endif
|
2002-03-14 11:26:49 +00:00
|
|
|
#ifndef _URLOBJ_HXX //autogen
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXDOCFILE_HXX //autogen
|
|
|
|
#include <sfx2/docfile.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFX_DOCFILT_HACK_HXX //autogen
|
|
|
|
#include <sfx2/docfilt.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFX_FCONTNR_HXX //autogen
|
|
|
|
#include <sfx2/fcontnr.hxx>
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifndef _SVDPAGV_HXX //autogen
|
|
|
|
#include <svx/svdpagv.hxx>
|
|
|
|
#endif
|
2002-03-14 11:26:49 +00:00
|
|
|
#include <svx/dialogs.hrc>
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILTERMANAGER_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKER_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERCONTROLACCESS_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include "sdresid.hxx"
|
|
|
|
#include "drawdoc.hxx"
|
2004-01-20 10:03:33 +00:00
|
|
|
#ifndef SD_WINDOW_HXX
|
|
|
|
#include "Window.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef SD_VIEW_HXX
|
|
|
|
#include "View.hxx"
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "strings.hrc"
|
|
|
|
#include "stlpool.hxx"
|
|
|
|
#include "glob.hrc"
|
|
|
|
#include "sdpage.hxx"
|
|
|
|
#include "strmname.h"
|
|
|
|
#include "strings.hrc"
|
2004-01-20 10:03:33 +00:00
|
|
|
#ifndef SD_DRAW_VIEW_SHELL_HXX
|
|
|
|
#include "DrawViewShell.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef SD_OUTLINE_VIEW_SHELL_HXX
|
|
|
|
#include "OutlineViewShell.hxx"
|
|
|
|
#endif
|
|
|
|
#include "DrawDocShell.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "app.hrc"
|
|
|
|
#include "unmovss.hxx"
|
2004-05-10 14:46:59 +00:00
|
|
|
//CHINA001 #include "inspagob.hxx"
|
2004-01-20 10:03:33 +00:00
|
|
|
#ifndef SD_OUTLINER_HXX
|
|
|
|
#include "Outliner.hxx"
|
|
|
|
#endif
|
2004-05-10 14:46:59 +00:00
|
|
|
#include "sdabstdlg.hxx" //CHINA001
|
|
|
|
#include "inspagob.hrc" //CHINA001
|
2001-05-28 06:40:41 +00:00
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::uno;
|
2001-06-15 17:08:04 +00:00
|
|
|
using namespace ::com::sun::star::ui::dialogs;
|
2001-05-28 06:40:41 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::rtl;
|
|
|
|
|
2004-01-20 10:03:33 +00:00
|
|
|
namespace sd {
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
TYPEINIT1( FuInsertFile, FuPoor );
|
|
|
|
|
|
|
|
#define POOL_BUFFER_SIZE (USHORT)32768
|
|
|
|
#define BASIC_BUFFER_SIZE (USHORT)8192
|
|
|
|
#define DOCUMENT_BUFFER_SIZE (USHORT)32768
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Konstruktor
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2004-01-20 10:03:33 +00:00
|
|
|
FuInsertFile::FuInsertFile (
|
|
|
|
ViewShell* pViewSh,
|
|
|
|
::sd::Window* pWin,
|
|
|
|
::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc,
|
|
|
|
SfxRequest& rReq)
|
|
|
|
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-12-12 11:48:35 +00:00
|
|
|
SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher();
|
2002-03-14 11:26:49 +00:00
|
|
|
::std::vector< String > aFilterVector;
|
2001-12-12 11:48:35 +00:00
|
|
|
const SfxItemSet* pArgs = rReq.GetArgs ();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
FuInsertFile::GetSupportedFilterVector( aFilterVector );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!pArgs)
|
|
|
|
{
|
2001-12-12 11:48:35 +00:00
|
|
|
sfx2::FileDialogHelper aFileDialog( WB_OPEN | SFXWB_INSERT | WB_STDMODAL );
|
|
|
|
Reference< XFilePicker > xFilePicker( aFileDialog.GetFilePicker(), UNO_QUERY );
|
2001-05-28 06:40:41 +00:00
|
|
|
Reference< XFilterManager > xFilterManager( xFilePicker, UNO_QUERY );
|
2003-09-19 07:17:20 +00:00
|
|
|
String aCont;
|
2001-12-12 11:48:35 +00:00
|
|
|
const SfxFilter* pFilter = NULL;
|
2001-02-21 12:14:54 +00:00
|
|
|
|
2001-05-28 06:40:41 +00:00
|
|
|
aFileDialog.SetTitle( String( SdResId(STR_DLG_INSERT_PAGES_FROM_FILE ) ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if( pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
|
2003-09-19 07:17:20 +00:00
|
|
|
aCont = String( RTL_CONSTASCII_USTRINGPARAM( "simpress" ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2003-09-19 07:17:20 +00:00
|
|
|
aCont = String( RTL_CONSTASCII_USTRINGPARAM( "sdraw" ) ) ;
|
|
|
|
SfxFilterMatcher aMatch( aCont );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-27 16:48:47 +00:00
|
|
|
if( xFilterManager.is() )
|
2000-12-14 11:02:47 +00:00
|
|
|
{
|
2001-12-12 11:48:35 +00:00
|
|
|
// Get filter for current format
|
2001-06-27 16:48:47 +00:00
|
|
|
try
|
|
|
|
{
|
2001-12-12 11:48:35 +00:00
|
|
|
String aExt;
|
|
|
|
String aAllSpec( SdResId( STR_ALL_FILES ) );
|
|
|
|
|
2001-07-23 11:15:41 +00:00
|
|
|
xFilterManager->appendFilter( aAllSpec, UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "*.*" ) ) );
|
|
|
|
xFilterManager->setCurrentFilter( aAllSpec ); // set default-filter (<All>)
|
|
|
|
|
2001-12-12 11:48:35 +00:00
|
|
|
// Get main filter
|
2003-09-19 07:17:20 +00:00
|
|
|
pFilter = SfxFilter::GetDefaultFilterFromFactory( aCont );
|
2001-06-27 16:48:47 +00:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-12-14 11:02:47 +00:00
|
|
|
|
2001-12-12 11:48:35 +00:00
|
|
|
// Get Draw filter for Impress and Impress filter for Draw as secondary filter
|
2001-06-27 16:48:47 +00:00
|
|
|
if( pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
|
|
|
|
aExt = UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( ".sxd" ) );
|
|
|
|
else
|
|
|
|
aExt = UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( ".sxi" ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2003-09-19 07:17:20 +00:00
|
|
|
pFilter = aMatch.GetFilter4Extension( aExt );
|
2001-06-27 16:48:47 +00:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-27 16:48:47 +00:00
|
|
|
// Get other filters
|
2003-09-19 07:17:20 +00:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARIMPRESS_50 );
|
2001-06-27 16:48:47 +00:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2001-12-12 11:48:35 +00:00
|
|
|
|
2003-09-19 07:17:20 +00:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARIMPRESS_50, SFX_FILTER_TEMPLATEPATH );
|
2001-06-27 16:48:47 +00:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2003-09-19 07:17:20 +00:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_50 );
|
2001-06-27 16:48:47 +00:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2001-12-12 11:48:35 +00:00
|
|
|
|
2003-09-19 07:17:20 +00:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_50, SFX_FILTER_TEMPLATEPATH );
|
2001-06-27 16:48:47 +00:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2003-09-19 07:17:20 +00:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_40 );
|
2001-06-27 16:48:47 +00:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2001-12-12 11:48:35 +00:00
|
|
|
|
2003-09-19 07:17:20 +00:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_40, SFX_FILTER_TEMPLATEPATH );
|
2001-06-27 16:48:47 +00:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2003-09-19 07:17:20 +00:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW );
|
2001-06-27 16:48:47 +00:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2001-12-12 11:48:35 +00:00
|
|
|
|
2003-09-19 07:17:20 +00:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW, SFX_FILTER_TEMPLATEPATH );
|
2001-06-27 16:48:47 +00:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
// add additional supported filters
|
|
|
|
::std::vector< String >::const_iterator aIter( aFilterVector.begin() );
|
2001-12-12 11:48:35 +00:00
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
while( aIter != aFilterVector.end() )
|
2001-12-12 11:48:35 +00:00
|
|
|
{
|
2002-03-14 11:26:49 +00:00
|
|
|
if( ( pFilter = rMatcher.GetFilter4Mime( *aIter ) ) != NULL )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2001-12-12 11:48:35 +00:00
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
++aIter;
|
2001-12-12 11:48:35 +00:00
|
|
|
}
|
2001-06-27 16:48:47 +00:00
|
|
|
}
|
|
|
|
catch(IllegalArgumentException)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-05-28 06:40:41 +00:00
|
|
|
if( aFileDialog.Execute() != ERRCODE_NONE )
|
2001-02-21 12:14:54 +00:00
|
|
|
return;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
{
|
2001-05-28 06:40:41 +00:00
|
|
|
aFilterName = aFileDialog.GetCurrentFilter();
|
2001-02-21 12:14:54 +00:00
|
|
|
aFile = aFileDialog.GetPath();
|
|
|
|
INetURLObject::SetBaseURL( aFile );
|
|
|
|
aFile = ::URIHelper::SmartRelToAbs( aFile, FALSE,
|
|
|
|
INetURLObject::WAS_ENCODED,
|
|
|
|
INetURLObject::DECODE_UNAMBIGUOUS );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SFX_REQUEST_ARG (rReq, pFileName, SfxStringItem, ID_VAL_DUMMY0, FALSE);
|
|
|
|
SFX_REQUEST_ARG (rReq, pFilterName, SfxStringItem, ID_VAL_DUMMY1, FALSE);
|
|
|
|
|
|
|
|
aFile = pFileName->GetValue ();
|
2001-02-21 12:14:54 +00:00
|
|
|
|
|
|
|
if( pFilterName )
|
2000-09-18 16:07:07 +00:00
|
|
|
aFilterName = pFilterName->GetValue ();
|
|
|
|
else
|
|
|
|
aFilterName = UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "*.sdd" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
pDocSh->SetWaitCursor( TRUE );
|
|
|
|
|
2001-02-21 12:14:54 +00:00
|
|
|
SfxMedium* pMedium = new SfxMedium( aFile, STREAM_READ | STREAM_NOCREATE, FALSE );
|
|
|
|
const SfxFilter* pFilter = NULL;
|
|
|
|
ErrCode nErr = SFX_APP()->GetFilterMatcher().GuessFilter( *pMedium, &pFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE );
|
2004-01-20 10:03:33 +00:00
|
|
|
BOOL bDrawMode = pViewSh->ISA(DrawViewShell);
|
2002-04-09 07:05:15 +00:00
|
|
|
BOOL bInserted = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-02-21 12:14:54 +00:00
|
|
|
if( pFilter )
|
2002-02-08 10:19:15 +00:00
|
|
|
{
|
2001-02-21 12:14:54 +00:00
|
|
|
pMedium->SetFilter( pFilter );
|
2002-02-08 10:19:15 +00:00
|
|
|
aFilterName = pFilter->GetFilterName();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-02-21 12:14:54 +00:00
|
|
|
if( pMedium->IsStorage() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
// Storage
|
2004-10-04 17:32:15 +00:00
|
|
|
uno::Reference < embed::XStorage > xStorage = pMedium->GetStorage();
|
|
|
|
if( xStorage.is() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 17:32:15 +00:00
|
|
|
uno::Reference < container::XNameAccess > xAccess (xStorage, uno::UNO_QUERY);
|
|
|
|
sal_Bool bIsStream = xAccess->hasByName( pStarDrawXMLContent ) && xStorage->isStreamElement( pStarDrawXMLContent ) ||
|
|
|
|
xAccess->hasByName( pStarDrawOldXMLContent ) && xStorage->isStreamElement( pStarDrawOldXMLContent );
|
|
|
|
|
|
|
|
if ( bIsStream &&
|
|
|
|
( !pFilter ||
|
2004-11-03 15:45:04 +00:00
|
|
|
( pFilter->GetServiceName().EqualsAscii( "com.sun.star.presentation.PresentationDocument" ) ||
|
|
|
|
pFilter->GetServiceName().EqualsAscii( "com.sun.star.drawing.DrawingDocument" ) ) ) )
|
2002-04-09 07:05:15 +00:00
|
|
|
{
|
|
|
|
pMedium->Close();
|
|
|
|
|
|
|
|
if( bDrawMode )
|
|
|
|
InsSDDinDrMode( pMedium );
|
|
|
|
else
|
|
|
|
InsSDDinOlMode( pMedium );
|
|
|
|
|
|
|
|
bInserted = TRUE;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
2001-12-12 11:48:35 +00:00
|
|
|
else if( pFilter )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-03-14 11:26:49 +00:00
|
|
|
BOOL bFound = ( ::std::find( aFilterVector.begin(), aFilterVector.end(), pFilter->GetMimeType() ) != aFilterVector.end() );
|
2001-12-12 11:48:35 +00:00
|
|
|
|
|
|
|
if( !bFound &&
|
|
|
|
( aFilterName.SearchAscii( "Text" ) != STRING_NOTFOUND ||
|
2002-02-08 10:19:15 +00:00
|
|
|
aFilterName.SearchAscii( "Rich" ) != STRING_NOTFOUND ||
|
2002-03-14 11:26:49 +00:00
|
|
|
aFilterName.SearchAscii( "RTF" ) != STRING_NOTFOUND ||
|
2001-12-12 11:48:35 +00:00
|
|
|
aFilterName.SearchAscii( "HTML" ) != STRING_NOTFOUND ) )
|
|
|
|
{
|
|
|
|
if( bDrawMode )
|
|
|
|
InsTextOrRTFinDrMode(pMedium);
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2001-12-12 11:48:35 +00:00
|
|
|
InsTextOrRTFinOlMode(pMedium);
|
2002-04-09 07:05:15 +00:00
|
|
|
|
|
|
|
bInserted = TRUE;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete pMedium;
|
|
|
|
pDocSh->SetWaitCursor( FALSE );
|
2002-04-09 07:05:15 +00:00
|
|
|
|
|
|
|
if( !bInserted )
|
|
|
|
{
|
|
|
|
ErrorBox aErrorBox( pWindow, WB_OK, String( SdResId( STR_READ_DATA_ERROR ) ) );
|
|
|
|
aErrorBox.Execute();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
FuInsertFile::~FuInsertFile()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
void FuInsertFile::Activate()
|
|
|
|
{
|
|
|
|
FuPoor::Activate();
|
|
|
|
}
|
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
void FuInsertFile::Deactivate()
|
|
|
|
{
|
|
|
|
FuPoor::Deactivate();
|
|
|
|
}
|
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
BOOL FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
|
|
|
|
{
|
|
|
|
BOOL bOK = FALSE;
|
|
|
|
|
|
|
|
// Liste mit Seitennamen (wenn NULL, dann alle Seiten)
|
|
|
|
List* pBookmarkList = NULL;
|
|
|
|
|
|
|
|
pDocSh->SetWaitCursor( FALSE );
|
2004-05-10 14:46:59 +00:00
|
|
|
//CHINA001 SdInsertPagesObjsDlg* pDlg = new SdInsertPagesObjsDlg( NULL, pDoc,
|
|
|
|
//CHINA001 pMedium, aFile );
|
|
|
|
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();//CHINA001
|
|
|
|
DBG_ASSERT(pFact, "SdAbstractDialogFactory fail!");//CHINA001
|
|
|
|
AbstractSdInsertPagesObjsDlg* pDlg = pFact->CreateSdInsertPagesObjsDlg(ResId( DLG_INSERT_PAGES_OBJS ), NULL, pDoc,
|
2000-09-18 16:07:07 +00:00
|
|
|
pMedium, aFile );
|
2004-05-10 14:46:59 +00:00
|
|
|
DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
|
2000-09-18 16:07:07 +00:00
|
|
|
// Ev. wird eine QueryBox geoeffnet ("Links aktualisieren?"),
|
|
|
|
// daher wird der Dialog der aktuelle DefModalDialogParent
|
2004-01-20 10:03:33 +00:00
|
|
|
::Window* pDefParent = GetpApp()->GetDefDialogParent();
|
2004-05-10 14:46:59 +00:00
|
|
|
GetpApp()->SetDefDialogParent(pDlg->GetWindow()); //CHINA001 GetpApp()->SetDefDialogParent(pDlg);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
USHORT nRet = pDlg->Execute();
|
|
|
|
|
|
|
|
GetpApp()->SetDefDialogParent(pDefParent);
|
|
|
|
|
|
|
|
pDocSh->SetWaitCursor( TRUE );
|
|
|
|
|
|
|
|
if( nRet == RET_OK )
|
|
|
|
{
|
|
|
|
// Zuerst Seiten einfuegen
|
|
|
|
pBookmarkList = pDlg->GetList( 1 ); // Seiten
|
|
|
|
BOOL bLink = pDlg->IsLink();
|
|
|
|
BOOL bReplace = FALSE;
|
|
|
|
SdPage* pPage = NULL;
|
2004-01-20 10:03:33 +00:00
|
|
|
::sd::View* pView = pViewShell->GetView();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-01-20 10:03:33 +00:00
|
|
|
if (pView->ISA(OutlineView))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-01-20 10:03:33 +00:00
|
|
|
pPage = static_cast<OutlineView*>(pView)->GetActualPage();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-01-20 10:03:33 +00:00
|
|
|
pPage = static_cast<SdPage*>(pView->GetPageViewPvNum(0)->GetPage());
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
USHORT nPos = 0xFFFF;
|
|
|
|
|
|
|
|
if (pPage && !pPage->IsMasterPage())
|
|
|
|
{
|
|
|
|
if (pPage->GetPageKind() == PK_STANDARD)
|
|
|
|
{
|
|
|
|
nPos = pPage->GetPageNum() + 2;
|
|
|
|
}
|
|
|
|
else if (pPage->GetPageKind() == PK_NOTES)
|
|
|
|
{
|
|
|
|
nPos = pPage->GetPageNum() + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL bNameOK;
|
|
|
|
List* pObjectBookmarkList = pDlg->GetList( 2 ); // Objekte
|
|
|
|
List* pExchangeList = NULL;
|
|
|
|
|
|
|
|
// Es werden ausgewaehlte Seiten und/oder ausgewaehlte Objekte oder
|
|
|
|
// alles eingefuegt, wenn pBookmarkList NULL ist!
|
|
|
|
if( pBookmarkList || !pObjectBookmarkList )
|
|
|
|
{
|
|
|
|
// Um zu gewaehrleisten, dass alle Seitennamen eindeutig sind, werden
|
|
|
|
// die einzufuegenden geprueft und gegebenenfalls in einer Ersatzliste
|
|
|
|
// aufgenommen
|
|
|
|
// bNameOK == FALSE -> Benutzer hat abgebrochen
|
|
|
|
bNameOK = pView->GetExchangeList( pExchangeList, pBookmarkList, 0 );
|
|
|
|
|
|
|
|
if( bNameOK )
|
|
|
|
bOK = pDoc->InsertBookmarkAsPage( pBookmarkList, pExchangeList,
|
|
|
|
bLink, bReplace, nPos,
|
2002-11-19 17:02:28 +00:00
|
|
|
FALSE, NULL, TRUE, TRUE, FALSE );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Loeschen der BookmarkList
|
|
|
|
if( pBookmarkList )
|
|
|
|
{
|
|
|
|
String* pString = (String*) pBookmarkList->First();
|
|
|
|
while( pString )
|
|
|
|
{
|
|
|
|
delete pString;
|
|
|
|
pString = (String*) pBookmarkList->Next();
|
|
|
|
}
|
|
|
|
delete pBookmarkList;
|
|
|
|
pBookmarkList = NULL;
|
|
|
|
}
|
|
|
|
// Loeschen der ExchangeList
|
|
|
|
if( pExchangeList )
|
|
|
|
{
|
|
|
|
String* pString = (String*) pExchangeList->First();
|
|
|
|
while( pString )
|
|
|
|
{
|
|
|
|
delete pString;
|
|
|
|
pString = (String*) pExchangeList->Next();
|
|
|
|
}
|
|
|
|
delete pExchangeList;
|
|
|
|
pExchangeList = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Dann Objekte einfuegen
|
|
|
|
//pBookmarkList = pDlg->GetList( 2 ); // Objekte
|
|
|
|
pBookmarkList = pObjectBookmarkList;
|
|
|
|
|
|
|
|
// Um zu gewaehrleisten... (s.o.)
|
|
|
|
bNameOK = pView->GetExchangeList( pExchangeList, pBookmarkList, 1 );
|
|
|
|
|
|
|
|
if( bNameOK )
|
|
|
|
bOK = pDoc->InsertBookmarkAsObject( pBookmarkList, pExchangeList,
|
|
|
|
bLink, NULL, NULL);
|
|
|
|
|
|
|
|
// Loeschen der BookmarkList
|
|
|
|
if( pBookmarkList )
|
|
|
|
{
|
|
|
|
String* pString = (String*) pBookmarkList->First();
|
|
|
|
while( pString )
|
|
|
|
{
|
|
|
|
delete pString;
|
|
|
|
pString = (String*) pBookmarkList->Next();
|
|
|
|
}
|
|
|
|
delete pBookmarkList;
|
|
|
|
pBookmarkList = NULL;
|
|
|
|
}
|
|
|
|
// Loeschen der ExchangeList
|
|
|
|
if( pExchangeList )
|
|
|
|
{
|
|
|
|
String* pString = (String*) pExchangeList->First();
|
|
|
|
while( pString )
|
|
|
|
{
|
|
|
|
delete pString;
|
|
|
|
pString = (String*) pExchangeList->Next();
|
|
|
|
}
|
|
|
|
delete pExchangeList;
|
|
|
|
pExchangeList = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pDlg->IsRemoveUnnessesaryMasterPages() )
|
|
|
|
pDoc->RemoveUnnessesaryMasterPages();
|
|
|
|
}
|
|
|
|
|
|
|
|
delete pDlg;
|
|
|
|
|
|
|
|
return (bOK);
|
|
|
|
}
|
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
|
|
|
|
{
|
|
|
|
pDocSh->SetWaitCursor( FALSE );
|
2004-05-10 14:46:59 +00:00
|
|
|
//CHINA001 SdInsertPagesObjsDlg* pDlg = new SdInsertPagesObjsDlg( NULL, pDoc,
|
|
|
|
//CHINA001 NULL, aFile );
|
|
|
|
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();//CHINA001
|
|
|
|
DBG_ASSERT(pFact, "SdAbstractDialogFactory fail!");//CHINA001
|
|
|
|
AbstractSdInsertPagesObjsDlg* pDlg = pFact->CreateSdInsertPagesObjsDlg(ResId( DLG_INSERT_PAGES_OBJS ), NULL, pDoc,
|
2000-09-18 16:07:07 +00:00
|
|
|
NULL, aFile );
|
2004-05-10 14:46:59 +00:00
|
|
|
DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
|
2000-09-18 16:07:07 +00:00
|
|
|
USHORT nRet = pDlg->Execute();
|
|
|
|
pDocSh->SetWaitCursor( TRUE );
|
|
|
|
|
|
|
|
if( nRet == RET_OK )
|
|
|
|
{
|
|
|
|
BOOL bLink = pDlg->IsLink();
|
|
|
|
|
|
|
|
// gewaehltes Dateiformat: Text oder RTF oder HTML (Default ist Text)
|
|
|
|
USHORT nFormat = EE_FORMAT_TEXT;
|
2001-01-24 11:17:32 +00:00
|
|
|
|
2002-02-08 10:19:15 +00:00
|
|
|
if( aFilterName.SearchAscii( "Rich") != STRING_NOTFOUND )
|
2000-09-18 16:07:07 +00:00
|
|
|
nFormat = EE_FORMAT_RTF;
|
2001-01-24 11:17:32 +00:00
|
|
|
else if( aFilterName.SearchAscii( "HTML" ) != STRING_NOTFOUND )
|
2000-09-18 16:07:07 +00:00
|
|
|
nFormat = EE_FORMAT_HTML;
|
|
|
|
|
|
|
|
// einen eigenen Outliner erzeugen, denn:
|
|
|
|
// der Dokument-Outliner koennte gerade vom Gliederungsmodus
|
|
|
|
// benutzt werden;
|
|
|
|
// der Draw-Outliner der Drawing Engine koennte zwischendurch
|
|
|
|
// was zeichnen muessen;
|
|
|
|
// der globale Outliner koennte in SdPage::CreatePresObj
|
|
|
|
// benutzt werden
|
2002-11-06 11:50:26 +00:00
|
|
|
// SfxItemPool* pPool = pDoc->GetDrawOutliner().GetEmptyItemSet().GetPool();
|
2004-01-20 10:03:33 +00:00
|
|
|
SdrOutliner* pOutliner = new ::sd::Outliner( pDoc, OUTLINERMODE_TEXTOBJECT );
|
2002-11-06 11:50:26 +00:00
|
|
|
// pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)pDoc->GetStyleSheetPool());
|
|
|
|
// pOutliner->SetEditTextObjectPool(pPool);
|
|
|
|
// pOutliner->SetForbiddenCharsTable( pDoc->GetForbiddenCharsTable() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Referenz-Device setzen
|
2002-07-26 07:32:44 +00:00
|
|
|
pOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *pDocSh ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-01-20 10:03:33 +00:00
|
|
|
SdPage* pPage = static_cast<DrawViewShell*>(pViewShell)->GetActualPage();
|
2000-09-18 16:07:07 +00:00
|
|
|
aLayoutName = pPage->GetLayoutName();
|
|
|
|
aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
|
|
|
|
|
|
|
|
pOutliner->SetPaperSize(pPage->GetSize());
|
|
|
|
pOutliner->SetMinDepth(0);
|
|
|
|
|
|
|
|
SvStream* pStream = pMedium->GetInStream();
|
|
|
|
DBG_ASSERT( pStream, "Kein InStream!" );
|
2001-04-20 11:11:15 +00:00
|
|
|
pStream->Seek( 0 );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
ULONG nErr = pOutliner->Read( *pStream, nFormat, pDocSh->GetHeaderAttributes() );
|
|
|
|
|
|
|
|
if (nErr || !pOutliner->GetEditEngine().GetText().Len())
|
|
|
|
{
|
|
|
|
ErrorBox aErrorBox( pWindow, (WinBits)WB_OK,
|
|
|
|
String(SdResId(STR_READ_DATA_ERROR)));
|
|
|
|
aErrorBox.Execute();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// ist es eine Masterpage?
|
2004-01-20 10:03:33 +00:00
|
|
|
if (static_cast<DrawViewShell*>(pViewShell)->GetEditMode() == EM_MASTERPAGE &&
|
2000-09-18 16:07:07 +00:00
|
|
|
!pPage->IsMasterPage())
|
|
|
|
{
|
2004-07-12 14:02:59 +00:00
|
|
|
pPage = (SdPage*)(&(pPage->TRG_GetMasterPage()));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DBG_ASSERT(pPage, "Seite nicht gefunden");
|
|
|
|
|
|
|
|
// wenn gerade editiert wird, in dieses Textobjekt einfliessen lassen
|
|
|
|
OutlinerView* pOutlinerView = pView->GetTextEditOutlinerView();
|
|
|
|
if( pOutlinerView )
|
|
|
|
{
|
|
|
|
SdrObject* pObj = pView->GetTextEditObject();
|
|
|
|
if( pObj &&
|
|
|
|
pObj->GetObjInventor() == SdrInventor &&
|
|
|
|
pObj->GetObjIdentifier() == OBJ_TITLETEXT &&
|
|
|
|
pOutliner->GetParagraphCount() > 1 )
|
|
|
|
{
|
|
|
|
// In Titelobjekten darf nur ein Absatz vorhanden sein
|
|
|
|
while ( pOutliner->GetParagraphCount() > 1 )
|
|
|
|
{
|
|
|
|
Paragraph* pPara = pOutliner->GetParagraph( 0 );
|
|
|
|
ULONG nLen = pOutliner->GetText( pPara, 1 ).Len();
|
2001-02-21 12:14:54 +00:00
|
|
|
pOutliner->QuickDelete( ESelection( 0, (USHORT) nLen, 1, 0 ) );
|
|
|
|
pOutliner->QuickInsertLineBreak( ESelection( 0, (USHORT) nLen, 0, (USHORT) nLen ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OutlinerParaObject* pOPO = pOutliner->CreateParaObject();
|
|
|
|
|
|
|
|
if (pOutlinerView)
|
|
|
|
{
|
|
|
|
pOutlinerView->InsertText(*pOPO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SdrRectObj* pTO = new SdrRectObj(OBJ_TEXT);
|
|
|
|
pTO->SetOutlinerParaObject(pOPO);
|
2001-04-02 13:48:19 +00:00
|
|
|
|
|
|
|
pView->BegUndo(String(SdResId(STR_UNDO_INSERT_TEXTFRAME)));
|
|
|
|
pPage->InsertObject(pTO);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// koennte groesser sein als die max. erlaubte Groesse:
|
|
|
|
// falls noetig, die Objektgroesse begrenzen
|
2001-04-02 13:48:19 +00:00
|
|
|
Size aSize(pOutliner->CalcTextSize());
|
2000-09-18 16:07:07 +00:00
|
|
|
Size aMaxSize = pDoc->GetMaxObjSize();
|
|
|
|
aSize.Height() = Min(aSize.Height(), aMaxSize.Height());
|
|
|
|
aSize.Width() = Min(aSize.Width(), aMaxSize.Width());
|
|
|
|
aSize = pWindow->LogicToPixel(aSize);
|
|
|
|
|
|
|
|
// in der Mitte des Fensters absetzen
|
|
|
|
Size aTemp(pWindow->GetOutputSizePixel());
|
|
|
|
Point aPos(aTemp.Width() / 2, aTemp.Height() / 2);
|
|
|
|
aPos.X() -= aSize.Width() / 2;
|
|
|
|
aPos.Y() -= aSize.Height() / 2;
|
|
|
|
aSize = pWindow->PixelToLogic(aSize);
|
|
|
|
aPos = pWindow->PixelToLogic(aPos);
|
|
|
|
pTO->SetLogicRect(Rectangle(aPos, aSize));
|
|
|
|
|
|
|
|
if (pDlg->IsLink())
|
|
|
|
{
|
|
|
|
pTO->SetTextLink(aFile, aFilterName, gsl_getSystemTextEncoding() );
|
|
|
|
}
|
|
|
|
|
|
|
|
pView->AddUndo(new SdrUndoInsertObj(*pTO));
|
|
|
|
pView->EndUndo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete pOutliner;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete pDlg;
|
|
|
|
}
|
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium)
|
|
|
|
{
|
|
|
|
// gewaehltes Dateiformat: Text oder RTF oder HTML (Default ist Text)
|
|
|
|
USHORT nFormat = EE_FORMAT_TEXT;
|
2001-01-24 11:17:32 +00:00
|
|
|
|
2002-02-08 10:19:15 +00:00
|
|
|
if( aFilterName.SearchAscii( "Rich") != STRING_NOTFOUND )
|
2000-09-18 16:07:07 +00:00
|
|
|
nFormat = EE_FORMAT_RTF;
|
2001-01-24 11:17:32 +00:00
|
|
|
else if( aFilterName.SearchAscii( "HTML" ) != STRING_NOTFOUND )
|
2000-09-18 16:07:07 +00:00
|
|
|
nFormat = EE_FORMAT_HTML;
|
|
|
|
|
2004-01-20 10:03:33 +00:00
|
|
|
::Outliner* pDocliner = static_cast<OutlineView*>(pView)->GetOutliner();
|
2000-09-18 16:07:07 +00:00
|
|
|
List* pList = pDocliner->GetView(0)->CreateSelectionList();
|
|
|
|
Paragraph* pPara = (Paragraph*)pList->First();
|
|
|
|
|
|
|
|
// wo soll eingefuegt werden?
|
2001-02-21 12:14:54 +00:00
|
|
|
while ( pDocliner->GetDepth( (USHORT) pDocliner->GetAbsPos( pPara ) ) != 0)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pPara = pDocliner->GetParent(pPara);
|
|
|
|
}
|
|
|
|
ULONG nTargetPos = pDocliner->GetAbsPos(pPara) + 1;
|
|
|
|
|
|
|
|
// Layout der Vorgaengerseite uebernehmen
|
|
|
|
USHORT nPage = 0;
|
|
|
|
pPara = pDocliner->GetParagraph( pDocliner->GetAbsPos( pPara ) - 1 );
|
|
|
|
while (pPara)
|
|
|
|
{
|
|
|
|
ULONG nPos = pDocliner->GetAbsPos( pPara );
|
2001-02-21 12:14:54 +00:00
|
|
|
if ( pDocliner->GetDepth( (USHORT) nPos ) == 0 )
|
2000-09-18 16:07:07 +00:00
|
|
|
nPage++;
|
|
|
|
pPara = pDocliner->GetParagraph( nPos - 1 );
|
|
|
|
}
|
|
|
|
SdPage* pPage = pDoc->GetSdPage(nPage, PK_STANDARD);
|
|
|
|
aLayoutName = pPage->GetLayoutName();
|
|
|
|
aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
|
|
|
|
|
|
|
|
// einen eigenen Outliner erzeugen, denn:
|
|
|
|
// der Dokument-Outliner koennte gerade vom Gliederungsmodus
|
|
|
|
// benutzt werden;
|
|
|
|
// der Draw-Outliner der Drawing Engine koennte zwischendurch
|
|
|
|
// was zeichnen muessen;
|
|
|
|
// der globale Outliner koennte in SdPage::CreatePresObj
|
|
|
|
// benutzt werden
|
2004-01-20 10:03:33 +00:00
|
|
|
::Outliner* pOutliner = new ::Outliner( &pDoc->GetItemPool(), OUTLINERMODE_OUTLINEOBJECT );
|
2000-09-18 16:07:07 +00:00
|
|
|
pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)pDoc->GetStyleSheetPool());
|
|
|
|
|
|
|
|
// Referenz-Device setzen
|
2002-07-26 07:32:44 +00:00
|
|
|
pOutliner->SetRefDevice(SD_MOD()->GetRefDevice( *pDocSh ));
|
2000-09-18 16:07:07 +00:00
|
|
|
pOutliner->SetPaperSize(Size(0x7fffffff, 0x7fffffff));
|
|
|
|
|
|
|
|
SvStream* pStream = pMedium->GetInStream();
|
|
|
|
DBG_ASSERT( pStream, "Kein InStream!" );
|
2001-04-20 11:11:15 +00:00
|
|
|
pStream->Seek( 0 );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
ULONG nErr = pOutliner->Read(*pStream, nFormat, pDocSh->GetHeaderAttributes());
|
|
|
|
|
|
|
|
if (nErr || !pOutliner->GetEditEngine().GetText().Len())
|
|
|
|
{
|
|
|
|
ErrorBox aErrorBox( pWindow, (WinBits)WB_OK,
|
|
|
|
String(SdResId(STR_READ_DATA_ERROR)));
|
|
|
|
aErrorBox.Execute();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ULONG nParaCount = pOutliner->GetParagraphCount();
|
|
|
|
|
|
|
|
// fuer Fortschrittsanzeige: Anzahl der Ebene-0-Absaetze
|
|
|
|
USHORT nNewPages = 0;
|
|
|
|
pPara = pOutliner->GetParagraph( 0 );
|
|
|
|
while (pPara)
|
|
|
|
{
|
|
|
|
ULONG nPos = pOutliner->GetAbsPos( pPara );
|
2001-02-21 12:14:54 +00:00
|
|
|
if( pOutliner->GetDepth( (USHORT) nPos ) == 0 )
|
2000-09-18 16:07:07 +00:00
|
|
|
nNewPages++;
|
|
|
|
pPara = pOutliner->GetParagraph( ++nPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
pDocSh->SetWaitCursor( FALSE );
|
|
|
|
|
|
|
|
SfxProgress* pProgress = new SfxProgress( pDocSh, String( SdResId(STR_CREATE_PAGES)), nNewPages);
|
|
|
|
if( pProgress )
|
|
|
|
pProgress->SetState( 0, 100 );
|
|
|
|
|
|
|
|
nNewPages = 0;
|
|
|
|
|
|
|
|
pDocliner->GetUndoManager().EnterListAction(
|
|
|
|
String(SdResId(STR_UNDO_INSERT_FILE)), String() );
|
|
|
|
|
|
|
|
ULONG nSourcePos = 0;
|
|
|
|
SfxStyleSheet* pStyleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
|
|
|
|
Paragraph* pSourcePara = pOutliner->GetParagraph( 0 );
|
|
|
|
while (pSourcePara)
|
|
|
|
{
|
|
|
|
ULONG nPos = pOutliner->GetAbsPos( pSourcePara );
|
2001-02-21 12:14:54 +00:00
|
|
|
USHORT nDepth = pOutliner->GetDepth( (USHORT) nPos );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// den letzte Absatz nur uebernehmen, wenn er gefuellt ist
|
|
|
|
if (nSourcePos < nParaCount - 1 ||
|
|
|
|
pOutliner->GetText(pSourcePara).Len() > 0)
|
|
|
|
{
|
|
|
|
pDocliner->Insert( pOutliner->GetText(pSourcePara), nTargetPos, nDepth );
|
|
|
|
String aStyleSheetName( pStyleSheet->GetName() );
|
|
|
|
aStyleSheetName.Erase( aStyleSheetName.Len()-1, 1 );
|
|
|
|
aStyleSheetName += String::CreateFromInt32( nDepth );
|
|
|
|
SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool();
|
|
|
|
SfxStyleSheet* pOutlStyle = (SfxStyleSheet*) pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() );
|
|
|
|
pDocliner->SetStyleSheet( nTargetPos, pOutlStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nDepth == 0 )
|
|
|
|
{
|
|
|
|
nNewPages++;
|
|
|
|
if( pProgress )
|
|
|
|
pProgress->SetState( nNewPages );
|
|
|
|
}
|
|
|
|
|
|
|
|
pSourcePara = pOutliner->GetParagraph( ++nPos );
|
|
|
|
nTargetPos++;
|
|
|
|
nSourcePos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pDocliner->GetUndoManager().LeaveListAction();
|
|
|
|
|
|
|
|
if( pProgress )
|
|
|
|
delete pProgress;
|
|
|
|
|
|
|
|
pDocSh->SetWaitCursor( TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
delete pOutliner;
|
|
|
|
}
|
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
void FuInsertFile::InsSDDinOlMode(SfxMedium* pMedium)
|
|
|
|
{
|
2004-01-20 10:03:33 +00:00
|
|
|
OutlineView* pOlView = static_cast<OutlineView*>(pView);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Outliner-Inhalte ins SdDrawDocument uebertragen
|
|
|
|
pOlView->PrepareClose();
|
|
|
|
|
|
|
|
// einlesen wie im Zeichenmodus
|
|
|
|
if (InsSDDinDrMode(pMedium))
|
|
|
|
{
|
2004-01-20 10:03:33 +00:00
|
|
|
::Outliner* pOutliner = pOlView->GetViewByWindow(pWindow)->GetOutliner();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Benachrichtigungs-Links temporaer trennen
|
|
|
|
Link aOldParagraphInsertedHdl = pOutliner->GetParaInsertedHdl();
|
|
|
|
pOutliner->SetParaInsertedHdl( Link(NULL, NULL));
|
|
|
|
Link aOldParagraphRemovingHdl = pOutliner->GetParaRemovingHdl();
|
|
|
|
pOutliner->SetParaRemovingHdl( Link(NULL, NULL));
|
|
|
|
Link aOldDepthChangedHdl = pOutliner->GetDepthChangedHdl();
|
|
|
|
pOutliner->SetDepthChangedHdl( Link(NULL, NULL));
|
|
|
|
Link aOldBeginMovingHdl = pOutliner->GetBeginMovingHdl();
|
|
|
|
pOutliner->SetBeginMovingHdl( Link(NULL, NULL));
|
|
|
|
Link aOldEndMovingHdl = pOutliner->GetEndMovingHdl();
|
|
|
|
pOutliner->SetEndMovingHdl( Link(NULL, NULL));
|
|
|
|
|
|
|
|
Link aOldStatusEventHdl = pOutliner->GetStatusEventHdl();
|
|
|
|
pOutliner->SetStatusEventHdl(Link(NULL, NULL));
|
|
|
|
|
|
|
|
pOutliner->Clear();
|
|
|
|
pOlView->FillOutliner();
|
|
|
|
|
|
|
|
// Links wieder setzen
|
|
|
|
pOutliner->SetParaInsertedHdl(aOldParagraphInsertedHdl);
|
|
|
|
pOutliner->SetParaRemovingHdl(aOldParagraphRemovingHdl);
|
|
|
|
pOutliner->SetDepthChangedHdl(aOldDepthChangedHdl);
|
|
|
|
pOutliner->SetBeginMovingHdl(aOldBeginMovingHdl);
|
|
|
|
pOutliner->SetEndMovingHdl(aOldEndMovingHdl);
|
|
|
|
pOutliner->SetStatusEventHdl(aOldStatusEventHdl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-03-14 11:26:49 +00:00
|
|
|
void FuInsertFile::GetSupportedFilterVector( ::std::vector< String >& rFilterVector )
|
|
|
|
{
|
|
|
|
SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher();
|
|
|
|
const SfxFilter* pSearchFilter = NULL;
|
|
|
|
|
|
|
|
rFilterVector.clear();
|
|
|
|
|
|
|
|
if( ( pSearchFilter = rMatcher.GetFilter4Mime( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "text/plain" ) ) ) ) != NULL )
|
|
|
|
rFilterVector.push_back( pSearchFilter->GetMimeType() );
|
|
|
|
|
|
|
|
if( ( pSearchFilter = rMatcher.GetFilter4Mime( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "application/rtf" ) ) ) ) != NULL )
|
|
|
|
rFilterVector.push_back( pSearchFilter->GetMimeType() );
|
|
|
|
|
|
|
|
if( ( pSearchFilter = rMatcher.GetFilter4Mime( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "text/html" ) ) ) ) != NULL )
|
|
|
|
rFilterVector.push_back( pSearchFilter->GetMimeType() );
|
|
|
|
}
|
2004-01-20 10:03:33 +00:00
|
|
|
|
|
|
|
} // end of namespace sd
|