1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sw.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include <hintids.hxx>
26cdf0e10cSrcweir #include <svx/svxids.hrc>
27cdf0e10cSrcweir #include <svl/stritem.hxx>
28cdf0e10cSrcweir #include <svx/drawitem.hxx>
29cdf0e10cSrcweir #include <svx/svdmodel.hxx>
30cdf0e10cSrcweir #include <svx/svdoutl.hxx>
31cdf0e10cSrcweir #include <svx/xtable.hxx>
32cdf0e10cSrcweir #include <docsh.hxx>
33cdf0e10cSrcweir #include <doc.hxx>
34*26ea3662SArmin Le Grand #include <drawdoc.hxx>
35cdf0e10cSrcweir
36cdf0e10cSrcweir using namespace ::com::sun::star;
37cdf0e10cSrcweir
38cdf0e10cSrcweir /*--------------------------------------------------------------------
39cdf0e10cSrcweir Beschreibung: Document laden
40cdf0e10cSrcweir --------------------------------------------------------------------*/
41cdf0e10cSrcweir
InitDrawModelAndDocShell(SwDocShell * pSwDocShell,SwDrawModel * pSwDrawDocument)42*26ea3662SArmin Le Grand void InitDrawModelAndDocShell(SwDocShell* pSwDocShell, SwDrawModel* pSwDrawDocument)
43cdf0e10cSrcweir {
44*26ea3662SArmin Le Grand if(pSwDrawDocument)
45cdf0e10cSrcweir {
46*26ea3662SArmin Le Grand if(pSwDocShell == pSwDrawDocument->GetObjectShell())
47*26ea3662SArmin Le Grand {
48*26ea3662SArmin Le Grand // association already done, nothing to do
49cdf0e10cSrcweir }
50cdf0e10cSrcweir else
51*26ea3662SArmin Le Grand {
52*26ea3662SArmin Le Grand // set object shell (mainly for FormControl stuff), maybe zero
53*26ea3662SArmin Le Grand pSwDrawDocument->SetObjectShell(pSwDocShell);
54*26ea3662SArmin Le Grand
55*26ea3662SArmin Le Grand // set persist, maybe zero
56*26ea3662SArmin Le Grand pSwDrawDocument->SetPersist(pSwDocShell);
57*26ea3662SArmin Le Grand
58*26ea3662SArmin Le Grand // get and decide on the color table to use
59*26ea3662SArmin Le Grand if(pSwDocShell)
60*26ea3662SArmin Le Grand {
61*26ea3662SArmin Le Grand const SvxColorTableItem* pColItemFromDocShell = static_cast< const SvxColorTableItem* >(pSwDocShell->GetItem(SID_COLOR_TABLE));
62*26ea3662SArmin Le Grand
63*26ea3662SArmin Le Grand if(pColItemFromDocShell)
64*26ea3662SArmin Le Grand {
65*26ea3662SArmin Le Grand // the DocShell has a ColorTable, use it also in DrawingLayer
66*26ea3662SArmin Le Grand pSwDrawDocument->SetColorTableAtSdrModel(pColItemFromDocShell->GetColorTable());
67*26ea3662SArmin Le Grand }
68*26ea3662SArmin Le Grand else
69*26ea3662SArmin Le Grand {
70*26ea3662SArmin Le Grand // Use the ColorTable which is used at the DrawingLayer's SdrModel
71*26ea3662SArmin Le Grand pSwDocShell->PutItem(SvxColorTableItem(pSwDrawDocument->GetColorTableFromSdrModel(), SID_COLOR_TABLE));
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
74*26ea3662SArmin Le Grand // add other tables in SfxItemSet of the DocShell
75*26ea3662SArmin Le Grand pSwDocShell->PutItem(SvxGradientListItem(pSwDrawDocument->GetGradientListFromSdrModel(), SID_GRADIENT_LIST));
76*26ea3662SArmin Le Grand pSwDocShell->PutItem(SvxHatchListItem(pSwDrawDocument->GetHatchListFromSdrModel(), SID_HATCH_LIST));
77*26ea3662SArmin Le Grand pSwDocShell->PutItem(SvxBitmapListItem(pSwDrawDocument->GetBitmapListFromSdrModel(), SID_BITMAP_LIST));
78*26ea3662SArmin Le Grand pSwDocShell->PutItem(SvxDashListItem(pSwDrawDocument->GetDashListFromSdrModel(), SID_DASH_LIST));
79*26ea3662SArmin Le Grand pSwDocShell->PutItem(SvxLineEndListItem(pSwDrawDocument->GetLineEndListFromSdrModel(), SID_LINEEND_LIST));
80*26ea3662SArmin Le Grand }
81cdf0e10cSrcweir
82*26ea3662SArmin Le Grand // init hyphenator for DrawingLayer outliner
83*26ea3662SArmin Le Grand uno::Reference<linguistic2::XHyphenator> xHyphenator(::GetHyphenator());
84*26ea3662SArmin Le Grand Outliner& rOutliner = pSwDrawDocument->GetDrawOutliner();
85cdf0e10cSrcweir
86*26ea3662SArmin Le Grand rOutliner.SetHyphenator(xHyphenator);
87*26ea3662SArmin Le Grand }
88*26ea3662SArmin Le Grand }
89*26ea3662SArmin Le Grand else if(pSwDocShell)
90*26ea3662SArmin Le Grand {
91*26ea3662SArmin Le Grand // fallback: add the default color list to have one when someone requests it from the DocShell
92*26ea3662SArmin Le Grand pSwDocShell->PutItem(SvxColorTableItem(XColorList::GetStdColorList(), SID_COLOR_TABLE));
93*26ea3662SArmin Le Grand }
94*26ea3662SArmin Le Grand }
95*26ea3662SArmin Le Grand
96*26ea3662SArmin Le Grand //eof
97