xref: /aoo41x/main/sd/source/ui/dlg/inspagob.cxx (revision 79aad27f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #ifdef SD_DLLIMPLEMENTATION
28 #undef SD_DLLIMPLEMENTATION
29 #endif
30 
31 
32 #include "inspagob.hxx"
33 
34 #include "strings.hrc"
35 #include "res_bmp.hrc"
36 #include "sdresid.hxx"
37 #include "drawdoc.hxx"
38 #include "DrawDocShell.hxx"
39 #include "ViewShell.hxx"
40 #include "inspagob.hrc"
41 
42 
43 /*************************************************************************
44 |*
45 |*	Ctor
46 |*
47 \************************************************************************/
48 
SdInsertPagesObjsDlg(::Window * pWindow,const SdDrawDocument * pInDoc,SfxMedium * pSfxMedium,const String & rFileName)49 SdInsertPagesObjsDlg::SdInsertPagesObjsDlg(
50     ::Window* pWindow,
51     const SdDrawDocument* pInDoc,
52     SfxMedium* pSfxMedium,
53     const String& rFileName )
54     : ModalDialog     ( pWindow, SdResId( DLG_INSERT_PAGES_OBJS ) ),
55       aLbTree         ( this, SdResId( LB_TREE ) ),
56       aCbxLink        ( this, SdResId( CBX_LINK ) ),
57       aCbxMasters     ( this, SdResId( CBX_CHECK_MASTERS ) ),
58       aBtnOk          ( this, SdResId( BTN_OK ) ),
59       aBtnCancel      ( this, SdResId( BTN_CANCEL ) ),
60       aBtnHelp        ( this, SdResId( BTN_HELP ) ),
61       pMedium 		( pSfxMedium ),
62       mpDoc			( pInDoc ),
63       rName			( rFileName )
64 {
65 	FreeResource();
66 
67 	aLbTree.SetViewFrame( ( (SdDrawDocument*) pInDoc )->GetDocSh()->GetViewShell()->GetViewFrame() );
68 
69 	aLbTree.SetSelectHdl( LINK( this, SdInsertPagesObjsDlg, SelectObjectHdl ) );
70 
71 	// Text wird eingefuegt
72 	if( !pMedium )
73 		SetText( String( SdResId( STR_INSERT_TEXT ) ) );
74 
75 	Reset();
76 }
77 
78 /*************************************************************************
79 |*
80 |*	Dtor
81 |*
82 \************************************************************************/
83 
~SdInsertPagesObjsDlg()84 SdInsertPagesObjsDlg::~SdInsertPagesObjsDlg()
85 {
86 }
87 
88 /*************************************************************************
89 |*
90 |*	Fuellt die TreeLB in Abhaengigkeit des Mediums. Ist kein Medium
91 |*	vorhanden, handelt es sich um ein Text- und kein Drawdokument
92 |*
93 \************************************************************************/
94 
Reset()95 void SdInsertPagesObjsDlg::Reset()
96 {
97 	if( pMedium )
98 	{
99 		aLbTree.SetSelectionMode( MULTIPLE_SELECTION );
100 
101         // transfer ownership of Medium
102 		aLbTree.Fill( mpDoc, pMedium, rName );
103 	}
104 	else
105 	{
106 		Color aColor( COL_WHITE );
107 		Bitmap aBmpText( SdResId( BMP_DOC_TEXT ) );
108 		Image aImgText( aBmpText, aColor );
109 		Bitmap aBmpTextH( SdResId( BMP_DOC_TEXT_H ) );
110 		Image aImgTextH( aBmpTextH, Color( COL_BLACK ) );
111 		SvLBoxEntry* pEntry = aLbTree.InsertEntry( rName, aImgText, aImgText );
112 		aLbTree.SetExpandedEntryBmp( pEntry, aImgTextH, BMP_COLOR_HIGHCONTRAST );
113 		aLbTree.SetCollapsedEntryBmp( pEntry, aImgTextH, BMP_COLOR_HIGHCONTRAST );
114 	}
115 
116 	aCbxMasters.Check( sal_True );
117 }
118 
119 /*************************************************************************
120 |*
121 |*	Liefert die Liste zurueck
122 |*	nType == 0 -> Seiten
123 |*	nType == 1 -> Objekte
124 |*
125 \************************************************************************/
126 
GetList(sal_uInt16 nType)127 List* SdInsertPagesObjsDlg::GetList( sal_uInt16 nType )
128 {
129 	// Bei Draw-Dokumenten muss bei der Selektion des Dokumentes NULL
130 	// zurueckgegeben werden
131 	if( pMedium )
132 	{
133 		// Um zu gewaehrleisten, dass die Bookmarks geoeffnet sind
134 		// (Wenn gesamtes Dokument ausgewaehlt wurde)
135 		aLbTree.GetBookmarkDoc();
136 
137 		// Wenn das Dokument (mit-)selektiert oder nichst selektiert ist,
138 		// wird das gesamte Dokument (und nicht mehr!) eingefuegt.
139 		if( aLbTree.GetSelectionCount() == 0 ||
140 			( aLbTree.IsSelected( aLbTree.First() ) ) )
141 			return( NULL ); // #37350#
142 	}
143 	return( aLbTree.GetSelectEntryList( nType ) );
144 }
145 
146 /*************************************************************************
147 |*
148 |*	Ist Verknuepfung gechecked
149 |*
150 \************************************************************************/
151 
IsLink()152 sal_Bool SdInsertPagesObjsDlg::IsLink()
153 {
154 	return( aCbxLink.IsChecked() );
155 }
156 
157 /*************************************************************************
158 |*
159 |*	Ist Verknuepfung gechecked
160 |*
161 \************************************************************************/
162 
IsRemoveUnnessesaryMasterPages() const163 sal_Bool SdInsertPagesObjsDlg::IsRemoveUnnessesaryMasterPages() const
164 {
165 	return( aCbxMasters.IsChecked() );
166 }
167 
168 /*************************************************************************
169 |*
170 |* Enabled und selektiert Endfarben-LB
171 |*
172 \************************************************************************/
173 
IMPL_LINK(SdInsertPagesObjsDlg,SelectObjectHdl,void *,EMPTYARG)174 IMPL_LINK( SdInsertPagesObjsDlg, SelectObjectHdl, void *, EMPTYARG )
175 {
176 	if( aLbTree.IsLinkableSelected() )
177 		aCbxLink.Enable();
178 	else
179 		aCbxLink.Disable();
180 
181 	return( 0 );
182 }
183 
184 
185