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>
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
39using namespace com::sun::star;
40
41bool 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
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 /* 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_pDocument, aPath);
78 pStyleSheetPool->setAllParaStandard();
79 }
80 }
81
82 // SetDocumentModified is not allowed anymore in Load/InitNew!
83 InitItems();
85
86 return bRet;
87}
88
89void 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
99
100 ScDrawLayer* pDrawLayer = m_pDocument->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 }
115 {
116 // always use global color table instead of local copy
118 }
119
121 (m_pDocument->GetForbiddenCharacters() && m_pDocument->IsValidAsianCompression() && m_pDocument->IsValidAsianKerning()))
122 return;
123
124 // get settings from SvxAsianConfig
125 SvxAsianConfig aAsian;
126
127 if (!m_pDocument->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_pDocument->SetForbiddenCharacters( xForbiddenTable );
146 }
147 }
148
149 if ( !m_pDocument->IsValidAsianCompression() )
150 {
151 // set compression mode from configuration if not already set (e.g. XML import)
152 m_pDocument->SetAsianCompression( aAsian.GetCharDistanceCompression() );
153 }
154
155 if ( !m_pDocument->IsValidAsianKerning() )
156 {
157 // set asian punctuation kerning from configuration if not already set (e.g. XML import)
158 m_pDocument->SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed
159 }
160}
161
163{
164 ScDrawLayer* pDrawLayer = m_pDocument->GetDrawLayer();
165 if (pDrawLayer)
166 pDrawLayer->SetObjectShell( nullptr );
167}
168
170{
171 ScDrawLayer* pDrawLayer = m_pDocument->GetDrawLayer();
172 if (!pDrawLayer)
173 {
174 m_pDocument->InitDrawLayer(this);
175 pDrawLayer = m_pDocument->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: */
void SetObjectShell(SfxObjectShell *pShell)
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
void NotifyDrawUndo(std::unique_ptr< SdrUndoAction >)
Definition: docfunc.cxx:120
void SetEmpty(bool bSet)
Definition: docsh2.cxx:89
SAL_DLLPRIVATE void ResetDrawObjectShell()
Definition: docsh2.cxx:162
void UpdateFontList()
Definition: docsh3.cxx:456
sal_uInt16 m_nDocumentLock
Definition: docsh.hxx:98
std::unique_ptr< ScDocFunc > m_pDocFunc
Definition: docsh.hxx:88
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &) override
Definition: docsh2.cxx:41
SAL_DLLPRIVATE void InitItems()
Definition: docsh2.cxx:94
std::shared_ptr< ScDocument > m_pDocument
Definition: docsh.hxx:82
ScDrawLayer * MakeDrawLayer()
Definition: docsh2.cxx:169
bool m_bIsEmpty
Definition: docsh.hxx:93
SAL_DLLPRIVATE void InitOptions(bool bForLoading)
Definition: docsh3.cxx:403
void CalcOutputFactor()
Definition: docsh3.cxx:355
void SetVisAreaOrSize(const tools::Rectangle &rVisArea)
Definition: docsh6.cxx:73
virtual ScOrcusFilters * GetOrcusFilters()=0
static SC_DLLPUBLIC ScFormatFilterPlugin & Get()
Definition: impex.cxx:2684
static SC_DLLPUBLIC sal_uInt16 nStdRowHeight
Definition: global.hxx:596
Collection of orcus filter wrappers.
virtual bool importODS_Styles(ScDocument &rDoc, OUString &aFileName) const =0
Used to import just the styles from an xml file.
XBitmapListRef GetBitmapList() const
void SetNotifyUndoActionHdl(const std::function< void(std::unique_ptr< SdrUndoAction >)> &rLink)
XDashListRef GetDashList() const
XGradientListRef GetGradientList() const
XPatternListRef GetPatternList() const
void setLock(bool bLock)
XLineEndListRef GetLineEndList() const
XColorListRef GetColorList() const
XHatchListRef GetHatchList() const
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage)
void PutItem(const SfxPoolItem &rItem)
CharCompressType GetCharDistanceCompression() const
bool GetStartEndChars(css::lang::Locale const &locale, OUString &startChars, OUString &endChars) const
css::uno::Sequence< css::lang::Locale > GetStartEndCharLocales() const
bool IsKerningWesternTextOnly() const
static std::shared_ptr< SvxForbiddenCharactersTable > makeForbiddenCharactersTable(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
static XColorListRef GetStdColorList()
static bool IsFuzzing()
URL aURL
#define OLE_STD_CELLS_X
Definition: global.hxx:104
#define OLE_STD_CELLS_Y
Definition: global.hxx:105
constexpr sal_Int32 STD_COL_WIDTH
Definition: global.hxx:87
Reference< XComponentContext > getProcessComponentContext()
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)