LibreOffice Module sw (master)  1
drawdoc.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <svx/svxids.hrc>
21 
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>
30 
31 using namespace com::sun::star;
32 
33 // Constructor
35 : FmFormModel(
36  &pDoc->GetAttrPool(),
37  pDoc->GetDocShell())
38  , m_pDoc( pDoc )
39 {
40  SetScaleUnit( MapUnit::MapTwip );
42 
43  // use common InitDrawModelAndDocShell which will set the associations as needed,
44  // including SvxColorTableItem with WhichID SID_COLOR_TABLE
46 
47  // copy all the default values to the SdrModel
49  if( pSdrPool )
50  {
51  const sal_uInt16 aWhichRanges[] =
52  {
55  0
56  };
57 
58  SfxItemPool& rDocPool = m_pDoc->GetAttrPool();
59  sal_uInt16 nEdtWhich, nSlotId;
60  const SfxPoolItem* pItem;
61  for( const sal_uInt16* pRangeArr = aWhichRanges;
62  *pRangeArr; pRangeArr += 2 )
63  for( sal_uInt16 nW = *pRangeArr, nEnd = *(pRangeArr+1);
64  nW < nEnd; ++nW )
65  if( nullptr != (pItem = rDocPool.GetPoolDefaultItem( nW )) &&
66  0 != (nSlotId = rDocPool.GetSlotId( nW ) ) &&
67  nSlotId != nW &&
68  0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
69  nSlotId != nEdtWhich )
70  {
71  std::unique_ptr<SfxPoolItem> pCpy(pItem->Clone());
72  pCpy->SetWhich( nEdtWhich );
73  pSdrPool->SetPoolDefaultItem( *pCpy );
74  }
75  }
76 
78  // Implementation for asian compression
80 }
81 
82 // Destructor
83 
85 {
86  Broadcast(SdrHint(SdrHintKind::ModelCleared));
87 
88  ClearModel(true);
89 }
90 
98 SdrPage* SwDrawModel::AllocPage(bool bMasterPage)
99 {
100  SwDPage* pPage = new SwDPage(*this, bMasterPage);
101  pPage->SetName("Controls");
102  return pPage;
103 }
104 
105 uno::Reference<embed::XStorage> SwDrawModel::GetDocumentStorage() const
106 {
107  return m_pDoc->GetDocStorage();
108 }
109 
110 uno::Reference< uno::XInterface > SwDrawModel::createUnoModel()
111 {
112  uno::Reference< uno::XInterface > xModel;
113 
114  try
115  {
116  if ( GetDoc().GetDocShell() )
117  {
118  xModel = GetDoc().GetDocShell()->GetModel();
119  }
120  }
121  catch( uno::RuntimeException& )
122  {
123  OSL_FAIL( "<SwDrawModel::createUnoModel()> - could *not* retrieve model at <SwDocShell>" );
124  }
125 
126  return xModel;
127 }
128 
130 {
131  rSet.Put(SvxColorListItem(GetColorList(), SID_COLOR_TABLE));
132  rSet.Put(SvxGradientListItem(GetGradientList(), SID_GRADIENT_LIST));
133  rSet.Put(SvxHatchListItem(GetHatchList(), SID_HATCH_LIST));
134  rSet.Put(SvxBitmapListItem(GetBitmapList(), SID_BITMAP_LIST));
135  rSet.Put(SvxPatternListItem(GetPatternList(), SID_PATTERN_LIST));
136 }
137 
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::embed::XStorage > GetDocStorage()
Definition: docnew.cxx:606
SwDocShell * GetDocShell()
Definition: doc.hxx:1348
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
const SfxPoolItem * GetPoolDefaultItem(sal_uInt16 nWhich) const
void SetForbiddenCharsTable(const std::shared_ptr< SvxForbiddenCharactersTable > &xForbiddenChars)
Definition: doc.hxx:184
virtual CharCompressType getCharacterCompressionType() const override
Get the character compression type for Asian characters.
virtual css::uno::Reference< css::uno::XInterface > createUnoModel() override
override of is needed to provide corresponding uno model.
Definition: drawdoc.cxx:110
void SetSwapGraphics()
void SetCharCompressType(CharCompressType nType)
css::uno::Reference< css::frame::XModel > GetModel() const
virtual ~SwDrawModel() override
Definition: drawdoc.cxx:84
const SwDoc & GetDoc() const
Definition: drawdoc.hxx:35
XPatternListRef GetPatternList() const
SwDoc * m_pDoc
Definition: docbm.cxx:1190
virtual SdrPage * AllocPage(bool bMasterPage) override
Create a new page (SdPage) and return a pointer to it back.
Definition: drawdoc.cxx:98
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
SwDrawModel(SwDoc *pDoc)
Definition: drawdoc.cxx:34
void SetName(const OUString &rName)
virtual std::shared_ptr< SvxForbiddenCharactersTable > & getForbiddenCharacterTable() override
Get the forbidden character table and creates one if necessary.
void InitDrawModelAndDocShell(SwDocShell *pSwDocShell, SwDrawModel *pSwDrawDocument)
Definition: docshdrw.cxx:32
XGradientListRef GetGradientList() const
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
void PutAreaListItems(SfxItemSet &rSet) const
Put needed items for XPropertyList entries from the DrawModel.
Definition: drawdoc.cxx:129
SfxItemPool * GetSecondaryPool() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
XHatchListRef GetHatchList() const
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
void SetWhich(sal_uInt16 nId)
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:185
constexpr sal_uInt16 RES_PARATR_END(82)
SwDoc * m_pDoc
Definition: drawdoc.hxx:29
constexpr sal_uInt16 RES_CHRATR_END(46)
XBitmapListRef GetBitmapList() const
virtual css::uno::Reference< css::embed::XStorage > GetDocumentStorage() const override
Definition: drawdoc.cxx:105
Reference< XModel > xModel
void SetScaleUnit(MapUnit eMap)
XColorListRef GetColorList() const
void ClearModel(bool bCalledFromDestructor)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1315