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