1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
27 #include "drwlayer.hxx"
28 #include "stlpool.hxx"
30 #include "docshimp.hxx"
31 #include "docfunc.hxx"
34 using namespace com::sun::star
;
36 //------------------------------------------------------------------
38 sal_Bool
ScDocShell::InitNew( const uno::Reference
< embed::XStorage
>& xStor
)
40 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog
, "sc", "nn93723", "ScDocShell::InitNew" );
42 sal_Bool bRet
= SfxObjectShell::InitNew( xStor
);
44 aDocument
.MakeTable(0);
45 // zusaetzliche Tabellen werden von der ersten View angelegt,
46 // wenn bIsEmpty dann noch sal_True ist
50 Size
aSize( (long) ( STD_COL_WIDTH
* HMM_PER_TWIPS
* OLE_STD_CELLS_X
),
51 (long) ( ScGlobal::nStdRowHeight
* HMM_PER_TWIPS
* OLE_STD_CELLS_Y
) );
52 // hier muss auch der Start angepasst werden
53 SetVisAreaOrSize( Rectangle( Point(), aSize
), sal_True
);
56 aDocument
.SetDrawDefaults(); // drawing layer defaults that are set only in InitNew
58 // InitOptions sets the document languages, must be called before CreateStandardStyles
61 aDocument
.GetStyleSheetPool()->CreateStandardStyles();
62 aDocument
.UpdStlShtPtrsFrmNms();
64 // SetDocumentModified ist in Load/InitNew nicht mehr erlaubt!
72 //------------------------------------------------------------------
74 bool ScDocShell::IsEmpty() const
80 void ScDocShell::SetEmpty(bool bSet
)
85 //------------------------------------------------------------------
87 void ScDocShell::InitItems()
89 // AllItemSet fuer Controller mit benoetigten Items fuellen:
91 // Druck-Optionen werden beim Drucken und evtl. in GetPrinter gesetzt
95 ScDrawLayer
* pDrawLayer
= aDocument
.GetDrawLayer();
98 PutItem( SvxColorListItem ( pDrawLayer
->GetColorList(), SID_COLOR_TABLE
) );
99 PutItem( SvxGradientListItem( pDrawLayer
->GetGradientList(), SID_GRADIENT_LIST
) );
100 PutItem( SvxHatchListItem ( pDrawLayer
->GetHatchList(), SID_HATCH_LIST
) );
101 PutItem( SvxBitmapListItem ( pDrawLayer
->GetBitmapList(), SID_BITMAP_LIST
) );
102 PutItem( SvxDashListItem ( pDrawLayer
->GetDashList(), SID_DASH_LIST
) );
103 PutItem( SvxLineEndListItem ( pDrawLayer
->GetLineEndList(), SID_LINEEND_LIST
) );
105 // andere Anpassungen nach dem Anlegen des DrawLayers
107 pDrawLayer
->SetNotifyUndoActionHdl( LINK( pDocFunc
, ScDocFunc
, NotifyDrawUndo
) );
111 // always use global color table instead of local copy
112 PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE
) );
115 if ( !aDocument
.GetForbiddenCharacters().is() ||
116 !aDocument
.IsValidAsianCompression() || !aDocument
.IsValidAsianKerning() )
118 // get settings from SvxAsianConfig
119 SvxAsianConfig aAsian
;
121 if ( !aDocument
.GetForbiddenCharacters().is() )
123 // set forbidden characters if necessary
124 uno::Sequence
<lang::Locale
> aLocales
= aAsian
.GetStartEndCharLocales();
125 if (aLocales
.getLength())
127 rtl::Reference
<SvxForbiddenCharactersTable
> xForbiddenTable
=
128 new SvxForbiddenCharactersTable( comphelper::getComponentContext(aDocument
.GetServiceManager()) );
130 const lang::Locale
* pLocales
= aLocales
.getConstArray();
131 for (sal_Int32 i
= 0; i
< aLocales
.getLength(); i
++)
133 i18n::ForbiddenCharacters aForbidden
;
134 aAsian
.GetStartEndChars( pLocales
[i
], aForbidden
.beginLine
, aForbidden
.endLine
);
135 LanguageType eLang
= LanguageTag(pLocales
[i
]).getLanguageType();
137 xForbiddenTable
->SetForbiddenCharacters( eLang
, aForbidden
);
140 aDocument
.SetForbiddenCharacters( xForbiddenTable
);
144 if ( !aDocument
.IsValidAsianCompression() )
146 // set compression mode from configuration if not already set (e.g. XML import)
147 aDocument
.SetAsianCompression( sal::static_int_cast
<sal_uInt8
>( aAsian
.GetCharDistanceCompression() ) );
150 if ( !aDocument
.IsValidAsianKerning() )
152 // set asian punctuation kerning from configuration if not already set (e.g. XML import)
153 aDocument
.SetAsianKerning( !aAsian
.IsKerningWesternTextOnly() ); // reversed
158 //------------------------------------------------------------------
160 void ScDocShell::ResetDrawObjectShell()
162 ScDrawLayer
* pDrawLayer
= aDocument
.GetDrawLayer();
164 pDrawLayer
->SetObjectShell( NULL
);
167 //------------------------------------------------------------------
169 void ScDocShell::Activate()
174 void ScDocShell::Deactivate()
178 //------------------------------------------------------------------
181 ScDrawLayer
* ScDocShell::MakeDrawLayer()
183 ScDrawLayer
* pDrawLayer
= aDocument
.GetDrawLayer();
186 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog
, "sc", "nn93723", "ScDocShell::MakeDrawLayer" );
188 aDocument
.InitDrawLayer(this);
189 pDrawLayer
= aDocument
.GetDrawLayer();
190 InitItems(); // incl. Undo und Basic
191 Broadcast( SfxSimpleHint( SC_HINT_DRWLAYER_NEW
) );
193 pDrawLayer
->setLock(true);
198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */