1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/svxids.hrc>
21 #include <svx/drawitem.hxx>
22 #include <svx/svdoutl.hxx>
23 #include <svx/xtable.hxx>
24 #include <unotools/configmgr.hxx>
26 #include <drawdoc.hxx>
27 #include <swtypes.hxx>
29 using namespace ::com::sun::star
;
32 void InitDrawModelAndDocShell(SwDocShell
* pSwDocShell
, SwDrawModel
* pSwDrawDocument
)
36 if(pSwDocShell
== pSwDrawDocument
->GetObjectShell())
38 // association already done, nothing to do
42 // set object shell (mainly for FormControl stuff), maybe zero
43 pSwDrawDocument
->SetObjectShell(pSwDocShell
);
45 // set persist, maybe zero
46 pSwDrawDocument
->SetPersist(pSwDocShell
);
48 // get and decide on the color table to use
51 const SvxColorListItem
* pColItemFromDocShell
= pSwDocShell
->GetItem(SID_COLOR_TABLE
);
53 if(pColItemFromDocShell
)
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()));
61 // Use the ColorTable which is used at the DrawingLayer's SdrModel
62 XColorListRef xColorList
= pSwDrawDocument
->GetColorList();
65 pSwDocShell
->PutItem(SvxColorListItem(xColorList
, SID_COLOR_TABLE
));
67 else if (!utl::ConfigManager::IsFuzzing())
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
);
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
));
86 // init hyphenator for DrawingLayer outliner
87 uno::Reference
<linguistic2::XHyphenator
> xHyphenator(::GetHyphenator());
88 Outliner
& rOutliner
= pSwDrawDocument
->GetDrawOutliner();
90 rOutliner
.SetHyphenator(xHyphenator
);
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
));
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */