Bump version to 4.3-4
[LibreOffice.git] / sc / source / ui / docshell / docsh2.cxx
blobcbf967aaf74c081eb5a873df71de3776d7564c3e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "scitems.hxx"
21 #include <svx/drawitem.hxx>
22 #include <svl/asiancfg.hxx>
23 #include <editeng/forbiddencharacterstable.hxx>
24 #include <editeng/unolingu.hxx>
26 #include "drwlayer.hxx"
27 #include "stlpool.hxx"
28 #include "docsh.hxx"
29 #include "docshimp.hxx"
30 #include "docfunc.hxx"
31 #include "sc.hrc"
33 using namespace com::sun::star;
35 bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
37 bool bRet = SfxObjectShell::InitNew( xStor );
39 aDocument.MakeTable(0);
41 // Additional tables are created by the first View, if bIsEmpty is still sal_True
42 if( bRet )
44 Size aSize( (long) ( STD_COL_WIDTH * HMM_PER_TWIPS * OLE_STD_CELLS_X ),
45 (long) ( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) );
46 // Also adjust start here
47 SetVisAreaOrSize( Rectangle( Point(), aSize ), true );
50 // InitOptions sets the document languages, must be called before CreateStandardStyles
51 InitOptions(false);
53 aDocument.GetStyleSheetPool()->CreateStandardStyles();
54 aDocument.UpdStlShtPtrsFrmNms();
56 // SetDocumentModified is not allowed anymoe in Load/InitNew!
57 InitItems();
58 CalcOutputFactor();
60 return bRet;
63 bool ScDocShell::IsEmpty() const
65 return bIsEmpty;
69 void ScDocShell::SetEmpty(bool bSet)
71 bIsEmpty = bSet;
74 void ScDocShell::InitItems()
76 // Fill AllItemSet for Controller with needed Items:
77 // Printer Options are set in GetPrinter when printing
78 UpdateFontList();
80 ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
81 if (pDrawLayer)
83 PutItem( SvxColorListItem ( pDrawLayer->GetColorList(), SID_COLOR_TABLE ) );
84 PutItem( SvxGradientListItem( pDrawLayer->GetGradientList(), SID_GRADIENT_LIST ) );
85 PutItem( SvxHatchListItem ( pDrawLayer->GetHatchList(), SID_HATCH_LIST ) );
86 PutItem( SvxBitmapListItem ( pDrawLayer->GetBitmapList(), SID_BITMAP_LIST ) );
87 PutItem( SvxDashListItem ( pDrawLayer->GetDashList(), SID_DASH_LIST ) );
88 PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) );
90 // Other modifications after creation of the DrawLayer
91 pDrawLayer->SetNotifyUndoActionHdl( LINK( pDocFunc, ScDocFunc, NotifyDrawUndo ) );
93 else
95 // always use global color table instead of local copy
96 PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) );
99 if ( !aDocument.GetForbiddenCharacters().is() ||
100 !aDocument.IsValidAsianCompression() || !aDocument.IsValidAsianKerning() )
102 // get settings from SvxAsianConfig
103 SvxAsianConfig aAsian;
105 if ( !aDocument.GetForbiddenCharacters().is() )
107 // set forbidden characters if necessary
108 uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
109 if (aLocales.getLength())
111 rtl::Reference<SvxForbiddenCharactersTable> xForbiddenTable =
112 new SvxForbiddenCharactersTable( comphelper::getProcessComponentContext() );
114 const lang::Locale* pLocales = aLocales.getConstArray();
115 for (sal_Int32 i = 0; i < aLocales.getLength(); i++)
117 i18n::ForbiddenCharacters aForbidden;
118 aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine );
119 LanguageType eLang = LanguageTag::convertToLanguageType(pLocales[i]);
121 xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden );
124 aDocument.SetForbiddenCharacters( xForbiddenTable );
128 if ( !aDocument.IsValidAsianCompression() )
130 // set compression mode from configuration if not already set (e.g. XML import)
131 aDocument.SetAsianCompression( sal::static_int_cast<sal_uInt8>( aAsian.GetCharDistanceCompression() ) );
134 if ( !aDocument.IsValidAsianKerning() )
136 // set asian punctuation kerning from configuration if not already set (e.g. XML import)
137 aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed
142 void ScDocShell::ResetDrawObjectShell()
144 ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
145 if (pDrawLayer)
146 pDrawLayer->SetObjectShell( NULL );
149 void ScDocShell::Activate()
154 void ScDocShell::Deactivate()
159 ScDrawLayer* ScDocShell::MakeDrawLayer()
161 ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
162 if (!pDrawLayer)
164 aDocument.InitDrawLayer(this);
165 pDrawLayer = aDocument.GetDrawLayer();
166 InitItems(); // including Undo and Basic
167 Broadcast( SfxSimpleHint( SC_HINT_DRWLAYER_NEW ) );
168 if (nDocumentLock)
169 pDrawLayer->setLock(true);
171 return pDrawLayer;
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */