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_pDocument->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  if (ScStyleSheetPool* pStyleSheetPool = m_pDocument->GetStyleSheetPool())
62  {
63  pStyleSheetPool->CreateStandardStyles();
64  m_pDocument->UpdStlShtPtrsFrmNms();
65 
66  if (!m_bUcalcTest)
67  {
68  /* Create styles that are imported through Orcus */
69 
70  OUString aURL("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/calc/styles.xml");
71  rtl::Bootstrap::expandMacros(aURL);
72 
73  OUString aPath;
74  osl::FileBase::getSystemPathFromFileURL(aURL, aPath);
75 
77  if (pOrcus)
78  {
79  pOrcus->importODS_Styles(*m_pDocument, aPath);
80  pStyleSheetPool->setAllParaStandard();
81  }
82  }
83  }
84 
85  // SetDocumentModified is not allowed anymore in Load/InitNew!
86  InitItems();
87  CalcOutputFactor();
88 
89  return bRet;
90 }
91 
92 void ScDocShell::SetEmpty(bool bSet)
93 {
94  m_bIsEmpty = bSet;
95 }
96 
98 {
99  // Fill AllItemSet for Controller with needed Items:
100  // Printer Options are set in GetPrinter when printing
101  UpdateFontList();
102 
103  ScDrawLayer* pDrawLayer = m_pDocument->GetDrawLayer();
104  if (pDrawLayer)
105  {
106  PutItem( SvxColorListItem ( pDrawLayer->GetColorList(), SID_COLOR_TABLE ) );
107  PutItem( SvxGradientListItem( pDrawLayer->GetGradientList(), SID_GRADIENT_LIST ) );
108  PutItem( SvxHatchListItem ( pDrawLayer->GetHatchList(), SID_HATCH_LIST ) );
109  PutItem( SvxBitmapListItem ( pDrawLayer->GetBitmapList(), SID_BITMAP_LIST ) );
110  PutItem( SvxPatternListItem ( pDrawLayer->GetPatternList(), SID_PATTERN_LIST ) );
111  PutItem( SvxDashListItem ( pDrawLayer->GetDashList(), SID_DASH_LIST ) );
112  PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) );
113 
114  // Other modifications after creation of the DrawLayer
115  pDrawLayer->SetNotifyUndoActionHdl( std::bind( &ScDocFunc::NotifyDrawUndo, m_pDocFunc.get(), std::placeholders::_1 ) );
116  }
117  else if (!utl::ConfigManager::IsFuzzing())
118  {
119  // always use global color table instead of local copy
120  PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) );
121  }
122 
124  (m_pDocument->GetForbiddenCharacters() && m_pDocument->IsValidAsianCompression() && m_pDocument->IsValidAsianKerning()))
125  return;
126 
127  // get settings from SvxAsianConfig
128  SvxAsianConfig aAsian;
129 
130  if (!m_pDocument->GetForbiddenCharacters())
131  {
132  // set forbidden characters if necessary
133  const uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
134  if (aLocales.hasElements())
135  {
136  std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenTable(
138 
139  for (const lang::Locale& rLocale : aLocales)
140  {
141  i18n::ForbiddenCharacters aForbidden;
142  aAsian.GetStartEndChars( rLocale, aForbidden.beginLine, aForbidden.endLine );
144 
145  xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden );
146  }
147 
148  m_pDocument->SetForbiddenCharacters( xForbiddenTable );
149  }
150  }
151 
152  if ( !m_pDocument->IsValidAsianCompression() )
153  {
154  // set compression mode from configuration if not already set (e.g. XML import)
155  m_pDocument->SetAsianCompression( aAsian.GetCharDistanceCompression() );
156  }
157 
158  if ( !m_pDocument->IsValidAsianKerning() )
159  {
160  // set asian punctuation kerning from configuration if not already set (e.g. XML import)
161  m_pDocument->SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed
162  }
163 }
164 
166 {
167  ScDrawLayer* pDrawLayer = m_pDocument->GetDrawLayer();
168  if (pDrawLayer)
169  pDrawLayer->SetObjectShell( nullptr );
170 }
171 
173 {
174  ScDrawLayer* pDrawLayer = m_pDocument->GetDrawLayer();
175  if (!pDrawLayer)
176  {
177  m_pDocument->InitDrawLayer(this);
178  pDrawLayer = m_pDocument->GetDrawLayer();
179  InitItems(); // including Undo and Basic
180  Broadcast( SfxHint( SfxHintId::ScDrawLayerNew ) );
181  if (m_nDocumentLock)
182  pDrawLayer->setLock(true);
183  }
184  return pDrawLayer;
185 }
186 
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_Int32 STD_COL_WIDTH
Definition: global.hxx:86
#define OLE_STD_CELLS_Y
Definition: global.hxx:104
URL aURL
bool IsKerningWesternTextOnly() const
Collection of orcus filter wrappers.
void NotifyDrawUndo(std::unique_ptr< SdrUndoAction >)
Definition: docfunc.cxx:120
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
#define OLE_STD_CELLS_X
Definition: global.hxx:103
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:2622
SAL_DLLPRIVATE void InitItems()
Definition: docsh2.cxx:97
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
static bool IsFuzzing()
void SetEmpty(bool bSet)
Definition: docsh2.cxx:92
XLineEndListRef GetLineEndList() const
static std::shared_ptr< SvxForbiddenCharactersTable > makeForbiddenCharactersTable(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
ScDrawLayer * MakeDrawLayer()
Definition: docsh2.cxx:172
static XColorListRef GetStdColorList()
static SC_DLLPUBLIC sal_uInt16 nStdRowHeight
Definition: global.hxx:581
bool GetStartEndChars(css::lang::Locale const &locale, OUString &startChars, OUString &endChars) const
CharCompressType GetCharDistanceCompression() const
SAL_DLLPRIVATE void ResetDrawObjectShell()
Definition: docsh2.cxx:165
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