fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / docshell / docsh2.cxx
blob6f8b4f4b57f147d717c46639f81713e0543589b6
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 void ScDocShell::SetEmpty(bool bSet)
65 bIsEmpty = bSet;
68 void ScDocShell::InitItems()
70 // Fill AllItemSet for Controller with needed Items:
71 // Printer Options are set in GetPrinter when printing
72 UpdateFontList();
74 ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
75 if (pDrawLayer)
77 PutItem( SvxColorListItem ( pDrawLayer->GetColorList(), SID_COLOR_TABLE ) );
78 PutItem( SvxGradientListItem( pDrawLayer->GetGradientList(), SID_GRADIENT_LIST ) );
79 PutItem( SvxHatchListItem ( pDrawLayer->GetHatchList(), SID_HATCH_LIST ) );
80 PutItem( SvxBitmapListItem ( pDrawLayer->GetBitmapList(), SID_BITMAP_LIST ) );
81 PutItem( SvxDashListItem ( pDrawLayer->GetDashList(), SID_DASH_LIST ) );
82 PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) );
84 // Other modifications after creation of the DrawLayer
85 pDrawLayer->SetNotifyUndoActionHdl( LINK( pDocFunc, ScDocFunc, NotifyDrawUndo ) );
87 else
89 // always use global color table instead of local copy
90 PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) );
93 if ( !aDocument.GetForbiddenCharacters().is() ||
94 !aDocument.IsValidAsianCompression() || !aDocument.IsValidAsianKerning() )
96 // get settings from SvxAsianConfig
97 SvxAsianConfig aAsian;
99 if ( !aDocument.GetForbiddenCharacters().is() )
101 // set forbidden characters if necessary
102 uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
103 if (aLocales.getLength())
105 rtl::Reference<SvxForbiddenCharactersTable> xForbiddenTable =
106 new SvxForbiddenCharactersTable( comphelper::getProcessComponentContext() );
108 const lang::Locale* pLocales = aLocales.getConstArray();
109 for (sal_Int32 i = 0; i < aLocales.getLength(); i++)
111 i18n::ForbiddenCharacters aForbidden;
112 aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine );
113 LanguageType eLang = LanguageTag::convertToLanguageType(pLocales[i]);
115 xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden );
118 aDocument.SetForbiddenCharacters( xForbiddenTable );
122 if ( !aDocument.IsValidAsianCompression() )
124 // set compression mode from configuration if not already set (e.g. XML import)
125 aDocument.SetAsianCompression( sal::static_int_cast<sal_uInt8>( aAsian.GetCharDistanceCompression() ) );
128 if ( !aDocument.IsValidAsianKerning() )
130 // set asian punctuation kerning from configuration if not already set (e.g. XML import)
131 aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed
136 void ScDocShell::ResetDrawObjectShell()
138 ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
139 if (pDrawLayer)
140 pDrawLayer->SetObjectShell( NULL );
143 ScDrawLayer* ScDocShell::MakeDrawLayer()
145 ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
146 if (!pDrawLayer)
148 aDocument.InitDrawLayer(this);
149 pDrawLayer = aDocument.GetDrawLayer();
150 InitItems(); // including Undo and Basic
151 Broadcast( SfxSimpleHint( SC_HINT_DRWLAYER_NEW ) );
152 if (nDocumentLock)
153 pDrawLayer->setLock(true);
155 return pDrawLayer;
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */