LibreOffice Module sc (master)  1
docsh2.cxx
Go to the documentation of this file.
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 <rtl/bootstrap.hxx>
21 #include <osl/file.hxx>
22 #include <svx/drawitem.hxx>
23 #include <svl/asiancfg.hxx>
25 #include <orcusfilters.hxx>
26 #include <config_folders.h>
27 #include <unotools/configmgr.hxx>
29 #include <o3tl/unit_conversion.hxx>
30 
31 #include <drwlayer.hxx>
32 #include <stlpool.hxx>
33 #include <docsh.hxx>
34 #include <docfunc.hxx>
35 #include <svx/svxids.hrc>
36 #include <filter.hxx>
37 #include <functional>
38 
39 using namespace com::sun::star;
40 
41 bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
42 {
43  bool bRet = SfxObjectShell::InitNew( xStor );
44 
45  m_aDocument.MakeTable(0);
46 
47  // Additional tables are created by the first View, if bIsEmpty is still sal_True
48  if( bRet )
49  {
50  Size aSize(
54  // Also adjust start here
55  SetVisAreaOrSize( tools::Rectangle( Point(), aSize ) );
56  }
57 
58  // InitOptions sets the document languages, must be called before CreateStandardStyles
59  InitOptions(false);
60 
61  m_aDocument.GetStyleSheetPool()->CreateStandardStyles();
62  m_aDocument.UpdStlShtPtrsFrmNms();
63 
64  if (!m_bUcalcTest)
65  {
66  /* Create styles that are imported through Orcus */
67 
68  OUString aURL("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/calc/styles.xml");
69  rtl::Bootstrap::expandMacros(aURL);
70 
71  OUString aPath;
72  osl::FileBase::getSystemPathFromFileURL(aURL, aPath);
73 
75  if (pOrcus)
76  {
77  pOrcus->importODS_Styles(m_aDocument, aPath);
78  m_aDocument.GetStyleSheetPool()->setAllParaStandard();
79  }
80  }
81 
82  // SetDocumentModified is not allowed anymore in Load/InitNew!
83  InitItems();
84  CalcOutputFactor();
85 
86  return bRet;
87 }
88 
89 void ScDocShell::SetEmpty(bool bSet)
90 {
91  m_bIsEmpty = bSet;
92 }
93 
95 {
96  // Fill AllItemSet for Controller with needed Items:
97  // Printer Options are set in GetPrinter when printing
98  UpdateFontList();
99 
100  ScDrawLayer* pDrawLayer = m_aDocument.GetDrawLayer();
101  if (pDrawLayer)
102  {
103  PutItem( SvxColorListItem ( pDrawLayer->GetColorList(), SID_COLOR_TABLE ) );
104  PutItem( SvxGradientListItem( pDrawLayer->GetGradientList(), SID_GRADIENT_LIST ) );
105  PutItem( SvxHatchListItem ( pDrawLayer->GetHatchList(), SID_HATCH_LIST ) );
106  PutItem( SvxBitmapListItem ( pDrawLayer->GetBitmapList(), SID_BITMAP_LIST ) );
107  PutItem( SvxPatternListItem ( pDrawLayer->GetPatternList(), SID_PATTERN_LIST ) );
108  PutItem( SvxDashListItem ( pDrawLayer->GetDashList(), SID_DASH_LIST ) );
109  PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) );
110 
111  // Other modifications after creation of the DrawLayer
112  pDrawLayer->SetNotifyUndoActionHdl( std::bind( &ScDocFunc::NotifyDrawUndo, m_pDocFunc.get(), std::placeholders::_1 ) );
113  }
114  else if (!utl::ConfigManager::IsFuzzing())
115  {
116  // always use global color table instead of local copy
117  PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) );
118  }
119 
121  (m_aDocument.GetForbiddenCharacters() && m_aDocument.IsValidAsianCompression() && m_aDocument.IsValidAsianKerning()))
122  return;
123 
124  // get settings from SvxAsianConfig
125  SvxAsianConfig aAsian;
126 
127  if (!m_aDocument.GetForbiddenCharacters())
128  {
129  // set forbidden characters if necessary
130  const uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
131  if (aLocales.hasElements())
132  {
133  std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenTable(
135 
136  for (const lang::Locale& rLocale : aLocales)
137  {
138  i18n::ForbiddenCharacters aForbidden;
139  aAsian.GetStartEndChars( rLocale, aForbidden.beginLine, aForbidden.endLine );
141 
142  xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden );
143  }
144 
145  m_aDocument.SetForbiddenCharacters( xForbiddenTable );
146  }
147  }
148 
149  if ( !m_aDocument.IsValidAsianCompression() )
150  {
151  // set compression mode from configuration if not already set (e.g. XML import)
152  m_aDocument.SetAsianCompression( aAsian.GetCharDistanceCompression() );
153  }
154 
155  if ( !m_aDocument.IsValidAsianKerning() )
156  {
157  // set asian punctuation kerning from configuration if not already set (e.g. XML import)
158  m_aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed
159  }
160 }
161 
163 {
164  ScDrawLayer* pDrawLayer = m_aDocument.GetDrawLayer();
165  if (pDrawLayer)
166  pDrawLayer->SetObjectShell( nullptr );
167 }
168 
170 {
171  ScDrawLayer* pDrawLayer = m_aDocument.GetDrawLayer();
172  if (!pDrawLayer)
173  {
174  m_aDocument.InitDrawLayer(this);
175  pDrawLayer = m_aDocument.GetDrawLayer();
176  InitItems(); // including Undo and Basic
177  Broadcast( SfxHint( SfxHintId::ScDrawLayerNew ) );
178  if (m_nDocumentLock)
179  pDrawLayer->setLock(true);
180  }
181  return pDrawLayer;
182 }
183 
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define OLE_STD_CELLS_Y
Definition: global.hxx:114
URL aURL
bool IsKerningWesternTextOnly() const
Collection of orcus filter wrappers.
void NotifyDrawUndo(std::unique_ptr< SdrUndoAction >)
Definition: docfunc.cxx:108
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
#define OLE_STD_CELLS_X
Definition: global.hxx:113
void SetNotifyUndoActionHdl(const std::function< void(std::unique_ptr< SdrUndoAction >)> &rLink)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
XDashListRef GetDashList() const
static SC_DLLPUBLIC ScFormatFilterPlugin & Get()
Definition: impex.cxx:2428
SAL_DLLPRIVATE void InitItems()
Definition: docsh2.cxx:94
virtual bool importODS_Styles(ScDocument &rDoc, OUString &aFileName) const =0
Used to import just the styles from an xml file.
XPatternListRef GetPatternList() const
virtual ScOrcusFilters * GetOrcusFilters()=0
#define STD_COL_WIDTH
Definition: global.hxx:94
static bool IsFuzzing()
void SetEmpty(bool bSet)
Definition: docsh2.cxx:89
XLineEndListRef GetLineEndList() const
static std::shared_ptr< SvxForbiddenCharactersTable > makeForbiddenCharactersTable(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
ScDrawLayer * MakeDrawLayer()
Definition: docsh2.cxx:169
static XColorListRef GetStdColorList()
static SC_DLLPUBLIC sal_uInt16 nStdRowHeight
Definition: global.hxx:583
bool GetStartEndChars(css::lang::Locale const &locale, OUString &startChars, OUString &endChars) const
CharCompressType GetCharDistanceCompression() const
SAL_DLLPRIVATE void ResetDrawObjectShell()
Definition: docsh2.cxx:162
XGradientListRef GetGradientList() const
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage)
void setLock(bool bLock)
css::uno::Sequence< css::lang::Locale > GetStartEndCharLocales() const
XHatchListRef GetHatchList() const
void SetObjectShell(SfxObjectShell *pShell)
Reference< XComponentContext > getProcessComponentContext()
XBitmapListRef GetBitmapList() const
XColorListRef GetColorList() const
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &) override
Definition: docsh2.cxx:41