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 #include <tools/stream.hxx>
22 #include <unotools/configmgr.hxx>
23 #include <sot/storage.hxx>
24 #include <svl/intitem.hxx>
26 
27 #include <svx/xtable.hxx>
28 #include <svx/drawitem.hxx>
29 #include <viewsh.hxx>
30 #include <doc.hxx>
31 #include <rootfrm.hxx>
32 #include <drawdoc.hxx>
33 #include <dpage.hxx>
34 #include <docsh.hxx>
35 #include <shellio.hxx>
36 #include <hintids.hxx>
39 
40 using namespace com::sun::star;
41 
42 // Constructor
44 : FmFormModel(
45  &pDoc->GetAttrPool(),
46  pDoc->GetDocShell())
47  , m_pDoc( pDoc )
48 {
49  SetScaleUnit( MapUnit::MapTwip );
51 
52  // use common InitDrawModelAndDocShell which will set the associations as needed,
53  // including SvxColorTableItem with WhichID SID_COLOR_TABLE
55 
56  // copy all the default values to the SdrModel
58  if( pSdrPool )
59  {
60  const sal_uInt16 aWhichRanges[] =
61  {
64  0
65  };
66 
67  SfxItemPool& rDocPool = m_pDoc->GetAttrPool();
68  sal_uInt16 nEdtWhich, nSlotId;
69  const SfxPoolItem* pItem;
70  for( const sal_uInt16* pRangeArr = aWhichRanges;
71  *pRangeArr; pRangeArr += 2 )
72  for( sal_uInt16 nW = *pRangeArr, nEnd = *(pRangeArr+1);
73  nW < nEnd; ++nW )
74  if( nullptr != (pItem = rDocPool.GetPoolDefaultItem( nW )) &&
75  0 != (nSlotId = rDocPool.GetSlotId( nW ) ) &&
76  nSlotId != nW &&
77  0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
78  nSlotId != nEdtWhich )
79  {
80  std::unique_ptr<SfxPoolItem> pCpy(pItem->Clone());
81  pCpy->SetWhich( nEdtWhich );
82  pSdrPool->SetPoolDefaultItem( *pCpy );
83  }
84  }
85 
87  // Implementation for asian compression
89 }
90 
91 // Destructor
92 
94 {
95  Broadcast(SdrHint(SdrHintKind::ModelCleared));
96 
97  ClearModel(true);
98 }
99 
107 SdrPage* SwDrawModel::AllocPage(bool bMasterPage)
108 {
109  SwDPage* pPage = new SwDPage(*this, bMasterPage);
110  pPage->SetName("Controls");
111  return pPage;
112 }
113 
114 uno::Reference<embed::XStorage> SwDrawModel::GetDocumentStorage() const
115 {
116  return m_pDoc->GetDocStorage();
117 }
118 
119 uno::Reference< uno::XInterface > SwDrawModel::createUnoModel()
120 {
121  uno::Reference< uno::XInterface > xModel;
122 
123  try
124  {
125  if ( GetDoc().GetDocShell() )
126  {
127  xModel = GetDoc().GetDocShell()->GetModel();
128  }
129  }
130  catch( uno::RuntimeException& )
131  {
132  OSL_FAIL( "<SwDrawModel::createUnoModel()> - could *not* retrieve model at <SwDocShell>" );
133  }
134 
135  return xModel;
136 }
137 
139 {
140  rSet.Put(SvxColorListItem(GetColorList(), SID_COLOR_TABLE));
141  rSet.Put(SvxGradientListItem(GetGradientList(), SID_GRADIENT_LIST));
142  rSet.Put(SvxHatchListItem(GetHatchList(), SID_HATCH_LIST));
143  rSet.Put(SvxBitmapListItem(GetBitmapList(), SID_BITMAP_LIST));
144  rSet.Put(SvxPatternListItem(GetPatternList(), SID_PATTERN_LIST));
145 }
146 
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::embed::XStorage > GetDocStorage()
Definition: docnew.cxx:625
SwDocShell * GetDocShell()
Definition: doc.hxx:1340
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:185
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:119
void SetSwapGraphics()
void SetCharCompressType(CharCompressType nType)
css::uno::Reference< css::frame::XModel > GetModel() const
virtual ~SwDrawModel() override
Definition: drawdoc.cxx:93
const SwDoc & GetDoc() const
Definition: drawdoc.hxx:35
XPatternListRef GetPatternList() const
virtual SdrPage * AllocPage(bool bMasterPage) override
Create a new page (SdPage) and return a pointer to it back.
Definition: drawdoc.cxx:107
#define RES_CHRATR_END
Definition: hintids.hxx:114
#define RES_PARATR_BEGIN
Definition: hintids.hxx:160
SwDrawModel(SwDoc *pDoc)
Definition: drawdoc.cxx:43
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:36
XGradientListRef GetGradientList() const
#define RES_CHRATR_BEGIN
Definition: hintids.hxx:68
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
void PutAreaListItems(SfxItemSet &rSet) const
Put needed items for XPropertyList entries from the DrawModel.
Definition: drawdoc.cxx:138
SfxItemPool * GetSecondaryPool() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
XHatchListRef GetHatchList() const
void SetWhich(sal_uInt16 nId)
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:218
SwDoc * m_pDoc
Definition: drawdoc.hxx:29
XBitmapListRef GetBitmapList() const
virtual css::uno::Reference< css::embed::XStorage > GetDocumentStorage() const override
Definition: drawdoc.cxx:114
Reference< XModel > xModel
void SetScaleUnit(MapUnit eMap)
XColorListRef GetColorList() const
void ClearModel(bool bCalledFromDestructor)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1307
#define RES_PARATR_END
Definition: hintids.hxx:180