xref: /aoo42x/main/sfx2/source/doc/new.cxx (revision d119d52d)
1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d119d52dSAndrew Rist  * distributed with this work for additional information
6*d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d119d52dSAndrew Rist  *
11*d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist  *
13*d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d119d52dSAndrew Rist  * specific language governing permissions and limitations
18*d119d52dSAndrew Rist  * under the License.
19*d119d52dSAndrew Rist  *
20*d119d52dSAndrew Rist  *************************************************************/
21*d119d52dSAndrew Rist 
22*d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir #include <sfx2/new.hxx>
27cdf0e10cSrcweir #include <vcl/gdimtf.hxx>
28cdf0e10cSrcweir #include <vcl/msgbox.hxx>
29cdf0e10cSrcweir #include <vcl/morebtn.hxx>
30cdf0e10cSrcweir #include <svtools/svmedit.hxx>
31cdf0e10cSrcweir #include <svl/itemset.hxx>
32cdf0e10cSrcweir #include <svl/eitem.hxx>
33cdf0e10cSrcweir #include <svtools/sfxecode.hxx>
34cdf0e10cSrcweir #include <svtools/ehdl.hxx>
35cdf0e10cSrcweir #include <tools/urlobj.hxx>
36cdf0e10cSrcweir #include <unotools/localfilehelper.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include "new.hrc"
39cdf0e10cSrcweir #include "doc.hrc"
40cdf0e10cSrcweir #include <sfx2/sfx.hrc>
41cdf0e10cSrcweir #include "helpid.hrc"
42cdf0e10cSrcweir #include "sfxtypes.hxx"
43cdf0e10cSrcweir #include <sfx2/app.hxx>
44cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
45cdf0e10cSrcweir #include <sfx2/docfac.hxx>
46cdf0e10cSrcweir #include <sfx2/objsh.hxx>
47cdf0e10cSrcweir #include "fltfnc.hxx"
48cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
49cdf0e10cSrcweir #include "sfx2/viewfac.hxx"
50cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
51cdf0e10cSrcweir #include <sfx2/docfile.hxx>
52cdf0e10cSrcweir #include "preview.hxx"
53cdf0e10cSrcweir #include <sfx2/printer.hxx>
54cdf0e10cSrcweir #include <vcl/waitobj.hxx>
55cdf0e10cSrcweir #include <vcl/virdev.hxx>
56cdf0e10cSrcweir #include <vcl/jobset.hxx>
57cdf0e10cSrcweir #include <svtools/accessibilityoptions.hxx>
58cdf0e10cSrcweir 
59cdf0e10cSrcweir // Draw modes
60cdf0e10cSrcweir #define OUTPUT_DRAWMODE_COLOR		(DRAWMODE_DEFAULT)
61cdf0e10cSrcweir #define OUTPUT_DRAWMODE_GRAYSCALE   (DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_BLACKTEXT | DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT)
62cdf0e10cSrcweir #define OUTPUT_DRAWMODE_BLACKWHITE  (DRAWMODE_BLACKLINE | DRAWMODE_BLACKTEXT | DRAWMODE_WHITEFILL | DRAWMODE_GRAYBITMAP | DRAWMODE_WHITEGRADIENT)
63cdf0e10cSrcweir #define OUTPUT_DRAWMODE_CONTRAST	(DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
64cdf0e10cSrcweir 
65cdf0e10cSrcweir //========================================================================
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #define MORE_BTN(x) pMoreBt->x
68cdf0e10cSrcweir 
69cdf0e10cSrcweir //========================================================================
70cdf0e10cSrcweir 
71cdf0e10cSrcweir void SfxPreviewBase_Impl::SetObjectShell( SfxObjectShell* pObj )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir     ::boost::shared_ptr<GDIMetaFile> pFile = pObj
74cdf0e10cSrcweir         ? pObj->GetPreviewMetaFile()
75cdf0e10cSrcweir         : ::boost::shared_ptr<GDIMetaFile>();
76cdf0e10cSrcweir 	pMetaFile = pFile;
77cdf0e10cSrcweir 	Invalidate();
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir SfxPreviewBase_Impl::SfxPreviewBase_Impl(
81cdf0e10cSrcweir 	Window* pParent, const ResId& rResId )
82cdf0e10cSrcweir 	: Window(pParent, rResId), pMetaFile()
83cdf0e10cSrcweir {
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir SfxPreviewBase_Impl::SfxPreviewBase_Impl( Window* pParent )
87cdf0e10cSrcweir 	: Window(pParent, 0 ), pMetaFile()
88cdf0e10cSrcweir {
89cdf0e10cSrcweir 	Resize();
90cdf0e10cSrcweir 	Show();
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir SfxPreviewBase_Impl::~SfxPreviewBase_Impl()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir void SfxPreviewBase_Impl::Resize()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	Invalidate();
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir void SfxPreviewBase_Impl::SetGDIFile( ::boost::shared_ptr<GDIMetaFile> pFile )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir 	pMetaFile = pFile;
105cdf0e10cSrcweir 	Invalidate();
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir SfxFrameWindow* SfxPreviewWin_Impl::PreviewFactory(
109cdf0e10cSrcweir 	SfxFrame* pFrame, const String& /*rName*/ )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir 	return new SfxFrameWindow( new SfxPreviewWin_Impl(
112cdf0e10cSrcweir 		&pFrame->GetCurrentViewFrame()->GetWindow()  ) );
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir void SfxPreviewWin_Impl::ImpPaint(
116cdf0e10cSrcweir 	const Rectangle&, GDIMetaFile* pFile, Window* pWindow )
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	Size aTmpSize = pFile ? pFile->GetPrefSize() : Size(1,1 );
119cdf0e10cSrcweir 	DBG_ASSERT( aTmpSize.Height()*aTmpSize.Width(),
120cdf0e10cSrcweir 				"size of first page is 0, overload GetFirstPageSize or set vis-area!" );
121cdf0e10cSrcweir #define FRAME 4
122cdf0e10cSrcweir 	long nWidth = pWindow->GetOutputSize().Width() - 2*FRAME;
123cdf0e10cSrcweir 	long nHeight = pWindow->GetOutputSize().Height() - 2*FRAME;
124cdf0e10cSrcweir 	if( nWidth < 0 ) nWidth = 0;
125cdf0e10cSrcweir 	if( nHeight < 0 ) nHeight = 0;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	double dRatio=((double)aTmpSize.Width())/aTmpSize.Height();
128cdf0e10cSrcweir 	double dRatioPreV=((double) nWidth ) / nHeight;
129cdf0e10cSrcweir 	Size aSize;
130cdf0e10cSrcweir 	Point aPoint;
131cdf0e10cSrcweir 	if (dRatio>dRatioPreV)
132cdf0e10cSrcweir 	{
133cdf0e10cSrcweir 		aSize=Size(nWidth, (sal_uInt16)(nWidth/dRatio));
134cdf0e10cSrcweir 		aPoint=Point( 0, (sal_uInt16)((nHeight-aSize.Height())/2));
135cdf0e10cSrcweir 	}
136cdf0e10cSrcweir 	else
137cdf0e10cSrcweir 	{
138cdf0e10cSrcweir 		aSize=Size((sal_uInt16)(nHeight*dRatio), nHeight);
139cdf0e10cSrcweir 		aPoint=Point((sal_uInt16)((nWidth-aSize.Width())/2),0);
140cdf0e10cSrcweir 	}
141cdf0e10cSrcweir 	Point bPoint=Point(nWidth,nHeight)-aPoint;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	pWindow->SetLineColor();
145cdf0e10cSrcweir 	Color aLightGrayCol( COL_LIGHTGRAY );
146cdf0e10cSrcweir 	pWindow->SetFillColor( aLightGrayCol );
147cdf0e10cSrcweir 	pWindow->DrawRect( Rectangle( Point( 0,0 ), pWindow->GetOutputSize() ) );
148cdf0e10cSrcweir 	if ( pFile )
149cdf0e10cSrcweir 	{
150cdf0e10cSrcweir 		Color aBlackCol( COL_BLACK );
151cdf0e10cSrcweir 		Color aWhiteCol( COL_WHITE );
152cdf0e10cSrcweir 		pWindow->SetLineColor( aBlackCol );
153cdf0e10cSrcweir 		pWindow->SetFillColor( aWhiteCol );
154cdf0e10cSrcweir 		pWindow->DrawRect( Rectangle( aPoint + Point( FRAME, FRAME ), bPoint + Point( FRAME, FRAME ) ) );
155cdf0e10cSrcweir //!		pFile->Move( Point( FRAME, FRAME ) );
156cdf0e10cSrcweir //!		pFile->Scale( Fraction( aTmpSize.Width(), aSize.Width() ),
157cdf0e10cSrcweir //!					  Fraction( aTmpSize.Height(), aSize.Height() ) );
158cdf0e10cSrcweir 		pFile->WindStart();
159cdf0e10cSrcweir 		pFile->Play( pWindow, aPoint + Point( FRAME, FRAME ), aSize  );
160cdf0e10cSrcweir 	}
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir void SfxPreviewWin_Impl::Paint( const Rectangle& rRect )
164cdf0e10cSrcweir {
165cdf0e10cSrcweir 	ImpPaint( rRect, pMetaFile.get(), this );
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir SfxPreviewWin::SfxPreviewWin(
169cdf0e10cSrcweir 	Window* pParent, const ResId& rResId, SfxObjectShellLock &rDocSh )
170cdf0e10cSrcweir 	: Window(pParent, rResId), rDocShell( rDocSh )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir 	SetHelpId( HID_PREVIEW_FRAME );
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     // adjust contrast mode initially
175cdf0e10cSrcweir     bool bUseContrast = UseHighContrastSetting();
176cdf0e10cSrcweir     SetDrawMode( bUseContrast ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     // #107818# This preview window is for document previews.  Therefore
179cdf0e10cSrcweir     // right-to-left mode should be off
180cdf0e10cSrcweir     EnableRTL( sal_False );
181cdf0e10cSrcweir }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir void SfxPreviewWin::Paint( const Rectangle& rRect )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir 	SfxViewFrame *pFrame = SfxViewFrame::GetFirst( &rDocShell );
186cdf0e10cSrcweir 	if ( pFrame && pFrame->GetViewShell() &&
187cdf0e10cSrcweir 		 pFrame->GetViewShell()->GetPrinter() &&
188cdf0e10cSrcweir 		 pFrame->GetViewShell()->GetPrinter()->IsPrinting() )
189cdf0e10cSrcweir     {
190cdf0e10cSrcweir         return;
191cdf0e10cSrcweir     }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     Size            aTmpSize( rDocShell->GetFirstPageSize() );
194cdf0e10cSrcweir     GDIMetaFile     aMtf;
195cdf0e10cSrcweir     VirtualDevice   aDevice;
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     DBG_ASSERT( aTmpSize.Height() * aTmpSize.Width(), "size of first page is 0, overload GetFirstPageSize or set vis-area!" );
198cdf0e10cSrcweir 
199cdf0e10cSrcweir     aMtf.SetPrefSize( aTmpSize );
200cdf0e10cSrcweir     aDevice.EnableOutput( sal_False );
201cdf0e10cSrcweir     aDevice.SetMapMode( rDocShell->GetMapUnit() );
202cdf0e10cSrcweir     aDevice.SetDrawMode( GetDrawMode() );
203cdf0e10cSrcweir     aMtf.Record( &aDevice );
204cdf0e10cSrcweir     rDocShell->DoDraw( &aDevice, Point(0,0), aTmpSize, JobSetup(), ASPECT_THUMBNAIL );
205cdf0e10cSrcweir     aMtf.Stop();
206cdf0e10cSrcweir     aMtf.WindStart();
207cdf0e10cSrcweir     SfxPreviewWin_Impl::ImpPaint( rRect, &aMtf, this );
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir void SfxPreviewWin::DataChanged( const DataChangedEvent& rDCEvt )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir 	Window::DataChanged( rDCEvt );
213cdf0e10cSrcweir 
214cdf0e10cSrcweir     if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
215cdf0e10cSrcweir         (rDCEvt.GetFlags() & SETTINGS_STYLE) )
216cdf0e10cSrcweir     {
217cdf0e10cSrcweir         // adjust contrast mode
218cdf0e10cSrcweir         bool bUseContrast = UseHighContrastSetting();
219cdf0e10cSrcweir         SetDrawMode( bUseContrast ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
220cdf0e10cSrcweir     }
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir bool SfxPreviewWin::UseHighContrastSetting() const
224cdf0e10cSrcweir {
225cdf0e10cSrcweir     return GetSettings().GetStyleSettings().GetHighContrastMode();
226cdf0e10cSrcweir }
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 
229cdf0e10cSrcweir class SfxNewFileDialog_Impl
230cdf0e10cSrcweir {
231cdf0e10cSrcweir 	FixedText aRegionFt;
232cdf0e10cSrcweir 	ListBox aRegionLb;
233cdf0e10cSrcweir 	FixedText aTemplateFt;
234cdf0e10cSrcweir 	ListBox aTemplateLb;
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 	CheckBox aPreviewBtn;
237cdf0e10cSrcweir 	SfxPreviewWin_Impl aPreviewWin;
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 	FixedText aTitleFt;
240cdf0e10cSrcweir 	Edit aTitleEd;
241cdf0e10cSrcweir 	FixedText aThemaFt;
242cdf0e10cSrcweir 	Edit aThemaEd;
243cdf0e10cSrcweir 	FixedText aKeywordsFt;
244cdf0e10cSrcweir 	Edit aKeywordsEd;
245cdf0e10cSrcweir 	FixedText aDescFt;
246cdf0e10cSrcweir 	MultiLineEdit aDescEd;
247cdf0e10cSrcweir     FixedLine aDocinfoGb;
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     CheckBox aTextStyleCB;
250cdf0e10cSrcweir     CheckBox aFrameStyleCB;
251cdf0e10cSrcweir     CheckBox aPageStyleCB;
252cdf0e10cSrcweir     CheckBox aNumStyleCB;
253cdf0e10cSrcweir     CheckBox aMergeStyleCB;
254cdf0e10cSrcweir     PushButton aLoadFilePB;
255cdf0e10cSrcweir 
256cdf0e10cSrcweir     OKButton aOkBt;
257cdf0e10cSrcweir 	CancelButton aCancelBt;
258cdf0e10cSrcweir 	HelpButton aHelpBt;
259cdf0e10cSrcweir 	MoreButton* pMoreBt;
260cdf0e10cSrcweir 	Timer aPrevTimer;
261cdf0e10cSrcweir 	String aNone;
262cdf0e10cSrcweir     String sLoadTemplate;
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	sal_uInt16 nFlags;
265cdf0e10cSrcweir 	SfxDocumentTemplates aTemplates;
266cdf0e10cSrcweir 	SfxObjectShellLock xDocShell;
267cdf0e10cSrcweir 	SfxNewFileDialog* pAntiImpl;
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 	void ClearInfo();
270cdf0e10cSrcweir 	DECL_LINK( Update, void * );
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 	DECL_LINK( RegionSelect, ListBox * );
273cdf0e10cSrcweir 	DECL_LINK( TemplateSelect, ListBox * );
274cdf0e10cSrcweir 	DECL_LINK( DoubleClick, ListBox * );
275cdf0e10cSrcweir 	void TogglePreview(CheckBox *);
276cdf0e10cSrcweir 	DECL_LINK( Expand, MoreButton * );
277cdf0e10cSrcweir 	DECL_LINK( PreviewClick, CheckBox * );
278cdf0e10cSrcweir     DECL_LINK( LoadFile, PushButton* );
279cdf0e10cSrcweir 	sal_uInt16  GetSelectedTemplatePos() const;
280cdf0e10cSrcweir 
281cdf0e10cSrcweir public:
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 	SfxNewFileDialog_Impl( SfxNewFileDialog* pAntiImplP, sal_uInt16 nFlags );
284cdf0e10cSrcweir 	~SfxNewFileDialog_Impl();
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 		// Liefert sal_False, wenn '- Keine -' als Vorlage eingestellt ist
287cdf0e10cSrcweir 		// Nur wenn IsTemplate() sal_True liefert, koennen Vorlagennamen
288cdf0e10cSrcweir 		// erfragt werden
289cdf0e10cSrcweir 	sal_Bool IsTemplate() const;
290cdf0e10cSrcweir 	String GetTemplateRegion() const;
291cdf0e10cSrcweir 	String GetTemplateName() const;
292cdf0e10cSrcweir 	String GetTemplateFileName() const;
293cdf0e10cSrcweir 
294cdf0e10cSrcweir     sal_uInt16  GetTemplateFlags()const;
295cdf0e10cSrcweir     void    SetTemplateFlags(sal_uInt16 nSet);
296cdf0e10cSrcweir };
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 
299cdf0e10cSrcweir //-------------------------------------------------------------------------
300cdf0e10cSrcweir 
301cdf0e10cSrcweir void SfxNewFileDialog_Impl::ClearInfo()
302cdf0e10cSrcweir {
303cdf0e10cSrcweir 	const String aNo;
304cdf0e10cSrcweir 	aTitleEd.SetText(aNo);
305cdf0e10cSrcweir 	aThemaEd.SetText(aNo);
306cdf0e10cSrcweir 	aKeywordsEd.SetText(aNo);
307cdf0e10cSrcweir 	aDescEd.SetText(aNo);
308cdf0e10cSrcweir }
309cdf0e10cSrcweir 
310cdf0e10cSrcweir //-------------------------------------------------------------------------
311cdf0e10cSrcweir 
312cdf0e10cSrcweir IMPL_LINK( SfxNewFileDialog_Impl, Update, void *, EMPTYARG )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir 	if ( xDocShell.Is() )
315cdf0e10cSrcweir 	{
316cdf0e10cSrcweir 		if ( xDocShell->GetProgress() )
317cdf0e10cSrcweir 			return sal_False;
318cdf0e10cSrcweir 		xDocShell.Clear();
319cdf0e10cSrcweir 	}
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	const sal_uInt16 nEntry = GetSelectedTemplatePos();
322cdf0e10cSrcweir 	if(!nEntry)
323cdf0e10cSrcweir 	{
324cdf0e10cSrcweir 		ClearInfo();
325cdf0e10cSrcweir 		aPreviewWin.Invalidate();
326cdf0e10cSrcweir 		aPreviewWin.SetObjectShell( 0);
327cdf0e10cSrcweir 		return 0;
328cdf0e10cSrcweir 	}
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 	if ( aPreviewBtn.IsChecked() && (nFlags & SFXWB_PREVIEW) == SFXWB_PREVIEW)
331cdf0e10cSrcweir 	{
332cdf0e10cSrcweir 
333cdf0e10cSrcweir         String aFileName = aTemplates.GetPath( aRegionLb.GetSelectEntryPos(), nEntry-1);
334cdf0e10cSrcweir         INetURLObject aTestObj( aFileName );
335cdf0e10cSrcweir         if( aTestObj.GetProtocol() == INET_PROT_NOT_VALID )
336cdf0e10cSrcweir         {
337cdf0e10cSrcweir             // temp. fix until Templates are managed by UCB compatible service
338cdf0e10cSrcweir             // does NOT work with locally cached components !
339cdf0e10cSrcweir             String aTemp;
340cdf0e10cSrcweir             utl::LocalFileHelper::ConvertPhysicalNameToURL( aFileName, aTemp );
341cdf0e10cSrcweir             aFileName = aTemp;
342cdf0e10cSrcweir         }
343cdf0e10cSrcweir 
344cdf0e10cSrcweir         INetURLObject aObj( aFileName );
345cdf0e10cSrcweir 		for ( SfxObjectShell* pTmp = SfxObjectShell::GetFirst();
346cdf0e10cSrcweir 			  pTmp;
347cdf0e10cSrcweir 			  pTmp = SfxObjectShell::GetNext(*pTmp) )
348cdf0e10cSrcweir 		{
349cdf0e10cSrcweir 			//! fsys bug op==
350cdf0e10cSrcweir 			if ( pTmp->GetMedium())
351cdf0e10cSrcweir 				// ??? HasName() MM
352cdf0e10cSrcweir                 if( INetURLObject( pTmp->GetMedium()->GetName() ) == aObj )
353cdf0e10cSrcweir 				{
354cdf0e10cSrcweir 					xDocShell = pTmp;
355cdf0e10cSrcweir 					break;
356cdf0e10cSrcweir 				}
357cdf0e10cSrcweir 		}
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 		if ( !xDocShell.Is() )
360cdf0e10cSrcweir 		{
361cdf0e10cSrcweir 			Window *pParent = Application::GetDefDialogParent();
362cdf0e10cSrcweir 			Application::SetDefDialogParent( pAntiImpl );
363cdf0e10cSrcweir 			SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE,pAntiImpl);
364cdf0e10cSrcweir 			SfxApplication *pSfxApp = SFX_APP();
365cdf0e10cSrcweir 			sal_uIntPtr lErr;
366cdf0e10cSrcweir 			SfxItemSet* pSet = new SfxAllItemSet( pSfxApp->GetPool() );
367cdf0e10cSrcweir 			pSet->Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
368cdf0e10cSrcweir 			pSet->Put( SfxBoolItem( SID_PREVIEW, sal_True ) );
369cdf0e10cSrcweir 			lErr = pSfxApp->LoadTemplate( xDocShell, aFileName, sal_True, pSet );
370cdf0e10cSrcweir 			if( lErr )
371cdf0e10cSrcweir 				ErrorHandler::HandleError(lErr);
372cdf0e10cSrcweir 			Application::SetDefDialogParent( pParent );
373cdf0e10cSrcweir 			if ( !xDocShell.Is() )
374cdf0e10cSrcweir 			{
375cdf0e10cSrcweir 				aPreviewWin.SetObjectShell( 0 );
376cdf0e10cSrcweir 				return sal_False;
377cdf0e10cSrcweir 			}
378cdf0e10cSrcweir 		}
379cdf0e10cSrcweir 
380cdf0e10cSrcweir 		aPreviewWin.SetObjectShell( xDocShell );
381cdf0e10cSrcweir 	}
382cdf0e10cSrcweir 	return sal_True;
383cdf0e10cSrcweir }
384cdf0e10cSrcweir 
385cdf0e10cSrcweir //-------------------------------------------------------------------------
386cdf0e10cSrcweir 
387cdf0e10cSrcweir IMPL_LINK( SfxNewFileDialog_Impl, RegionSelect, ListBox *, pBox )
388cdf0e10cSrcweir {
389cdf0e10cSrcweir 	if ( xDocShell.Is() && xDocShell->GetProgress() )
390cdf0e10cSrcweir 		return 0;
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 	const sal_uInt16 nRegion = pBox->GetSelectEntryPos();
393cdf0e10cSrcweir 	const sal_uInt16 nCount = aTemplates.GetRegionCount()? aTemplates.GetCount(nRegion): 0;
394cdf0e10cSrcweir 	aTemplateLb.SetUpdateMode(sal_False);
395cdf0e10cSrcweir 	aTemplateLb.Clear();
396cdf0e10cSrcweir 	String aSel=aRegionLb.GetSelectEntry();
397cdf0e10cSrcweir 	sal_uInt16 nc=aSel.Search('(');
398cdf0e10cSrcweir 	if (nc-1&&nc!=STRING_NOTFOUND)
399cdf0e10cSrcweir 		aSel.Erase(nc-1);
400cdf0e10cSrcweir 	if (aSel.CompareIgnoreCaseToAscii( String(SfxResId(STR_STANDARD)) )==COMPARE_EQUAL)
401cdf0e10cSrcweir 		aTemplateLb.InsertEntry(aNone);
402cdf0e10cSrcweir 	for (sal_uInt16 i = 0; i < nCount; ++i)
403cdf0e10cSrcweir 		aTemplateLb.InsertEntry(aTemplates.GetName(nRegion, i));
404cdf0e10cSrcweir 	aTemplateLb.SelectEntryPos(0);
405cdf0e10cSrcweir 	aTemplateLb.SetUpdateMode(sal_True);
406cdf0e10cSrcweir 	aTemplateLb.Invalidate();
407cdf0e10cSrcweir 	aTemplateLb.Update();
408cdf0e10cSrcweir 	return 0;
409cdf0e10cSrcweir }
410cdf0e10cSrcweir 
411cdf0e10cSrcweir //-------------------------------------------------------------------------
412cdf0e10cSrcweir 
413cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxNewFileDialog_Impl, Expand, MoreButton *, EMPTYARG )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir 	TemplateSelect(&aTemplateLb);
416cdf0e10cSrcweir 	return 0;
417cdf0e10cSrcweir }
418cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxNewFileDialog_Impl, Expand, MoreButton *, pMoreButton )
419cdf0e10cSrcweir 
420cdf0e10cSrcweir //-------------------------------------------------------------------------
421cdf0e10cSrcweir 
422cdf0e10cSrcweir IMPL_LINK( SfxNewFileDialog_Impl, PreviewClick, CheckBox *, pBox )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir 	if ( xDocShell.Is() && xDocShell->GetProgress() )
425cdf0e10cSrcweir 		return 0;
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 	sal_uInt16 nEntry = GetSelectedTemplatePos();
428cdf0e10cSrcweir 	if ( nEntry && pBox->IsChecked() )
429cdf0e10cSrcweir 	{
430cdf0e10cSrcweir 		if(!Update(0))
431cdf0e10cSrcweir 			aPreviewWin.Invalidate();
432cdf0e10cSrcweir 	}
433cdf0e10cSrcweir 	else
434cdf0e10cSrcweir 	{
435cdf0e10cSrcweir 		if (xDocShell.Is())
436cdf0e10cSrcweir 			xDocShell.Clear();
437cdf0e10cSrcweir 		aPreviewWin.SetObjectShell( 0 );
438cdf0e10cSrcweir 	}
439cdf0e10cSrcweir 	return 0;
440cdf0e10cSrcweir }
441cdf0e10cSrcweir 
442cdf0e10cSrcweir //-------------------------------------------------------------------------
443cdf0e10cSrcweir 
444cdf0e10cSrcweir IMPL_LINK( SfxNewFileDialog_Impl, TemplateSelect, ListBox *, EMPTYARG )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir 	// noch am Laden
447cdf0e10cSrcweir 	if ( xDocShell && xDocShell->GetProgress() )
448cdf0e10cSrcweir 		return 0;
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 	if ( !MORE_BTN(GetState()) )
451cdf0e10cSrcweir 		// Dialog nicht aufgeklappt
452cdf0e10cSrcweir 		return 0;
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 	aPrevTimer.Start();
455cdf0e10cSrcweir 	return 0;
456cdf0e10cSrcweir }
457cdf0e10cSrcweir 
458cdf0e10cSrcweir //-------------------------------------------------------------------------
459cdf0e10cSrcweir 
460cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxNewFileDialog_Impl, DoubleClick, ListBox *, pListBox )
461cdf0e10cSrcweir {
462cdf0e10cSrcweir     (void)pListBox;
463cdf0e10cSrcweir     // noch am Laden
464cdf0e10cSrcweir 	if ( !xDocShell.Is() || !xDocShell->GetProgress() )
465cdf0e10cSrcweir 		pAntiImpl->EndDialog(RET_OK);
466cdf0e10cSrcweir 	return 0;
467cdf0e10cSrcweir }
468cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxNewFileDialog_Impl, DoubleClick, ListBox *, pListBox )
469cdf0e10cSrcweir 
470cdf0e10cSrcweir //-------------------------------------------------------------------------
471cdf0e10cSrcweir 
472cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxNewFileDialog_Impl, LoadFile, PushButton *, EMPTYARG )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir     pAntiImpl->EndDialog(RET_TEMPLATE_LOAD);
475cdf0e10cSrcweir 	return 0;
476cdf0e10cSrcweir }
477cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxNewFileDialog_Impl, LoadFile, PushButton *, EMPTYARG )
478cdf0e10cSrcweir //-------------------------------------------------------------------------
479cdf0e10cSrcweir 
480cdf0e10cSrcweir sal_uInt16  SfxNewFileDialog_Impl::GetSelectedTemplatePos() const
481cdf0e10cSrcweir {
482cdf0e10cSrcweir 	sal_uInt16 nEntry=aTemplateLb.GetSelectEntryPos();
483cdf0e10cSrcweir 	String aSel=aRegionLb.GetSelectEntry().Copy();
484cdf0e10cSrcweir 	sal_uInt16 nc=aSel.Search('(');
485cdf0e10cSrcweir 	if (nc-1&&nc!=STRING_NOTFOUND)
486cdf0e10cSrcweir 		aSel.Erase(nc-1);
487cdf0e10cSrcweir 	if (aSel.CompareIgnoreCaseToAscii(String(SfxResId(STR_STANDARD)))!=COMPARE_EQUAL)
488cdf0e10cSrcweir 		nEntry++;
489cdf0e10cSrcweir 	if (!aTemplateLb.GetSelectEntryCount())
490cdf0e10cSrcweir 		nEntry=0;
491cdf0e10cSrcweir 	return nEntry;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir 
494cdf0e10cSrcweir //-------------------------------------------------------------------------
495cdf0e10cSrcweir 
496cdf0e10cSrcweir sal_Bool SfxNewFileDialog_Impl::IsTemplate() const
497cdf0e10cSrcweir {
498cdf0e10cSrcweir 	return GetSelectedTemplatePos()!=0;
499cdf0e10cSrcweir 
500cdf0e10cSrcweir }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir //-------------------------------------------------------------------------
503cdf0e10cSrcweir 
504cdf0e10cSrcweir String SfxNewFileDialog_Impl::GetTemplateFileName() const
505cdf0e10cSrcweir {
506cdf0e10cSrcweir 	if(!IsTemplate() || !aTemplates.GetRegionCount())
507cdf0e10cSrcweir 		return String();
508cdf0e10cSrcweir 	return aTemplates.GetPath(aRegionLb.GetSelectEntryPos(),
509cdf0e10cSrcweir 							  GetSelectedTemplatePos()-1);
510cdf0e10cSrcweir }
511cdf0e10cSrcweir 
512cdf0e10cSrcweir //-------------------------------------------------------------------------
513cdf0e10cSrcweir 
514cdf0e10cSrcweir String SfxNewFileDialog_Impl::GetTemplateRegion() const
515cdf0e10cSrcweir {
516cdf0e10cSrcweir 	if(!IsTemplate() || !aTemplates.GetRegionCount())
517cdf0e10cSrcweir 		return String();
518cdf0e10cSrcweir 	return aRegionLb.GetSelectEntry();
519cdf0e10cSrcweir }
520cdf0e10cSrcweir 
521cdf0e10cSrcweir //-------------------------------------------------------------------------
522cdf0e10cSrcweir 
523cdf0e10cSrcweir String SfxNewFileDialog_Impl::GetTemplateName() const
524cdf0e10cSrcweir {
525cdf0e10cSrcweir 	if(!IsTemplate() || !aTemplates.GetRegionCount())
526cdf0e10cSrcweir 		return String();
527cdf0e10cSrcweir 	return aTemplateLb.GetSelectEntry();
528cdf0e10cSrcweir }
529cdf0e10cSrcweir 
530cdf0e10cSrcweir //-------------------------------------------------------------------------
531cdf0e10cSrcweir 
532cdf0e10cSrcweir void AdjustPosSize_Impl(Window *pWin, short nMoveOffset, short nSizeOffset)
533cdf0e10cSrcweir {
534cdf0e10cSrcweir 	Point aPos(pWin->GetPosPixel());
535cdf0e10cSrcweir 	Size aSize(pWin->GetSizePixel());
536cdf0e10cSrcweir 	aPos.X() -= nMoveOffset;
537cdf0e10cSrcweir 	aSize.Width() += nSizeOffset;
538cdf0e10cSrcweir 	pWin->SetPosSizePixel(aPos, aSize);
539cdf0e10cSrcweir }
540cdf0e10cSrcweir //-------------------------------------------------------------------------
541cdf0e10cSrcweir sal_uInt16  SfxNewFileDialog_Impl::GetTemplateFlags()const
542cdf0e10cSrcweir {
543cdf0e10cSrcweir     sal_uInt16 nRet = aTextStyleCB.IsChecked() ? SFX_LOAD_TEXT_STYLES : 0;
544cdf0e10cSrcweir     if(aFrameStyleCB.IsChecked())
545cdf0e10cSrcweir         nRet |= SFX_LOAD_FRAME_STYLES;
546cdf0e10cSrcweir     if(aPageStyleCB.IsChecked())
547cdf0e10cSrcweir         nRet |= SFX_LOAD_PAGE_STYLES;
548cdf0e10cSrcweir     if(aNumStyleCB.IsChecked())
549cdf0e10cSrcweir         nRet |= SFX_LOAD_NUM_STYLES;
550cdf0e10cSrcweir     if(aMergeStyleCB.IsChecked())
551cdf0e10cSrcweir         nRet |= SFX_MERGE_STYLES;
552cdf0e10cSrcweir     return nRet;
553cdf0e10cSrcweir }
554cdf0e10cSrcweir //-------------------------------------------------------------------------
555cdf0e10cSrcweir void    SfxNewFileDialog_Impl::SetTemplateFlags(sal_uInt16 nSet)
556cdf0e10cSrcweir {
557cdf0e10cSrcweir     aTextStyleCB.Check(  0 != (nSet&SFX_LOAD_TEXT_STYLES ));
558cdf0e10cSrcweir     aFrameStyleCB.Check( 0 != (nSet&SFX_LOAD_FRAME_STYLES));
559cdf0e10cSrcweir     aPageStyleCB.Check(  0 != (nSet&SFX_LOAD_PAGE_STYLES ));
560cdf0e10cSrcweir     aNumStyleCB.Check(   0 != (nSet&SFX_LOAD_NUM_STYLES  ));
561cdf0e10cSrcweir     aMergeStyleCB.Check( 0 != (nSet&SFX_MERGE_STYLES     ));
562cdf0e10cSrcweir }
563cdf0e10cSrcweir 
564cdf0e10cSrcweir //-------------------------------------------------------------------------
565cdf0e10cSrcweir 
566cdf0e10cSrcweir SfxNewFileDialog_Impl::SfxNewFileDialog_Impl(
567cdf0e10cSrcweir 	SfxNewFileDialog* pAntiImplP, sal_uInt16 nFl)
568cdf0e10cSrcweir 	:	aRegionFt( pAntiImplP, SfxResId( FT_REGION ) ),
569cdf0e10cSrcweir 		aRegionLb( pAntiImplP, SfxResId( LB_REGION ) ),
570cdf0e10cSrcweir 		aTemplateFt( pAntiImplP, SfxResId( FT_TEMPLATE ) ),
571cdf0e10cSrcweir 		aTemplateLb( pAntiImplP, SfxResId( LB_TEMPLATE ) ),
572cdf0e10cSrcweir 		aPreviewBtn( pAntiImplP, SfxResId( BTN_PREVIEW ) ),
573cdf0e10cSrcweir 		aPreviewWin( pAntiImplP, SfxResId( WIN_PREVIEW ) ),
574cdf0e10cSrcweir 		aTitleFt( pAntiImplP, SfxResId( FT_TITLE ) ),
575cdf0e10cSrcweir 		aTitleEd( pAntiImplP, SfxResId( ED_TITLE ) ),
576cdf0e10cSrcweir 		aThemaFt( pAntiImplP, SfxResId( FT_THEMA ) ),
577cdf0e10cSrcweir 		aThemaEd( pAntiImplP, SfxResId( ED_THEMA ) ),
578cdf0e10cSrcweir 		aKeywordsFt( pAntiImplP, SfxResId( FT_KEYWORDS ) ),
579cdf0e10cSrcweir 		aKeywordsEd( pAntiImplP, SfxResId( ED_KEYWORDS ) ),
580cdf0e10cSrcweir 		aDescFt( pAntiImplP, SfxResId( FT_DESC ) ),
581cdf0e10cSrcweir 		aDescEd( pAntiImplP, SfxResId( ED_DESC ) ),
582cdf0e10cSrcweir 		aDocinfoGb( pAntiImplP, SfxResId( GB_DOCINFO ) ),
583cdf0e10cSrcweir         aTextStyleCB( pAntiImplP, SfxResId(  CB_TEXT_STYLE )),
584cdf0e10cSrcweir         aFrameStyleCB( pAntiImplP, SfxResId( CB_FRAME_STYLE )),
585cdf0e10cSrcweir         aPageStyleCB( pAntiImplP, SfxResId(  CB_PAGE_STYLE )),
586cdf0e10cSrcweir         aNumStyleCB( pAntiImplP, SfxResId(   CB_NUM_STYLE  )),
587cdf0e10cSrcweir         aMergeStyleCB( pAntiImplP, SfxResId( CB_MERGE_STYLE )),
588cdf0e10cSrcweir         aLoadFilePB( pAntiImplP, SfxResId(   PB_LOAD_FILE )),
589cdf0e10cSrcweir 	    aOkBt( pAntiImplP, SfxResId( BT_OK ) ),
590cdf0e10cSrcweir 		aCancelBt( pAntiImplP, SfxResId( BT_CANCEL ) ),
591cdf0e10cSrcweir 		aHelpBt( pAntiImplP, SfxResId( BT_HELP ) ),
592cdf0e10cSrcweir 		pMoreBt( new MoreButton( pAntiImplP, SfxResId( BT_MORE ) ) ),
593cdf0e10cSrcweir 		aNone( SfxResId(STR_NONE) ),
594cdf0e10cSrcweir         sLoadTemplate( SfxResId(STR_LOAD_TEMPLATE)),
595cdf0e10cSrcweir 		nFlags(nFl),
596cdf0e10cSrcweir 		pAntiImpl( pAntiImplP )
597cdf0e10cSrcweir {
598cdf0e10cSrcweir 	short nMoveOffset = *(short *)pAntiImplP->GetClassRes();
599cdf0e10cSrcweir 	pAntiImplP->IncrementRes(sizeof(short));
600cdf0e10cSrcweir 	short nExpandSize= *(short *)pAntiImplP->GetClassRes();
601cdf0e10cSrcweir 	pAntiImplP->IncrementRes(sizeof(short));
602cdf0e10cSrcweir 	pAntiImplP->FreeResource();
603cdf0e10cSrcweir 
604cdf0e10cSrcweir 	if (!nFlags)
605cdf0e10cSrcweir 		MORE_BTN(Hide());
606cdf0e10cSrcweir     else if(SFXWB_LOAD_TEMPLATE == nFlags)
607cdf0e10cSrcweir     {
608cdf0e10cSrcweir         aLoadFilePB.SetClickHdl(LINK(this, SfxNewFileDialog_Impl, LoadFile));
609cdf0e10cSrcweir         aLoadFilePB.Show();
610cdf0e10cSrcweir         aTextStyleCB.Show();
611cdf0e10cSrcweir         aFrameStyleCB.Show();
612cdf0e10cSrcweir         aPageStyleCB.Show();
613cdf0e10cSrcweir         aNumStyleCB.Show();
614cdf0e10cSrcweir         aMergeStyleCB.Show();
615cdf0e10cSrcweir         Size aSize(pAntiImplP->GetOutputSizePixel());
616cdf0e10cSrcweir         Size aTmp(pAntiImplP->LogicToPixel(Size(16, 16), MAP_APPFONT));
617cdf0e10cSrcweir         aSize.Height() += aTmp.Height();
618cdf0e10cSrcweir         pAntiImplP->SetOutputSizePixel(aSize);
619cdf0e10cSrcweir         pMoreBt->Hide();
620cdf0e10cSrcweir         aTextStyleCB.Check();
621cdf0e10cSrcweir         pAntiImplP->SetText(sLoadTemplate);
622cdf0e10cSrcweir     }
623cdf0e10cSrcweir     else
624cdf0e10cSrcweir 	{
625cdf0e10cSrcweir 		MORE_BTN(SetClickHdl(LINK(this, SfxNewFileDialog_Impl, Expand)));
626cdf0e10cSrcweir 		if((nFlags & SFXWB_PREVIEW) == SFXWB_PREVIEW)
627cdf0e10cSrcweir 		{
628cdf0e10cSrcweir 			MORE_BTN(AddWindow(&aPreviewBtn));
629cdf0e10cSrcweir 			MORE_BTN(AddWindow(&aPreviewWin));
630cdf0e10cSrcweir 			aPreviewBtn.SetClickHdl(LINK(this, SfxNewFileDialog_Impl, PreviewClick));
631cdf0e10cSrcweir 		}
632cdf0e10cSrcweir 		else
633cdf0e10cSrcweir 		{
634cdf0e10cSrcweir 			aPreviewBtn.Hide();
635cdf0e10cSrcweir 			aPreviewWin.Hide();
636cdf0e10cSrcweir 			nMoveOffset = (short)pAntiImplP->LogicToPixel(
637cdf0e10cSrcweir 				Size(nMoveOffset, nMoveOffset), MAP_APPFONT).Width();
638cdf0e10cSrcweir 			nExpandSize = (short)pAntiImplP->LogicToPixel(
639cdf0e10cSrcweir 				Size(nExpandSize, nExpandSize), MAP_APPFONT).Width();
640cdf0e10cSrcweir 			AdjustPosSize_Impl(&aTitleFt, nMoveOffset, 0);
641cdf0e10cSrcweir 			AdjustPosSize_Impl(&aTitleEd, nMoveOffset, nExpandSize);
642cdf0e10cSrcweir 			AdjustPosSize_Impl(&aThemaFt, nMoveOffset, 0);
643cdf0e10cSrcweir 			AdjustPosSize_Impl(&aThemaEd, nMoveOffset, nExpandSize);
644cdf0e10cSrcweir 			AdjustPosSize_Impl(&aKeywordsFt, nMoveOffset, 0);
645cdf0e10cSrcweir 			AdjustPosSize_Impl(&aKeywordsEd, nMoveOffset, nExpandSize);
646cdf0e10cSrcweir 			AdjustPosSize_Impl(&aDescFt , nMoveOffset, 0);
647cdf0e10cSrcweir 			AdjustPosSize_Impl(&aDescEd , nMoveOffset, nExpandSize);
648cdf0e10cSrcweir 			AdjustPosSize_Impl(&aDocinfoGb, nMoveOffset, nExpandSize);
649cdf0e10cSrcweir 		}
650cdf0e10cSrcweir 	}
651cdf0e10cSrcweir 
652cdf0e10cSrcweir 	String &rExtra = pAntiImplP->GetExtraData();
653cdf0e10cSrcweir 	sal_uInt16 nTokCount = rExtra.GetTokenCount( '|' );
654cdf0e10cSrcweir 	if( nTokCount > 0 && nFlags )
655cdf0e10cSrcweir 		MORE_BTN(SetState( rExtra.GetToken( 0, '|' ) == 'Y' ));
656cdf0e10cSrcweir 	if( nTokCount > 1 && nFlags )
657cdf0e10cSrcweir 		aPreviewBtn.Check( rExtra.GetToken( 1 ,'|' ) == 'Y' );
658cdf0e10cSrcweir 
659cdf0e10cSrcweir 	aTemplateLb.SetDoubleClickHdl(LINK(this, SfxNewFileDialog_Impl, DoubleClick));
660cdf0e10cSrcweir 
661cdf0e10cSrcweir 	// update the template configuration if necessary
662cdf0e10cSrcweir 	{
663cdf0e10cSrcweir 		WaitObject aWaitCursor( pAntiImplP->GetParent() );
664cdf0e10cSrcweir 		aTemplates.Update( sal_True /* be smart */ );
665cdf0e10cSrcweir 	}
666cdf0e10cSrcweir 	// fill the list boxes
667cdf0e10cSrcweir 	const sal_uInt16 nCount = aTemplates.GetRegionCount();
668cdf0e10cSrcweir 	if (nCount)
669cdf0e10cSrcweir 	{
670cdf0e10cSrcweir 		for(sal_uInt16 i = 0; i < nCount; ++i)
671cdf0e10cSrcweir 			aRegionLb.InsertEntry(aTemplates.GetFullRegionName(i));
672cdf0e10cSrcweir 		aRegionLb.SetSelectHdl(LINK(this, SfxNewFileDialog_Impl, RegionSelect));
673cdf0e10cSrcweir 	}
674cdf0e10cSrcweir 
675cdf0e10cSrcweir 	aPrevTimer.SetTimeout( 500 );
676cdf0e10cSrcweir 	aPrevTimer.SetTimeoutHdl( LINK( this, SfxNewFileDialog_Impl, Update));
677cdf0e10cSrcweir 
678cdf0e10cSrcweir //	 else
679cdf0e10cSrcweir //		  aRegionLb.InsertEntry(String(SfxResId(STR_STANDARD)));
680cdf0e10cSrcweir 	aRegionLb.SelectEntryPos(0);
681cdf0e10cSrcweir 	RegionSelect(&aRegionLb);
682cdf0e10cSrcweir }
683cdf0e10cSrcweir 
684cdf0e10cSrcweir //-------------------------------------------------------------------------
685cdf0e10cSrcweir 
686cdf0e10cSrcweir SfxNewFileDialog_Impl::~SfxNewFileDialog_Impl()
687cdf0e10cSrcweir {
688cdf0e10cSrcweir 	String &rExtra = pAntiImpl->GetExtraData();
689cdf0e10cSrcweir 	rExtra = MORE_BTN(GetState()) ? 'Y' : 'N';
690cdf0e10cSrcweir 	rExtra += '|';
691cdf0e10cSrcweir 	rExtra += aPreviewBtn.IsChecked() ? 'Y' : 'N';
692cdf0e10cSrcweir 
693cdf0e10cSrcweir 	delete pMoreBt;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir //-------------------------------------------------------------------------
696cdf0e10cSrcweir SfxNewFileDialog::SfxNewFileDialog(Window *pParent, sal_uInt16 nFlags)
697cdf0e10cSrcweir 	: SfxModalDialog( pParent, SfxResId( DLG_NEW_FILE ) )
698cdf0e10cSrcweir {
699cdf0e10cSrcweir 	pImpl = new SfxNewFileDialog_Impl( this, nFlags );
700cdf0e10cSrcweir }
701cdf0e10cSrcweir //-------------------------------------------------------------------------
702cdf0e10cSrcweir SfxNewFileDialog::~SfxNewFileDialog()
703cdf0e10cSrcweir {
704cdf0e10cSrcweir 	delete pImpl;
705cdf0e10cSrcweir }
706cdf0e10cSrcweir //-------------------------------------------------------------------------
707cdf0e10cSrcweir sal_Bool SfxNewFileDialog::IsTemplate() const
708cdf0e10cSrcweir {
709cdf0e10cSrcweir 	return pImpl->IsTemplate();
710cdf0e10cSrcweir }
711cdf0e10cSrcweir //-------------------------------------------------------------------------
712cdf0e10cSrcweir String SfxNewFileDialog::GetTemplateRegion() const
713cdf0e10cSrcweir {
714cdf0e10cSrcweir 	return pImpl->GetTemplateRegion();
715cdf0e10cSrcweir }
716cdf0e10cSrcweir //-------------------------------------------------------------------------
717cdf0e10cSrcweir String SfxNewFileDialog::GetTemplateName() const
718cdf0e10cSrcweir {
719cdf0e10cSrcweir 	return pImpl->GetTemplateName();
720cdf0e10cSrcweir }
721cdf0e10cSrcweir //-------------------------------------------------------------------------
722cdf0e10cSrcweir String SfxNewFileDialog::GetTemplateFileName() const
723cdf0e10cSrcweir {
724cdf0e10cSrcweir 	return pImpl->GetTemplateFileName();
725cdf0e10cSrcweir }
726cdf0e10cSrcweir //-------------------------------------------------------------------------
727cdf0e10cSrcweir sal_uInt16 SfxNewFileDialog::GetTemplateFlags()const
728cdf0e10cSrcweir {
729cdf0e10cSrcweir     return pImpl->GetTemplateFlags();
730cdf0e10cSrcweir 
731cdf0e10cSrcweir }
732cdf0e10cSrcweir //-------------------------------------------------------------------------
733cdf0e10cSrcweir void    SfxNewFileDialog::SetTemplateFlags(sal_uInt16 nSet)
734cdf0e10cSrcweir {
735cdf0e10cSrcweir     pImpl->SetTemplateFlags(nSet);
736cdf0e10cSrcweir }
737cdf0e10cSrcweir 
738