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 : #include <rtl/logfile.hxx>
26 :
27 : #include "drwlayer.hxx"
28 : #include "stlpool.hxx"
29 : #include "docsh.hxx"
30 : #include "docshimp.hxx"
31 : #include "docfunc.hxx"
32 : #include "sc.hrc"
33 :
34 : using namespace com::sun::star;
35 :
36 : //------------------------------------------------------------------
37 :
38 238 : sal_Bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
39 : {
40 : RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::InitNew" );
41 :
42 238 : sal_Bool bRet = SfxObjectShell::InitNew( xStor );
43 :
44 238 : aDocument.MakeTable(0);
45 : // zusaetzliche Tabellen werden von der ersten View angelegt,
46 : // wenn bIsEmpty dann noch sal_True ist
47 :
48 238 : if( bRet )
49 : {
50 : Size aSize( (long) ( STD_COL_WIDTH * HMM_PER_TWIPS * OLE_STD_CELLS_X ),
51 238 : (long) ( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) );
52 : // hier muss auch der Start angepasst werden
53 238 : SetVisAreaOrSize( Rectangle( Point(), aSize ), sal_True );
54 : }
55 :
56 : // InitOptions sets the document languages, must be called before CreateStandardStyles
57 238 : InitOptions(false);
58 :
59 238 : aDocument.GetStyleSheetPool()->CreateStandardStyles();
60 238 : aDocument.UpdStlShtPtrsFrmNms();
61 :
62 : // SetDocumentModified ist in Load/InitNew nicht mehr erlaubt!
63 :
64 238 : InitItems();
65 238 : CalcOutputFactor();
66 :
67 238 : return bRet;
68 : }
69 :
70 : //------------------------------------------------------------------
71 :
72 212 : bool ScDocShell::IsEmpty() const
73 : {
74 212 : return bIsEmpty;
75 : }
76 :
77 :
78 177 : void ScDocShell::SetEmpty(bool bSet)
79 : {
80 177 : bIsEmpty = bSet;
81 177 : }
82 :
83 : //------------------------------------------------------------------
84 :
85 635 : void ScDocShell::InitItems()
86 : {
87 : // AllItemSet fuer Controller mit benoetigten Items fuellen:
88 :
89 : // Druck-Optionen werden beim Drucken und evtl. in GetPrinter gesetzt
90 :
91 635 : UpdateFontList();
92 :
93 635 : ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
94 635 : if (pDrawLayer)
95 : {
96 340 : PutItem( SvxColorListItem ( pDrawLayer->GetColorList(), SID_COLOR_TABLE ) );
97 340 : PutItem( SvxGradientListItem( pDrawLayer->GetGradientList(), SID_GRADIENT_LIST ) );
98 340 : PutItem( SvxHatchListItem ( pDrawLayer->GetHatchList(), SID_HATCH_LIST ) );
99 340 : PutItem( SvxBitmapListItem ( pDrawLayer->GetBitmapList(), SID_BITMAP_LIST ) );
100 340 : PutItem( SvxDashListItem ( pDrawLayer->GetDashList(), SID_DASH_LIST ) );
101 340 : PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) );
102 :
103 : // andere Anpassungen nach dem Anlegen des DrawLayers
104 :
105 340 : pDrawLayer->SetNotifyUndoActionHdl( LINK( pDocFunc, ScDocFunc, NotifyDrawUndo ) );
106 : }
107 : else
108 : {
109 : // always use global color table instead of local copy
110 295 : PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) );
111 : }
112 :
113 1908 : if ( !aDocument.GetForbiddenCharacters().is() ||
114 1908 : !aDocument.IsValidAsianCompression() || !aDocument.IsValidAsianKerning() )
115 : {
116 : // get settings from SvxAsianConfig
117 632 : SvxAsianConfig aAsian;
118 :
119 632 : if ( !aDocument.GetForbiddenCharacters().is() )
120 : {
121 : // set forbidden characters if necessary
122 632 : uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
123 632 : if (aLocales.getLength())
124 : {
125 : rtl::Reference<SvxForbiddenCharactersTable> xForbiddenTable =
126 0 : new SvxForbiddenCharactersTable( comphelper::getProcessComponentContext() );
127 :
128 0 : const lang::Locale* pLocales = aLocales.getConstArray();
129 0 : for (sal_Int32 i = 0; i < aLocales.getLength(); i++)
130 : {
131 0 : i18n::ForbiddenCharacters aForbidden;
132 0 : aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine );
133 0 : LanguageType eLang = LanguageTag(pLocales[i]).getLanguageType();
134 :
135 0 : xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden );
136 0 : }
137 :
138 0 : aDocument.SetForbiddenCharacters( xForbiddenTable );
139 632 : }
140 : }
141 :
142 632 : if ( !aDocument.IsValidAsianCompression() )
143 : {
144 : // set compression mode from configuration if not already set (e.g. XML import)
145 238 : aDocument.SetAsianCompression( sal::static_int_cast<sal_uInt8>( aAsian.GetCharDistanceCompression() ) );
146 : }
147 :
148 632 : if ( !aDocument.IsValidAsianKerning() )
149 : {
150 : // set asian punctuation kerning from configuration if not already set (e.g. XML import)
151 238 : aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed
152 632 : }
153 : }
154 635 : }
155 :
156 : //------------------------------------------------------------------
157 :
158 468 : void ScDocShell::ResetDrawObjectShell()
159 : {
160 468 : ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
161 468 : if (pDrawLayer)
162 256 : pDrawLayer->SetObjectShell( NULL );
163 468 : }
164 :
165 : //------------------------------------------------------------------
166 :
167 0 : void ScDocShell::Activate()
168 : {
169 0 : }
170 :
171 :
172 0 : void ScDocShell::Deactivate()
173 : {
174 0 : }
175 :
176 : //------------------------------------------------------------------
177 :
178 :
179 711 : ScDrawLayer* ScDocShell::MakeDrawLayer()
180 : {
181 711 : ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
182 711 : if (!pDrawLayer)
183 : {
184 : RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::MakeDrawLayer" );
185 :
186 263 : aDocument.InitDrawLayer(this);
187 263 : pDrawLayer = aDocument.GetDrawLayer();
188 263 : InitItems(); // incl. Undo und Basic
189 263 : Broadcast( SfxSimpleHint( SC_HINT_DRWLAYER_NEW ) );
190 263 : if (nDocumentLock)
191 30 : pDrawLayer->setLock(true);
192 : }
193 711 : return pDrawLayer;
194 93 : }
195 :
196 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|