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(&rDoc.GetAttrPool(), rDoc.GetDocShell())
36  , m_rDoc(rDoc)
37 {
38  SetScaleUnit( MapUnit::MapTwip );
40 
41  // use common InitDrawModelAndDocShell which will set the associations as needed,
42  // including SvxColorTableItem with WhichID SID_COLOR_TABLE
44 
45  // copy all the default values to the SdrModel
47  if( pSdrPool )
48  {
49  const sal_uInt16 aWhichRanges[] =
50  {
53  0
54  };
55 
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 )
68  {
69  std::unique_ptr<SfxPoolItem> pCpy(pItem->Clone());
70  pCpy->SetWhich( nEdtWhich );
71  pSdrPool->SetPoolDefaultItem( *pCpy );
72  }
73  }
74 
76  // Implementation for asian compression
78 }
79 
80 // Destructor
81 
83 {
84  Broadcast(SdrHint(SdrHintKind::ModelCleared));
85 
86  ClearModel(true);
87 }
88 
96 SdrPage* SwDrawModel::AllocPage(bool bMasterPage)
97 {
98  SwDPage* pPage = new SwDPage(*this, bMasterPage);
99  pPage->SetName("Controls");
100  return pPage;
101 }
102 
103 uno::Reference<embed::XStorage> SwDrawModel::GetDocumentStorage() const
104 {
105  return m_rDoc.GetDocStorage();
106 }
107 
108 uno::Reference< uno::XInterface > SwDrawModel::createUnoModel()
109 {
110  uno::Reference< uno::XInterface > xModel;
111 
112  try
113  {
114  if ( GetDoc().GetDocShell() )
115  {
116  xModel = GetDoc().GetDocShell()->GetModel();
117  }
118  }
119  catch( uno::RuntimeException& )
120  {
121  OSL_FAIL( "<SwDrawModel::createUnoModel()> - could *not* retrieve model at <SwDocShell>" );
122  }
123 
124  return xModel;
125 }
126 
128 {
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));
134 }
135 
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::embed::XStorage > GetDocStorage()
Definition: docnew.cxx:627
SwDocShell * GetDocShell()
Definition: doc.hxx:1350
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:186
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:108
void SetSwapGraphics()
void SetCharCompressType(CharCompressType nType)
css::uno::Reference< css::frame::XModel > GetModel() const
virtual ~SwDrawModel() override
Definition: drawdoc.cxx:82
const SwDoc & GetDoc() const
Definition: drawdoc.hxx:35
XPatternListRef GetPatternList() const
SwDoc & m_rDoc
Definition: docbm.cxx:1205
virtual SdrPage * AllocPage(bool bMasterPage) override
Create a new page (SdPage) and return a pointer to it back.
Definition: drawdoc.cxx:96
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
void SetName(const OUString &rName)
virtual std::shared_ptr< SvxForbiddenCharactersTable > & getForbiddenCharacterTable() override
Get the forbidden character table and creates one if necessary.
SwDoc & m_rDoc
Definition: drawdoc.hxx:29
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:127
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:186
constexpr sal_uInt16 RES_PARATR_END(82)
constexpr sal_uInt16 RES_CHRATR_END(46)
XBitmapListRef GetBitmapList() const
virtual css::uno::Reference< css::embed::XStorage > GetDocumentStorage() const override
Definition: drawdoc.cxx:103
Reference< XModel > xModel
void SetScaleUnit(MapUnit eMap)
XColorListRef GetColorList() const
SwDrawModel(SwDoc &rDoc)
Definition: drawdoc.cxx:34
void ClearModel(bool bCalledFromDestructor)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1317