1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file
5b3f79822SAndrew Rist * distributed with this work for additional information
6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at
10b3f79822SAndrew Rist *
11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist *
13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist * software distributed under the License is distributed on an
15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the
17b3f79822SAndrew Rist * specific language governing permissions and limitations
18b3f79822SAndrew Rist * under the License.
19b3f79822SAndrew Rist *
20b3f79822SAndrew Rist *************************************************************/
21b3f79822SAndrew Rist
22b3f79822SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <svx/svdpage.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <svx/xtable.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include "scitems.hxx"
34cdf0e10cSrcweir #include <tools/gen.hxx>
35cdf0e10cSrcweir #include <svtools/ctrltool.hxx>
36cdf0e10cSrcweir #include <editeng/flstitem.hxx>
37cdf0e10cSrcweir #include <svx/drawitem.hxx>
38cdf0e10cSrcweir #include <sfx2/printer.hxx>
39cdf0e10cSrcweir #include <svl/smplhint.hxx>
40cdf0e10cSrcweir #include <svx/svditer.hxx>
41cdf0e10cSrcweir #include <svx/svdobj.hxx>
42cdf0e10cSrcweir #include <svx/svdoole2.hxx>
43cdf0e10cSrcweir #include <vcl/svapp.hxx>
44cdf0e10cSrcweir #include <svl/asiancfg.hxx>
45cdf0e10cSrcweir #include <editeng/forbiddencharacterstable.hxx>
46cdf0e10cSrcweir #include <editeng/unolingu.hxx>
47cdf0e10cSrcweir #include <rtl/logfile.hxx>
48cdf0e10cSrcweir
49cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
50cdf0e10cSrcweir #include <basic/sbstar.hxx>
51cdf0e10cSrcweir #include <basic/basmgr.hxx>
52cdf0e10cSrcweir #include <sfx2/app.hxx>
53cdf0e10cSrcweir
54cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
55cdf0e10cSrcweir /*
56cdf0e10cSrcweir #include <svdrwetc.hxx>
57cdf0e10cSrcweir #include <svdrwobx.hxx>
58cdf0e10cSrcweir #include <sostor.hxx>
59cdf0e10cSrcweir */
60cdf0e10cSrcweir #include "drwlayer.hxx"
61cdf0e10cSrcweir #include "stlpool.hxx"
62cdf0e10cSrcweir #include "docsh.hxx"
63cdf0e10cSrcweir #include "docshimp.hxx"
64cdf0e10cSrcweir #include "docfunc.hxx"
65cdf0e10cSrcweir #include "sc.hrc"
66cdf0e10cSrcweir
67cdf0e10cSrcweir using namespace com::sun::star;
68cdf0e10cSrcweir
69cdf0e10cSrcweir //------------------------------------------------------------------
70cdf0e10cSrcweir
InitNew(const uno::Reference<embed::XStorage> & xStor)71cdf0e10cSrcweir sal_Bool __EXPORT ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::InitNew" );
74cdf0e10cSrcweir
75cdf0e10cSrcweir sal_Bool bRet = SfxObjectShell::InitNew( xStor );
76cdf0e10cSrcweir
77cdf0e10cSrcweir aDocument.MakeTable(0);
78cdf0e10cSrcweir // zusaetzliche Tabellen werden von der ersten View angelegt,
79cdf0e10cSrcweir // wenn bIsEmpty dann noch sal_True ist
80cdf0e10cSrcweir
81cdf0e10cSrcweir if( bRet )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir Size aSize( (long) ( STD_COL_WIDTH * HMM_PER_TWIPS * OLE_STD_CELLS_X ),
84cdf0e10cSrcweir (long) ( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) );
85cdf0e10cSrcweir // hier muss auch der Start angepasst werden
86cdf0e10cSrcweir SetVisAreaOrSize( Rectangle( Point(), aSize ), sal_True );
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
89cdf0e10cSrcweir // InitOptions sets the document languages, must be called before CreateStandardStyles
90cdf0e10cSrcweir InitOptions(false);
91cdf0e10cSrcweir
92cdf0e10cSrcweir aDocument.GetStyleSheetPool()->CreateStandardStyles();
93cdf0e10cSrcweir aDocument.UpdStlShtPtrsFrmNms();
94cdf0e10cSrcweir
95cdf0e10cSrcweir // SetDocumentModified ist in Load/InitNew nicht mehr erlaubt!
96cdf0e10cSrcweir
97cdf0e10cSrcweir InitItems();
98cdf0e10cSrcweir CalcOutputFactor();
99cdf0e10cSrcweir #if 0
100cdf0e10cSrcweir uno::Any aGlobs;
101cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs(1);
102cdf0e10cSrcweir aArgs[ 0 ] <<= GetModel();
103cdf0e10cSrcweir aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs );
104cdf0e10cSrcweir GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs );
105cdf0e10cSrcweir // Fake ThisComponent being setup by Activate ( which is a view
106cdf0e10cSrcweir // related thing ),
107cdf0e10cSrcweir // a) if another document is opened then in theory ThisComponent
108cdf0e10cSrcweir // will be reset as before,
109cdf0e10cSrcweir // b) when this document is 'really' Activated then ThisComponent
110cdf0e10cSrcweir // again will be set as before
111cdf0e10cSrcweir // The only wrinkle seems if this document is loaded 'InVisible'
112cdf0e10cSrcweir // but.. I don't see that this is possible from the vba API
113cdf0e10cSrcweir // I could be wrong though
114cdf0e10cSrcweir // There may be implications setting the current component
115cdf0e10cSrcweir // too early :-/ so I will just manually set the Basic Variables
116cdf0e10cSrcweir BasicManager* pAppMgr = SFX_APP()->GetBasicManager();
117cdf0e10cSrcweir if ( pAppMgr )
118cdf0e10cSrcweir pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] );
119cdf0e10cSrcweir #endif
120cdf0e10cSrcweir
121cdf0e10cSrcweir return bRet;
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
124cdf0e10cSrcweir //------------------------------------------------------------------
125cdf0e10cSrcweir
IsEmpty() const126cdf0e10cSrcweir sal_Bool ScDocShell::IsEmpty() const
127cdf0e10cSrcweir {
128cdf0e10cSrcweir return bIsEmpty;
129cdf0e10cSrcweir }
130cdf0e10cSrcweir
131cdf0e10cSrcweir
SetEmpty(sal_Bool bSet)132cdf0e10cSrcweir void ScDocShell::SetEmpty(sal_Bool bSet)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir bIsEmpty = bSet;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
137cdf0e10cSrcweir //------------------------------------------------------------------
138cdf0e10cSrcweir
InitItems()139cdf0e10cSrcweir void ScDocShell::InitItems()
140cdf0e10cSrcweir {
141cdf0e10cSrcweir // AllItemSet fuer Controller mit benoetigten Items fuellen:
142cdf0e10cSrcweir
143cdf0e10cSrcweir // if ( pImpl->pFontList )
144cdf0e10cSrcweir // delete pImpl->pFontList;
145cdf0e10cSrcweir
146cdf0e10cSrcweir // Druck-Optionen werden beim Drucken und evtl. in GetPrinter gesetzt
147cdf0e10cSrcweir
148cdf0e10cSrcweir // pImpl->pFontList = new FontList( GetPrinter(), Application::GetDefaultDevice() );
149cdf0e10cSrcweir //PutItem( SvxFontListItem( pImpl->pFontList, SID_ATTR_CHAR_FONTLIST ) );
150cdf0e10cSrcweir UpdateFontList();
151cdf0e10cSrcweir
152cdf0e10cSrcweir ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
153cdf0e10cSrcweir if (pDrawLayer)
154cdf0e10cSrcweir {
155*c7be74b1SArmin Le Grand PutItem( SvxColorTableItem ( pDrawLayer->GetColorTableFromSdrModel(), SID_COLOR_TABLE ) );
156*c7be74b1SArmin Le Grand PutItem( SvxGradientListItem( pDrawLayer->GetGradientListFromSdrModel(), SID_GRADIENT_LIST ) );
157*c7be74b1SArmin Le Grand PutItem( SvxHatchListItem ( pDrawLayer->GetHatchListFromSdrModel(), SID_HATCH_LIST ) );
158*c7be74b1SArmin Le Grand PutItem( SvxBitmapListItem ( pDrawLayer->GetBitmapListFromSdrModel(), SID_BITMAP_LIST ) );
159*c7be74b1SArmin Le Grand PutItem( SvxDashListItem ( pDrawLayer->GetDashListFromSdrModel(), SID_DASH_LIST ) );
160*c7be74b1SArmin Le Grand PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndListFromSdrModel(), SID_LINEEND_LIST ) );
161cdf0e10cSrcweir
162cdf0e10cSrcweir // andere Anpassungen nach dem Anlegen des DrawLayers
163cdf0e10cSrcweir
164cdf0e10cSrcweir pDrawLayer->SetNotifyUndoActionHdl( LINK( pDocFunc, ScDocFunc, NotifyDrawUndo ) );
165cdf0e10cSrcweir
166cdf0e10cSrcweir //if (SfxObjectShell::HasSbxObject())
167cdf0e10cSrcweir pDrawLayer->UpdateBasic(); // DocShell-Basic in DrawPages setzen
168cdf0e10cSrcweir }
169cdf0e10cSrcweir else
170cdf0e10cSrcweir {
171cdf0e10cSrcweir // always use global color table instead of local copy
17297e8a929SArmin Le Grand PutItem( SvxColorTableItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) );
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
175cdf0e10cSrcweir if ( !aDocument.GetForbiddenCharacters().isValid() ||
176cdf0e10cSrcweir !aDocument.IsValidAsianCompression() || !aDocument.IsValidAsianKerning() )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir // get settings from SvxAsianConfig
179cdf0e10cSrcweir SvxAsianConfig aAsian( sal_False );
180cdf0e10cSrcweir
181cdf0e10cSrcweir if ( !aDocument.GetForbiddenCharacters().isValid() )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir // set forbidden characters if necessary
184cdf0e10cSrcweir uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
185cdf0e10cSrcweir if (aLocales.getLength())
186cdf0e10cSrcweir {
187cdf0e10cSrcweir vos::ORef<SvxForbiddenCharactersTable> xForbiddenTable =
188cdf0e10cSrcweir new SvxForbiddenCharactersTable( aDocument.GetServiceManager() );
189cdf0e10cSrcweir
190cdf0e10cSrcweir const lang::Locale* pLocales = aLocales.getConstArray();
191cdf0e10cSrcweir for (sal_Int32 i = 0; i < aLocales.getLength(); i++)
192cdf0e10cSrcweir {
193cdf0e10cSrcweir i18n::ForbiddenCharacters aForbidden;
194cdf0e10cSrcweir aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine );
195cdf0e10cSrcweir LanguageType eLang = SvxLocaleToLanguage(pLocales[i]);
196cdf0e10cSrcweir //pDoc->SetForbiddenCharacters( eLang, aForbidden );
197cdf0e10cSrcweir
198cdf0e10cSrcweir xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden );
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
201cdf0e10cSrcweir aDocument.SetForbiddenCharacters( xForbiddenTable );
202cdf0e10cSrcweir }
203cdf0e10cSrcweir }
204cdf0e10cSrcweir
205cdf0e10cSrcweir if ( !aDocument.IsValidAsianCompression() )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir // set compression mode from configuration if not already set (e.g. XML import)
208cdf0e10cSrcweir aDocument.SetAsianCompression( sal::static_int_cast<sal_uInt8>( aAsian.GetCharDistanceCompression() ) );
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir if ( !aDocument.IsValidAsianKerning() )
212cdf0e10cSrcweir {
213cdf0e10cSrcweir // set asian punctuation kerning from configuration if not already set (e.g. XML import)
214cdf0e10cSrcweir aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed
215cdf0e10cSrcweir }
216cdf0e10cSrcweir }
217cdf0e10cSrcweir }
218cdf0e10cSrcweir
219cdf0e10cSrcweir //------------------------------------------------------------------
220cdf0e10cSrcweir
ResetDrawObjectShell()221cdf0e10cSrcweir void ScDocShell::ResetDrawObjectShell()
222cdf0e10cSrcweir {
223cdf0e10cSrcweir ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
224cdf0e10cSrcweir if (pDrawLayer)
225cdf0e10cSrcweir pDrawLayer->SetObjectShell( NULL );
226cdf0e10cSrcweir }
227cdf0e10cSrcweir
228cdf0e10cSrcweir //------------------------------------------------------------------
229cdf0e10cSrcweir
Activate()230cdf0e10cSrcweir void __EXPORT ScDocShell::Activate()
231cdf0e10cSrcweir {
232cdf0e10cSrcweir }
233cdf0e10cSrcweir
234cdf0e10cSrcweir
Deactivate()235cdf0e10cSrcweir void __EXPORT ScDocShell::Deactivate()
236cdf0e10cSrcweir {
237cdf0e10cSrcweir }
238cdf0e10cSrcweir
239cdf0e10cSrcweir //------------------------------------------------------------------
240cdf0e10cSrcweir
241cdf0e10cSrcweir
MakeDrawLayer()242cdf0e10cSrcweir ScDrawLayer* ScDocShell::MakeDrawLayer()
243cdf0e10cSrcweir {
244cdf0e10cSrcweir ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
245cdf0e10cSrcweir if (!pDrawLayer)
246cdf0e10cSrcweir {
247cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::MakeDrawLayer" );
248cdf0e10cSrcweir
249cdf0e10cSrcweir aDocument.InitDrawLayer(this);
250cdf0e10cSrcweir pDrawLayer = aDocument.GetDrawLayer();
251cdf0e10cSrcweir InitItems(); // incl. Undo und Basic
252cdf0e10cSrcweir Broadcast( SfxSimpleHint( SC_HINT_DRWLAYER_NEW ) );
253cdf0e10cSrcweir if (nDocumentLock)
254cdf0e10cSrcweir pDrawLayer->setLock(sal_True);
255cdf0e10cSrcweir }
256cdf0e10cSrcweir return pDrawLayer;
257cdf0e10cSrcweir }
258