2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 12:42:08 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:42:08 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:42:08 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:42:08 +00: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 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:42:08 +00: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 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:42:08 +00: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 23:08:29 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-16 20:03:33 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
#include <svx/svxids.hrc>
|
|
|
|
#include <tools/stream.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/pathoptions.hxx>
|
2004-10-04 18:05:21 +00:00
|
|
|
#include <sot/storage.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/intitem.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/forbiddencharacterstable.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2004-10-04 18:05:21 +00:00
|
|
|
#include <unotools/ucbstreamhelper.hxx>
|
2004-02-03 15:25:06 +00:00
|
|
|
#include <svx/xtable.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <svx/drawitem.hxx>
|
|
|
|
#include <viewsh.hxx>
|
|
|
|
#include <doc.hxx>
|
|
|
|
#include <rootfrm.hxx>
|
|
|
|
#include <drawdoc.hxx>
|
|
|
|
#include <dpage.hxx>
|
|
|
|
#include <docsh.hxx>
|
|
|
|
#include <shellio.hxx>
|
2001-04-03 10:11:26 +00:00
|
|
|
#include <hintids.hxx>
|
2004-10-04 18:05:21 +00:00
|
|
|
#include <com/sun/star/embed/ElementModes.hpp>
|
|
|
|
|
|
|
|
using namespace com::sun::star;
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Konstruktor
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2000-10-06 12:11:18 +00:00
|
|
|
const String GetPalettePath()
|
|
|
|
{
|
|
|
|
SvtPathOptions aPathOpt;
|
|
|
|
return aPathOpt.GetPalettePath();
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwDrawDocument::SwDrawDocument( SwDoc* pD ) :
|
2001-02-09 10:54:30 +00:00
|
|
|
FmFormModel( ::GetPalettePath(), &pD->GetAttrPool(),
|
2001-02-13 15:15:25 +00:00
|
|
|
pD->GetDocShell(), TRUE ),
|
2000-09-18 23:08:29 +00:00
|
|
|
pDoc( pD )
|
|
|
|
{
|
|
|
|
SetScaleUnit( MAP_TWIP );
|
|
|
|
SetSwapGraphics( TRUE );
|
|
|
|
|
|
|
|
SwDocShell* pDocSh = pDoc->GetDocShell();
|
|
|
|
if ( pDocSh )
|
|
|
|
{
|
|
|
|
SetObjectShell( pDocSh );
|
|
|
|
SvxColorTableItem* pColItem = ( SvxColorTableItem* )
|
2007-05-10 14:58:07 +00:00
|
|
|
( pDocSh->GetItem( SID_COLOR_TABLE ) );
|
2000-09-18 23:08:29 +00:00
|
|
|
XColorTable *pXCol = pColItem ? pColItem->GetColorTable() :
|
2004-02-03 15:25:06 +00:00
|
|
|
XColorTable::GetStdColorTable();
|
2000-09-18 23:08:29 +00:00
|
|
|
SetColorTable( pXCol );
|
|
|
|
|
|
|
|
if ( !pColItem )
|
2007-05-10 14:58:07 +00:00
|
|
|
pDocSh->PutItem( SvxColorTableItem( pXCol, SID_COLOR_TABLE ) );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2007-05-10 14:58:07 +00:00
|
|
|
pDocSh->PutItem( SvxGradientListItem( GetGradientList(), SID_GRADIENT_LIST ));
|
|
|
|
pDocSh->PutItem( SvxHatchListItem( GetHatchList(), SID_HATCH_LIST ) );
|
|
|
|
pDocSh->PutItem( SvxBitmapListItem( GetBitmapList(), SID_BITMAP_LIST ) );
|
|
|
|
pDocSh->PutItem( SvxDashListItem( GetDashList(), SID_DASH_LIST ) );
|
|
|
|
pDocSh->PutItem( SvxLineEndListItem( GetLineEndList(), SID_LINEEND_LIST ) );
|
2000-09-18 23:08:29 +00:00
|
|
|
pDocSh->PutItem( SfxUInt16Item(SID_ATTR_LINEEND_WIDTH_DEFAULT, 111) );
|
|
|
|
SetObjectShell( pDocSh );
|
|
|
|
}
|
|
|
|
else
|
2004-02-03 15:25:06 +00:00
|
|
|
SetColorTable( XColorTable::GetStdColorTable() );
|
2001-04-03 10:11:26 +00:00
|
|
|
|
|
|
|
// copy all the default values to the SdrModel
|
|
|
|
SfxItemPool* pSdrPool = pD->GetAttrPool().GetSecondaryPool();
|
|
|
|
if( pSdrPool )
|
|
|
|
{
|
|
|
|
const USHORT aWhichRanges[] =
|
|
|
|
{
|
|
|
|
RES_CHRATR_BEGIN, RES_CHRATR_END,
|
|
|
|
RES_PARATR_BEGIN, RES_PARATR_END,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
SfxItemPool& rDocPool = pD->GetAttrPool();
|
|
|
|
USHORT nEdtWhich, nSlotId;
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
for( const USHORT* pRangeArr = aWhichRanges;
|
|
|
|
*pRangeArr; pRangeArr += 2 )
|
|
|
|
for( USHORT nW = *pRangeArr, nEnd = *(pRangeArr+1);
|
|
|
|
nW < nEnd; ++nW )
|
|
|
|
if( 0 != (pItem = rDocPool.GetPoolDefaultItem( nW )) &&
|
|
|
|
0 != (nSlotId = rDocPool.GetSlotId( nW ) ) &&
|
|
|
|
nSlotId != nW &&
|
|
|
|
0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
|
|
|
|
nSlotId != nEdtWhich )
|
|
|
|
{
|
|
|
|
SfxPoolItem* pCpy = pItem->Clone();
|
|
|
|
pCpy->SetWhich( nEdtWhich );
|
|
|
|
pSdrPool->SetPoolDefaultItem( *pCpy );
|
|
|
|
delete pCpy;
|
|
|
|
}
|
|
|
|
}
|
2001-04-06 16:41:37 +00:00
|
|
|
|
2006-08-14 15:06:23 +00:00
|
|
|
SetForbiddenCharsTable( pD->getForbiddenCharacterTable() );
|
2001-06-26 13:19:42 +00:00
|
|
|
// #87795# Implementation for asian compression
|
2007-09-27 07:43:23 +00:00
|
|
|
SetCharCompressType( static_cast<UINT16>(pD->getCharacterCompressionType() ));
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Destruktor
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
SwDrawDocument::~SwDrawDocument()
|
|
|
|
{
|
2003-03-27 14:45:43 +00:00
|
|
|
Broadcast(SdrHint(HINT_MODELCLEARED));
|
|
|
|
|
2004-05-10 13:24:51 +00:00
|
|
|
// #116168#
|
|
|
|
ClearModel(sal_True);
|
|
|
|
//Clear();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Diese Methode erzeugt eine neue Seite (SdPage) und gibt einen Zeiger
|
|
|
|
|* darauf zurueck. Die Drawing Engine benutzt diese Methode beim Laden
|
|
|
|
|* zur Erzeugung von Seiten (deren Typ sie ja nicht kennt, da es ABLEITUNGEN
|
|
|
|
|* der SdrPage sind).
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
|
2010-10-05 07:57:55 -05:00
|
|
|
SdrPage* SwDrawDocument::AllocPage(bool bMasterPage)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:43:23 +00:00
|
|
|
SwDPage* pPage = new SwDPage(*this, 0 != bMasterPage);
|
2000-09-18 23:08:29 +00:00
|
|
|
pPage->SetName( String::CreateFromAscii(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM( "Controls" )) );
|
|
|
|
return pPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-03 16:02:17 +00:00
|
|
|
SvStream* SwDrawDocument::GetDocumentStream( SdrDocumentStreamInfo& rInfo ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-11-02 15:05:52 +00:00
|
|
|
SvStream* pRet = NULL;
|
2004-10-04 18:05:21 +00:00
|
|
|
uno::Reference < embed::XStorage > xRoot( pDoc->GetDocStorage() );
|
|
|
|
if( xRoot.is() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-11-02 15:05:52 +00:00
|
|
|
if( rInfo.maUserData.Len() &&
|
|
|
|
( rInfo.maUserData.GetToken( 0, ':' ) ==
|
|
|
|
String( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package" ) ) ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-11-02 15:05:52 +00:00
|
|
|
const String aPicturePath( rInfo.maUserData.GetToken( 1, ':' ) );
|
|
|
|
|
|
|
|
// graphic from picture stream in picture storage in XML package
|
|
|
|
if( aPicturePath.GetTokenCount( '/' ) == 2 )
|
|
|
|
{
|
|
|
|
const String aPictureStorageName( aPicturePath.GetToken( 0, '/' ) );
|
|
|
|
const String aPictureStreamName( aPicturePath.GetToken( 1, '/' ) );
|
|
|
|
|
2004-10-04 18:05:21 +00:00
|
|
|
try
|
2001-11-02 15:05:52 +00:00
|
|
|
{
|
2004-10-04 18:05:21 +00:00
|
|
|
uno::Reference < embed::XStorage > xPictureStorage = xRoot->openStorageElement(
|
|
|
|
aPictureStorageName, embed::ElementModes::READ );
|
|
|
|
uno::Reference < io::XStream > xStream = xPictureStorage->openStreamElement(
|
|
|
|
aPictureStreamName, embed::ElementModes::READ );
|
|
|
|
pRet = utl::UcbStreamHelper::CreateStream( xStream );
|
2001-11-02 15:05:52 +00:00
|
|
|
if( pRet )
|
|
|
|
{
|
|
|
|
rInfo.mbDeleteAfterUse = TRUE;
|
2004-10-04 18:05:21 +00:00
|
|
|
rInfo.mxStorageRef = xPictureStorage;
|
2001-11-02 15:05:52 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-04 18:05:21 +00:00
|
|
|
catch ( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
2001-11-02 15:05:52 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
SdrLayerID SwDrawDocument::GetControlExportLayerId( const SdrObject & ) const
|
|
|
|
{
|
|
|
|
//fuer Versionen < 5.0, es gab nur Hell und Heaven
|
|
|
|
return (SdrLayerID)pDoc->GetHeavenId();
|
|
|
|
}
|
|
|
|
|
2006-03-06 12:44:24 +00:00
|
|
|
// --> OD 2006-03-01 #b6382898#
|
|
|
|
uno::Reference< uno::XInterface > SwDrawDocument::createUnoModel()
|
|
|
|
{
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2006-03-06 12:44:24 +00:00
|
|
|
uno::Reference< uno::XInterface > xModel;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2006-03-06 12:44:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if ( GetDoc().GetDocShell() )
|
|
|
|
{
|
|
|
|
xModel = GetDoc().GetDocShell()->GetModel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::RuntimeException& )
|
|
|
|
{
|
|
|
|
ASSERT( false,
|
|
|
|
"<SwDrawDocument::createUnoModel()> - could *not* retrieve model at <SwDocShell>" );
|
|
|
|
}
|
|
|
|
|
|
|
|
return xModel;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2006-03-06 12:44:24 +00:00
|
|
|
// <--
|