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>
26 #include "drwlayer.hxx"
27 #include "stlpool.hxx"
29 #include "docshimp.hxx"
30 #include "docfunc.hxx"
33 using namespace com::sun::star
;
35 //------------------------------------------------------------------
37 sal_Bool
ScDocShell::InitNew( const uno::Reference
< embed::XStorage
>& xStor
)
39 sal_Bool bRet
= SfxObjectShell::InitNew( xStor
);
41 aDocument
.MakeTable(0);
42 // zusaetzliche Tabellen werden von der ersten View angelegt,
43 // wenn bIsEmpty dann noch sal_True ist
47 Size
aSize( (long) ( STD_COL_WIDTH
* HMM_PER_TWIPS
* OLE_STD_CELLS_X
),
48 (long) ( ScGlobal::nStdRowHeight
* HMM_PER_TWIPS
* OLE_STD_CELLS_Y
) );
49 // hier muss auch der Start angepasst werden
50 SetVisAreaOrSize( Rectangle( Point(), aSize
), sal_True
);
53 // InitOptions sets the document languages, must be called before CreateStandardStyles
56 aDocument
.GetStyleSheetPool()->CreateStandardStyles();
57 aDocument
.UpdStlShtPtrsFrmNms();
59 // SetDocumentModified ist in Load/InitNew nicht mehr erlaubt!
67 //------------------------------------------------------------------
69 bool ScDocShell::IsEmpty() const
75 void ScDocShell::SetEmpty(bool bSet
)
80 //------------------------------------------------------------------
82 void ScDocShell::InitItems()
84 // AllItemSet fuer Controller mit benoetigten Items fuellen:
86 // Druck-Optionen werden beim Drucken und evtl. in GetPrinter gesetzt
90 ScDrawLayer
* pDrawLayer
= aDocument
.GetDrawLayer();
93 PutItem( SvxColorListItem ( pDrawLayer
->GetColorList(), SID_COLOR_TABLE
) );
94 PutItem( SvxGradientListItem( pDrawLayer
->GetGradientList(), SID_GRADIENT_LIST
) );
95 PutItem( SvxHatchListItem ( pDrawLayer
->GetHatchList(), SID_HATCH_LIST
) );
96 PutItem( SvxBitmapListItem ( pDrawLayer
->GetBitmapList(), SID_BITMAP_LIST
) );
97 PutItem( SvxDashListItem ( pDrawLayer
->GetDashList(), SID_DASH_LIST
) );
98 PutItem( SvxLineEndListItem ( pDrawLayer
->GetLineEndList(), SID_LINEEND_LIST
) );
100 // andere Anpassungen nach dem Anlegen des DrawLayers
102 pDrawLayer
->SetNotifyUndoActionHdl( LINK( pDocFunc
, ScDocFunc
, NotifyDrawUndo
) );
106 // always use global color table instead of local copy
107 PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE
) );
110 if ( !aDocument
.GetForbiddenCharacters().is() ||
111 !aDocument
.IsValidAsianCompression() || !aDocument
.IsValidAsianKerning() )
113 // get settings from SvxAsianConfig
114 SvxAsianConfig aAsian
;
116 if ( !aDocument
.GetForbiddenCharacters().is() )
118 // set forbidden characters if necessary
119 uno::Sequence
<lang::Locale
> aLocales
= aAsian
.GetStartEndCharLocales();
120 if (aLocales
.getLength())
122 rtl::Reference
<SvxForbiddenCharactersTable
> xForbiddenTable
=
123 new SvxForbiddenCharactersTable( comphelper::getProcessComponentContext() );
125 const lang::Locale
* pLocales
= aLocales
.getConstArray();
126 for (sal_Int32 i
= 0; i
< aLocales
.getLength(); i
++)
128 i18n::ForbiddenCharacters aForbidden
;
129 aAsian
.GetStartEndChars( pLocales
[i
], aForbidden
.beginLine
, aForbidden
.endLine
);
130 LanguageType eLang
= LanguageTag::convertToLanguageType(pLocales
[i
]);
132 xForbiddenTable
->SetForbiddenCharacters( eLang
, aForbidden
);
135 aDocument
.SetForbiddenCharacters( xForbiddenTable
);
139 if ( !aDocument
.IsValidAsianCompression() )
141 // set compression mode from configuration if not already set (e.g. XML import)
142 aDocument
.SetAsianCompression( sal::static_int_cast
<sal_uInt8
>( aAsian
.GetCharDistanceCompression() ) );
145 if ( !aDocument
.IsValidAsianKerning() )
147 // set asian punctuation kerning from configuration if not already set (e.g. XML import)
148 aDocument
.SetAsianKerning( !aAsian
.IsKerningWesternTextOnly() ); // reversed
153 //------------------------------------------------------------------
155 void ScDocShell::ResetDrawObjectShell()
157 ScDrawLayer
* pDrawLayer
= aDocument
.GetDrawLayer();
159 pDrawLayer
->SetObjectShell( NULL
);
162 //------------------------------------------------------------------
164 void ScDocShell::Activate()
169 void ScDocShell::Deactivate()
173 //------------------------------------------------------------------
176 ScDrawLayer
* ScDocShell::MakeDrawLayer()
178 ScDrawLayer
* pDrawLayer
= aDocument
.GetDrawLayer();
181 aDocument
.InitDrawLayer(this);
182 pDrawLayer
= aDocument
.GetDrawLayer();
183 InitItems(); // incl. Undo und Basic
184 Broadcast( SfxSimpleHint( SC_HINT_DRWLAYER_NEW
) );
186 pDrawLayer
->setLock(true);
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */