2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-16 20:03:33 +00:00
|
|
|
|
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;
|
|
|
|
|
2013-02-15 18:43:38 +01:00
|
|
|
// Constructor
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-10-16 11:18:56 +02:00
|
|
|
const OUString GetPalettePath()
|
2000-10-06 12:11:18 +00:00
|
|
|
{
|
|
|
|
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(),
|
2014-01-28 19:59:54 +01:00
|
|
|
pD->GetDocShell(), true ),
|
2000-09-18 23:08:29 +00:00
|
|
|
pDoc( pD )
|
|
|
|
{
|
|
|
|
SetScaleUnit( MAP_TWIP );
|
2014-01-28 19:59:54 +01:00
|
|
|
SetSwapGraphics( true );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwDocShell* pDocSh = pDoc->GetDocShell();
|
|
|
|
if ( pDocSh )
|
|
|
|
{
|
|
|
|
SetObjectShell( pDocSh );
|
2011-09-23 14:05:07 +01:00
|
|
|
SvxColorListItem* pColItem = ( SvxColorListItem* )
|
2007-05-10 14:58:07 +00:00
|
|
|
( pDocSh->GetItem( SID_COLOR_TABLE ) );
|
2011-09-23 14:05:07 +01:00
|
|
|
XColorListRef pXCol = pColItem ? pColItem->GetColorList() :
|
|
|
|
XColorList::GetStdColorList();
|
|
|
|
SetPropertyList( static_cast<XPropertyList *> (pXCol.get()) );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
if ( !pColItem )
|
2011-09-23 14:05:07 +01:00
|
|
|
pDocSh->PutItem( SvxColorListItem( 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
|
2011-09-23 14:05:07 +01:00
|
|
|
SetPropertyList( static_cast<XPropertyList *> (XColorList::GetStdColorList().get()) );
|
2001-04-03 10:11:26 +00:00
|
|
|
|
|
|
|
// copy all the default values to the SdrModel
|
|
|
|
SfxItemPool* pSdrPool = pD->GetAttrPool().GetSecondaryPool();
|
|
|
|
if( pSdrPool )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_uInt16 aWhichRanges[] =
|
2001-04-03 10:11:26 +00:00
|
|
|
{
|
|
|
|
RES_CHRATR_BEGIN, RES_CHRATR_END,
|
|
|
|
RES_PARATR_BEGIN, RES_PARATR_END,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
SfxItemPool& rDocPool = pD->GetAttrPool();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nEdtWhich, nSlotId;
|
2001-04-03 10:11:26 +00:00
|
|
|
const SfxPoolItem* pItem;
|
2011-01-17 15:06:54 +01:00
|
|
|
for( const sal_uInt16* pRangeArr = aWhichRanges;
|
2001-04-03 10:11:26 +00:00
|
|
|
*pRangeArr; pRangeArr += 2 )
|
2011-01-17 15:06:54 +01:00
|
|
|
for( sal_uInt16 nW = *pRangeArr, nEnd = *(pRangeArr+1);
|
2001-04-03 10:11:26 +00:00
|
|
|
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() );
|
2011-02-08 08:51:51 +01:00
|
|
|
// Implementation for asian compression
|
2011-01-17 15:06:54 +01:00
|
|
|
SetCharCompressType( static_cast<sal_uInt16>(pD->getCharacterCompressionType() ));
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-02-15 18:43:38 +01:00
|
|
|
// Destructor
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwDrawDocument::~SwDrawDocument()
|
|
|
|
{
|
2003-03-27 14:45:43 +00:00
|
|
|
Broadcast(SdrHint(HINT_MODELCLEARED));
|
|
|
|
|
2004-05-10 13:24:51 +00:00
|
|
|
ClearModel(sal_True);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-05-05 17:42:22 +02:00
|
|
|
/** Create a new page (SdPage) and return a pointer to it back.
|
|
|
|
*
|
|
|
|
* The drawing engine is using this method while loading for the creating of
|
|
|
|
* pages (whose type it not even know, because they are inherited from SdrPage).
|
|
|
|
*
|
|
|
|
* @return Pointer to the new page.
|
|
|
|
*/
|
2010-10-05 07:57:55 -05:00
|
|
|
SdrPage* SwDrawDocument::AllocPage(bool bMasterPage)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-01-17 17:11:45 +01:00
|
|
|
SwDPage* pPage = new SwDPage(*this, bMasterPage);
|
2013-04-07 12:06:47 +02:00
|
|
|
pPage->SetName(OUString("Controls"));
|
2000-09-18 23:08:29 +00:00
|
|
|
return pPage;
|
|
|
|
}
|
|
|
|
|
2011-12-02 23:43:23 +01:00
|
|
|
uno::Reference<embed::XStorage> SwDrawDocument::GetDocumentStorage() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-12-02 23:43:23 +01:00
|
|
|
return pDoc->GetDocStorage();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SdrLayerID SwDrawDocument::GetControlExportLayerId( const SdrObject & ) const
|
|
|
|
{
|
2013-02-13 19:39:39 +01:00
|
|
|
//for versions < 5.0, there was only Hell and Heaven
|
2000-09-18 23:08:29 +00:00
|
|
|
return (SdrLayerID)pDoc->GetHeavenId();
|
|
|
|
}
|
|
|
|
|
2006-03-06 12:44:24 +00:00
|
|
|
uno::Reference< uno::XInterface > SwDrawDocument::createUnoModel()
|
|
|
|
{
|
|
|
|
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& )
|
|
|
|
{
|
2011-03-12 11:51:35 +01:00
|
|
|
OSL_FAIL( "<SwDrawDocument::createUnoModel()> - could *not* retrieve model at <SwDocShell>" );
|
2006-03-06 12:44:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return xModel;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|