LCOV - code coverage report
Current view: top level - sw/source/uibase/app - docshdrw.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 25 28 89.3 %
Date: 2014-11-03 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       20769 : void InitDrawModelAndDocShell(SwDocShell* pSwDocShell, SwDrawModel* pSwDrawDocument)
      37             : {
      38       20769 :     if(pSwDrawDocument)
      39             :     {
      40       20769 :         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       10453 :             pSwDrawDocument->SetObjectShell(pSwDocShell);
      48             : 
      49             :             // set persist, maybe zero
      50       10453 :             pSwDrawDocument->SetPersist(pSwDocShell);
      51             : 
      52             :             // get and decide on the color table to use
      53       10453 :             if(pSwDocShell)
      54             :             {
      55        5228 :                 const SvxColorListItem* pColItemFromDocShell = static_cast< const SvxColorListItem* >(pSwDocShell->GetItem(SID_COLOR_TABLE));
      56             : 
      57        5228 :                 if(pColItemFromDocShell)
      58             :                 {
      59             :                     // the DocShell has a ColorTable, use it also in DrawingLayer
      60         184 :                     XColorListRef xCol(pColItemFromDocShell->GetColorList());
      61         184 :                     pSwDrawDocument->SetPropertyList(static_cast<XPropertyList*>(xCol.get()));
      62             :                 }
      63             :                 else
      64             :                 {
      65             :                     // Use the ColorTable which is used at the DrawingLayer's SdrModel
      66        5044 :                     XColorListRef xColorList = pSwDrawDocument->GetColorList();
      67        5044 :                     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        5044 :                         xColorList = XColorList::GetStdColorList();
      76        5044 :                         pSwDocShell->PutItem(SvxColorListItem(xColorList, SID_COLOR_TABLE));
      77        5044 :                         pSwDrawDocument->SetPropertyList(xColorList.get());
      78        5044 :                     }
      79             :                 }
      80             : 
      81             :                 // add other tables in SfxItemSet of the DocShell
      82        5228 :                 pSwDocShell->PutItem(SvxGradientListItem(pSwDrawDocument->GetGradientList(), SID_GRADIENT_LIST));
      83        5228 :                 pSwDocShell->PutItem(SvxHatchListItem(pSwDrawDocument->GetHatchList(), SID_HATCH_LIST));
      84        5228 :                 pSwDocShell->PutItem(SvxBitmapListItem(pSwDrawDocument->GetBitmapList(), SID_BITMAP_LIST));
      85        5228 :                 pSwDocShell->PutItem(SvxDashListItem(pSwDrawDocument->GetDashList(), SID_DASH_LIST));
      86        5228 :                 pSwDocShell->PutItem(SvxLineEndListItem(pSwDrawDocument->GetLineEndList(), SID_LINEEND_LIST));
      87             :             }
      88             : 
      89             :             // init hyphenator for DrawingLayer outliner
      90       10453 :             uno::Reference<linguistic2::XHyphenator> xHyphenator(::GetHyphenator());
      91       10453 :             Outliner& rOutliner = pSwDrawDocument->GetDrawOutliner();
      92             : 
      93       10453 :             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       21039 : }
     102             : 
     103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10