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