1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svx/svxids.hrc>
21 #include <tools/stream.hxx>
22 #include <unotools/configmgr.hxx>
23 #include <unotools/pathoptions.hxx>
24 #include <sot/storage.hxx>
25 #include <svl/intitem.hxx>
26 #include <editeng/forbiddencharacterstable.hxx>
28 #include <svx/xtable.hxx>
29 #include <svx/drawitem.hxx>
32 #include <rootfrm.hxx>
33 #include <drawdoc.hxx>
36 #include <shellio.hxx>
37 #include <hintids.hxx>
38 #include <DocumentSettingManager.hxx>
39 #include <IDocumentDrawModelAccess.hxx>
41 using namespace com::sun::star
;
45 const OUString
GetPalettePath()
47 if (utl::ConfigManager::IsFuzzing())
49 SvtPathOptions aPathOpt
;
50 return aPathOpt
.GetPalettePath();
53 SwDrawModel::SwDrawModel(SwDoc
*const pDoc
)
54 : FmFormModel( ::GetPalettePath(), &pDoc
->GetAttrPool(),
55 pDoc
->GetDocShell(), true )
58 SetScaleUnit( MapUnit::MapTwip
);
61 // use common InitDrawModelAndDocShell which will set the associations as needed,
62 // including SvxColorTableItem with WhichID SID_COLOR_TABLE
63 InitDrawModelAndDocShell(m_pDoc
->GetDocShell(), this);
65 // copy all the default values to the SdrModel
66 SfxItemPool
* pSdrPool
= m_pDoc
->GetAttrPool().GetSecondaryPool();
69 const sal_uInt16 aWhichRanges
[] =
71 RES_CHRATR_BEGIN
, RES_CHRATR_END
,
72 RES_PARATR_BEGIN
, RES_PARATR_END
,
76 SfxItemPool
& rDocPool
= m_pDoc
->GetAttrPool();
77 sal_uInt16 nEdtWhich
, nSlotId
;
78 const SfxPoolItem
* pItem
;
79 for( const sal_uInt16
* pRangeArr
= aWhichRanges
;
80 *pRangeArr
; pRangeArr
+= 2 )
81 for( sal_uInt16 nW
= *pRangeArr
, nEnd
= *(pRangeArr
+1);
83 if( nullptr != (pItem
= rDocPool
.GetPoolDefaultItem( nW
)) &&
84 0 != (nSlotId
= rDocPool
.GetSlotId( nW
) ) &&
86 0 != (nEdtWhich
= pSdrPool
->GetWhich( nSlotId
)) &&
87 nSlotId
!= nEdtWhich
)
89 SfxPoolItem
* pCpy
= pItem
->Clone();
90 pCpy
->SetWhich( nEdtWhich
);
91 pSdrPool
->SetPoolDefaultItem( *pCpy
);
96 SetForbiddenCharsTable(m_pDoc
->GetDocumentSettingManager().getForbiddenCharacterTable());
97 // Implementation for asian compression
98 SetCharCompressType( m_pDoc
->GetDocumentSettingManager().getCharacterCompressionType() );
103 SwDrawModel::~SwDrawModel()
105 Broadcast(SdrHint(SdrHintKind::ModelCleared
));
110 /** Create a new page (SdPage) and return a pointer to it back.
112 * The drawing engine is using this method while loading for the creating of
113 * pages (whose type it not even know, because they are inherited from SdrPage).
115 * @return Pointer to the new page.
117 SdrPage
* SwDrawModel::AllocPage(bool bMasterPage
)
119 SwDPage
* pPage
= new SwDPage(*this, bMasterPage
);
120 pPage
->SetName("Controls");
124 uno::Reference
<embed::XStorage
> SwDrawModel::GetDocumentStorage() const
126 return m_pDoc
->GetDocStorage();
129 uno::Reference
< uno::XInterface
> SwDrawModel::createUnoModel()
131 uno::Reference
< uno::XInterface
> xModel
;
135 if ( GetDoc().GetDocShell() )
137 xModel
= GetDoc().GetDocShell()->GetModel();
140 catch( uno::RuntimeException
& )
142 OSL_FAIL( "<SwDrawModel::createUnoModel()> - could *not* retrieve model at <SwDocShell>" );
148 void SwDrawModel::PutAreaListItems(SfxItemSet
& rSet
) const
150 rSet
.Put(SvxColorListItem(GetColorList(), SID_COLOR_TABLE
));
151 rSet
.Put(SvxGradientListItem(GetGradientList(), SID_GRADIENT_LIST
));
152 rSet
.Put(SvxHatchListItem(GetHatchList(), SID_HATCH_LIST
));
153 rSet
.Put(SvxBitmapListItem(GetBitmapList(), SID_BITMAP_LIST
));
154 rSet
.Put(SvxPatternListItem(GetPatternList(), SID_PATTERN_LIST
));
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */