merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / docshell / docsh2.cxx
blobc3a429980d7132821e4766a10c3d5f0f9b20a95b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docsh2.cxx,v $
10 * $Revision: 1.25.32.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
35 #include <svx/svdpage.hxx>
38 #include <svx/xtable.hxx>
40 #include "scitems.hxx"
41 #include <tools/gen.hxx>
42 #include <svtools/ctrltool.hxx>
43 #include <svx/flstitem.hxx>
44 #include <svx/drawitem.hxx>
45 #include <sfx2/printer.hxx>
46 #include <svtools/smplhint.hxx>
47 #include <svx/svditer.hxx>
48 #include <svx/svdobj.hxx>
49 #include <svx/svdoole2.hxx>
50 #include <vcl/svapp.hxx>
51 #include <svx/asiancfg.hxx>
52 #include <svx/forbiddencharacterstable.hxx>
53 #include <svx/unolingu.hxx>
54 #include <rtl/logfile.hxx>
58 // INCLUDE ---------------------------------------------------------------
60 #include <svdrwetc.hxx>
61 #include <svdrwobx.hxx>
62 #include <sostor.hxx>
64 #include "drwlayer.hxx"
65 #include "stlpool.hxx"
66 #include "docsh.hxx"
67 #include "docshimp.hxx"
68 #include "docfunc.hxx"
69 #include "sc.hrc"
71 using namespace com::sun::star;
73 //------------------------------------------------------------------
75 BOOL __EXPORT ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
77 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::InitNew" );
79 BOOL bRet = SfxObjectShell::InitNew( xStor );
81 aDocument.MakeTable(0);
82 // zusaetzliche Tabellen werden von der ersten View angelegt,
83 // wenn bIsEmpty dann noch TRUE ist
85 if( bRet )
87 Size aSize( (long) ( STD_COL_WIDTH * HMM_PER_TWIPS * OLE_STD_CELLS_X ),
88 (long) ( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) );
89 // hier muss auch der Start angepasst werden
90 SetVisAreaOrSize( Rectangle( Point(), aSize ), TRUE );
93 aDocument.SetDrawDefaults(); // drawing layer defaults that are set only in InitNew
95 // InitOptions sets the document languages, must be called before CreateStandardStyles
96 InitOptions();
98 aDocument.GetStyleSheetPool()->CreateStandardStyles();
99 aDocument.UpdStlShtPtrsFrmNms();
101 // SetDocumentModified ist in Load/InitNew nicht mehr erlaubt!
103 InitItems();
104 CalcOutputFactor();
106 return bRet;
109 //------------------------------------------------------------------
111 BOOL ScDocShell::IsEmpty() const
113 return bIsEmpty;
117 void ScDocShell::SetEmpty(BOOL bSet)
119 bIsEmpty = bSet;
122 //------------------------------------------------------------------
124 void ScDocShell::InitItems()
126 // AllItemSet fuer Controller mit benoetigten Items fuellen:
128 // if ( pImpl->pFontList )
129 // delete pImpl->pFontList;
131 // Druck-Optionen werden beim Drucken und evtl. in GetPrinter gesetzt
133 // pImpl->pFontList = new FontList( GetPrinter(), Application::GetDefaultDevice() );
134 //PutItem( SvxFontListItem( pImpl->pFontList, SID_ATTR_CHAR_FONTLIST ) );
135 UpdateFontList();
137 ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
138 if (pDrawLayer)
140 PutItem( SvxColorTableItem ( pDrawLayer->GetColorTable(), SID_COLOR_TABLE ) );
141 PutItem( SvxGradientListItem( pDrawLayer->GetGradientList(), SID_GRADIENT_LIST ) );
142 PutItem( SvxHatchListItem ( pDrawLayer->GetHatchList(), SID_HATCH_LIST ) );
143 PutItem( SvxBitmapListItem ( pDrawLayer->GetBitmapList(), SID_BITMAP_LIST ) );
144 PutItem( SvxDashListItem ( pDrawLayer->GetDashList(), SID_DASH_LIST ) );
145 PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) );
147 // andere Anpassungen nach dem Anlegen des DrawLayers
149 pDrawLayer->SetNotifyUndoActionHdl( LINK( pDocFunc, ScDocFunc, NotifyDrawUndo ) );
151 //if (SfxObjectShell::HasSbxObject())
152 pDrawLayer->UpdateBasic(); // DocShell-Basic in DrawPages setzen
154 else
156 // always use global color table instead of local copy
157 PutItem( SvxColorTableItem( XColorTable::GetStdColorTable(), SID_COLOR_TABLE ) );
160 if ( !aDocument.GetForbiddenCharacters().isValid() ||
161 !aDocument.IsValidAsianCompression() || !aDocument.IsValidAsianKerning() )
163 // get settings from SvxAsianConfig
164 SvxAsianConfig aAsian( sal_False );
166 if ( !aDocument.GetForbiddenCharacters().isValid() )
168 // set forbidden characters if necessary
169 uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
170 if (aLocales.getLength())
172 vos::ORef<SvxForbiddenCharactersTable> xForbiddenTable =
173 new SvxForbiddenCharactersTable( aDocument.GetServiceManager() );
175 const lang::Locale* pLocales = aLocales.getConstArray();
176 for (sal_Int32 i = 0; i < aLocales.getLength(); i++)
178 i18n::ForbiddenCharacters aForbidden;
179 aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine );
180 LanguageType eLang = SvxLocaleToLanguage(pLocales[i]);
181 //pDoc->SetForbiddenCharacters( eLang, aForbidden );
183 xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden );
186 aDocument.SetForbiddenCharacters( xForbiddenTable );
190 if ( !aDocument.IsValidAsianCompression() )
192 // set compression mode from configuration if not already set (e.g. XML import)
193 aDocument.SetAsianCompression( sal::static_int_cast<BYTE>( aAsian.GetCharDistanceCompression() ) );
196 if ( !aDocument.IsValidAsianKerning() )
198 // set asian punctuation kerning from configuration if not already set (e.g. XML import)
199 aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed
204 //------------------------------------------------------------------
206 void ScDocShell::ResetDrawObjectShell()
208 ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
209 if (pDrawLayer)
210 pDrawLayer->SetObjectShell( NULL );
213 //------------------------------------------------------------------
215 void __EXPORT ScDocShell::Activate()
220 void __EXPORT ScDocShell::Deactivate()
224 //------------------------------------------------------------------
227 ScDrawLayer* ScDocShell::MakeDrawLayer()
229 ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
230 if (!pDrawLayer)
232 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::MakeDrawLayer" );
234 aDocument.InitDrawLayer(this);
235 pDrawLayer = aDocument.GetDrawLayer();
236 InitItems(); // incl. Undo und Basic
237 Broadcast( SfxSimpleHint( SC_HINT_DRWLAYER_NEW ) );
238 if (nDocumentLock)
239 pDrawLayer->setLock(TRUE);
241 return pDrawLayer;