xref: /AOO41X/main/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx (revision ca62e2c2083b5d0995f1245bad6c2edfb455fbec)
1*02c50d82SAndre Fischer /**************************************************************
2*02c50d82SAndre Fischer  *
3*02c50d82SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4*02c50d82SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5*02c50d82SAndre Fischer  * distributed with this work for additional information
6*02c50d82SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7*02c50d82SAndre Fischer  * to you under the Apache License, Version 2.0 (the
8*02c50d82SAndre Fischer  * "License"); you may not use this file except in compliance
9*02c50d82SAndre Fischer  * with the License.  You may obtain a copy of the License at
10*02c50d82SAndre Fischer  *
11*02c50d82SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12*02c50d82SAndre Fischer  *
13*02c50d82SAndre Fischer  * Unless required by applicable law or agreed to in writing,
14*02c50d82SAndre Fischer  * software distributed under the License is distributed on an
15*02c50d82SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*02c50d82SAndre Fischer  * KIND, either express or implied.  See the License for the
17*02c50d82SAndre Fischer  * specific language governing permissions and limitations
18*02c50d82SAndre Fischer  * under the License.
19*02c50d82SAndre Fischer  *
20*02c50d82SAndre Fischer  *************************************************************/
21*02c50d82SAndre Fischer 
22*02c50d82SAndre Fischer #include "precompiled_sd.hxx"
23*02c50d82SAndre Fischer 
24*02c50d82SAndre Fischer #include "CurrentMasterPagesSelector.hxx"
25*02c50d82SAndre Fischer #include "PreviewValueSet.hxx"
26*02c50d82SAndre Fischer #include "ViewShellBase.hxx"
27*02c50d82SAndre Fischer #include "SidebarShellManager.hxx"
28*02c50d82SAndre Fischer #include "DrawViewShell.hxx"
29*02c50d82SAndre Fischer #include "drawdoc.hxx"
30*02c50d82SAndre Fischer #include "sdpage.hxx"
31*02c50d82SAndre Fischer #include "MasterPageContainer.hxx"
32*02c50d82SAndre Fischer #include "MasterPageDescriptor.hxx"
33*02c50d82SAndre Fischer #include "EventMultiplexer.hxx"
34*02c50d82SAndre Fischer #include "app.hrc"
35*02c50d82SAndre Fischer #include "DrawDocShell.hxx"
36*02c50d82SAndre Fischer #include "DrawViewShell.hxx"
37*02c50d82SAndre Fischer #include "res_bmp.hrc"
38*02c50d82SAndre Fischer #include "sdresid.hxx"
39*02c50d82SAndre Fischer #include "helpids.h"
40*02c50d82SAndre Fischer 
41*02c50d82SAndre Fischer #include <vcl/image.hxx>
42*02c50d82SAndre Fischer #include <svx/svdmodel.hxx>
43*02c50d82SAndre Fischer #include <sfx2/request.hxx>
44*02c50d82SAndre Fischer 
45*02c50d82SAndre Fischer #include <set>
46*02c50d82SAndre Fischer 
47*02c50d82SAndre Fischer 
48*02c50d82SAndre Fischer using namespace ::com::sun::star;
49*02c50d82SAndre Fischer 
50*02c50d82SAndre Fischer namespace sd { namespace sidebar {
51*02c50d82SAndre Fischer 
Create(::Window * pParent,ViewShellBase & rViewShellBase,const cssu::Reference<css::ui::XSidebar> & rxSidebar)52*02c50d82SAndre Fischer MasterPagesSelector* CurrentMasterPagesSelector::Create (
53*02c50d82SAndre Fischer     ::Window* pParent,
54*02c50d82SAndre Fischer     ViewShellBase& rViewShellBase,
55*02c50d82SAndre Fischer     const cssu::Reference<css::ui::XSidebar>& rxSidebar)
56*02c50d82SAndre Fischer {
57*02c50d82SAndre Fischer     SdDrawDocument* pDocument = rViewShellBase.GetDocument();
58*02c50d82SAndre Fischer     if (pDocument == NULL)
59*02c50d82SAndre Fischer         return NULL;
60*02c50d82SAndre Fischer 
61*02c50d82SAndre Fischer     ::boost::shared_ptr<MasterPageContainer> pContainer (new MasterPageContainer());
62*02c50d82SAndre Fischer 
63*02c50d82SAndre Fischer     MasterPagesSelector* pSelector(
64*02c50d82SAndre Fischer         new CurrentMasterPagesSelector (
65*02c50d82SAndre Fischer             pParent,
66*02c50d82SAndre Fischer             *pDocument,
67*02c50d82SAndre Fischer             rViewShellBase,
68*02c50d82SAndre Fischer             pContainer,
69*02c50d82SAndre Fischer             rxSidebar));
70*02c50d82SAndre Fischer     pSelector->LateInit();
71*02c50d82SAndre Fischer     pSelector->SetHelpId( HID_SD_TASK_PANE_PREVIEW_CURRENT );
72*02c50d82SAndre Fischer 
73*02c50d82SAndre Fischer     return pSelector;
74*02c50d82SAndre Fischer }
75*02c50d82SAndre Fischer 
76*02c50d82SAndre Fischer 
77*02c50d82SAndre Fischer 
78*02c50d82SAndre Fischer 
CurrentMasterPagesSelector(::Window * pParent,SdDrawDocument & rDocument,ViewShellBase & rBase,const::boost::shared_ptr<MasterPageContainer> & rpContainer,const cssu::Reference<css::ui::XSidebar> & rxSidebar)79*02c50d82SAndre Fischer CurrentMasterPagesSelector::CurrentMasterPagesSelector (
80*02c50d82SAndre Fischer     ::Window* pParent,
81*02c50d82SAndre Fischer     SdDrawDocument& rDocument,
82*02c50d82SAndre Fischer     ViewShellBase& rBase,
83*02c50d82SAndre Fischer     const ::boost::shared_ptr<MasterPageContainer>& rpContainer,
84*02c50d82SAndre Fischer     const cssu::Reference<css::ui::XSidebar>& rxSidebar)
85*02c50d82SAndre Fischer     : MasterPagesSelector (pParent, rDocument, rBase, rpContainer, rxSidebar)
86*02c50d82SAndre Fischer {
87*02c50d82SAndre Fischer     // For this master page selector only we change the default action for
88*02c50d82SAndre Fischer     // left clicks.
89*02c50d82SAndre Fischer     mnDefaultClickAction = SID_TP_APPLY_TO_SELECTED_SLIDES;
90*02c50d82SAndre Fischer 
91*02c50d82SAndre Fischer     Link aLink (LINK(this,CurrentMasterPagesSelector,EventMultiplexerListener));
92*02c50d82SAndre Fischer     rBase.GetEventMultiplexer()->AddEventListener(aLink,
93*02c50d82SAndre Fischer         sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE
94*02c50d82SAndre Fischer         | sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL
95*02c50d82SAndre Fischer         | sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER
96*02c50d82SAndre Fischer         | sd::tools::EventMultiplexerEvent::EID_PAGE_ORDER
97*02c50d82SAndre Fischer         | sd::tools::EventMultiplexerEvent::EID_SHAPE_CHANGED
98*02c50d82SAndre Fischer         | sd::tools::EventMultiplexerEvent::EID_SHAPE_INSERTED
99*02c50d82SAndre Fischer         | sd::tools::EventMultiplexerEvent::EID_SHAPE_REMOVED);
100*02c50d82SAndre Fischer }
101*02c50d82SAndre Fischer 
102*02c50d82SAndre Fischer 
103*02c50d82SAndre Fischer 
104*02c50d82SAndre Fischer 
~CurrentMasterPagesSelector(void)105*02c50d82SAndre Fischer CurrentMasterPagesSelector::~CurrentMasterPagesSelector (void)
106*02c50d82SAndre Fischer {
107*02c50d82SAndre Fischer     if (mrDocument.GetDocSh() != NULL)
108*02c50d82SAndre Fischer     {
109*02c50d82SAndre Fischer         EndListening(*mrDocument.GetDocSh());
110*02c50d82SAndre Fischer     }
111*02c50d82SAndre Fischer     else
112*02c50d82SAndre Fischer     {
113*02c50d82SAndre Fischer         OSL_ASSERT(mrDocument.GetDocSh() != NULL);
114*02c50d82SAndre Fischer     }
115*02c50d82SAndre Fischer 
116*02c50d82SAndre Fischer     Link aLink (LINK(this,CurrentMasterPagesSelector,EventMultiplexerListener));
117*02c50d82SAndre Fischer     mrBase.GetEventMultiplexer()->RemoveEventListener(aLink);
118*02c50d82SAndre Fischer }
119*02c50d82SAndre Fischer 
120*02c50d82SAndre Fischer 
121*02c50d82SAndre Fischer 
122*02c50d82SAndre Fischer 
LateInit(void)123*02c50d82SAndre Fischer void CurrentMasterPagesSelector::LateInit (void)
124*02c50d82SAndre Fischer {
125*02c50d82SAndre Fischer     MasterPagesSelector::LateInit();
126*02c50d82SAndre Fischer     MasterPagesSelector::Fill();
127*02c50d82SAndre Fischer     if (mrDocument.GetDocSh() != NULL)
128*02c50d82SAndre Fischer     {
129*02c50d82SAndre Fischer         StartListening(*mrDocument.GetDocSh());
130*02c50d82SAndre Fischer     }
131*02c50d82SAndre Fischer     else
132*02c50d82SAndre Fischer     {
133*02c50d82SAndre Fischer         OSL_ASSERT(mrDocument.GetDocSh() != NULL);
134*02c50d82SAndre Fischer     }
135*02c50d82SAndre Fischer }
136*02c50d82SAndre Fischer 
137*02c50d82SAndre Fischer 
138*02c50d82SAndre Fischer 
139*02c50d82SAndre Fischer 
Fill(ItemList & rItemList)140*02c50d82SAndre Fischer void CurrentMasterPagesSelector::Fill (ItemList& rItemList)
141*02c50d82SAndre Fischer {
142*02c50d82SAndre Fischer 	sal_uInt16 nPageCount = mrDocument.GetMasterSdPageCount(PK_STANDARD);
143*02c50d82SAndre Fischer     SdPage* pMasterPage;
144*02c50d82SAndre Fischer     // Remember the names of the master pages that have been inserted to
145*02c50d82SAndre Fischer     // avoid double insertion.
146*02c50d82SAndre Fischer     ::std::set<String> aMasterPageNames;
147*02c50d82SAndre Fischer     for (sal_uInt16 nIndex=0; nIndex<nPageCount; nIndex++)
148*02c50d82SAndre Fischer     {
149*02c50d82SAndre Fischer         pMasterPage = mrDocument.GetMasterSdPage (nIndex, PK_STANDARD);
150*02c50d82SAndre Fischer         if (pMasterPage == NULL)
151*02c50d82SAndre Fischer             continue;
152*02c50d82SAndre Fischer 
153*02c50d82SAndre Fischer         // Use the name of the master page to avoid duplicate entries.
154*02c50d82SAndre Fischer         String sName (pMasterPage->GetName());
155*02c50d82SAndre Fischer         if (aMasterPageNames.find(sName)!=aMasterPageNames.end())
156*02c50d82SAndre Fischer             continue;
157*02c50d82SAndre Fischer         aMasterPageNames.insert (sName);
158*02c50d82SAndre Fischer 
159*02c50d82SAndre Fischer         // Look up the master page in the container and, when it is not yet
160*02c50d82SAndre Fischer         // in it, insert it.
161*02c50d82SAndre Fischer         MasterPageContainer::Token aToken = mpContainer->GetTokenForPageObject(pMasterPage);
162*02c50d82SAndre Fischer         if (aToken == MasterPageContainer::NIL_TOKEN)
163*02c50d82SAndre Fischer         {
164*02c50d82SAndre Fischer             SharedMasterPageDescriptor pDescriptor (new MasterPageDescriptor(
165*02c50d82SAndre Fischer                 MasterPageContainer::MASTERPAGE,
166*02c50d82SAndre Fischer                 nIndex,
167*02c50d82SAndre Fischer                 String(),
168*02c50d82SAndre Fischer                 pMasterPage->GetName(),
169*02c50d82SAndre Fischer                 String(),
170*02c50d82SAndre Fischer                 pMasterPage->IsPrecious(),
171*02c50d82SAndre Fischer                 ::boost::shared_ptr<PageObjectProvider>(new ExistingPageProvider(pMasterPage)),
172*02c50d82SAndre Fischer                 ::boost::shared_ptr<PreviewProvider>(new PagePreviewProvider())));
173*02c50d82SAndre Fischer             aToken = mpContainer->PutMasterPage(pDescriptor);
174*02c50d82SAndre Fischer         }
175*02c50d82SAndre Fischer 
176*02c50d82SAndre Fischer         rItemList.push_back(aToken);
177*02c50d82SAndre Fischer     }
178*02c50d82SAndre Fischer }
179*02c50d82SAndre Fischer 
180*02c50d82SAndre Fischer 
181*02c50d82SAndre Fischer 
182*02c50d82SAndre Fischer 
GetContextMenuResId(void) const183*02c50d82SAndre Fischer ResId CurrentMasterPagesSelector::GetContextMenuResId (void) const
184*02c50d82SAndre Fischer {
185*02c50d82SAndre Fischer     return SdResId(RID_TASKPANE_CURRENT_MASTERPAGESSELECTOR_POPUP);
186*02c50d82SAndre Fischer }
187*02c50d82SAndre Fischer 
188*02c50d82SAndre Fischer 
189*02c50d82SAndre Fischer 
190*02c50d82SAndre Fischer 
UpdateSelection(void)191*02c50d82SAndre Fischer void CurrentMasterPagesSelector::UpdateSelection (void)
192*02c50d82SAndre Fischer {
193*02c50d82SAndre Fischer     // Iterate over all pages and for the selected ones put the name of
194*02c50d82SAndre Fischer     // their master page into a set.
195*02c50d82SAndre Fischer 	sal_uInt16 nPageCount = mrDocument.GetSdPageCount(PK_STANDARD);
196*02c50d82SAndre Fischer     SdPage* pPage;
197*02c50d82SAndre Fischer     ::std::set<String> aNames;
198*02c50d82SAndre Fischer     sal_uInt16 nIndex;
199*02c50d82SAndre Fischer     bool bLoop (true);
200*02c50d82SAndre Fischer     for (nIndex=0; nIndex<nPageCount && bLoop; nIndex++)
201*02c50d82SAndre Fischer     {
202*02c50d82SAndre Fischer         pPage = mrDocument.GetSdPage (nIndex, PK_STANDARD);
203*02c50d82SAndre Fischer         if (pPage != NULL && pPage->IsSelected())
204*02c50d82SAndre Fischer         {
205*02c50d82SAndre Fischer             if ( ! pPage->TRG_HasMasterPage())
206*02c50d82SAndre Fischer             {
207*02c50d82SAndre Fischer                 // One of the pages has no master page.  This is an
208*02c50d82SAndre Fischer                 // indicator for that this method is called in the middle of
209*02c50d82SAndre Fischer                 // a document change and that the model is not in a valid
210*02c50d82SAndre Fischer                 // state.  Therefore we stop update the selection and wait
211*02c50d82SAndre Fischer                 // for another call to UpdateSelection when the model is
212*02c50d82SAndre Fischer                 // valid again.
213*02c50d82SAndre Fischer                 bLoop = false;
214*02c50d82SAndre Fischer             }
215*02c50d82SAndre Fischer             else
216*02c50d82SAndre Fischer             {
217*02c50d82SAndre Fischer                 SdrPage& rMasterPage (pPage->TRG_GetMasterPage());
218*02c50d82SAndre Fischer                 SdPage* pMasterPage = static_cast<SdPage*>(&rMasterPage);
219*02c50d82SAndre Fischer                 if (pMasterPage != NULL)
220*02c50d82SAndre Fischer                     aNames.insert (pMasterPage->GetName());
221*02c50d82SAndre Fischer             }
222*02c50d82SAndre Fischer         }
223*02c50d82SAndre Fischer     }
224*02c50d82SAndre Fischer 
225*02c50d82SAndre Fischer     // Find the items for the master pages in the set.
226*02c50d82SAndre Fischer     sal_uInt16 nItemCount (PreviewValueSet::GetItemCount());
227*02c50d82SAndre Fischer     for (nIndex=1; nIndex<=nItemCount && bLoop; nIndex++)
228*02c50d82SAndre Fischer     {
229*02c50d82SAndre Fischer         String sName (PreviewValueSet::GetItemText (nIndex));
230*02c50d82SAndre Fischer         if (aNames.find(sName) != aNames.end())
231*02c50d82SAndre Fischer         {
232*02c50d82SAndre Fischer             PreviewValueSet::SelectItem (nIndex);
233*02c50d82SAndre Fischer         }
234*02c50d82SAndre Fischer     }
235*02c50d82SAndre Fischer }
236*02c50d82SAndre Fischer 
237*02c50d82SAndre Fischer 
238*02c50d82SAndre Fischer 
239*02c50d82SAndre Fischer 
ExecuteCommand(const sal_Int32 nCommandId)240*02c50d82SAndre Fischer void CurrentMasterPagesSelector::ExecuteCommand (const sal_Int32 nCommandId)
241*02c50d82SAndre Fischer {
242*02c50d82SAndre Fischer 	if (nCommandId == SID_DELETE_MASTER_PAGE)
243*02c50d82SAndre Fischer     {
244*02c50d82SAndre Fischer         // Check once again that the master page can safely be deleted,
245*02c50d82SAndre Fischer         // i.e. is not used.
246*02c50d82SAndre Fischer         SdPage* pMasterPage = GetSelectedMasterPage();
247*02c50d82SAndre Fischer         if (pMasterPage != NULL
248*02c50d82SAndre Fischer             && mrDocument.GetMasterPageUserCount(pMasterPage) == 0)
249*02c50d82SAndre Fischer         {
250*02c50d82SAndre Fischer             // Removing the precious flag so that the following call to
251*02c50d82SAndre Fischer             // RemoveUnnessesaryMasterPages() will remove this master page.
252*02c50d82SAndre Fischer             pMasterPage->SetPrecious(false);
253*02c50d82SAndre Fischer             mrDocument.RemoveUnnecessaryMasterPages(pMasterPage, sal_False, sal_True);
254*02c50d82SAndre Fischer         }
255*02c50d82SAndre Fischer     }
256*02c50d82SAndre Fischer     else
257*02c50d82SAndre Fischer         MasterPagesSelector::ExecuteCommand(nCommandId);
258*02c50d82SAndre Fischer }
259*02c50d82SAndre Fischer 
260*02c50d82SAndre Fischer 
261*02c50d82SAndre Fischer 
262*02c50d82SAndre Fischer 
ProcessPopupMenu(Menu & rMenu)263*02c50d82SAndre Fischer void CurrentMasterPagesSelector::ProcessPopupMenu (Menu& rMenu)
264*02c50d82SAndre Fischer {
265*02c50d82SAndre Fischer     // Disable the SID_DELTE_MASTER slot when there is only one master page.
266*02c50d82SAndre Fischer     if (mrDocument.GetMasterPageUserCount(GetSelectedMasterPage()) > 0)
267*02c50d82SAndre Fischer     {
268*02c50d82SAndre Fischer         if (rMenu.GetItemPos(SID_DELETE_MASTER_PAGE) != MENU_ITEM_NOTFOUND)
269*02c50d82SAndre Fischer             rMenu.EnableItem(SID_DELETE_MASTER_PAGE, sal_False);
270*02c50d82SAndre Fischer     }
271*02c50d82SAndre Fischer 
272*02c50d82SAndre Fischer     ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
273*02c50d82SAndre Fischer         ::boost::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell()));
274*02c50d82SAndre Fischer 	if (pDrawViewShell
275*02c50d82SAndre Fischer         && pDrawViewShell->GetEditMode() == EM_MASTERPAGE)
276*02c50d82SAndre Fischer     {
277*02c50d82SAndre Fischer         if (rMenu.GetItemPos(SID_TP_EDIT_MASTER) != MENU_ITEM_NOTFOUND)
278*02c50d82SAndre Fischer             rMenu.EnableItem(SID_TP_EDIT_MASTER, sal_False);
279*02c50d82SAndre Fischer     }
280*02c50d82SAndre Fischer 
281*02c50d82SAndre Fischer     MasterPagesSelector::ProcessPopupMenu(rMenu);
282*02c50d82SAndre Fischer }
283*02c50d82SAndre Fischer 
284*02c50d82SAndre Fischer 
285*02c50d82SAndre Fischer 
286*02c50d82SAndre Fischer 
287*02c50d82SAndre Fischer 
288*02c50d82SAndre Fischer 
IMPL_LINK(CurrentMasterPagesSelector,EventMultiplexerListener,sd::tools::EventMultiplexerEvent *,pEvent)289*02c50d82SAndre Fischer IMPL_LINK(CurrentMasterPagesSelector,EventMultiplexerListener,
290*02c50d82SAndre Fischer     sd::tools::EventMultiplexerEvent*,pEvent)
291*02c50d82SAndre Fischer {
292*02c50d82SAndre Fischer     if (pEvent != NULL)
293*02c50d82SAndre Fischer     {
294*02c50d82SAndre Fischer         switch (pEvent->meEventId)
295*02c50d82SAndre Fischer         {
296*02c50d82SAndre Fischer             case sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
297*02c50d82SAndre Fischer             case sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL:
298*02c50d82SAndre Fischer             case sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER:
299*02c50d82SAndre Fischer             case sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION:
300*02c50d82SAndre Fischer                 UpdateSelection();
301*02c50d82SAndre Fischer                 break;
302*02c50d82SAndre Fischer 
303*02c50d82SAndre Fischer             case sd::tools::EventMultiplexerEvent::EID_PAGE_ORDER:
304*02c50d82SAndre Fischer 				// This is tricky.  If a master page is removed, moved, or
305*02c50d82SAndre Fischer 				// added we have to wait until both the notes master page
306*02c50d82SAndre Fischer 				// and the standard master page have been removed, moved,
307*02c50d82SAndre Fischer 				// or added.  We do this by looking at the number of master
308*02c50d82SAndre Fischer 				// pages which has to be odd in the consistent state (the
309*02c50d82SAndre Fischer 				// handout master page is always present).  If the number is
310*02c50d82SAndre Fischer 				// even we ignore the hint.
311*02c50d82SAndre Fischer                 if (mrBase.GetDocument()->GetMasterPageCount()%2 == 1)
312*02c50d82SAndre Fischer                     MasterPagesSelector::Fill();
313*02c50d82SAndre Fischer                 break;
314*02c50d82SAndre Fischer 
315*02c50d82SAndre Fischer             case sd::tools::EventMultiplexerEvent::EID_SHAPE_CHANGED:
316*02c50d82SAndre Fischer             case sd::tools::EventMultiplexerEvent::EID_SHAPE_INSERTED:
317*02c50d82SAndre Fischer             case sd::tools::EventMultiplexerEvent::EID_SHAPE_REMOVED:
318*02c50d82SAndre Fischer                 InvalidatePreview((const SdPage*)pEvent->mpUserData);
319*02c50d82SAndre Fischer                 break;
320*02c50d82SAndre Fischer         }
321*02c50d82SAndre Fischer     }
322*02c50d82SAndre Fischer 
323*02c50d82SAndre Fischer     return 0;
324*02c50d82SAndre Fischer }
325*02c50d82SAndre Fischer 
326*02c50d82SAndre Fischer 
327*02c50d82SAndre Fischer 
328*02c50d82SAndre Fischer 
Notify(SfxBroadcaster &,const SfxHint & rHint)329*02c50d82SAndre Fischer void CurrentMasterPagesSelector::Notify (SfxBroadcaster&, const SfxHint& rHint)
330*02c50d82SAndre Fischer {
331*02c50d82SAndre Fischer     const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
332*02c50d82SAndre Fischer     if (pSimpleHint != NULL)
333*02c50d82SAndre Fischer     {
334*02c50d82SAndre Fischer         if (pSimpleHint->GetId() == SFX_HINT_DOCCHANGED)
335*02c50d82SAndre Fischer         {
336*02c50d82SAndre Fischer             // Is the edit view visible in the center pane?
337*02c50d82SAndre Fischer             ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
338*02c50d82SAndre Fischer                 ::boost::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell()));
339*02c50d82SAndre Fischer             if (pDrawViewShell.get() != NULL)
340*02c50d82SAndre Fischer             {
341*02c50d82SAndre Fischer                 // Is the edit view in master page mode?
342*02c50d82SAndre Fischer             	if (pDrawViewShell->GetEditMode() == EM_MASTERPAGE)
343*02c50d82SAndre Fischer                 {
344*02c50d82SAndre Fischer                     // Mark the currently edited master page as precious.
345*02c50d82SAndre Fischer                     SdPage* pCurrentMasterPage = pDrawViewShell->getCurrentPage();
346*02c50d82SAndre Fischer                     if (pCurrentMasterPage != NULL)
347*02c50d82SAndre Fischer                         pCurrentMasterPage->SetPrecious(true);
348*02c50d82SAndre Fischer                 }
349*02c50d82SAndre Fischer             }
350*02c50d82SAndre Fischer         }
351*02c50d82SAndre Fischer     }
352*02c50d82SAndre Fischer }
353*02c50d82SAndre Fischer 
354*02c50d82SAndre Fischer 
355*02c50d82SAndre Fischer } } // end of namespace sd::sidebar
356