Line data Source code
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 "scitems.hxx"
21 : #include <svx/drawitem.hxx>
22 : #include <svl/asiancfg.hxx>
23 : #include <editeng/forbiddencharacterstable.hxx>
24 : #include <editeng/unolingu.hxx>
25 :
26 : #include "drwlayer.hxx"
27 : #include "stlpool.hxx"
28 : #include "docsh.hxx"
29 : #include "docshimp.hxx"
30 : #include "docfunc.hxx"
31 : #include "sc.hrc"
32 :
33 : using namespace com::sun::star;
34 :
35 441 : bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
36 : {
37 441 : bool bRet = SfxObjectShell::InitNew( xStor );
38 :
39 441 : aDocument.MakeTable(0);
40 :
41 : // Additional tables are created by the first View, if bIsEmpty is still sal_True
42 441 : if( bRet )
43 : {
44 : Size aSize( (long) ( STD_COL_WIDTH * HMM_PER_TWIPS * OLE_STD_CELLS_X ),
45 441 : (long) ( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) );
46 : // Also adjust start here
47 441 : SetVisAreaOrSize( Rectangle( Point(), aSize ), true );
48 : }
49 :
50 : // InitOptions sets the document languages, must be called before CreateStandardStyles
51 441 : InitOptions(false);
52 :
53 441 : aDocument.GetStyleSheetPool()->CreateStandardStyles();
54 441 : aDocument.UpdStlShtPtrsFrmNms();
55 :
56 : // SetDocumentModified is not allowed anymoe in Load/InitNew!
57 441 : InitItems();
58 441 : CalcOutputFactor();
59 :
60 441 : return bRet;
61 : }
62 :
63 336 : void ScDocShell::SetEmpty(bool bSet)
64 : {
65 336 : bIsEmpty = bSet;
66 336 : }
67 :
68 1250 : void ScDocShell::InitItems()
69 : {
70 : // Fill AllItemSet for Controller with needed Items:
71 : // Printer Options are set in GetPrinter when printing
72 1250 : UpdateFontList();
73 :
74 1250 : ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
75 1250 : if (pDrawLayer)
76 : {
77 708 : PutItem( SvxColorListItem ( pDrawLayer->GetColorList(), SID_COLOR_TABLE ) );
78 708 : PutItem( SvxGradientListItem( pDrawLayer->GetGradientList(), SID_GRADIENT_LIST ) );
79 708 : PutItem( SvxHatchListItem ( pDrawLayer->GetHatchList(), SID_HATCH_LIST ) );
80 708 : PutItem( SvxBitmapListItem ( pDrawLayer->GetBitmapList(), SID_BITMAP_LIST ) );
81 708 : PutItem( SvxDashListItem ( pDrawLayer->GetDashList(), SID_DASH_LIST ) );
82 708 : PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) );
83 :
84 : // Other modifications after creation of the DrawLayer
85 708 : pDrawLayer->SetNotifyUndoActionHdl( LINK( pDocFunc, ScDocFunc, NotifyDrawUndo ) );
86 : }
87 : else
88 : {
89 : // always use global color table instead of local copy
90 542 : PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) );
91 : }
92 :
93 3767 : if ( !aDocument.GetForbiddenCharacters().is() ||
94 3767 : !aDocument.IsValidAsianCompression() || !aDocument.IsValidAsianKerning() )
95 : {
96 : // get settings from SvxAsianConfig
97 1233 : SvxAsianConfig aAsian;
98 :
99 1233 : if ( !aDocument.GetForbiddenCharacters().is() )
100 : {
101 : // set forbidden characters if necessary
102 1233 : uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
103 1233 : if (aLocales.getLength())
104 : {
105 : rtl::Reference<SvxForbiddenCharactersTable> xForbiddenTable =
106 0 : new SvxForbiddenCharactersTable( comphelper::getProcessComponentContext() );
107 :
108 0 : const lang::Locale* pLocales = aLocales.getConstArray();
109 0 : for (sal_Int32 i = 0; i < aLocales.getLength(); i++)
110 : {
111 0 : i18n::ForbiddenCharacters aForbidden;
112 0 : aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine );
113 0 : LanguageType eLang = LanguageTag::convertToLanguageType(pLocales[i]);
114 :
115 0 : xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden );
116 0 : }
117 :
118 0 : aDocument.SetForbiddenCharacters( xForbiddenTable );
119 1233 : }
120 : }
121 :
122 1233 : if ( !aDocument.IsValidAsianCompression() )
123 : {
124 : // set compression mode from configuration if not already set (e.g. XML import)
125 442 : aDocument.SetAsianCompression( sal::static_int_cast<sal_uInt8>( aAsian.GetCharDistanceCompression() ) );
126 : }
127 :
128 1233 : if ( !aDocument.IsValidAsianKerning() )
129 : {
130 : // set asian punctuation kerning from configuration if not already set (e.g. XML import)
131 442 : aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed
132 1233 : }
133 : }
134 1250 : }
135 :
136 1289 : void ScDocShell::ResetDrawObjectShell()
137 : {
138 1289 : ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
139 1289 : if (pDrawLayer)
140 540 : pDrawLayer->SetObjectShell( NULL );
141 1289 : }
142 :
143 1533 : ScDrawLayer* ScDocShell::MakeDrawLayer()
144 : {
145 1533 : ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
146 1533 : if (!pDrawLayer)
147 : {
148 540 : aDocument.InitDrawLayer(this);
149 540 : pDrawLayer = aDocument.GetDrawLayer();
150 540 : InitItems(); // including Undo and Basic
151 540 : Broadcast( SfxSimpleHint( SC_HINT_DRWLAYER_NEW ) );
152 540 : if (nDocumentLock)
153 84 : pDrawLayer->setLock(true);
154 : }
155 1533 : return pDrawLayer;
156 156 : }
157 :
158 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|