1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: new.cxx,v $
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_sfx2.hxx"
33 #include <sfx2/new.hxx>
34 #include <vcl/gdimtf.hxx>
35 #include <vcl/msgbox.hxx>
36 #include <vcl/morebtn.hxx>
38 #include <svtools/svmedit.hxx>
40 #include <svtools/itemset.hxx>
41 #include <svtools/eitem.hxx>
42 #include <svtools/sfxecode.hxx>
43 #include <svtools/ehdl.hxx>
44 #include <tools/urlobj.hxx>
45 #include <unotools/localfilehelper.hxx>
51 #include <sfx2/sfx.hrc>
53 #include "sfxtypes.hxx"
54 #include <sfx2/app.hxx>
55 #include <sfx2/viewfrm.hxx>
56 #include <sfx2/docfac.hxx>
57 #include <sfx2/objsh.hxx>
59 #include <sfx2/viewsh.hxx>
60 #include "viewfac.hxx"
61 #include "sfxresid.hxx"
62 #include <sfx2/docfile.hxx>
63 #include "preview.hxx"
64 #include <sfx2/printer.hxx>
65 #include <vcl/waitobj.hxx>
66 #include <vcl/virdev.hxx>
67 #include <vcl/jobset.hxx>
68 #include <svtools/accessibilityoptions.hxx>
71 #define OUTPUT_DRAWMODE_COLOR (DRAWMODE_DEFAULT)
72 #define OUTPUT_DRAWMODE_GRAYSCALE (DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_BLACKTEXT | DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT)
73 #define OUTPUT_DRAWMODE_BLACKWHITE (DRAWMODE_BLACKLINE | DRAWMODE_BLACKTEXT | DRAWMODE_WHITEFILL | DRAWMODE_GRAYBITMAP | DRAWMODE_WHITEGRADIENT)
74 #define OUTPUT_DRAWMODE_CONTRAST (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
76 //========================================================================
78 #define MORE_BTN(x) pMoreBt->x
80 //========================================================================
82 void SfxPreviewBase_Impl::SetObjectShell( SfxObjectShell
* pObj
)
84 ::boost::shared_ptr
<GDIMetaFile
> pFile
= pObj
85 ? pObj
->GetPreviewMetaFile()
86 : ::boost::shared_ptr
<GDIMetaFile
>();
91 SfxPreviewBase_Impl::SfxPreviewBase_Impl(
92 Window
* pParent
, const ResId
& rResId
)
93 : Window(pParent
, rResId
), pMetaFile()
97 SfxPreviewBase_Impl::SfxPreviewBase_Impl( Window
* pParent
)
98 : Window(pParent
, 0 ), pMetaFile()
104 SfxPreviewBase_Impl::~SfxPreviewBase_Impl()
108 void SfxPreviewBase_Impl::Resize()
113 void SfxPreviewBase_Impl::SetGDIFile( ::boost::shared_ptr
<GDIMetaFile
> pFile
)
119 SfxFrameWindow
* SfxPreviewWin_Impl::PreviewFactory(
120 SfxFrame
* pFrame
, const String
& /*rName*/ )
122 return new SfxFrameWindow( new SfxPreviewWin_Impl(
123 &pFrame
->GetCurrentViewFrame()->GetWindow() ) );
126 void SfxPreviewWin_Impl::ImpPaint(
127 const Rectangle
&, GDIMetaFile
* pFile
, Window
* pWindow
)
129 Size aTmpSize
= pFile
? pFile
->GetPrefSize() : Size(1,1 );
130 DBG_ASSERT( aTmpSize
.Height()*aTmpSize
.Width(),
131 "size of first page is 0, overload GetFirstPageSize or set vis-area!" );
133 long nWidth
= pWindow
->GetOutputSize().Width() - 2*FRAME
;
134 long nHeight
= pWindow
->GetOutputSize().Height() - 2*FRAME
;
135 if( nWidth
< 0 ) nWidth
= 0;
136 if( nHeight
< 0 ) nHeight
= 0;
138 double dRatio
=((double)aTmpSize
.Width())/aTmpSize
.Height();
139 double dRatioPreV
=((double) nWidth
) / nHeight
;
142 if (dRatio
>dRatioPreV
)
144 aSize
=Size(nWidth
, (USHORT
)(nWidth
/dRatio
));
145 aPoint
=Point( 0, (USHORT
)((nHeight
-aSize
.Height())/2));
149 aSize
=Size((USHORT
)(nHeight
*dRatio
), nHeight
);
150 aPoint
=Point((USHORT
)((nWidth
-aSize
.Width())/2),0);
152 Point bPoint
=Point(nWidth
,nHeight
)-aPoint
;
155 pWindow
->SetLineColor();
156 Color
aLightGrayCol( COL_LIGHTGRAY
);
157 pWindow
->SetFillColor( aLightGrayCol
);
158 pWindow
->DrawRect( Rectangle( Point( 0,0 ), pWindow
->GetOutputSize() ) );
161 Color
aBlackCol( COL_BLACK
);
162 Color
aWhiteCol( COL_WHITE
);
163 pWindow
->SetLineColor( aBlackCol
);
164 pWindow
->SetFillColor( aWhiteCol
);
165 pWindow
->DrawRect( Rectangle( aPoint
+ Point( FRAME
, FRAME
), bPoint
+ Point( FRAME
, FRAME
) ) );
166 //! pFile->Move( Point( FRAME, FRAME ) );
167 //! pFile->Scale( Fraction( aTmpSize.Width(), aSize.Width() ),
168 //! Fraction( aTmpSize.Height(), aSize.Height() ) );
170 pFile
->Play( pWindow
, aPoint
+ Point( FRAME
, FRAME
), aSize
);
174 void SfxPreviewWin_Impl::Paint( const Rectangle
& rRect
)
176 ImpPaint( rRect
, pMetaFile
.get(), this );
179 SfxPreviewWin::SfxPreviewWin(
180 Window
* pParent
, const ResId
& rResId
, SfxObjectShellLock
&rDocSh
)
181 : Window(pParent
, rResId
), rDocShell( rDocSh
)
183 SetHelpId( HID_PREVIEW_FRAME
);
185 // adjust contrast mode initially
186 bool bUseContrast
= UseHighContrastSetting();
187 SetDrawMode( bUseContrast
? OUTPUT_DRAWMODE_CONTRAST
: OUTPUT_DRAWMODE_COLOR
);
189 // #107818# This preview window is for document previews. Therefore
190 // right-to-left mode should be off
194 void SfxPreviewWin::Paint( const Rectangle
& rRect
)
196 SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst( &rDocShell
);
197 if ( pFrame
&& pFrame
->GetViewShell() &&
198 pFrame
->GetViewShell()->GetPrinter() &&
199 pFrame
->GetViewShell()->GetPrinter()->IsPrinting() )
204 Size
aTmpSize( rDocShell
->GetFirstPageSize() );
206 VirtualDevice aDevice
;
208 DBG_ASSERT( aTmpSize
.Height() * aTmpSize
.Width(), "size of first page is 0, overload GetFirstPageSize or set vis-area!" );
210 aMtf
.SetPrefSize( aTmpSize
);
211 aDevice
.EnableOutput( FALSE
);
212 aDevice
.SetMapMode( rDocShell
->GetMapUnit() );
213 aDevice
.SetDrawMode( GetDrawMode() );
214 aMtf
.Record( &aDevice
);
215 rDocShell
->DoDraw( &aDevice
, Point(0,0), aTmpSize
, JobSetup(), ASPECT_THUMBNAIL
);
218 SfxPreviewWin_Impl::ImpPaint( rRect
, &aMtf
, this );
221 void SfxPreviewWin::DataChanged( const DataChangedEvent
& rDCEvt
)
223 Window::DataChanged( rDCEvt
);
225 if( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
226 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
228 // adjust contrast mode
229 bool bUseContrast
= UseHighContrastSetting();
230 SetDrawMode( bUseContrast
? OUTPUT_DRAWMODE_CONTRAST
: OUTPUT_DRAWMODE_COLOR
);
234 bool SfxPreviewWin::UseHighContrastSetting() const
236 return GetSettings().GetStyleSettings().GetHighContrastMode();
240 class SfxNewFileDialog_Impl
244 FixedText aTemplateFt
;
247 CheckBox aPreviewBtn
;
248 SfxPreviewWin_Impl aPreviewWin
;
254 FixedText aKeywordsFt
;
257 MultiLineEdit aDescEd
;
258 FixedLine aDocinfoGb
;
260 CheckBox aTextStyleCB
;
261 CheckBox aFrameStyleCB
;
262 CheckBox aPageStyleCB
;
263 CheckBox aNumStyleCB
;
264 CheckBox aMergeStyleCB
;
265 PushButton aLoadFilePB
;
268 CancelButton aCancelBt
;
273 String sLoadTemplate
;
276 SfxDocumentTemplates aTemplates
;
277 SfxObjectShellLock xDocShell
;
278 SfxNewFileDialog
* pAntiImpl
;
281 DECL_LINK( Update
, void * );
283 DECL_LINK( RegionSelect
, ListBox
* );
284 DECL_LINK( TemplateSelect
, ListBox
* );
285 DECL_LINK( DoubleClick
, ListBox
* );
286 void TogglePreview(CheckBox
*);
287 DECL_LINK( Expand
, MoreButton
* );
288 DECL_LINK( PreviewClick
, CheckBox
* );
289 DECL_LINK( LoadFile
, PushButton
* );
290 USHORT
GetSelectedTemplatePos() const;
294 SfxNewFileDialog_Impl( SfxNewFileDialog
* pAntiImplP
, USHORT nFlags
);
295 ~SfxNewFileDialog_Impl();
297 // Liefert FALSE, wenn '- Keine -' als Vorlage eingestellt ist
298 // Nur wenn IsTemplate() TRUE liefert, koennen Vorlagennamen
300 BOOL
IsTemplate() const;
301 String
GetTemplateRegion() const;
302 String
GetTemplateName() const;
303 String
GetTemplateFileName() const;
305 USHORT
GetTemplateFlags()const;
306 void SetTemplateFlags(USHORT nSet
);
310 //-------------------------------------------------------------------------
312 void SfxNewFileDialog_Impl::ClearInfo()
315 aTitleEd
.SetText(aNo
);
316 aThemaEd
.SetText(aNo
);
317 aKeywordsEd
.SetText(aNo
);
318 aDescEd
.SetText(aNo
);
321 //-------------------------------------------------------------------------
323 IMPL_LINK( SfxNewFileDialog_Impl
, Update
, void *, EMPTYARG
)
325 if ( xDocShell
.Is() )
327 if ( xDocShell
->GetProgress() )
332 const USHORT nEntry
= GetSelectedTemplatePos();
336 aPreviewWin
.Invalidate();
337 aPreviewWin
.SetObjectShell( 0);
341 if ( aPreviewBtn
.IsChecked() && (nFlags
& SFXWB_PREVIEW
) == SFXWB_PREVIEW
)
344 String aFileName
= aTemplates
.GetPath( aRegionLb
.GetSelectEntryPos(), nEntry
-1);
345 INetURLObject
aTestObj( aFileName
);
346 if( aTestObj
.GetProtocol() == INET_PROT_NOT_VALID
)
348 // temp. fix until Templates are managed by UCB compatible service
349 // does NOT work with locally cached components !
351 utl::LocalFileHelper::ConvertPhysicalNameToURL( aFileName
, aTemp
);
355 INetURLObject
aObj( aFileName
);
356 for ( SfxObjectShell
* pTmp
= SfxObjectShell::GetFirst();
358 pTmp
= SfxObjectShell::GetNext(*pTmp
) )
361 if ( pTmp
->GetMedium())
363 if( INetURLObject( pTmp
->GetMedium()->GetName() ) == aObj
)
370 if ( !xDocShell
.Is() )
372 Window
*pParent
= Application::GetDefDialogParent();
373 Application::SetDefDialogParent( pAntiImpl
);
374 SfxErrorContext
eEC(ERRCTX_SFX_LOADTEMPLATE
,pAntiImpl
);
375 SfxApplication
*pSfxApp
= SFX_APP();
377 SfxItemSet
* pSet
= new SfxAllItemSet( pSfxApp
->GetPool() );
378 pSet
->Put( SfxBoolItem( SID_TEMPLATE
, TRUE
) );
379 pSet
->Put( SfxBoolItem( SID_PREVIEW
, TRUE
) );
380 lErr
= pSfxApp
->LoadTemplate( xDocShell
, aFileName
, TRUE
, pSet
);
382 ErrorHandler::HandleError(lErr
);
383 Application::SetDefDialogParent( pParent
);
384 if ( !xDocShell
.Is() )
386 aPreviewWin
.SetObjectShell( 0 );
391 aPreviewWin
.SetObjectShell( xDocShell
);
396 //-------------------------------------------------------------------------
398 IMPL_LINK( SfxNewFileDialog_Impl
, RegionSelect
, ListBox
*, pBox
)
400 if ( xDocShell
.Is() && xDocShell
->GetProgress() )
403 const USHORT nRegion
= pBox
->GetSelectEntryPos();
404 const USHORT nCount
= aTemplates
.GetRegionCount()? aTemplates
.GetCount(nRegion
): 0;
405 aTemplateLb
.SetUpdateMode(FALSE
);
407 String aSel
=aRegionLb
.GetSelectEntry();
408 USHORT nc
=aSel
.Search('(');
409 if (nc
-1&&nc
!=STRING_NOTFOUND
)
411 if (aSel
.CompareIgnoreCaseToAscii( String(SfxResId(STR_STANDARD
)) )==COMPARE_EQUAL
)
412 aTemplateLb
.InsertEntry(aNone
);
413 for (USHORT i
= 0; i
< nCount
; ++i
)
414 aTemplateLb
.InsertEntry(aTemplates
.GetName(nRegion
, i
));
415 aTemplateLb
.SelectEntryPos(0);
416 aTemplateLb
.SetUpdateMode(TRUE
);
417 aTemplateLb
.Invalidate();
418 aTemplateLb
.Update();
422 //-------------------------------------------------------------------------
424 IMPL_LINK_INLINE_START( SfxNewFileDialog_Impl
, Expand
, MoreButton
*, EMPTYARG
)
426 TemplateSelect(&aTemplateLb
);
429 IMPL_LINK_INLINE_END( SfxNewFileDialog_Impl
, Expand
, MoreButton
*, pMoreButton
)
431 //-------------------------------------------------------------------------
433 IMPL_LINK( SfxNewFileDialog_Impl
, PreviewClick
, CheckBox
*, pBox
)
435 if ( xDocShell
.Is() && xDocShell
->GetProgress() )
438 USHORT nEntry
= GetSelectedTemplatePos();
439 if ( nEntry
&& pBox
->IsChecked() )
442 aPreviewWin
.Invalidate();
448 aPreviewWin
.SetObjectShell( 0 );
453 //-------------------------------------------------------------------------
455 IMPL_LINK( SfxNewFileDialog_Impl
, TemplateSelect
, ListBox
*, EMPTYARG
)
458 if ( xDocShell
&& xDocShell
->GetProgress() )
461 if ( !MORE_BTN(GetState()) )
462 // Dialog nicht aufgeklappt
469 //-------------------------------------------------------------------------
471 IMPL_LINK_INLINE_START( SfxNewFileDialog_Impl
, DoubleClick
, ListBox
*, pListBox
)
475 if ( !xDocShell
.Is() || !xDocShell
->GetProgress() )
476 pAntiImpl
->EndDialog(RET_OK
);
479 IMPL_LINK_INLINE_END( SfxNewFileDialog_Impl
, DoubleClick
, ListBox
*, pListBox
)
481 //-------------------------------------------------------------------------
483 IMPL_LINK_INLINE_START( SfxNewFileDialog_Impl
, LoadFile
, PushButton
*, EMPTYARG
)
485 pAntiImpl
->EndDialog(RET_TEMPLATE_LOAD
);
488 IMPL_LINK_INLINE_END( SfxNewFileDialog_Impl
, LoadFile
, PushButton
*, EMPTYARG
)
489 //-------------------------------------------------------------------------
491 USHORT
SfxNewFileDialog_Impl::GetSelectedTemplatePos() const
493 USHORT nEntry
=aTemplateLb
.GetSelectEntryPos();
494 String aSel
=aRegionLb
.GetSelectEntry().Copy();
495 USHORT nc
=aSel
.Search('(');
496 if (nc
-1&&nc
!=STRING_NOTFOUND
)
498 if (aSel
.CompareIgnoreCaseToAscii(String(SfxResId(STR_STANDARD
)))!=COMPARE_EQUAL
)
500 if (!aTemplateLb
.GetSelectEntryCount())
505 //-------------------------------------------------------------------------
507 BOOL
SfxNewFileDialog_Impl::IsTemplate() const
509 return GetSelectedTemplatePos()!=0;
513 //-------------------------------------------------------------------------
515 String
SfxNewFileDialog_Impl::GetTemplateFileName() const
517 if(!IsTemplate() || !aTemplates
.GetRegionCount())
519 return aTemplates
.GetPath(aRegionLb
.GetSelectEntryPos(),
520 GetSelectedTemplatePos()-1);
523 //-------------------------------------------------------------------------
525 String
SfxNewFileDialog_Impl::GetTemplateRegion() const
527 if(!IsTemplate() || !aTemplates
.GetRegionCount())
529 return aRegionLb
.GetSelectEntry();
532 //-------------------------------------------------------------------------
534 String
SfxNewFileDialog_Impl::GetTemplateName() const
536 if(!IsTemplate() || !aTemplates
.GetRegionCount())
538 return aTemplateLb
.GetSelectEntry();
541 //-------------------------------------------------------------------------
543 void AdjustPosSize_Impl(Window
*pWin
, short nMoveOffset
, short nSizeOffset
)
545 Point
aPos(pWin
->GetPosPixel());
546 Size
aSize(pWin
->GetSizePixel());
547 aPos
.X() -= nMoveOffset
;
548 aSize
.Width() += nSizeOffset
;
549 pWin
->SetPosSizePixel(aPos
, aSize
);
551 //-------------------------------------------------------------------------
552 USHORT
SfxNewFileDialog_Impl::GetTemplateFlags()const
554 USHORT nRet
= aTextStyleCB
.IsChecked() ? SFX_LOAD_TEXT_STYLES
: 0;
555 if(aFrameStyleCB
.IsChecked())
556 nRet
|= SFX_LOAD_FRAME_STYLES
;
557 if(aPageStyleCB
.IsChecked())
558 nRet
|= SFX_LOAD_PAGE_STYLES
;
559 if(aNumStyleCB
.IsChecked())
560 nRet
|= SFX_LOAD_NUM_STYLES
;
561 if(aMergeStyleCB
.IsChecked())
562 nRet
|= SFX_MERGE_STYLES
;
565 //-------------------------------------------------------------------------
566 void SfxNewFileDialog_Impl::SetTemplateFlags(USHORT nSet
)
568 aTextStyleCB
.Check( 0 != (nSet
&SFX_LOAD_TEXT_STYLES
));
569 aFrameStyleCB
.Check( 0 != (nSet
&SFX_LOAD_FRAME_STYLES
));
570 aPageStyleCB
.Check( 0 != (nSet
&SFX_LOAD_PAGE_STYLES
));
571 aNumStyleCB
.Check( 0 != (nSet
&SFX_LOAD_NUM_STYLES
));
572 aMergeStyleCB
.Check( 0 != (nSet
&SFX_MERGE_STYLES
));
575 //-------------------------------------------------------------------------
577 SfxNewFileDialog_Impl::SfxNewFileDialog_Impl(
578 SfxNewFileDialog
* pAntiImplP
, USHORT nFl
)
579 : aRegionFt( pAntiImplP
, SfxResId( FT_REGION
) ),
580 aRegionLb( pAntiImplP
, SfxResId( LB_REGION
) ),
581 aTemplateFt( pAntiImplP
, SfxResId( FT_TEMPLATE
) ),
582 aTemplateLb( pAntiImplP
, SfxResId( LB_TEMPLATE
) ),
583 aPreviewBtn( pAntiImplP
, SfxResId( BTN_PREVIEW
) ),
584 aPreviewWin( pAntiImplP
, SfxResId( WIN_PREVIEW
) ),
585 aTitleFt( pAntiImplP
, SfxResId( FT_TITLE
) ),
586 aTitleEd( pAntiImplP
, SfxResId( ED_TITLE
) ),
587 aThemaFt( pAntiImplP
, SfxResId( FT_THEMA
) ),
588 aThemaEd( pAntiImplP
, SfxResId( ED_THEMA
) ),
589 aKeywordsFt( pAntiImplP
, SfxResId( FT_KEYWORDS
) ),
590 aKeywordsEd( pAntiImplP
, SfxResId( ED_KEYWORDS
) ),
591 aDescFt( pAntiImplP
, SfxResId( FT_DESC
) ),
592 aDescEd( pAntiImplP
, SfxResId( ED_DESC
) ),
593 aDocinfoGb( pAntiImplP
, SfxResId( GB_DOCINFO
) ),
594 aTextStyleCB( pAntiImplP
, SfxResId( CB_TEXT_STYLE
)),
595 aFrameStyleCB( pAntiImplP
, SfxResId( CB_FRAME_STYLE
)),
596 aPageStyleCB( pAntiImplP
, SfxResId( CB_PAGE_STYLE
)),
597 aNumStyleCB( pAntiImplP
, SfxResId( CB_NUM_STYLE
)),
598 aMergeStyleCB( pAntiImplP
, SfxResId( CB_MERGE_STYLE
)),
599 aLoadFilePB( pAntiImplP
, SfxResId( PB_LOAD_FILE
)),
600 aOkBt( pAntiImplP
, SfxResId( BT_OK
) ),
601 aCancelBt( pAntiImplP
, SfxResId( BT_CANCEL
) ),
602 aHelpBt( pAntiImplP
, SfxResId( BT_HELP
) ),
603 pMoreBt( new MoreButton( pAntiImplP
, SfxResId( BT_MORE
) ) ),
604 aNone( SfxResId(STR_NONE
) ),
605 sLoadTemplate( SfxResId(STR_LOAD_TEMPLATE
)),
607 pAntiImpl( pAntiImplP
)
609 short nMoveOffset
= *(short *)pAntiImplP
->GetClassRes();
610 pAntiImplP
->IncrementRes(sizeof(short));
611 short nExpandSize
= *(short *)pAntiImplP
->GetClassRes();
612 pAntiImplP
->IncrementRes(sizeof(short));
613 pAntiImplP
->FreeResource();
617 else if(SFXWB_LOAD_TEMPLATE
== nFlags
)
619 aLoadFilePB
.SetClickHdl(LINK(this, SfxNewFileDialog_Impl
, LoadFile
));
622 aFrameStyleCB
.Show();
625 aMergeStyleCB
.Show();
626 Size
aSize(pAntiImplP
->GetOutputSizePixel());
627 Size
aTmp(pAntiImplP
->LogicToPixel(Size(16, 16), MAP_APPFONT
));
628 aSize
.Height() += aTmp
.Height();
629 pAntiImplP
->SetOutputSizePixel(aSize
);
631 aTextStyleCB
.Check();
632 pAntiImplP
->SetText(sLoadTemplate
);
636 MORE_BTN(SetClickHdl(LINK(this, SfxNewFileDialog_Impl
, Expand
)));
637 if((nFlags
& SFXWB_PREVIEW
) == SFXWB_PREVIEW
)
639 MORE_BTN(AddWindow(&aPreviewBtn
));
640 MORE_BTN(AddWindow(&aPreviewWin
));
641 aPreviewBtn
.SetClickHdl(LINK(this, SfxNewFileDialog_Impl
, PreviewClick
));
647 nMoveOffset
= (short)pAntiImplP
->LogicToPixel(
648 Size(nMoveOffset
, nMoveOffset
), MAP_APPFONT
).Width();
649 nExpandSize
= (short)pAntiImplP
->LogicToPixel(
650 Size(nExpandSize
, nExpandSize
), MAP_APPFONT
).Width();
651 AdjustPosSize_Impl(&aTitleFt
, nMoveOffset
, 0);
652 AdjustPosSize_Impl(&aTitleEd
, nMoveOffset
, nExpandSize
);
653 AdjustPosSize_Impl(&aThemaFt
, nMoveOffset
, 0);
654 AdjustPosSize_Impl(&aThemaEd
, nMoveOffset
, nExpandSize
);
655 AdjustPosSize_Impl(&aKeywordsFt
, nMoveOffset
, 0);
656 AdjustPosSize_Impl(&aKeywordsEd
, nMoveOffset
, nExpandSize
);
657 AdjustPosSize_Impl(&aDescFt
, nMoveOffset
, 0);
658 AdjustPosSize_Impl(&aDescEd
, nMoveOffset
, nExpandSize
);
659 AdjustPosSize_Impl(&aDocinfoGb
, nMoveOffset
, nExpandSize
);
663 String
&rExtra
= pAntiImplP
->GetExtraData();
664 USHORT nTokCount
= rExtra
.GetTokenCount( '|' );
665 if( nTokCount
> 0 && nFlags
)
666 MORE_BTN(SetState( rExtra
.GetToken( 0, '|' ) == 'Y' ));
667 if( nTokCount
> 1 && nFlags
)
668 aPreviewBtn
.Check( rExtra
.GetToken( 1 ,'|' ) == 'Y' );
670 aTemplateLb
.SetDoubleClickHdl(LINK(this, SfxNewFileDialog_Impl
, DoubleClick
));
672 // update the template configuration if necessary
674 WaitObject
aWaitCursor( pAntiImplP
->GetParent() );
675 aTemplates
.Update( sal_True
/* be smart */ );
677 // fill the list boxes
678 const USHORT nCount
= aTemplates
.GetRegionCount();
681 for(USHORT i
= 0; i
< nCount
; ++i
)
682 aRegionLb
.InsertEntry(aTemplates
.GetFullRegionName(i
));
683 aRegionLb
.SetSelectHdl(LINK(this, SfxNewFileDialog_Impl
, RegionSelect
));
686 aPrevTimer
.SetTimeout( 500 );
687 aPrevTimer
.SetTimeoutHdl( LINK( this, SfxNewFileDialog_Impl
, Update
));
690 // aRegionLb.InsertEntry(String(SfxResId(STR_STANDARD)));
691 aRegionLb
.SelectEntryPos(0);
692 RegionSelect(&aRegionLb
);
695 //-------------------------------------------------------------------------
697 SfxNewFileDialog_Impl::~SfxNewFileDialog_Impl()
699 String
&rExtra
= pAntiImpl
->GetExtraData();
700 rExtra
= MORE_BTN(GetState()) ? 'Y' : 'N';
702 rExtra
+= aPreviewBtn
.IsChecked() ? 'Y' : 'N';
706 //-------------------------------------------------------------------------
707 SfxNewFileDialog::SfxNewFileDialog(Window
*pParent
, USHORT nFlags
)
708 : SfxModalDialog( pParent
, SfxResId( DLG_NEW_FILE
) )
710 pImpl
= new SfxNewFileDialog_Impl( this, nFlags
);
712 //-------------------------------------------------------------------------
713 SfxNewFileDialog::~SfxNewFileDialog()
717 //-------------------------------------------------------------------------
718 BOOL
SfxNewFileDialog::IsTemplate() const
720 return pImpl
->IsTemplate();
722 //-------------------------------------------------------------------------
723 String
SfxNewFileDialog::GetTemplateRegion() const
725 return pImpl
->GetTemplateRegion();
727 //-------------------------------------------------------------------------
728 String
SfxNewFileDialog::GetTemplateName() const
730 return pImpl
->GetTemplateName();
732 //-------------------------------------------------------------------------
733 String
SfxNewFileDialog::GetTemplateFileName() const
735 return pImpl
->GetTemplateFileName();
737 //-------------------------------------------------------------------------
738 USHORT
SfxNewFileDialog::GetTemplateFlags()const
740 return pImpl
->GetTemplateFlags();
743 //-------------------------------------------------------------------------
744 void SfxNewFileDialog::SetTemplateFlags(USHORT nSet
)
746 pImpl
->SetTemplateFlags(nSet
);