2000-09-18 11:07:07 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 14:20:36 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 14:20:36 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 14:20:36 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 14:20:36 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 14:20:36 -05:00
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 14:20:36 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 12:51:00 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sd.hxx"
|
|
|
|
|
2004-01-20 04:03:33 -06:00
|
|
|
#include "fuinsfil.hxx"
|
2000-09-18 11:07:07 -05:00
|
|
|
#include <vcl/wrkwin.hxx>
|
|
|
|
#include <sfx2/progress.hxx>
|
2010-01-08 11:32:51 -06:00
|
|
|
#include <editeng/outliner.hxx>
|
2000-09-18 11:07:07 -05:00
|
|
|
#ifndef _EDITENG_HXX
|
2010-01-08 11:32:51 -06:00
|
|
|
#include <editeng/editeng.hxx>
|
2000-09-18 11:07:07 -05:00
|
|
|
#endif
|
2009-10-15 17:05:16 -05:00
|
|
|
#include <svl/stritem.hxx>
|
2000-09-18 11:07:07 -05:00
|
|
|
#include <sfx2/request.hxx>
|
|
|
|
#include <sfx2/app.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <sfx2/printer.hxx>
|
|
|
|
#include <svx/svdorect.hxx>
|
|
|
|
#include <svx/svdundo.hxx>
|
|
|
|
#include <svx/svdoutl.hxx>
|
2001-05-28 01:40:41 -05:00
|
|
|
#include <sfx2/filedlghelper.hxx>
|
2000-09-18 11:07:07 -05:00
|
|
|
#include <sot/formats.hxx>
|
2009-10-15 17:05:16 -05:00
|
|
|
#include <svl/urihelper.hxx>
|
2010-01-08 11:32:51 -06:00
|
|
|
#include <editeng/forbiddencharacterstable.hxx>
|
2002-03-14 05:26:49 -06:00
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#include <sfx2/docfile.hxx>
|
|
|
|
#include <sfx2/docfilt.hxx>
|
|
|
|
#include <sfx2/fcontnr.hxx>
|
2000-09-18 11:07:07 -05:00
|
|
|
#include <svx/svdpagv.hxx>
|
2002-03-14 05:26:49 -06:00
|
|
|
#include <svx/dialogs.hrc>
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
#include "sdresid.hxx"
|
|
|
|
#include "drawdoc.hxx"
|
2004-01-20 04:03:33 -06:00
|
|
|
#include "Window.hxx"
|
|
|
|
#include "View.hxx"
|
2000-09-18 11:07:07 -05:00
|
|
|
#include "strings.hrc"
|
|
|
|
#include "stlpool.hxx"
|
|
|
|
#include "glob.hrc"
|
|
|
|
#include "sdpage.hxx"
|
|
|
|
#include "strmname.h"
|
|
|
|
#include "strings.hrc"
|
2004-01-20 04:03:33 -06:00
|
|
|
#include "DrawViewShell.hxx"
|
|
|
|
#include "OutlineViewShell.hxx"
|
|
|
|
#include "DrawDocShell.hxx"
|
2005-01-18 08:16:48 -06:00
|
|
|
#include "GraphicDocShell.hxx"
|
2000-09-18 11:07:07 -05:00
|
|
|
#include "app.hrc"
|
|
|
|
#include "unmovss.hxx"
|
2004-01-20 04:03:33 -06:00
|
|
|
#include "Outliner.hxx"
|
2006-12-12 10:18:47 -06:00
|
|
|
#include "sdabstdlg.hxx"
|
2005-12-14 09:59:21 -06:00
|
|
|
|
|
|
|
using ::rtl::OUString;
|
2001-05-28 01:40:41 -05:00
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::uno;
|
2001-06-15 12:08:04 -05:00
|
|
|
using namespace ::com::sun::star::ui::dialogs;
|
2001-05-28 01:40:41 -05:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2004-01-20 04:03:33 -06:00
|
|
|
namespace sd {
|
2000-09-18 11:07:07 -05: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 04:03:33 -06:00
|
|
|
FuInsertFile::FuInsertFile (
|
|
|
|
ViewShell* pViewSh,
|
|
|
|
::sd::Window* pWin,
|
|
|
|
::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc,
|
|
|
|
SfxRequest& rReq)
|
|
|
|
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
|
2005-12-14 09:59:21 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionReference FuInsertFile::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
|
|
|
{
|
|
|
|
FunctionReference xFunc( new FuInsertFile( pViewSh, pWin, pView, pDoc, rReq ) );
|
|
|
|
xFunc->DoExecute(rReq);
|
|
|
|
return xFunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuInsertFile::DoExecute( SfxRequest& rReq )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2001-12-12 05:48:35 -06:00
|
|
|
SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher();
|
2002-03-14 05:26:49 -06:00
|
|
|
::std::vector< String > aFilterVector;
|
2001-12-12 05:48:35 -06:00
|
|
|
const SfxItemSet* pArgs = rReq.GetArgs ();
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2002-03-14 05:26:49 -06:00
|
|
|
FuInsertFile::GetSupportedFilterVector( aFilterVector );
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
if (!pArgs)
|
|
|
|
{
|
2001-12-12 05:48:35 -06:00
|
|
|
sfx2::FileDialogHelper aFileDialog( WB_OPEN | SFXWB_INSERT | WB_STDMODAL );
|
|
|
|
Reference< XFilePicker > xFilePicker( aFileDialog.GetFilePicker(), UNO_QUERY );
|
2001-05-28 01:40:41 -05:00
|
|
|
Reference< XFilterManager > xFilterManager( xFilePicker, UNO_QUERY );
|
2005-01-18 08:16:48 -06:00
|
|
|
String aOwnCont;
|
|
|
|
String aOtherCont;
|
2001-12-12 05:48:35 -06:00
|
|
|
const SfxFilter* pFilter = NULL;
|
2001-02-21 06:14:54 -06:00
|
|
|
|
2001-05-28 01:40:41 -05:00
|
|
|
aFileDialog.SetTitle( String( SdResId(STR_DLG_INSERT_PAGES_FROM_FILE ) ) );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2006-12-12 10:18:47 -06:00
|
|
|
if( mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
|
2005-01-18 08:16:48 -06:00
|
|
|
{
|
|
|
|
aOwnCont = String( RTL_CONSTASCII_USTRINGPARAM( "simpress" ) );
|
|
|
|
aOtherCont = String( RTL_CONSTASCII_USTRINGPARAM( "sdraw" ) ) ;
|
|
|
|
}
|
2000-09-18 11:07:07 -05:00
|
|
|
else
|
2005-01-18 08:16:48 -06:00
|
|
|
{
|
|
|
|
aOtherCont = String( RTL_CONSTASCII_USTRINGPARAM( "simpress" ) );
|
|
|
|
aOwnCont = String( RTL_CONSTASCII_USTRINGPARAM( "sdraw" ) ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
SfxFilterMatcher aMatch( aOwnCont );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2001-06-27 11:48:47 -05:00
|
|
|
if( xFilterManager.is() )
|
2000-12-14 05:02:47 -06:00
|
|
|
{
|
2001-12-12 05:48:35 -06:00
|
|
|
// Get filter for current format
|
2001-06-27 11:48:47 -05:00
|
|
|
try
|
|
|
|
{
|
2001-12-12 05:48:35 -06:00
|
|
|
String aExt;
|
|
|
|
String aAllSpec( SdResId( STR_ALL_FILES ) );
|
|
|
|
|
2001-07-23 06:15:41 -05:00
|
|
|
xFilterManager->appendFilter( aAllSpec, UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "*.*" ) ) );
|
|
|
|
xFilterManager->setCurrentFilter( aAllSpec ); // set default-filter (<All>)
|
|
|
|
|
2001-12-12 05:48:35 -06:00
|
|
|
// Get main filter
|
2005-01-18 08:16:48 -06:00
|
|
|
pFilter = SfxFilter::GetDefaultFilterFromFactory( aOwnCont );
|
2001-06-27 11:48:47 -05:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-12-14 05:02:47 -06:00
|
|
|
|
2005-01-18 08:16:48 -06:00
|
|
|
// get cross filter
|
|
|
|
pFilter = SfxFilter::GetDefaultFilterFromFactory( aOtherCont );
|
|
|
|
if( pFilter )
|
|
|
|
{
|
|
|
|
pFilter = aMatch.GetFilter4Extension( pFilter->GetDefaultExtension() );
|
|
|
|
if ( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// get femplate filter
|
2006-12-12 10:18:47 -06:00
|
|
|
if( mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
|
2005-01-18 08:16:48 -06:00
|
|
|
pFilter = DrawDocShell::Factory().GetTemplateFilter();
|
2001-06-27 11:48:47 -05:00
|
|
|
else
|
2005-01-18 08:16:48 -06:00
|
|
|
pFilter = GraphicDocShell::Factory().GetTemplateFilter();
|
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2005-01-18 08:16:48 -06:00
|
|
|
// get Powerpoint filter
|
|
|
|
aExt = UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( ".ppt" ) );
|
2003-09-19 02:17:20 -05:00
|
|
|
pFilter = aMatch.GetFilter4Extension( aExt );
|
2001-06-27 11:48:47 -05:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2005-01-18 08:16:48 -06:00
|
|
|
// Get other draw/impress filters
|
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARIMPRESS_60, SFX_FILTER_IMPORT, SFX_FILTER_TEMPLATEPATH );
|
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
|
|
|
|
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARIMPRESS_60, SFX_FILTER_TEMPLATEPATH );
|
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
|
|
|
|
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_60, SFX_FILTER_IMPORT, SFX_FILTER_TEMPLATEPATH );
|
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
|
|
|
|
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_60, SFX_FILTER_TEMPLATEPATH );
|
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
|
|
|
|
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARIMPRESS_50, SFX_FILTER_IMPORT, SFX_FILTER_TEMPLATEPATH );
|
2001-06-27 11:48:47 -05:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2001-12-12 05:48:35 -06:00
|
|
|
|
2003-09-19 02:17:20 -05:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARIMPRESS_50, SFX_FILTER_TEMPLATEPATH );
|
2001-06-27 11:48:47 -05:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2005-01-18 08:16:48 -06:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_50, SFX_FILTER_IMPORT, SFX_FILTER_TEMPLATEPATH );
|
2001-06-27 11:48:47 -05:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2001-12-12 05:48:35 -06:00
|
|
|
|
2003-09-19 02:17:20 -05:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_50, SFX_FILTER_TEMPLATEPATH );
|
2001-06-27 11:48:47 -05:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2005-01-18 08:16:48 -06:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_40, SFX_FILTER_IMPORT, SFX_FILTER_TEMPLATEPATH );
|
2001-06-27 11:48:47 -05:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2001-12-12 05:48:35 -06:00
|
|
|
|
2003-09-19 02:17:20 -05:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_40, SFX_FILTER_TEMPLATEPATH );
|
2001-06-27 11:48:47 -05:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2005-01-18 08:16:48 -06:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW, SFX_FILTER_IMPORT, SFX_FILTER_TEMPLATEPATH );
|
2001-06-27 11:48:47 -05:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2001-12-12 05:48:35 -06:00
|
|
|
|
2003-09-19 02:17:20 -05:00
|
|
|
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW, SFX_FILTER_TEMPLATEPATH );
|
2001-06-27 11:48:47 -05:00
|
|
|
if( pFilter )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2002-03-14 05:26:49 -06:00
|
|
|
// add additional supported filters
|
|
|
|
::std::vector< String >::const_iterator aIter( aFilterVector.begin() );
|
2001-12-12 05:48:35 -06:00
|
|
|
|
2002-03-14 05:26:49 -06:00
|
|
|
while( aIter != aFilterVector.end() )
|
2001-12-12 05:48:35 -06:00
|
|
|
{
|
2002-03-14 05:26:49 -06:00
|
|
|
if( ( pFilter = rMatcher.GetFilter4Mime( *aIter ) ) != NULL )
|
|
|
|
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
|
2001-12-12 05:48:35 -06:00
|
|
|
|
2002-03-14 05:26:49 -06:00
|
|
|
++aIter;
|
2001-12-12 05:48:35 -06:00
|
|
|
}
|
2001-06-27 11:48:47 -05:00
|
|
|
}
|
|
|
|
catch(IllegalArgumentException)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2001-05-28 01:40:41 -05:00
|
|
|
if( aFileDialog.Execute() != ERRCODE_NONE )
|
2001-02-21 06:14:54 -06:00
|
|
|
return;
|
2000-09-18 11:07:07 -05:00
|
|
|
else
|
|
|
|
{
|
2001-05-28 01:40:41 -05:00
|
|
|
aFilterName = aFileDialog.GetCurrentFilter();
|
2001-02-21 06:14:54 -06:00
|
|
|
aFile = aFileDialog.GetPath();
|
2000-09-18 11:07:07 -05: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 06:14:54 -06:00
|
|
|
|
|
|
|
if( pFilterName )
|
2000-09-18 11:07:07 -05:00
|
|
|
aFilterName = pFilterName->GetValue ();
|
|
|
|
}
|
|
|
|
|
2006-12-12 10:18:47 -06:00
|
|
|
mpDocSh->SetWaitCursor( TRUE );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2001-02-21 06:14:54 -06:00
|
|
|
SfxMedium* pMedium = new SfxMedium( aFile, STREAM_READ | STREAM_NOCREATE, FALSE );
|
|
|
|
const SfxFilter* pFilter = NULL;
|
2006-12-12 10:18:47 -06:00
|
|
|
|
|
|
|
SFX_APP()->GetFilterMatcher().GuessFilter( *pMedium, &pFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE );
|
|
|
|
|
|
|
|
BOOL bDrawMode = mpViewShell && mpViewShell->ISA(DrawViewShell);
|
2002-04-09 02:05:15 -05:00
|
|
|
BOOL bInserted = FALSE;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2001-02-21 06:14:54 -06:00
|
|
|
if( pFilter )
|
2002-02-08 04:19:15 -06:00
|
|
|
{
|
2001-02-21 06:14:54 -06:00
|
|
|
pMedium->SetFilter( pFilter );
|
2002-02-08 04:19:15 -06:00
|
|
|
aFilterName = pFilter->GetFilterName();
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2005-01-18 08:16:48 -06:00
|
|
|
if( pMedium->IsStorage() || ( pMedium->GetInStream() && SotStorage::IsStorageFile( pMedium->GetInStream() ) ) )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2005-01-18 08:16:48 -06:00
|
|
|
if ( pFilter->GetServiceName().EqualsAscii( "com.sun.star.presentation.PresentationDocument" ) ||
|
|
|
|
pFilter->GetServiceName().EqualsAscii( "com.sun.star.drawing.DrawingDocument" ) )
|
2002-04-09 02:05:15 -05:00
|
|
|
{
|
2005-01-18 08:16:48 -06:00
|
|
|
// Draw, Impress or PowerPoint document
|
|
|
|
// the ownership of the Medium is transferred
|
2002-04-09 02:05:15 -05:00
|
|
|
if( bDrawMode )
|
|
|
|
InsSDDinDrMode( pMedium );
|
|
|
|
else
|
|
|
|
InsSDDinOlMode( pMedium );
|
|
|
|
|
2005-01-18 08:16:48 -06:00
|
|
|
// don't delete Medium here, ownership of pMedium has changed in this case
|
2002-04-09 02:05:15 -05:00
|
|
|
bInserted = TRUE;
|
|
|
|
}
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
2005-01-18 08:16:48 -06:00
|
|
|
else
|
2004-11-17 08:14:05 -06:00
|
|
|
{
|
2005-01-18 08:16:48 -06:00
|
|
|
BOOL bFound = ( ::std::find( aFilterVector.begin(), aFilterVector.end(), pFilter->GetMimeType() ) != aFilterVector.end() );
|
|
|
|
if( !bFound &&
|
|
|
|
( aFilterName.SearchAscii( "Text" ) != STRING_NOTFOUND ||
|
|
|
|
aFilterName.SearchAscii( "Rich" ) != STRING_NOTFOUND ||
|
|
|
|
aFilterName.SearchAscii( "RTF" ) != STRING_NOTFOUND ||
|
|
|
|
aFilterName.SearchAscii( "HTML" ) != STRING_NOTFOUND ) )
|
|
|
|
{
|
|
|
|
bFound = TRUE;
|
|
|
|
}
|
2004-11-17 08:14:05 -06:00
|
|
|
|
2005-01-18 08:16:48 -06:00
|
|
|
if( bFound )
|
|
|
|
{
|
|
|
|
if( bDrawMode )
|
|
|
|
InsTextOrRTFinDrMode(pMedium);
|
|
|
|
else
|
|
|
|
InsTextOrRTFinOlMode(pMedium);
|
2002-04-09 02:05:15 -05:00
|
|
|
|
2005-01-18 08:16:48 -06:00
|
|
|
bInserted = TRUE;
|
|
|
|
delete pMedium;
|
|
|
|
}
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-12 10:18:47 -06:00
|
|
|
mpDocSh->SetWaitCursor( FALSE );
|
2002-04-09 02:05:15 -05:00
|
|
|
|
|
|
|
if( !bInserted )
|
|
|
|
{
|
2006-12-12 10:18:47 -06:00
|
|
|
ErrorBox aErrorBox( mpWindow, WB_OK, String( SdResId( STR_READ_DATA_ERROR ) ) );
|
2002-04-09 02:05:15 -05:00
|
|
|
aErrorBox.Execute();
|
2005-01-18 08:16:48 -06:00
|
|
|
delete pMedium;
|
2002-04-09 02:05:15 -05:00
|
|
|
}
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
2002-03-14 05:26:49 -06:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
BOOL FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
|
|
|
|
{
|
|
|
|
BOOL bOK = FALSE;
|
|
|
|
|
|
|
|
// Liste mit Seitennamen (wenn NULL, dann alle Seiten)
|
|
|
|
List* pBookmarkList = NULL;
|
|
|
|
|
2006-12-12 10:18:47 -06:00
|
|
|
mpDocSh->SetWaitCursor( FALSE );
|
2005-01-18 08:16:48 -06:00
|
|
|
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
|
2006-12-12 10:18:47 -06:00
|
|
|
AbstractSdInsertPagesObjsDlg* pDlg = pFact ? pFact->CreateSdInsertPagesObjsDlg( NULL, mpDoc, pMedium, aFile ) : 0;
|
|
|
|
|
|
|
|
if( !pDlg )
|
|
|
|
return FALSE;
|
2005-01-18 08:16:48 -06:00
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
// Ev. wird eine QueryBox geoeffnet ("Links aktualisieren?"),
|
|
|
|
// daher wird der Dialog der aktuelle DefModalDialogParent
|
2004-01-20 04:03:33 -06:00
|
|
|
::Window* pDefParent = GetpApp()->GetDefDialogParent();
|
2005-01-18 08:16:48 -06:00
|
|
|
GetpApp()->SetDefDialogParent(pDlg->GetWindow());
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
USHORT nRet = pDlg->Execute();
|
|
|
|
|
|
|
|
GetpApp()->SetDefDialogParent(pDefParent);
|
|
|
|
|
2006-12-12 10:18:47 -06:00
|
|
|
mpDocSh->SetWaitCursor( TRUE );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if( nRet == RET_OK )
|
|
|
|
{
|
|
|
|
// Zuerst Seiten einfuegen
|
|
|
|
pBookmarkList = pDlg->GetList( 1 ); // Seiten
|
|
|
|
BOOL bLink = pDlg->IsLink();
|
|
|
|
BOOL bReplace = FALSE;
|
|
|
|
SdPage* pPage = NULL;
|
2006-12-12 10:18:47 -06:00
|
|
|
::sd::View* pView = mpViewShell->GetView();
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2004-01-20 04:03:33 -06:00
|
|
|
if (pView->ISA(OutlineView))
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2004-01-20 04:03:33 -06:00
|
|
|
pPage = static_cast<OutlineView*>(pView)->GetActualPage();
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-11-14 07:29:27 -06:00
|
|
|
pPage = static_cast<SdPage*>(pView->GetSdrPageView()->GetPage());
|
2000-09-18 11:07:07 -05: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
|
2006-12-12 10:18:47 -06:00
|
|
|
bNameOK = mpView->GetExchangeList( pExchangeList, pBookmarkList, 0 );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if( bNameOK )
|
2006-12-12 10:18:47 -06:00
|
|
|
bOK = mpDoc->InsertBookmarkAsPage( pBookmarkList, pExchangeList,
|
2000-09-18 11:07:07 -05:00
|
|
|
bLink, bReplace, nPos,
|
2002-11-19 11:02:28 -06:00
|
|
|
FALSE, NULL, TRUE, TRUE, FALSE );
|
2000-09-18 11:07:07 -05: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.)
|
2006-12-12 10:18:47 -06:00
|
|
|
bNameOK = mpView->GetExchangeList( pExchangeList, pBookmarkList, 1 );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if( bNameOK )
|
2006-12-12 10:18:47 -06:00
|
|
|
bOK = mpDoc->InsertBookmarkAsObject( pBookmarkList, pExchangeList,
|
2000-09-18 11:07:07 -05:00
|
|
|
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() )
|
2009-01-21 08:22:27 -06:00
|
|
|
mpDoc->RemoveUnnecessaryMasterPages();
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
delete pDlg;
|
|
|
|
|
|
|
|
return (bOK);
|
|
|
|
}
|
|
|
|
|
2002-03-14 05:26:49 -06:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
|
|
|
|
{
|
2006-12-12 10:18:47 -06:00
|
|
|
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
|
|
|
|
AbstractSdInsertPagesObjsDlg* pDlg = pFact ? pFact->CreateSdInsertPagesObjsDlg(NULL, mpDoc, NULL, aFile ) : 0;
|
|
|
|
if( !pDlg )
|
|
|
|
return;
|
|
|
|
|
|
|
|
mpDocSh->SetWaitCursor( FALSE );
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
USHORT nRet = pDlg->Execute();
|
2006-12-12 10:18:47 -06:00
|
|
|
mpDocSh->SetWaitCursor( TRUE );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if( nRet == RET_OK )
|
|
|
|
{
|
|
|
|
// gewaehltes Dateiformat: Text oder RTF oder HTML (Default ist Text)
|
|
|
|
USHORT nFormat = EE_FORMAT_TEXT;
|
2001-01-24 05:17:32 -06:00
|
|
|
|
2002-02-08 04:19:15 -06:00
|
|
|
if( aFilterName.SearchAscii( "Rich") != STRING_NOTFOUND )
|
2000-09-18 11:07:07 -05:00
|
|
|
nFormat = EE_FORMAT_RTF;
|
2001-01-24 05:17:32 -06:00
|
|
|
else if( aFilterName.SearchAscii( "HTML" ) != STRING_NOTFOUND )
|
2000-09-18 11:07:07 -05: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
|
2006-12-12 10:18:47 -06:00
|
|
|
// SfxItemPool* pPool = mpDoc->GetDrawOutliner().GetEmptyItemSet().GetPool();
|
|
|
|
SdrOutliner* pOutliner = new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT );
|
|
|
|
// pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)mpDoc->GetStyleSheetPool());
|
2002-11-06 05:50:26 -06:00
|
|
|
// pOutliner->SetEditTextObjectPool(pPool);
|
2006-12-12 10:18:47 -06:00
|
|
|
// pOutliner->SetForbiddenCharsTable( mpDoc->GetForbiddenCharsTable() );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
// Referenz-Device setzen
|
2006-12-12 10:18:47 -06:00
|
|
|
pOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2006-12-12 10:18:47 -06:00
|
|
|
SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
|
2000-09-18 11:07:07 -05:00
|
|
|
aLayoutName = pPage->GetLayoutName();
|
|
|
|
aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
|
|
|
|
|
|
|
|
pOutliner->SetPaperSize(pPage->GetSize());
|
|
|
|
|
|
|
|
SvStream* pStream = pMedium->GetInStream();
|
|
|
|
DBG_ASSERT( pStream, "Kein InStream!" );
|
2001-04-20 06:11:15 -05:00
|
|
|
pStream->Seek( 0 );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2006-12-12 10:18:47 -06:00
|
|
|
ULONG nErr = pOutliner->Read( *pStream, pMedium->GetBaseURL(), nFormat, mpDocSh->GetHeaderAttributes() );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if (nErr || !pOutliner->GetEditEngine().GetText().Len())
|
|
|
|
{
|
2006-12-12 10:18:47 -06:00
|
|
|
ErrorBox aErrorBox( mpWindow, (WinBits)WB_OK,
|
2000-09-18 11:07:07 -05:00
|
|
|
String(SdResId(STR_READ_DATA_ERROR)));
|
|
|
|
aErrorBox.Execute();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// ist es eine Masterpage?
|
2006-12-12 10:18:47 -06:00
|
|
|
if (static_cast<DrawViewShell*>(mpViewShell)->GetEditMode() == EM_MASTERPAGE &&
|
2000-09-18 11:07:07 -05:00
|
|
|
!pPage->IsMasterPage())
|
|
|
|
{
|
2004-07-12 09:02:59 -05:00
|
|
|
pPage = (SdPage*)(&(pPage->TRG_GetMasterPage()));
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
DBG_ASSERT(pPage, "Seite nicht gefunden");
|
|
|
|
|
|
|
|
// wenn gerade editiert wird, in dieses Textobjekt einfliessen lassen
|
2006-12-12 10:18:47 -06:00
|
|
|
OutlinerView* pOutlinerView = mpView->GetTextEditOutlinerView();
|
2000-09-18 11:07:07 -05:00
|
|
|
if( pOutlinerView )
|
|
|
|
{
|
2006-12-12 10:18:47 -06:00
|
|
|
SdrObject* pObj = mpView->GetTextEditObject();
|
2000-09-18 11:07:07 -05:00
|
|
|
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 06:14:54 -06:00
|
|
|
pOutliner->QuickDelete( ESelection( 0, (USHORT) nLen, 1, 0 ) );
|
|
|
|
pOutliner->QuickInsertLineBreak( ESelection( 0, (USHORT) nLen, 0, (USHORT) nLen ) );
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OutlinerParaObject* pOPO = pOutliner->CreateParaObject();
|
|
|
|
|
|
|
|
if (pOutlinerView)
|
|
|
|
{
|
|
|
|
pOutlinerView->InsertText(*pOPO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SdrRectObj* pTO = new SdrRectObj(OBJ_TEXT);
|
|
|
|
pTO->SetOutlinerParaObject(pOPO);
|
2001-04-02 08:48:19 -05:00
|
|
|
|
2009-06-04 11:21:29 -05:00
|
|
|
const bool bUndo = mpView->IsUndoEnabled();
|
|
|
|
if( bUndo )
|
|
|
|
mpView->BegUndo(String(SdResId(STR_UNDO_INSERT_TEXTFRAME)));
|
2001-04-02 08:48:19 -05:00
|
|
|
pPage->InsertObject(pTO);
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
// koennte groesser sein als die max. erlaubte Groesse:
|
|
|
|
// falls noetig, die Objektgroesse begrenzen
|
2001-04-02 08:48:19 -05:00
|
|
|
Size aSize(pOutliner->CalcTextSize());
|
2006-12-12 10:18:47 -06:00
|
|
|
Size aMaxSize = mpDoc->GetMaxObjSize();
|
2000-09-18 11:07:07 -05:00
|
|
|
aSize.Height() = Min(aSize.Height(), aMaxSize.Height());
|
|
|
|
aSize.Width() = Min(aSize.Width(), aMaxSize.Width());
|
2006-12-12 10:18:47 -06:00
|
|
|
aSize = mpWindow->LogicToPixel(aSize);
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
// in der Mitte des Fensters absetzen
|
2006-12-12 10:18:47 -06:00
|
|
|
Size aTemp(mpWindow->GetOutputSizePixel());
|
2000-09-18 11:07:07 -05:00
|
|
|
Point aPos(aTemp.Width() / 2, aTemp.Height() / 2);
|
|
|
|
aPos.X() -= aSize.Width() / 2;
|
|
|
|
aPos.Y() -= aSize.Height() / 2;
|
2006-12-12 10:18:47 -06:00
|
|
|
aSize = mpWindow->PixelToLogic(aSize);
|
|
|
|
aPos = mpWindow->PixelToLogic(aPos);
|
2000-09-18 11:07:07 -05:00
|
|
|
pTO->SetLogicRect(Rectangle(aPos, aSize));
|
|
|
|
|
|
|
|
if (pDlg->IsLink())
|
|
|
|
{
|
|
|
|
pTO->SetTextLink(aFile, aFilterName, gsl_getSystemTextEncoding() );
|
|
|
|
}
|
|
|
|
|
2009-06-04 11:21:29 -05:00
|
|
|
if( bUndo )
|
|
|
|
{
|
|
|
|
mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoInsertObject(*pTO));
|
|
|
|
mpView->EndUndo();
|
|
|
|
}
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
delete pOutliner;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete pDlg;
|
|
|
|
}
|
|
|
|
|
2002-03-14 05:26:49 -06:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium)
|
|
|
|
{
|
|
|
|
// gewaehltes Dateiformat: Text oder RTF oder HTML (Default ist Text)
|
|
|
|
USHORT nFormat = EE_FORMAT_TEXT;
|
2001-01-24 05:17:32 -06:00
|
|
|
|
2002-02-08 04:19:15 -06:00
|
|
|
if( aFilterName.SearchAscii( "Rich") != STRING_NOTFOUND )
|
2000-09-18 11:07:07 -05:00
|
|
|
nFormat = EE_FORMAT_RTF;
|
2001-01-24 05:17:32 -06:00
|
|
|
else if( aFilterName.SearchAscii( "HTML" ) != STRING_NOTFOUND )
|
2000-09-18 11:07:07 -05:00
|
|
|
nFormat = EE_FORMAT_HTML;
|
|
|
|
|
2006-12-12 10:18:47 -06:00
|
|
|
::Outliner* pDocliner = static_cast<OutlineView*>(mpView)->GetOutliner();
|
2000-09-18 11:07:07 -05:00
|
|
|
List* pList = pDocliner->GetView(0)->CreateSelectionList();
|
|
|
|
Paragraph* pPara = (Paragraph*)pList->First();
|
|
|
|
|
|
|
|
// wo soll eingefuegt werden?
|
2008-07-30 08:11:43 -05:00
|
|
|
while( !pDocliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
|
2000-09-18 11:07:07 -05: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 );
|
2008-07-30 08:11:43 -05:00
|
|
|
if ( pDocliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
|
2000-09-18 11:07:07 -05:00
|
|
|
nPage++;
|
|
|
|
pPara = pDocliner->GetParagraph( nPos - 1 );
|
|
|
|
}
|
2006-12-12 10:18:47 -06:00
|
|
|
SdPage* pPage = mpDoc->GetSdPage(nPage, PK_STANDARD);
|
2000-09-18 11:07:07 -05:00
|
|
|
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
|
2006-12-12 10:18:47 -06:00
|
|
|
::Outliner* pOutliner = new ::Outliner( &mpDoc->GetItemPool(), OUTLINERMODE_OUTLINEOBJECT );
|
|
|
|
pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)mpDoc->GetStyleSheetPool());
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
// Referenz-Device setzen
|
2006-12-12 10:18:47 -06:00
|
|
|
pOutliner->SetRefDevice(SD_MOD()->GetRefDevice( *mpDocSh ));
|
2000-09-18 11:07:07 -05:00
|
|
|
pOutliner->SetPaperSize(Size(0x7fffffff, 0x7fffffff));
|
|
|
|
|
|
|
|
SvStream* pStream = pMedium->GetInStream();
|
|
|
|
DBG_ASSERT( pStream, "Kein InStream!" );
|
2001-04-20 06:11:15 -05:00
|
|
|
pStream->Seek( 0 );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2006-12-12 10:18:47 -06:00
|
|
|
ULONG nErr = pOutliner->Read(*pStream, pMedium->GetBaseURL(), nFormat, mpDocSh->GetHeaderAttributes());
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if (nErr || !pOutliner->GetEditEngine().GetText().Len())
|
|
|
|
{
|
2006-12-12 10:18:47 -06:00
|
|
|
ErrorBox aErrorBox( mpWindow, (WinBits)WB_OK,
|
2000-09-18 11:07:07 -05:00
|
|
|
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 );
|
2008-07-30 08:11:43 -05:00
|
|
|
if( pOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
|
2000-09-18 11:07:07 -05:00
|
|
|
nNewPages++;
|
|
|
|
pPara = pOutliner->GetParagraph( ++nPos );
|
|
|
|
}
|
|
|
|
|
2006-12-12 10:18:47 -06:00
|
|
|
mpDocSh->SetWaitCursor( FALSE );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2006-12-12 10:18:47 -06:00
|
|
|
SfxProgress* pProgress = new SfxProgress( mpDocSh, String( SdResId(STR_CREATE_PAGES)), nNewPages);
|
2000-09-18 11:07:07 -05:00
|
|
|
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 );
|
2008-06-06 06:04:15 -05:00
|
|
|
sal_Int16 nDepth = pOutliner->GetDepth( (USHORT) nPos );
|
2000-09-18 11:07:07 -05: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 );
|
2008-06-06 06:04:15 -05:00
|
|
|
aStyleSheetName += String::CreateFromInt32( nDepth <= 0 ? 1 : nDepth+1 );
|
2006-12-12 10:18:47 -06:00
|
|
|
SfxStyleSheetBasePool* pStylePool = mpDoc->GetStyleSheetPool();
|
2000-09-18 11:07:07 -05:00
|
|
|
SfxStyleSheet* pOutlStyle = (SfxStyleSheet*) pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() );
|
|
|
|
pDocliner->SetStyleSheet( nTargetPos, pOutlStyle );
|
|
|
|
}
|
|
|
|
|
2008-07-30 08:11:43 -05:00
|
|
|
if( pDocliner->HasParaFlag( pSourcePara, PARAFLAG_ISPAGE ) )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
|
|
|
nNewPages++;
|
|
|
|
if( pProgress )
|
|
|
|
pProgress->SetState( nNewPages );
|
|
|
|
}
|
|
|
|
|
|
|
|
pSourcePara = pOutliner->GetParagraph( ++nPos );
|
|
|
|
nTargetPos++;
|
|
|
|
nSourcePos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pDocliner->GetUndoManager().LeaveListAction();
|
|
|
|
|
|
|
|
if( pProgress )
|
|
|
|
delete pProgress;
|
|
|
|
|
2006-12-12 10:18:47 -06:00
|
|
|
mpDocSh->SetWaitCursor( TRUE );
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
delete pOutliner;
|
|
|
|
}
|
|
|
|
|
2002-03-14 05:26:49 -06:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2005-01-18 08:16:48 -06:00
|
|
|
BOOL FuInsertFile::InsSDDinOlMode(SfxMedium* pMedium)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2006-12-12 10:18:47 -06:00
|
|
|
OutlineView* pOlView = static_cast<OutlineView*>(mpView);
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
// Outliner-Inhalte ins SdDrawDocument uebertragen
|
|
|
|
pOlView->PrepareClose();
|
|
|
|
|
|
|
|
// einlesen wie im Zeichenmodus
|
|
|
|
if (InsSDDinDrMode(pMedium))
|
|
|
|
{
|
2006-12-12 10:18:47 -06:00
|
|
|
::Outliner* pOutliner = pOlView->GetViewByWindow(mpWindow)->GetOutliner();
|
2000-09-18 11:07:07 -05: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);
|
2005-01-18 08:16:48 -06:00
|
|
|
|
|
|
|
return TRUE;
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
2005-01-18 08:16:48 -06:00
|
|
|
else
|
|
|
|
return FALSE;
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
2002-03-14 05:26:49 -06:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2002-03-14 05:26:49 -06: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 04:03:33 -06:00
|
|
|
|
|
|
|
} // end of namespace sd
|