xref: /aoo41x/main/sd/source/ui/dlg/inspagob.cxx (revision cdf0e10c)
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_sd.hxx"
30 
31 #ifdef SD_DLLIMPLEMENTATION
32 #undef SD_DLLIMPLEMENTATION
33 #endif
34 
35 
36 #include "inspagob.hxx"
37 
38 #include "strings.hrc"
39 #include "res_bmp.hrc"
40 #include "sdresid.hxx"
41 #include "drawdoc.hxx"
42 #include "DrawDocShell.hxx"
43 #include "ViewShell.hxx"
44 #include "inspagob.hrc"
45 
46 
47 /*************************************************************************
48 |*
49 |*	Ctor
50 |*
51 \************************************************************************/
52 
53 SdInsertPagesObjsDlg::SdInsertPagesObjsDlg(
54     ::Window* pWindow,
55     const SdDrawDocument* pInDoc,
56     SfxMedium* pSfxMedium,
57     const String& rFileName )
58     : ModalDialog     ( pWindow, SdResId( DLG_INSERT_PAGES_OBJS ) ),
59       aLbTree         ( this, SdResId( LB_TREE ) ),
60       aCbxLink        ( this, SdResId( CBX_LINK ) ),
61       aCbxMasters     ( this, SdResId( CBX_CHECK_MASTERS ) ),
62       aBtnOk          ( this, SdResId( BTN_OK ) ),
63       aBtnCancel      ( this, SdResId( BTN_CANCEL ) ),
64       aBtnHelp        ( this, SdResId( BTN_HELP ) ),
65       pMedium 		( pSfxMedium ),
66       mpDoc			( pInDoc ),
67       rName			( rFileName )
68 {
69 	FreeResource();
70 
71 	aLbTree.SetViewFrame( ( (SdDrawDocument*) pInDoc )->GetDocSh()->GetViewShell()->GetViewFrame() );
72 
73 	aLbTree.SetSelectHdl( LINK( this, SdInsertPagesObjsDlg, SelectObjectHdl ) );
74 
75 	// Text wird eingefuegt
76 	if( !pMedium )
77 		SetText( String( SdResId( STR_INSERT_TEXT ) ) );
78 
79 	Reset();
80 }
81 
82 /*************************************************************************
83 |*
84 |*	Dtor
85 |*
86 \************************************************************************/
87 
88 SdInsertPagesObjsDlg::~SdInsertPagesObjsDlg()
89 {
90 }
91 
92 /*************************************************************************
93 |*
94 |*	Fuellt die TreeLB in Abhaengigkeit des Mediums. Ist kein Medium
95 |*	vorhanden, handelt es sich um ein Text- und kein Drawdokument
96 |*
97 \************************************************************************/
98 
99 void SdInsertPagesObjsDlg::Reset()
100 {
101 	if( pMedium )
102 	{
103 		aLbTree.SetSelectionMode( MULTIPLE_SELECTION );
104 
105         // transfer ownership of Medium
106 		aLbTree.Fill( mpDoc, pMedium, rName );
107 	}
108 	else
109 	{
110 		Color aColor( COL_WHITE );
111 		Bitmap aBmpText( SdResId( BMP_DOC_TEXT ) );
112 		Image aImgText( aBmpText, aColor );
113 		Bitmap aBmpTextH( SdResId( BMP_DOC_TEXT_H ) );
114 		Image aImgTextH( aBmpTextH, Color( COL_BLACK ) );
115 		SvLBoxEntry* pEntry = aLbTree.InsertEntry( rName, aImgText, aImgText );
116 		aLbTree.SetExpandedEntryBmp( pEntry, aImgTextH, BMP_COLOR_HIGHCONTRAST );
117 		aLbTree.SetCollapsedEntryBmp( pEntry, aImgTextH, BMP_COLOR_HIGHCONTRAST );
118 	}
119 
120 	aCbxMasters.Check( sal_True );
121 }
122 
123 /*************************************************************************
124 |*
125 |*	Liefert die Liste zurueck
126 |*	nType == 0 -> Seiten
127 |*	nType == 1 -> Objekte
128 |*
129 \************************************************************************/
130 
131 List* SdInsertPagesObjsDlg::GetList( sal_uInt16 nType )
132 {
133 	// Bei Draw-Dokumenten muss bei der Selektion des Dokumentes NULL
134 	// zurueckgegeben werden
135 	if( pMedium )
136 	{
137 		// Um zu gewaehrleisten, dass die Bookmarks geoeffnet sind
138 		// (Wenn gesamtes Dokument ausgewaehlt wurde)
139 		aLbTree.GetBookmarkDoc();
140 
141 		// Wenn das Dokument (mit-)selektiert oder nichst selektiert ist,
142 		// wird das gesamte Dokument (und nicht mehr!) eingefuegt.
143 		if( aLbTree.GetSelectionCount() == 0 ||
144 			( aLbTree.IsSelected( aLbTree.First() ) ) )
145 			return( NULL ); // #37350#
146 	}
147 	return( aLbTree.GetSelectEntryList( nType ) );
148 }
149 
150 /*************************************************************************
151 |*
152 |*	Ist Verknuepfung gechecked
153 |*
154 \************************************************************************/
155 
156 sal_Bool SdInsertPagesObjsDlg::IsLink()
157 {
158 	return( aCbxLink.IsChecked() );
159 }
160 
161 /*************************************************************************
162 |*
163 |*	Ist Verknuepfung gechecked
164 |*
165 \************************************************************************/
166 
167 sal_Bool SdInsertPagesObjsDlg::IsRemoveUnnessesaryMasterPages() const
168 {
169 	return( aCbxMasters.IsChecked() );
170 }
171 
172 /*************************************************************************
173 |*
174 |* Enabled und selektiert Endfarben-LB
175 |*
176 \************************************************************************/
177 
178 IMPL_LINK( SdInsertPagesObjsDlg, SelectObjectHdl, void *, EMPTYARG )
179 {
180 	if( aLbTree.IsLinkableSelected() )
181 		aCbxLink.Enable();
182 	else
183 		aCbxLink.Disable();
184 
185 	return( 0 );
186 }
187 
188 
189