Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "scitems.hxx"
30 : : #include <svx/drawitem.hxx>
31 : : #include <svl/asiancfg.hxx>
32 : : #include <editeng/forbiddencharacterstable.hxx>
33 : : #include <editeng/unolingu.hxx>
34 : : #include <rtl/logfile.hxx>
35 : :
36 : : #include "drwlayer.hxx"
37 : : #include "stlpool.hxx"
38 : : #include "docsh.hxx"
39 : : #include "docshimp.hxx"
40 : : #include "docfunc.hxx"
41 : : #include "sc.hrc"
42 : :
43 : : using namespace com::sun::star;
44 : :
45 : : //------------------------------------------------------------------
46 : :
47 : 319 : sal_Bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
48 : : {
49 : : RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::InitNew" );
50 : :
51 : 319 : sal_Bool bRet = SfxObjectShell::InitNew( xStor );
52 : :
53 : 319 : aDocument.MakeTable(0);
54 : : // zusaetzliche Tabellen werden von der ersten View angelegt,
55 : : // wenn bIsEmpty dann noch sal_True ist
56 : :
57 [ + - ]: 319 : if( bRet )
58 : : {
59 : : Size aSize( (long) ( STD_COL_WIDTH * HMM_PER_TWIPS * OLE_STD_CELLS_X ),
60 : 319 : (long) ( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) );
61 : : // hier muss auch der Start angepasst werden
62 [ + - ][ + - ]: 319 : SetVisAreaOrSize( Rectangle( Point(), aSize ), sal_True );
63 : : }
64 : :
65 : 319 : aDocument.SetDrawDefaults(); // drawing layer defaults that are set only in InitNew
66 : :
67 : : // InitOptions sets the document languages, must be called before CreateStandardStyles
68 : 319 : InitOptions(false);
69 : :
70 : 319 : aDocument.GetStyleSheetPool()->CreateStandardStyles();
71 : 319 : aDocument.UpdStlShtPtrsFrmNms();
72 : :
73 : : // SetDocumentModified ist in Load/InitNew nicht mehr erlaubt!
74 : :
75 : 319 : InitItems();
76 : 319 : CalcOutputFactor();
77 : :
78 : 319 : return bRet;
79 : : }
80 : :
81 : : //------------------------------------------------------------------
82 : :
83 : 237 : bool ScDocShell::IsEmpty() const
84 : : {
85 : 237 : return bIsEmpty;
86 : : }
87 : :
88 : :
89 : 223 : void ScDocShell::SetEmpty(bool bSet)
90 : : {
91 : 223 : bIsEmpty = bSet;
92 : 223 : }
93 : :
94 : : //------------------------------------------------------------------
95 : :
96 : 816 : void ScDocShell::InitItems()
97 : : {
98 : : // AllItemSet fuer Controller mit benoetigten Items fuellen:
99 : :
100 : : // Druck-Optionen werden beim Drucken und evtl. in GetPrinter gesetzt
101 : :
102 : 816 : UpdateFontList();
103 : :
104 : 816 : ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
105 [ + + ]: 816 : if (pDrawLayer)
106 : : {
107 [ + - ][ + - ]: 398 : PutItem( SvxColorListItem ( pDrawLayer->GetColorList(), SID_COLOR_TABLE ) );
[ + - ]
108 [ + - ][ + - ]: 398 : PutItem( SvxGradientListItem( pDrawLayer->GetGradientList(), SID_GRADIENT_LIST ) );
[ + - ]
109 [ + - ][ + - ]: 398 : PutItem( SvxHatchListItem ( pDrawLayer->GetHatchList(), SID_HATCH_LIST ) );
[ + - ]
110 [ + - ][ + - ]: 398 : PutItem( SvxBitmapListItem ( pDrawLayer->GetBitmapList(), SID_BITMAP_LIST ) );
[ + - ]
111 [ + - ][ + - ]: 398 : PutItem( SvxDashListItem ( pDrawLayer->GetDashList(), SID_DASH_LIST ) );
[ + - ]
112 [ + - ][ + - ]: 398 : PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) );
[ + - ]
113 : :
114 : : // andere Anpassungen nach dem Anlegen des DrawLayers
115 : :
116 : 398 : pDrawLayer->SetNotifyUndoActionHdl( LINK( pDocFunc, ScDocFunc, NotifyDrawUndo ) );
117 : :
118 : 398 : pDrawLayer->UpdateBasic(); // DocShell-Basic in DrawPages setzen
119 : : }
120 : : else
121 : : {
122 : : // always use global color table instead of local copy
123 [ + - ][ + - ]: 418 : PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) );
[ + - ]
124 : : }
125 : :
126 [ + - ][ + + ]: 822 : if ( !aDocument.GetForbiddenCharacters().is() ||
[ + - ][ - + ]
[ + - ]
[ + + # # ]
127 [ + - ][ + - ]: 6 : !aDocument.IsValidAsianCompression() || !aDocument.IsValidAsianKerning() )
128 : : {
129 : : // get settings from SvxAsianConfig
130 [ + - ]: 813 : SvxAsianConfig aAsian;
131 : :
132 [ + - ][ + - ]: 813 : if ( !aDocument.GetForbiddenCharacters().is() )
[ + - ]
133 : : {
134 : : // set forbidden characters if necessary
135 [ + - ]: 813 : uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
136 [ - + ]: 813 : if (aLocales.getLength())
137 : : {
138 : : rtl::Reference<SvxForbiddenCharactersTable> xForbiddenTable =
139 [ # # ][ # # ]: 0 : new SvxForbiddenCharactersTable( aDocument.GetServiceManager() );
[ # # ][ # # ]
140 : :
141 : 0 : const lang::Locale* pLocales = aLocales.getConstArray();
142 [ # # ]: 0 : for (sal_Int32 i = 0; i < aLocales.getLength(); i++)
143 : : {
144 : 0 : i18n::ForbiddenCharacters aForbidden;
145 [ # # ]: 0 : aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine );
146 [ # # ]: 0 : LanguageType eLang = SvxLocaleToLanguage(pLocales[i]);
147 : :
148 [ # # ]: 0 : xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden );
149 : 0 : }
150 : :
151 [ # # ][ # # ]: 0 : aDocument.SetForbiddenCharacters( xForbiddenTable );
[ # # ][ # # ]
152 [ + - ]: 813 : }
153 : : }
154 : :
155 [ + - ][ + + ]: 813 : if ( !aDocument.IsValidAsianCompression() )
156 : : {
157 : : // set compression mode from configuration if not already set (e.g. XML import)
158 [ + - ][ + - ]: 319 : aDocument.SetAsianCompression( sal::static_int_cast<sal_uInt8>( aAsian.GetCharDistanceCompression() ) );
159 : : }
160 : :
161 [ + - ][ + + ]: 813 : if ( !aDocument.IsValidAsianKerning() )
162 : : {
163 : : // set asian punctuation kerning from configuration if not already set (e.g. XML import)
164 [ + - ][ + - ]: 319 : aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed
165 [ + - ]: 813 : }
166 : : }
167 : 816 : }
168 : :
169 : : //------------------------------------------------------------------
170 : :
171 : 695 : void ScDocShell::ResetDrawObjectShell()
172 : : {
173 : 695 : ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
174 [ + + ]: 695 : if (pDrawLayer)
175 : 309 : pDrawLayer->SetObjectShell( NULL );
176 : 695 : }
177 : :
178 : : //------------------------------------------------------------------
179 : :
180 : 0 : void ScDocShell::Activate()
181 : : {
182 : 0 : }
183 : :
184 : :
185 : 0 : void ScDocShell::Deactivate()
186 : : {
187 : 0 : }
188 : :
189 : : //------------------------------------------------------------------
190 : :
191 : :
192 : 617 : ScDrawLayer* ScDocShell::MakeDrawLayer()
193 : : {
194 : 617 : ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
195 [ + + ]: 617 : if (!pDrawLayer)
196 : : {
197 : : RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::MakeDrawLayer" );
198 : :
199 : 316 : aDocument.InitDrawLayer(this);
200 : 316 : pDrawLayer = aDocument.GetDrawLayer();
201 : 316 : InitItems(); // incl. Undo und Basic
202 [ + - ]: 316 : Broadcast( SfxSimpleHint( SC_HINT_DRWLAYER_NEW ) );
203 [ + + ]: 316 : if (nDocumentLock)
204 : 24 : pDrawLayer->setLock(true);
205 : : }
206 : 617 : return pDrawLayer;
207 : : }
208 : :
209 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|