LCOV - code coverage report
Current view: top level - sw/source/uibase/app - docshdrw.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 25 28 89.3 %
Date: 2015-06-13 12:38:46 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      28             : #include <docsh.hxx>
      29             : #include <doc.hxx>
      30             : #include <drawdoc.hxx>
      31             : #include <IDocumentDrawModelAccess.hxx>
      32             : 
      33             : using namespace ::com::sun::star;
      34             : 
      35             : // Load Document
      36       12175 : void InitDrawModelAndDocShell(SwDocShell* pSwDocShell, SwDrawModel* pSwDrawDocument)
      37             : {
      38       12175 :     if(pSwDrawDocument)
      39             :     {
      40       12175 :         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        6117 :             pSwDrawDocument->SetObjectShell(pSwDocShell);
      48             : 
      49             :             // set persist, maybe zero
      50        6117 :             pSwDrawDocument->SetPersist(pSwDocShell);
      51             : 
      52             :             // get and decide on the color table to use
      53        6117 :             if(pSwDocShell)
      54             :             {
      55        3061 :                 const SvxColorListItem* pColItemFromDocShell = static_cast< const SvxColorListItem* >(pSwDocShell->GetItem(SID_COLOR_TABLE));
      56             : 
      57        3061 :                 if(pColItemFromDocShell)
      58             :                 {
      59             :                     // the DocShell has a ColorTable, use it also in DrawingLayer
      60         109 :                     XColorListRef xCol(pColItemFromDocShell->GetColorList());
      61         109 :                     pSwDrawDocument->SetPropertyList(static_cast<XPropertyList*>(xCol.get()));
      62             :                 }
      63             :                 else
      64             :                 {
      65             :                     // Use the ColorTable which is used at the DrawingLayer's SdrModel
      66        2952 :                     XColorListRef xColorList = pSwDrawDocument->GetColorList();
      67        2952 :                     if (xColorList.is())
      68             :                     {
      69           0 :                         pSwDocShell->PutItem(SvxColorListItem(xColorList, SID_COLOR_TABLE));
      70             :                     }
      71             :                     else
      72             :                     {
      73             :                         // there wasn't one, get the standard and set to the
      74             :                         // docshell and then to the drawdocument
      75        2952 :                         xColorList = XColorList::GetStdColorList();
      76        2952 :                         pSwDocShell->PutItem(SvxColorListItem(xColorList, SID_COLOR_TABLE));
      77        2952 :                         pSwDrawDocument->SetPropertyList(xColorList.get());
      78        2952 :                     }
      79             :                 }
      80             : 
      81             :                 // add other tables in SfxItemSet of the DocShell
      82        3061 :                 pSwDocShell->PutItem(SvxGradientListItem(pSwDrawDocument->GetGradientList(), SID_GRADIENT_LIST));
      83        3061 :                 pSwDocShell->PutItem(SvxHatchListItem(pSwDrawDocument->GetHatchList(), SID_HATCH_LIST));
      84        3061 :                 pSwDocShell->PutItem(SvxBitmapListItem(pSwDrawDocument->GetBitmapList(), SID_BITMAP_LIST));
      85        3061 :                 pSwDocShell->PutItem(SvxDashListItem(pSwDrawDocument->GetDashList(), SID_DASH_LIST));
      86        3061 :                 pSwDocShell->PutItem(SvxLineEndListItem(pSwDrawDocument->GetLineEndList(), SID_LINEEND_LIST));
      87             :             }
      88             : 
      89             :             // init hyphenator for DrawingLayer outliner
      90        6117 :             uno::Reference<linguistic2::XHyphenator> xHyphenator(::GetHyphenator());
      91        6117 :             Outliner& rOutliner = pSwDrawDocument->GetDrawOutliner();
      92             : 
      93        6117 :             rOutliner.SetHyphenator(xHyphenator);
      94             :         }
      95             :     }
      96           0 :     else if(pSwDocShell)
      97             :     {
      98             :         // fallback: add the default color list to have one when someone requests it from the DocShell
      99           0 :         pSwDocShell->PutItem(SvxColorListItem(XColorList::GetStdColorList(), SID_COLOR_TABLE));
     100             :     }
     101       12352 : }
     102             : 
     103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11