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