LibreOffice Module sw (master)  1
docshdrw.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 <hintids.hxx>
21 #include <svx/svxids.hrc>
22 #include <svl/stritem.hxx>
23 #include <svx/drawitem.hxx>
24 #include <svx/svdmodel.hxx>
25 #include <svx/svdoutl.hxx>
26 #include <svx/xtable.hxx>
27 #include <unotools/configmgr.hxx>
28 #include <docsh.hxx>
29 #include <doc.hxx>
30 #include <drawdoc.hxx>
32 
33 using namespace ::com::sun::star;
34 
35 // Load Document
36 void InitDrawModelAndDocShell(SwDocShell* pSwDocShell, SwDrawModel* pSwDrawDocument)
37 {
38  if(pSwDrawDocument)
39  {
40  if(pSwDocShell == pSwDrawDocument->GetObjectShell())
41  {
42  // association already done, nothing to do
43  }
44  else
45  {
46  // set object shell (mainly for FormControl stuff), maybe zero
47  pSwDrawDocument->SetObjectShell(pSwDocShell);
48 
49  // set persist, maybe zero
50  pSwDrawDocument->SetPersist(pSwDocShell);
51 
52  // get and decide on the color table to use
53  if(pSwDocShell)
54  {
55  const SvxColorListItem* pColItemFromDocShell = pSwDocShell->GetItem(SID_COLOR_TABLE);
56 
57  if(pColItemFromDocShell)
58  {
59  // the DocShell has a ColorTable, use it also in DrawingLayer
60  const XColorListRef& xCol(pColItemFromDocShell->GetColorList());
61  pSwDrawDocument->SetPropertyList(static_cast<XPropertyList*>(xCol.get()));
62  }
63  else
64  {
65  // Use the ColorTable which is used at the DrawingLayer's SdrModel
66  XColorListRef xColorList = pSwDrawDocument->GetColorList();
67  if (xColorList.is())
68  {
69  pSwDocShell->PutItem(SvxColorListItem(xColorList, SID_COLOR_TABLE));
70  }
72  {
73  // there wasn't one, get the standard and set to the
74  // docshell and then to the drawdocument
75  xColorList = XColorList::GetStdColorList();
76  pSwDocShell->PutItem(SvxColorListItem(xColorList, SID_COLOR_TABLE));
77  pSwDrawDocument->SetPropertyList(xColorList.get());
78  }
79  }
80 
81  // add other tables in SfxItemSet of the DocShell
82  pSwDocShell->PutItem(SvxGradientListItem(pSwDrawDocument->GetGradientList(), SID_GRADIENT_LIST));
83  pSwDocShell->PutItem(SvxHatchListItem(pSwDrawDocument->GetHatchList(), SID_HATCH_LIST));
84  pSwDocShell->PutItem(SvxBitmapListItem(pSwDrawDocument->GetBitmapList(), SID_BITMAP_LIST));
85  pSwDocShell->PutItem(SvxPatternListItem(pSwDrawDocument->GetPatternList(), SID_PATTERN_LIST));
86  pSwDocShell->PutItem(SvxDashListItem(pSwDrawDocument->GetDashList(), SID_DASH_LIST));
87  pSwDocShell->PutItem(SvxLineEndListItem(pSwDrawDocument->GetLineEndList(), SID_LINEEND_LIST));
88  }
89 
90  // init hyphenator for DrawingLayer outliner
91  uno::Reference<linguistic2::XHyphenator> xHyphenator(::GetHyphenator());
92  Outliner& rOutliner = pSwDrawDocument->GetDrawOutliner();
93 
94  rOutliner.SetHyphenator(xHyphenator);
95  }
96  }
97  else if(pSwDocShell)
98  {
99  // fallback: add the default color list to have one when someone requests it from the DocShell
100  pSwDocShell->PutItem(SvxColorListItem(XColorList::GetStdColorList(), SID_COLOR_TABLE));
101  }
102 }
103 
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SdrOutliner & GetDrawOutliner(const SdrTextObj *pObj=nullptr) const
uno::Reference< linguistic2::XHyphenator > GetHyphenator()
Definition: swtypes.cxx:50
XDashListRef GetDashList() const
void PutItem(const SfxPoolItem &rItem)
XPatternListRef GetPatternList() const
static bool IsFuzzing()
XLineEndListRef GetLineEndList() const
static XColorListRef GetStdColorList()
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
void InitDrawModelAndDocShell(SwDocShell *pSwDocShell, SwDrawModel *pSwDrawDocument)
Definition: docshdrw.cxx:36
XGradientListRef GetGradientList() const
const XColorListRef & GetColorList() const
XHatchListRef GetHatchList() const
void SetObjectShell(SfxObjectShell *pShell)
XBitmapListRef GetBitmapList() const
void SetHyphenator(css::uno::Reference< css::linguistic2::XHyphenator > const &xHyph)
XColorListRef GetColorList() const
void SetPersist(::comphelper::IEmbeddedHelper *p)
void SetPropertyList(XPropertyListRef const &p)
SfxObjectShell * GetObjectShell() const