xref: /trunk/main/svx/source/dialog/hyperdlg.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 // include ---------------------------------------------------------------
32 #include <vcl/settings.hxx>
33 #include <unotools/viewoptions.hxx>
34 #include "svx/hyperdlg.hxx"
35 #include <svx/svxdlg.hxx> //CHINA001
36 #include <sfx2/app.hxx>
37 #include <sfx2/sfxsids.hrc>
38 
39 //########################################################################
40 //#                                                                      #
41 //# Childwindow-Wrapper-Class                                            #
42 //#                                                                      #
43 //########################################################################
44 
45 SFX_IMPL_CHILDWINDOW(SvxHlinkDlgWrapper, SID_HYPERLINK_DIALOG)
46 
47 // -----------------------------------------------------------------------
48 
49 struct MyStruct
50 {
51     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;
52     SfxChildWinFactory* pFact;
53     sal_Bool                bHideNotDelete;
54     sal_Bool                bVisible;
55     sal_Bool                bHideAtToggle;
56     SfxModule*          pContextModule;
57     SfxWorkWindow*      pWorkWin;
58 };
59 
60 SvxHlinkDlgWrapper::SvxHlinkDlgWrapper( Window* _pParent, sal_uInt16 nId,
61                                                 SfxBindings* pBindings,
62                                                 SfxChildWinInfo* pInfo ) :
63     SfxChildWindow( _pParent, nId ),
64 
65     mpDlg( NULL )
66 
67 {
68     //CHINA001 pWindow = new SvxHpLinkDlg( _pParent, pBindings );
69     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
70     DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
71     mpDlg = pFact->CreateSvxHpLinkDlg( _pParent, pBindings, SID_HYPERLINK_DIALOG );
72     DBG_ASSERT(mpDlg, "Dialogdiet fail!");//CHINA001
73     pWindow = mpDlg->GetWindow();
74     ((MyStruct*)pImp)->bVisible = sal_False;
75 
76     Window* pTopWindow = 0;
77     if ( pInfo->aSize.Width() != 0 && pInfo->aSize.Height() != 0 &&
78             (0 != (pTopWindow = SFX_APP()->GetTopWindow())))
79     {
80         Size aParentSize( pTopWindow->GetSizePixel() );
81         Size aDlgSize ( GetSizePixel () );
82 
83         if( aParentSize.Width() < pInfo->aPos.X() )
84             pInfo->aPos.setX( aParentSize.Width()-aDlgSize.Width() < long(0.1*aParentSize.Width()) ?
85                               long(0.1*aParentSize.Width()) : aParentSize.Width()-aDlgSize.Width() );
86         if( aParentSize.Height() < pInfo->aPos. Y() )
87             pInfo->aPos.setY( aParentSize.Height()-aDlgSize.Height() < long(0.1*aParentSize.Height()) ?
88                               long(0.1*aParentSize.Height()) : aParentSize.Height()-aDlgSize.Height() );
89 
90         pWindow->SetPosPixel( pInfo->aPos );
91     }
92 
93     eChildAlignment = SFX_ALIGN_NOALIGNMENT;
94 
95     SetHideNotDelete( sal_True );
96 }
97 
98 SfxChildWinInfo SvxHlinkDlgWrapper::GetInfo() const
99 {
100     return SfxChildWindow::GetInfo();
101 }
102 
103 sal_Bool SvxHlinkDlgWrapper::QueryClose()
104 {
105     return mpDlg ? mpDlg->QueryClose() : sal_True;
106 }
107 
108