office-gobmx/sd/source/ui/func/fuinsfil.cxx

825 lines
31 KiB
C++
Raw Normal View History

2000-09-18 11:07:07 -05:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 11:07:07 -05:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 11:07:07 -05:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 11:07:07 -05:00
*
* This file is part of OpenOffice.org.
2000-09-18 11:07:07 -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
*
* 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
*
* 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
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx"
#include "fuinsfil.hxx"
2000-09-18 11:07:07 -05:00
#include <vcl/wrkwin.hxx>
#include <sfx2/progress.hxx>
#include <editeng/outliner.hxx>
2000-09-18 11:07:07 -05:00
#ifndef _EDITENG_HXX
#include <editeng/editeng.hxx>
2000-09-18 11:07:07 -05:00
#endif
#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>
#include <sfx2/filedlghelper.hxx>
2000-09-18 11:07:07 -05:00
#include <sot/formats.hxx>
#include <svl/urihelper.hxx>
#include <editeng/forbiddencharacterstable.hxx>
#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>
#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"
#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"
#include "DrawViewShell.hxx"
#include "OutlineViewShell.hxx"
#include "DrawDocShell.hxx"
#include "GraphicDocShell.hxx"
2000-09-18 11:07:07 -05:00
#include "app.hrc"
#include "unmovss.hxx"
#include "Outliner.hxx"
#include "sdabstdlg.hxx"
using ::rtl::OUString;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star;
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
|*
\************************************************************************/
FuInsertFile::FuInsertFile (
ViewShell* pViewSh,
::sd::Window* pWin,
::sd::View* pView,
SdDrawDocument* pDoc,
SfxRequest& rReq)
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
{
}
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
{
SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher();
::std::vector< String > aFilterVector;
const SfxItemSet* pArgs = rReq.GetArgs ();
2000-09-18 11:07:07 -05:00
FuInsertFile::GetSupportedFilterVector( aFilterVector );
2000-09-18 11:07:07 -05:00
if (!pArgs)
{
sfx2::FileDialogHelper aFileDialog( WB_OPEN | SFXWB_INSERT | WB_STDMODAL );
Reference< XFilePicker > xFilePicker( aFileDialog.GetFilePicker(), UNO_QUERY );
Reference< XFilterManager > xFilterManager( xFilePicker, UNO_QUERY );
String aOwnCont;
String aOtherCont;
const SfxFilter* pFilter = NULL;
aFileDialog.SetTitle( String( SdResId(STR_DLG_INSERT_PAGES_FROM_FILE ) ) );
2000-09-18 11:07:07 -05:00
if( mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
{
aOwnCont = String( RTL_CONSTASCII_USTRINGPARAM( "simpress" ) );
aOtherCont = String( RTL_CONSTASCII_USTRINGPARAM( "sdraw" ) ) ;
}
2000-09-18 11:07:07 -05:00
else
{
aOtherCont = String( RTL_CONSTASCII_USTRINGPARAM( "simpress" ) );
aOwnCont = String( RTL_CONSTASCII_USTRINGPARAM( "sdraw" ) ) ;
}
SfxFilterMatcher aMatch( aOwnCont );
2000-09-18 11:07:07 -05:00
if( xFilterManager.is() )
{
// Get filter for current format
try
{
String aExt;
String aAllSpec( SdResId( STR_ALL_FILES ) );
xFilterManager->appendFilter( aAllSpec, UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "*.*" ) ) );
xFilterManager->setCurrentFilter( aAllSpec ); // set default-filter (<All>)
// Get main filter
pFilter = SfxFilter::GetDefaultFilterFromFactory( aOwnCont );
if( pFilter )
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
// 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
if( mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
pFilter = DrawDocShell::Factory().GetTemplateFilter();
else
pFilter = GraphicDocShell::Factory().GetTemplateFilter();
if( pFilter )
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
2000-09-18 11:07:07 -05:00
// get Powerpoint filter
aExt = UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( ".ppt" ) );
pFilter = aMatch.GetFilter4Extension( aExt );
if( pFilter )
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
2000-09-18 11:07:07 -05: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 );
if( pFilter )
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARIMPRESS_50, SFX_FILTER_TEMPLATEPATH );
if( pFilter )
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
2000-09-18 11:07:07 -05:00
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_50, SFX_FILTER_IMPORT, SFX_FILTER_TEMPLATEPATH );
if( pFilter )
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_50, SFX_FILTER_TEMPLATEPATH );
if( pFilter )
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
2000-09-18 11:07:07 -05:00
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_40, SFX_FILTER_IMPORT, SFX_FILTER_TEMPLATEPATH );
if( pFilter )
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW_40, SFX_FILTER_TEMPLATEPATH );
if( pFilter )
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
2000-09-18 11:07:07 -05:00
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW, SFX_FILTER_IMPORT, SFX_FILTER_TEMPLATEPATH );
if( pFilter )
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
pFilter = aMatch.GetFilter4ClipBoardId( SOT_FORMATSTR_ID_STARDRAW, SFX_FILTER_TEMPLATEPATH );
if( pFilter )
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
2000-09-18 11:07:07 -05:00
// add additional supported filters
::std::vector< String >::const_iterator aIter( aFilterVector.begin() );
while( aIter != aFilterVector.end() )
{
if( ( pFilter = rMatcher.GetFilter4Mime( *aIter ) ) != NULL )
xFilterManager->appendFilter( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
++aIter;
}
}
catch(IllegalArgumentException)
{
}
}
2000-09-18 11:07:07 -05:00
if( aFileDialog.Execute() != ERRCODE_NONE )
return;
2000-09-18 11:07:07 -05:00
else
{
aFilterName = aFileDialog.GetCurrentFilter();
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 ();
if( pFilterName )
2000-09-18 11:07:07 -05:00
aFilterName = pFilterName->GetValue ();
}
mpDocSh->SetWaitCursor( TRUE );
2000-09-18 11:07:07 -05:00
SfxMedium* pMedium = new SfxMedium( aFile, STREAM_READ | STREAM_NOCREATE, FALSE );
const SfxFilter* pFilter = NULL;
SFX_APP()->GetFilterMatcher().GuessFilter( *pMedium, &pFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE );
BOOL bDrawMode = mpViewShell && mpViewShell->ISA(DrawViewShell);
BOOL bInserted = FALSE;
2000-09-18 11:07:07 -05:00
if( pFilter )
{
pMedium->SetFilter( pFilter );
aFilterName = pFilter->GetFilterName();
2000-09-18 11:07:07 -05:00
if( pMedium->IsStorage() || ( pMedium->GetInStream() && SotStorage::IsStorageFile( pMedium->GetInStream() ) ) )
2000-09-18 11:07:07 -05:00
{
if ( pFilter->GetServiceName().EqualsAscii( "com.sun.star.presentation.PresentationDocument" ) ||
pFilter->GetServiceName().EqualsAscii( "com.sun.star.drawing.DrawingDocument" ) )
{
// Draw, Impress or PowerPoint document
// the ownership of the Medium is transferred
if( bDrawMode )
InsSDDinDrMode( pMedium );
else
InsSDDinOlMode( pMedium );
// don't delete Medium here, ownership of pMedium has changed in this case
bInserted = TRUE;
}
2000-09-18 11:07:07 -05:00
}
else
{
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;
}
if( bFound )
{
if( bDrawMode )
InsTextOrRTFinDrMode(pMedium);
else
InsTextOrRTFinOlMode(pMedium);
bInserted = TRUE;
delete pMedium;
}
2000-09-18 11:07:07 -05:00
}
}
mpDocSh->SetWaitCursor( FALSE );
if( !bInserted )
{
ErrorBox aErrorBox( mpWindow, WB_OK, String( SdResId( STR_READ_DATA_ERROR ) ) );
aErrorBox.Execute();
delete pMedium;
}
2000-09-18 11:07:07 -05: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;
mpDocSh->SetWaitCursor( FALSE );
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
AbstractSdInsertPagesObjsDlg* pDlg = pFact ? pFact->CreateSdInsertPagesObjsDlg( NULL, mpDoc, pMedium, aFile ) : 0;
if( !pDlg )
return FALSE;
2000-09-18 11:07:07 -05:00
// Ev. wird eine QueryBox geoeffnet ("Links aktualisieren?"),
// daher wird der Dialog der aktuelle DefModalDialogParent
::Window* pDefParent = GetpApp()->GetDefDialogParent();
GetpApp()->SetDefDialogParent(pDlg->GetWindow());
2000-09-18 11:07:07 -05:00
USHORT nRet = pDlg->Execute();
GetpApp()->SetDefDialogParent(pDefParent);
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;
::sd::View* pView = mpViewShell->GetView();
2000-09-18 11:07:07 -05:00
if (pView->ISA(OutlineView))
2000-09-18 11:07:07 -05:00
{
pPage = static_cast<OutlineView*>(pView)->GetActualPage();
2000-09-18 11:07:07 -05:00
}
else
{
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
bNameOK = mpView->GetExchangeList( pExchangeList, pBookmarkList, 0 );
2000-09-18 11:07:07 -05:00
if( bNameOK )
bOK = mpDoc->InsertBookmarkAsPage( pBookmarkList, pExchangeList,
2000-09-18 11:07:07 -05:00
bLink, bReplace, nPos,
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.)
bNameOK = mpView->GetExchangeList( pExchangeList, pBookmarkList, 1 );
2000-09-18 11:07:07 -05:00
if( bNameOK )
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() )
CWS-TOOLING: integrate CWS sjfixes10 2009-01-15 14:02:24 +0100 af r266369 : #i88851# Finding the right font size is now an iterative process. 2009-01-15 11:01:59 +0100 wg r266354 : i97985 2009-01-15 10:57:33 +0100 wg r266353 : i97985 2009-01-15 10:48:53 +0100 wg r266347 : i97985 2009-01-15 10:48:23 +0100 wg r266346 : i97985 2009-01-15 10:46:47 +0100 wg r266345 : i97985 2009-01-15 10:45:43 +0100 wg r266344 : i97985 2009-01-15 10:45:14 +0100 wg r266343 : i97985 2009-01-15 10:44:38 +0100 wg r266342 : i97985 2009-01-15 10:43:56 +0100 wg r266341 : i97985 2009-01-15 10:42:50 +0100 wg r266340 : i97985 2009-01-15 10:41:40 +0100 wg r266339 : i97985 2009-01-15 10:39:46 +0100 wg r266337 : i97985 2009-01-15 10:00:09 +0100 hde r266336 : i98065 2009-01-13 15:48:20 +0100 wg r266232 : i97985 2009-01-13 13:22:05 +0100 wg r266217 : i97985 2009-01-13 12:34:05 +0100 wg r266210 : i97985 2009-01-13 12:30:56 +0100 wg r266209 : i97985 2009-01-13 12:26:56 +0100 wg r266208 : i97985 2009-01-12 15:58:06 +0100 wg r266165 : i97985 2009-01-12 15:43:24 +0100 wg r266163 : i97985 2009-01-08 16:21:47 +0100 sj r266023 : fixed warning 2009-01-08 15:33:34 +0100 sj r266017 : fixed warning 2009-01-06 18:13:42 +0100 sj r265935 : CWS-TOOLING: rebase CWS sjfixes10 to trunk@265758 (milestone: DEV300:m38) 2008-12-10 16:54:02 +0100 af r265206 : #i43354# Do not delete all unused master pages automatically. 2008-12-04 13:12:50 +0100 af r264836 : #i92795# Use BitmapEx for icons to allow transparency. 2008-12-02 17:01:49 +0100 af r264723 : #i93082# Fixed SID_INSERTPAGE_LAYOUT_MENU. 2008-11-28 14:37:28 +0100 af r264555 : #i88851# Changed association of Ctrl-'?' to views. 2008-11-28 11:38:52 +0100 af r264535 : #i96681# Set version to 1.0.2 2008-11-28 11:30:04 +0100 af r264533 : #i88851# Ctrl-1,2,3 switch to slide overview, notes, normal view. 2008-11-27 16:41:25 +0100 af r264505 : #i92144# Removed unused code. 2008-11-26 15:29:56 +0100 af r264401 : #i92574# Do not lock configuration controller when main pane is not available. 2008-11-21 10:13:40 +0100 sj r264112 : #i96146# applied patch (ambiguous && ||) 2008-11-20 20:12:06 +0100 sj r264097 : #i96083# applied patch (ambigous && ||) 2008-11-20 19:13:53 +0100 sj r264096 : #i96163# applied patch (ambigous && ||) 2008-11-20 18:39:10 +0100 sj r264093 : #i96165# applied patch (ambigous && ||) 2008-11-03 18:12:29 +0100 sj r263303 : #i93996# fixed word wrapping problem 2008-11-03 18:11:02 +0100 sj r263302 : #i93996# fixed word wrapping problem 2008-11-03 18:08:41 +0100 sj r263301 : #i93996# fixed word wrapping problem 2008-11-03 18:06:45 +0100 sj r263300 : #i93996# fixed word wrapping problem 2008-11-03 18:05:00 +0100 sj r263299 : #i94831,i93616# fixed crash when importing diagonal cell border lines, fixed table import 2008-11-03 18:00:43 +0100 sj r263298 : #i93718# spellchecking is no longer triggering the autolayout of connector objects
2009-01-21 08:22:27 -06:00
mpDoc->RemoveUnnecessaryMasterPages();
2000-09-18 11:07:07 -05:00
}
delete pDlg;
return (bOK);
}
// -----------------------------------------------------------------------------
2000-09-18 11:07:07 -05:00
void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
{
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();
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;
if( aFilterName.SearchAscii( "Rich") != STRING_NOTFOUND )
2000-09-18 11:07:07 -05:00
nFormat = EE_FORMAT_RTF;
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
// 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);
// pOutliner->SetForbiddenCharsTable( mpDoc->GetForbiddenCharsTable() );
2000-09-18 11:07:07 -05:00
// Referenz-Device setzen
pOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
2000-09-18 11:07:07 -05: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
ULONG nErr = pOutliner->Read( *pStream, pMedium->GetBaseURL(), nFormat, mpDocSh->GetHeaderAttributes() );
2000-09-18 11:07:07 -05:00
if (nErr || !pOutliner->GetEditEngine().GetText().Len())
{
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?
if (static_cast<DrawViewShell*>(mpViewShell)->GetEditMode() == EM_MASTERPAGE &&
2000-09-18 11:07:07 -05:00
!pPage->IsMasterPage())
{
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
OutlinerView* pOutlinerView = mpView->GetTextEditOutlinerView();
2000-09-18 11:07:07 -05:00
if( pOutlinerView )
{
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();
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);
const bool bUndo = mpView->IsUndoEnabled();
if( bUndo )
mpView->BegUndo(String(SdResId(STR_UNDO_INSERT_TEXTFRAME)));
pPage->InsertObject(pTO);
2000-09-18 11:07:07 -05:00
// koennte groesser sein als die max. erlaubte Groesse:
// falls noetig, die Objektgroesse begrenzen
Size aSize(pOutliner->CalcTextSize());
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());
aSize = mpWindow->LogicToPixel(aSize);
2000-09-18 11:07:07 -05:00
// in der Mitte des Fensters absetzen
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;
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() );
}
if( bUndo )
{
mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoInsertObject(*pTO));
mpView->EndUndo();
}
2000-09-18 11:07:07 -05:00
}
}
delete pOutliner;
}
delete pDlg;
}
// -----------------------------------------------------------------------------
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;
if( aFilterName.SearchAscii( "Rich") != STRING_NOTFOUND )
2000-09-18 11:07:07 -05:00
nFormat = EE_FORMAT_RTF;
else if( aFilterName.SearchAscii( "HTML" ) != STRING_NOTFOUND )
2000-09-18 11:07:07 -05:00
nFormat = EE_FORMAT_HTML;
::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?
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 );
if ( pDocliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
2000-09-18 11:07:07 -05:00
nPage++;
pPara = pDocliner->GetParagraph( nPos - 1 );
}
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
::Outliner* pOutliner = new ::Outliner( &mpDoc->GetItemPool(), OUTLINERMODE_OUTLINEOBJECT );
pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)mpDoc->GetStyleSheetPool());
2000-09-18 11:07:07 -05:00
// Referenz-Device setzen
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
ULONG nErr = pOutliner->Read(*pStream, pMedium->GetBaseURL(), nFormat, mpDocSh->GetHeaderAttributes());
2000-09-18 11:07:07 -05:00
if (nErr || !pOutliner->GetEditEngine().GetText().Len())
{
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 );
if( pOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
2000-09-18 11:07:07 -05:00
nNewPages++;
pPara = pOutliner->GetParagraph( ++nPos );
}
mpDocSh->SetWaitCursor( FALSE );
2000-09-18 11:07:07 -05: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 );
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 );
aStyleSheetName += String::CreateFromInt32( nDepth <= 0 ? 1 : nDepth+1 );
SfxStyleSheetBasePool* pStylePool = mpDoc->GetStyleSheetPool();
2000-09-18 11:07:07 -05:00
SfxStyleSheet* pOutlStyle = (SfxStyleSheet*) pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() );
pDocliner->SetStyleSheet( nTargetPos, pOutlStyle );
}
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;
mpDocSh->SetWaitCursor( TRUE );
2000-09-18 11:07:07 -05:00
}
delete pOutliner;
}
// -----------------------------------------------------------------------------
2000-09-18 11:07:07 -05:00
BOOL FuInsertFile::InsSDDinOlMode(SfxMedium* pMedium)
2000-09-18 11:07:07 -05: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))
{
::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);
return TRUE;
2000-09-18 11:07:07 -05:00
}
else
return FALSE;
2000-09-18 11:07:07 -05:00
}
// -----------------------------------------------------------------------------
2000-09-18 11:07:07 -05: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() );
}
} // end of namespace sd