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 <svx/drawitem.hxx>
23 #include <doc.hxx>
24 #include <drawdoc.hxx>
25 #include <dpage.hxx>
26 #include <docsh.hxx>
27 #include <hintids.hxx>
29 
30 using namespace com::sun::star;
31 
32 // Constructor
34 : FmFormModel(
35  &pDoc->GetAttrPool(),
36  pDoc->GetDocShell())
37  , m_pDoc( pDoc )
38 {
39  SetScaleUnit( MapUnit::MapTwip );
41 
42  // use common InitDrawModelAndDocShell which will set the associations as needed,
43  // including SvxColorTableItem with WhichID SID_COLOR_TABLE
45 
46  // copy all the default values to the SdrModel
48  if( pSdrPool )
49  {
50  const sal_uInt16 aWhichRanges[] =
51  {
54  0
55  };
56 
57  SfxItemPool& rDocPool = m_pDoc->GetAttrPool();
58  sal_uInt16 nEdtWhich, nSlotId;
59  const SfxPoolItem* pItem;
60  for( const sal_uInt16* pRangeArr = aWhichRanges;
61  *pRangeArr; pRangeArr += 2 )
62  for( sal_uInt16 nW = *pRangeArr, nEnd = *(pRangeArr+1);
63  nW < nEnd; ++nW )
64  if( nullptr != (pItem = rDocPool.GetPoolDefaultItem( nW )) &&
65  0 != (nSlotId = rDocPool.GetSlotId( nW ) ) &&
66  nSlotId != nW &&
67  0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
68  nSlotId != nEdtWhich )
69  {
70  std::unique_ptr<SfxPoolItem> pCpy(pItem->Clone());
71  pCpy->SetWhich( nEdtWhich );
72  pSdrPool->SetPoolDefaultItem( *pCpy );
73  }
74  }
75 
77  // Implementation for asian compression
79 }
80 
81 // Destructor
82 
84 {
85  Broadcast(SdrHint(SdrHintKind::ModelCleared));
86 
87  ClearModel(true);
88 }
89 
97 SdrPage* SwDrawModel::AllocPage(bool bMasterPage)
98 {
99  SwDPage* pPage = new SwDPage(*this, bMasterPage);
100  pPage->SetName("Controls");
101  return pPage;
102 }
103 
104 uno::Reference<embed::XStorage> SwDrawModel::GetDocumentStorage() const
105 {
106  return m_pDoc->GetDocStorage();
107 }
108 
109 uno::Reference< uno::XInterface > SwDrawModel::createUnoModel()
110 {
111  uno::Reference< uno::XInterface > xModel;
112 
113  try
114  {
115  if ( GetDoc().GetDocShell() )
116  {
117  xModel = GetDoc().GetDocShell()->GetModel();
118  }
119  }
120  catch( uno::RuntimeException& )
121  {
122  OSL_FAIL( "<SwDrawModel::createUnoModel()> - could *not* retrieve model at <SwDocShell>" );
123  }
124 
125  return xModel;
126 }
127 
129 {
130  rSet.Put(SvxColorListItem(GetColorList(), SID_COLOR_TABLE));
131  rSet.Put(SvxGradientListItem(GetGradientList(), SID_GRADIENT_LIST));
132  rSet.Put(SvxHatchListItem(GetHatchList(), SID_HATCH_LIST));
133  rSet.Put(SvxBitmapListItem(GetBitmapList(), SID_BITMAP_LIST));
134  rSet.Put(SvxPatternListItem(GetPatternList(), SID_PATTERN_LIST));
135 }
136 
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::embed::XStorage > GetDocStorage()
Definition: docnew.cxx:602
SwDocShell * GetDocShell()
Definition: doc.hxx:1342
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:109
void SetSwapGraphics()
void SetCharCompressType(CharCompressType nType)
css::uno::Reference< css::frame::XModel > GetModel() const
virtual ~SwDrawModel() override
Definition: drawdoc.cxx:83
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:97
#define RES_CHRATR_END
Definition: hintids.hxx:115
#define RES_PARATR_BEGIN
Definition: hintids.hxx:161
SwDrawModel(SwDoc *pDoc)
Definition: drawdoc.cxx:33
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:69
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
void PutAreaListItems(SfxItemSet &rSet) const
Put needed items for XPropertyList entries from the DrawModel.
Definition: drawdoc.cxx:128
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:185
SwDoc * m_pDoc
Definition: drawdoc.hxx:29
XBitmapListRef GetBitmapList() const
virtual css::uno::Reference< css::embed::XStorage > GetDocumentStorage() const override
Definition: drawdoc.cxx:104
Reference< XModel > xModel
void SetScaleUnit(MapUnit eMap)
XColorListRef GetColorList() const
void ClearModel(bool bCalledFromDestructor)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1309
#define RES_PARATR_END
Definition: hintids.hxx:181