nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / core / draw / drawdoc.cxx
blob401c9cf9c980ad99b54c21ab6caa0aa3154f0e06
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
22 #include <com/sun/star/frame/XModel.hpp>
23 #include <svx/drawitem.hxx>
24 #include <doc.hxx>
25 #include <drawdoc.hxx>
26 #include <dpage.hxx>
27 #include <docsh.hxx>
28 #include <hintids.hxx>
29 #include <DocumentSettingManager.hxx>
31 using namespace com::sun::star;
33 // Constructor
34 SwDrawModel::SwDrawModel(SwDoc& rDoc)
35 : FmFormModel(&rDoc.GetAttrPool(), rDoc.GetDocShell())
36 , m_rDoc(rDoc)
38 SetScaleUnit( MapUnit::MapTwip );
39 SetSwapGraphics();
41 // use common InitDrawModelAndDocShell which will set the associations as needed,
42 // including SvxColorTableItem with WhichID SID_COLOR_TABLE
43 InitDrawModelAndDocShell(m_rDoc.GetDocShell(), this);
45 // copy all the default values to the SdrModel
46 SfxItemPool* pSdrPool = m_rDoc.GetAttrPool().GetSecondaryPool();
47 if( pSdrPool )
49 const sal_uInt16 aWhichRanges[] =
51 RES_CHRATR_BEGIN, RES_CHRATR_END,
52 RES_PARATR_BEGIN, RES_PARATR_END,
56 SfxItemPool& rDocPool = m_rDoc.GetAttrPool();
57 sal_uInt16 nEdtWhich, nSlotId;
58 const SfxPoolItem* pItem;
59 for( const sal_uInt16* pRangeArr = aWhichRanges;
60 *pRangeArr; pRangeArr += 2 )
61 for( sal_uInt16 nW = *pRangeArr, nEnd = *(pRangeArr+1);
62 nW < nEnd; ++nW )
63 if( nullptr != (pItem = rDocPool.GetPoolDefaultItem( nW )) &&
64 0 != (nSlotId = rDocPool.GetSlotId( nW ) ) &&
65 nSlotId != nW &&
66 0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
67 nSlotId != nEdtWhich )
69 std::unique_ptr<SfxPoolItem> pCpy(pItem->Clone());
70 pCpy->SetWhich( nEdtWhich );
71 pSdrPool->SetPoolDefaultItem( *pCpy );
75 SetForbiddenCharsTable(m_rDoc.GetDocumentSettingManager().getForbiddenCharacterTable());
76 // Implementation for asian compression
77 SetCharCompressType( m_rDoc.GetDocumentSettingManager().getCharacterCompressionType() );
80 // Destructor
82 SwDrawModel::~SwDrawModel()
84 Broadcast(SdrHint(SdrHintKind::ModelCleared));
86 ClearModel(true);
89 /** Create a new page (SdPage) and return a pointer to it back.
91 * The drawing engine is using this method while loading for the creating of
92 * pages (whose type it not even know, because they are inherited from SdrPage).
94 * @return Pointer to the new page.
96 SdrPage* SwDrawModel::AllocPage(bool bMasterPage)
98 SwDPage* pPage = new SwDPage(*this, bMasterPage);
99 pPage->SetName("Controls");
100 return pPage;
103 uno::Reference<embed::XStorage> SwDrawModel::GetDocumentStorage() const
105 return m_rDoc.GetDocStorage();
108 uno::Reference< uno::XInterface > SwDrawModel::createUnoModel()
110 uno::Reference< uno::XInterface > xModel;
114 if ( GetDoc().GetDocShell() )
116 xModel = GetDoc().GetDocShell()->GetModel();
119 catch( uno::RuntimeException& )
121 OSL_FAIL( "<SwDrawModel::createUnoModel()> - could *not* retrieve model at <SwDocShell>" );
124 return xModel;
127 void SwDrawModel::PutAreaListItems(SfxItemSet& rSet) const
129 rSet.Put(SvxColorListItem(GetColorList(), SID_COLOR_TABLE));
130 rSet.Put(SvxGradientListItem(GetGradientList(), SID_GRADIENT_LIST));
131 rSet.Put(SvxHatchListItem(GetHatchList(), SID_HATCH_LIST));
132 rSet.Put(SvxBitmapListItem(GetBitmapList(), SID_BITMAP_LIST));
133 rSet.Put(SvxPatternListItem(GetPatternList(), SID_PATTERN_LIST));
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */