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 "MasterPageDescriptor.hxx" 25*02c50d82SAndre Fischer 26*02c50d82SAndre Fischer #include "DocumentHelper.hxx" 27*02c50d82SAndre Fischer #include "sdpage.hxx" 28*02c50d82SAndre Fischer #include <tools/urlobj.hxx> 29*02c50d82SAndre Fischer 30*02c50d82SAndre Fischer namespace sd { namespace sidebar { 31*02c50d82SAndre Fischer 32*02c50d82SAndre Fischer 33*02c50d82SAndre Fischer //===== MasterPageDescriptor ================================================== 34*02c50d82SAndre Fischer 35*02c50d82SAndre Fischer MasterPageDescriptor::MasterPageDescriptor ( 36*02c50d82SAndre Fischer MasterPageContainer::Origin eOrigin, 37*02c50d82SAndre Fischer const sal_Int32 nTemplateIndex, 38*02c50d82SAndre Fischer const String& rsURL, 39*02c50d82SAndre Fischer const String& rsPageName, 40*02c50d82SAndre Fischer const String& rsStyleName, 41*02c50d82SAndre Fischer const bool bIsPrecious, 42*02c50d82SAndre Fischer const ::boost::shared_ptr<PageObjectProvider>& rpPageObjectProvider, 43*02c50d82SAndre Fischer const ::boost::shared_ptr<PreviewProvider>& rpPreviewProvider) 44*02c50d82SAndre Fischer : maToken(MasterPageContainer::NIL_TOKEN), 45*02c50d82SAndre Fischer meOrigin(eOrigin), 46*02c50d82SAndre Fischer msURL(INetURLObject(rsURL).GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS)), 47*02c50d82SAndre Fischer msPageName(rsPageName), 48*02c50d82SAndre Fischer msStyleName(rsStyleName), 49*02c50d82SAndre Fischer mbIsPrecious(bIsPrecious), 50*02c50d82SAndre Fischer mpMasterPage(NULL), 51*02c50d82SAndre Fischer mpSlide(NULL), 52*02c50d82SAndre Fischer maSmallPreview(), 53*02c50d82SAndre Fischer maLargePreview(), 54*02c50d82SAndre Fischer mpPreviewProvider(rpPreviewProvider), 55*02c50d82SAndre Fischer mpPageObjectProvider(rpPageObjectProvider), 56*02c50d82SAndre Fischer mnTemplateIndex(nTemplateIndex), 57*02c50d82SAndre Fischer meURLClassification(URLCLASS_UNDETERMINED), 58*02c50d82SAndre Fischer mnUseCount(0) 59*02c50d82SAndre Fischer { 60*02c50d82SAndre Fischer } 61*02c50d82SAndre Fischer 62*02c50d82SAndre Fischer 63*02c50d82SAndre Fischer 64*02c50d82SAndre Fischer 65*02c50d82SAndre Fischer MasterPageDescriptor::MasterPageDescriptor (const MasterPageDescriptor& rDescriptor) 66*02c50d82SAndre Fischer : maToken(rDescriptor.maToken), 67*02c50d82SAndre Fischer meOrigin(rDescriptor.meOrigin), 68*02c50d82SAndre Fischer msURL(rDescriptor.msURL), 69*02c50d82SAndre Fischer msPageName(rDescriptor.msPageName), 70*02c50d82SAndre Fischer msStyleName(rDescriptor.msStyleName), 71*02c50d82SAndre Fischer mbIsPrecious(rDescriptor.mbIsPrecious), 72*02c50d82SAndre Fischer mpMasterPage(rDescriptor.mpMasterPage), 73*02c50d82SAndre Fischer mpSlide(rDescriptor.mpSlide), 74*02c50d82SAndre Fischer maSmallPreview(rDescriptor.maSmallPreview), 75*02c50d82SAndre Fischer maLargePreview(rDescriptor.maLargePreview), 76*02c50d82SAndre Fischer mpPreviewProvider(rDescriptor.mpPreviewProvider), 77*02c50d82SAndre Fischer mpPageObjectProvider(rDescriptor.mpPageObjectProvider), 78*02c50d82SAndre Fischer mnTemplateIndex(rDescriptor.mnTemplateIndex), 79*02c50d82SAndre Fischer meURLClassification(rDescriptor.meURLClassification), 80*02c50d82SAndre Fischer mnUseCount(rDescriptor.mnUseCount) 81*02c50d82SAndre Fischer { 82*02c50d82SAndre Fischer } 83*02c50d82SAndre Fischer 84*02c50d82SAndre Fischer 85*02c50d82SAndre Fischer 86*02c50d82SAndre Fischer 87*02c50d82SAndre Fischer MasterPageDescriptor::~MasterPageDescriptor (void) 88*02c50d82SAndre Fischer { 89*02c50d82SAndre Fischer } 90*02c50d82SAndre Fischer 91*02c50d82SAndre Fischer 92*02c50d82SAndre Fischer 93*02c50d82SAndre Fischer 94*02c50d82SAndre Fischer void MasterPageDescriptor::SetToken (MasterPageContainer::Token aToken) 95*02c50d82SAndre Fischer { 96*02c50d82SAndre Fischer maToken = aToken; 97*02c50d82SAndre Fischer } 98*02c50d82SAndre Fischer 99*02c50d82SAndre Fischer 100*02c50d82SAndre Fischer 101*02c50d82SAndre Fischer 102*02c50d82SAndre Fischer Image MasterPageDescriptor::GetPreview (MasterPageContainer::PreviewSize eSize) 103*02c50d82SAndre Fischer { 104*02c50d82SAndre Fischer if (eSize == MasterPageContainer::SMALL) 105*02c50d82SAndre Fischer return maSmallPreview; 106*02c50d82SAndre Fischer else 107*02c50d82SAndre Fischer return maLargePreview; 108*02c50d82SAndre Fischer } 109*02c50d82SAndre Fischer 110*02c50d82SAndre Fischer 111*02c50d82SAndre Fischer 112*02c50d82SAndre Fischer 113*02c50d82SAndre Fischer ::std::auto_ptr<std::vector<MasterPageContainerChangeEvent::EventType> > 114*02c50d82SAndre Fischer MasterPageDescriptor::Update ( 115*02c50d82SAndre Fischer const MasterPageDescriptor& rDescriptor) 116*02c50d82SAndre Fischer { 117*02c50d82SAndre Fischer bool bDataChanged (false); 118*02c50d82SAndre Fischer bool bIndexChanged (false); 119*02c50d82SAndre Fischer bool bPreviewChanged (false); 120*02c50d82SAndre Fischer 121*02c50d82SAndre Fischer if (meOrigin==MasterPageContainer::UNKNOWN 122*02c50d82SAndre Fischer && rDescriptor.meOrigin!=MasterPageContainer::UNKNOWN) 123*02c50d82SAndre Fischer { 124*02c50d82SAndre Fischer meOrigin = rDescriptor.meOrigin; 125*02c50d82SAndre Fischer bIndexChanged = true; 126*02c50d82SAndre Fischer } 127*02c50d82SAndre Fischer 128*02c50d82SAndre Fischer if (msURL.getLength()==0 && rDescriptor.msURL.getLength()!=0) 129*02c50d82SAndre Fischer { 130*02c50d82SAndre Fischer msURL = rDescriptor.msURL; 131*02c50d82SAndre Fischer bDataChanged = true; 132*02c50d82SAndre Fischer } 133*02c50d82SAndre Fischer 134*02c50d82SAndre Fischer if (msPageName.getLength()==0 && rDescriptor.msPageName.getLength()!=0) 135*02c50d82SAndre Fischer { 136*02c50d82SAndre Fischer msPageName = rDescriptor.msPageName; 137*02c50d82SAndre Fischer bDataChanged = true; 138*02c50d82SAndre Fischer } 139*02c50d82SAndre Fischer 140*02c50d82SAndre Fischer if (msStyleName.getLength()==0 && rDescriptor.msStyleName.getLength()!=0) 141*02c50d82SAndre Fischer { 142*02c50d82SAndre Fischer msStyleName = rDescriptor.msStyleName; 143*02c50d82SAndre Fischer bDataChanged = true; 144*02c50d82SAndre Fischer } 145*02c50d82SAndre Fischer 146*02c50d82SAndre Fischer if (mpPageObjectProvider.get()==NULL && rDescriptor.mpPageObjectProvider.get()!=NULL) 147*02c50d82SAndre Fischer { 148*02c50d82SAndre Fischer mpPageObjectProvider = rDescriptor.mpPageObjectProvider; 149*02c50d82SAndre Fischer bDataChanged = true; 150*02c50d82SAndre Fischer } 151*02c50d82SAndre Fischer 152*02c50d82SAndre Fischer if (mpPreviewProvider.get()==NULL && rDescriptor.mpPreviewProvider.get()!=NULL) 153*02c50d82SAndre Fischer { 154*02c50d82SAndre Fischer mpPreviewProvider = rDescriptor.mpPreviewProvider; 155*02c50d82SAndre Fischer bPreviewChanged = true; 156*02c50d82SAndre Fischer } 157*02c50d82SAndre Fischer 158*02c50d82SAndre Fischer if (mnTemplateIndex<0 && rDescriptor.mnTemplateIndex>=0) 159*02c50d82SAndre Fischer { 160*02c50d82SAndre Fischer mnTemplateIndex = rDescriptor.mnTemplateIndex; 161*02c50d82SAndre Fischer bIndexChanged = true; 162*02c50d82SAndre Fischer } 163*02c50d82SAndre Fischer 164*02c50d82SAndre Fischer // Prepare the list of event types that will be returned. 165*02c50d82SAndre Fischer ::std::auto_ptr<std::vector<MasterPageContainerChangeEvent::EventType> > pResult; 166*02c50d82SAndre Fischer if (bDataChanged || bIndexChanged || bPreviewChanged) 167*02c50d82SAndre Fischer { 168*02c50d82SAndre Fischer pResult.reset(new std::vector<MasterPageContainerChangeEvent::EventType>()); 169*02c50d82SAndre Fischer if (bDataChanged) 170*02c50d82SAndre Fischer pResult->push_back(MasterPageContainerChangeEvent::DATA_CHANGED); 171*02c50d82SAndre Fischer if (bIndexChanged) 172*02c50d82SAndre Fischer pResult->push_back(MasterPageContainerChangeEvent::INDEX_CHANGED); 173*02c50d82SAndre Fischer if (bPreviewChanged) 174*02c50d82SAndre Fischer pResult->push_back(MasterPageContainerChangeEvent::PREVIEW_CHANGED); 175*02c50d82SAndre Fischer } 176*02c50d82SAndre Fischer 177*02c50d82SAndre Fischer return pResult; 178*02c50d82SAndre Fischer } 179*02c50d82SAndre Fischer 180*02c50d82SAndre Fischer 181*02c50d82SAndre Fischer 182*02c50d82SAndre Fischer 183*02c50d82SAndre Fischer bool MasterPageDescriptor::UpdatePageObject ( 184*02c50d82SAndre Fischer sal_Int32 nCostThreshold, 185*02c50d82SAndre Fischer SdDrawDocument* pDocument) 186*02c50d82SAndre Fischer { 187*02c50d82SAndre Fischer bool bModified (false); 188*02c50d82SAndre Fischer 189*02c50d82SAndre Fischer // Update the page object when that is not yet known. 190*02c50d82SAndre Fischer if (mpMasterPage == NULL 191*02c50d82SAndre Fischer && mpPageObjectProvider.get()!=NULL 192*02c50d82SAndre Fischer && (nCostThreshold<0 || mpPageObjectProvider->GetCostIndex()<=nCostThreshold)) 193*02c50d82SAndre Fischer { 194*02c50d82SAndre Fischer // Note that pDocument may be NULL. 195*02c50d82SAndre Fischer 196*02c50d82SAndre Fischer SdPage* pPage = (*mpPageObjectProvider)(pDocument); 197*02c50d82SAndre Fischer if (meOrigin == MasterPageContainer::MASTERPAGE) 198*02c50d82SAndre Fischer { 199*02c50d82SAndre Fischer mpMasterPage = pPage; 200*02c50d82SAndre Fischer if (mpMasterPage != NULL) 201*02c50d82SAndre Fischer mpMasterPage->SetPrecious(mbIsPrecious); 202*02c50d82SAndre Fischer } 203*02c50d82SAndre Fischer else 204*02c50d82SAndre Fischer { 205*02c50d82SAndre Fischer // Master pages from templates are copied into the local document. 206*02c50d82SAndre Fischer if (pDocument != NULL) 207*02c50d82SAndre Fischer mpMasterPage = DocumentHelper::CopyMasterPageToLocalDocument(*pDocument,pPage); 208*02c50d82SAndre Fischer mpSlide = DocumentHelper::GetSlideForMasterPage(mpMasterPage); 209*02c50d82SAndre Fischer } 210*02c50d82SAndre Fischer 211*02c50d82SAndre Fischer if (mpMasterPage != NULL) 212*02c50d82SAndre Fischer { 213*02c50d82SAndre Fischer // Update page name and style name. 214*02c50d82SAndre Fischer if (msPageName.getLength() == 0) 215*02c50d82SAndre Fischer msPageName = mpMasterPage->GetName(); 216*02c50d82SAndre Fischer msStyleName = mpMasterPage->GetName(); 217*02c50d82SAndre Fischer 218*02c50d82SAndre Fischer // Delete an existing substitution. The next request for a preview 219*02c50d82SAndre Fischer // will create the real one. 220*02c50d82SAndre Fischer maSmallPreview = Image(); 221*02c50d82SAndre Fischer maLargePreview = Image(); 222*02c50d82SAndre Fischer mpPreviewProvider = ::boost::shared_ptr<PreviewProvider>(new PagePreviewProvider()); 223*02c50d82SAndre Fischer } 224*02c50d82SAndre Fischer else 225*02c50d82SAndre Fischer { 226*02c50d82SAndre Fischer DBG_ASSERT(false, "UpdatePageObject: master page is NULL"); 227*02c50d82SAndre Fischer } 228*02c50d82SAndre Fischer 229*02c50d82SAndre Fischer bModified = true; 230*02c50d82SAndre Fischer } 231*02c50d82SAndre Fischer 232*02c50d82SAndre Fischer return bModified; 233*02c50d82SAndre Fischer } 234*02c50d82SAndre Fischer 235*02c50d82SAndre Fischer 236*02c50d82SAndre Fischer 237*02c50d82SAndre Fischer 238*02c50d82SAndre Fischer bool MasterPageDescriptor::UpdatePreview ( 239*02c50d82SAndre Fischer sal_Int32 nCostThreshold, 240*02c50d82SAndre Fischer const Size& rSmallSize, 241*02c50d82SAndre Fischer const Size& rLargeSize, 242*02c50d82SAndre Fischer ::sd::PreviewRenderer& rRenderer) 243*02c50d82SAndre Fischer { 244*02c50d82SAndre Fischer bool bModified (false); 245*02c50d82SAndre Fischer 246*02c50d82SAndre Fischer // Update the preview when that is not yet known. 247*02c50d82SAndre Fischer if (maLargePreview.GetSizePixel().Width()==0 248*02c50d82SAndre Fischer && mpPreviewProvider.get()!=NULL 249*02c50d82SAndre Fischer && (nCostThreshold<0 || mpPreviewProvider->GetCostIndex()<=nCostThreshold)) 250*02c50d82SAndre Fischer { 251*02c50d82SAndre Fischer SdPage* pPage = mpSlide; 252*02c50d82SAndre Fischer if (pPage == NULL) 253*02c50d82SAndre Fischer { 254*02c50d82SAndre Fischer pPage = mpMasterPage; 255*02c50d82SAndre Fischer } 256*02c50d82SAndre Fischer maLargePreview = (*mpPreviewProvider)( 257*02c50d82SAndre Fischer rLargeSize.Width(), 258*02c50d82SAndre Fischer pPage, 259*02c50d82SAndre Fischer rRenderer); 260*02c50d82SAndre Fischer if (maLargePreview.GetSizePixel().Width() > 0) 261*02c50d82SAndre Fischer { 262*02c50d82SAndre Fischer // Create the small preview by scaling the large one down. 263*02c50d82SAndre Fischer maSmallPreview = rRenderer.ScaleBitmap( 264*02c50d82SAndre Fischer maLargePreview.GetBitmapEx(), 265*02c50d82SAndre Fischer rSmallSize.Width()); 266*02c50d82SAndre Fischer // The large preview may not have the desired width. Scale it 267*02c50d82SAndre Fischer // accrodingly. 268*02c50d82SAndre Fischer if (maLargePreview.GetSizePixel().Width() != rLargeSize.Width()) 269*02c50d82SAndre Fischer maLargePreview = rRenderer.ScaleBitmap( 270*02c50d82SAndre Fischer maLargePreview.GetBitmapEx(), 271*02c50d82SAndre Fischer rLargeSize.Width()); 272*02c50d82SAndre Fischer bModified = true; 273*02c50d82SAndre Fischer } 274*02c50d82SAndre Fischer } 275*02c50d82SAndre Fischer 276*02c50d82SAndre Fischer return bModified; 277*02c50d82SAndre Fischer } 278*02c50d82SAndre Fischer 279*02c50d82SAndre Fischer 280*02c50d82SAndre Fischer 281*02c50d82SAndre Fischer 282*02c50d82SAndre Fischer MasterPageDescriptor::URLClassification MasterPageDescriptor::GetURLClassification (void) 283*02c50d82SAndre Fischer { 284*02c50d82SAndre Fischer if (meURLClassification == URLCLASS_UNDETERMINED) 285*02c50d82SAndre Fischer { 286*02c50d82SAndre Fischer if (msURL.getLength() == 0) 287*02c50d82SAndre Fischer meURLClassification = URLCLASS_UNKNOWN; 288*02c50d82SAndre Fischer else if (msURL.indexOf(::rtl::OUString::createFromAscii("presnt"))>=0) 289*02c50d82SAndre Fischer { 290*02c50d82SAndre Fischer meURLClassification = URLCLASS_PRESENTATION; 291*02c50d82SAndre Fischer } 292*02c50d82SAndre Fischer else if (msURL.indexOf(::rtl::OUString::createFromAscii("layout"))>=0) 293*02c50d82SAndre Fischer { 294*02c50d82SAndre Fischer meURLClassification = URLCLASS_LAYOUT; 295*02c50d82SAndre Fischer } 296*02c50d82SAndre Fischer else if (msURL.indexOf(::rtl::OUString::createFromAscii("educate"))>=0) 297*02c50d82SAndre Fischer { 298*02c50d82SAndre Fischer meURLClassification = URLCLASS_OTHER; 299*02c50d82SAndre Fischer } 300*02c50d82SAndre Fischer else 301*02c50d82SAndre Fischer { 302*02c50d82SAndre Fischer meURLClassification = URLCLASS_USER; 303*02c50d82SAndre Fischer } 304*02c50d82SAndre Fischer } 305*02c50d82SAndre Fischer 306*02c50d82SAndre Fischer return meURLClassification; 307*02c50d82SAndre Fischer } 308*02c50d82SAndre Fischer 309*02c50d82SAndre Fischer 310*02c50d82SAndre Fischer 311*02c50d82SAndre Fischer //===== URLComparator ========================================================= 312*02c50d82SAndre Fischer 313*02c50d82SAndre Fischer MasterPageDescriptor::URLComparator::URLComparator (const ::rtl::OUString& sURL) 314*02c50d82SAndre Fischer : msURL(sURL) 315*02c50d82SAndre Fischer { 316*02c50d82SAndre Fischer } 317*02c50d82SAndre Fischer 318*02c50d82SAndre Fischer 319*02c50d82SAndre Fischer 320*02c50d82SAndre Fischer 321*02c50d82SAndre Fischer bool MasterPageDescriptor::URLComparator::operator() ( 322*02c50d82SAndre Fischer const SharedMasterPageDescriptor& rDescriptor) 323*02c50d82SAndre Fischer { 324*02c50d82SAndre Fischer if (rDescriptor.get() == NULL) 325*02c50d82SAndre Fischer return false; 326*02c50d82SAndre Fischer else 327*02c50d82SAndre Fischer return rDescriptor->msURL.equals(msURL); 328*02c50d82SAndre Fischer } 329*02c50d82SAndre Fischer 330*02c50d82SAndre Fischer 331*02c50d82SAndre Fischer 332*02c50d82SAndre Fischer 333*02c50d82SAndre Fischer // ===== StyleNameComparator ================================================== 334*02c50d82SAndre Fischer 335*02c50d82SAndre Fischer MasterPageDescriptor::StyleNameComparator::StyleNameComparator (const ::rtl::OUString& sStyleName) 336*02c50d82SAndre Fischer : msStyleName(sStyleName) 337*02c50d82SAndre Fischer { 338*02c50d82SAndre Fischer } 339*02c50d82SAndre Fischer 340*02c50d82SAndre Fischer 341*02c50d82SAndre Fischer 342*02c50d82SAndre Fischer 343*02c50d82SAndre Fischer bool MasterPageDescriptor::StyleNameComparator::operator() ( 344*02c50d82SAndre Fischer const SharedMasterPageDescriptor& rDescriptor) 345*02c50d82SAndre Fischer { 346*02c50d82SAndre Fischer if (rDescriptor.get() == NULL) 347*02c50d82SAndre Fischer return false; 348*02c50d82SAndre Fischer else 349*02c50d82SAndre Fischer return rDescriptor->msStyleName.equals(msStyleName); 350*02c50d82SAndre Fischer } 351*02c50d82SAndre Fischer 352*02c50d82SAndre Fischer 353*02c50d82SAndre Fischer 354*02c50d82SAndre Fischer 355*02c50d82SAndre Fischer //===== PageObjectComparator ================================================== 356*02c50d82SAndre Fischer 357*02c50d82SAndre Fischer MasterPageDescriptor::PageObjectComparator::PageObjectComparator (const SdPage* pPageObject) 358*02c50d82SAndre Fischer : mpMasterPage(pPageObject) 359*02c50d82SAndre Fischer { 360*02c50d82SAndre Fischer } 361*02c50d82SAndre Fischer 362*02c50d82SAndre Fischer 363*02c50d82SAndre Fischer 364*02c50d82SAndre Fischer 365*02c50d82SAndre Fischer bool MasterPageDescriptor::PageObjectComparator::operator() ( 366*02c50d82SAndre Fischer const SharedMasterPageDescriptor& rDescriptor) 367*02c50d82SAndre Fischer { 368*02c50d82SAndre Fischer if (rDescriptor.get() == NULL) 369*02c50d82SAndre Fischer return false; 370*02c50d82SAndre Fischer else 371*02c50d82SAndre Fischer return rDescriptor->mpMasterPage==mpMasterPage; 372*02c50d82SAndre Fischer } 373*02c50d82SAndre Fischer 374*02c50d82SAndre Fischer 375*02c50d82SAndre Fischer 376*02c50d82SAndre Fischer 377*02c50d82SAndre Fischer //===== AllComparator ========================================================= 378*02c50d82SAndre Fischer 379*02c50d82SAndre Fischer MasterPageDescriptor::AllComparator::AllComparator(const SharedMasterPageDescriptor& rDescriptor) 380*02c50d82SAndre Fischer : mpDescriptor(rDescriptor) 381*02c50d82SAndre Fischer { 382*02c50d82SAndre Fischer } 383*02c50d82SAndre Fischer 384*02c50d82SAndre Fischer 385*02c50d82SAndre Fischer 386*02c50d82SAndre Fischer 387*02c50d82SAndre Fischer bool MasterPageDescriptor::AllComparator::operator() (const SharedMasterPageDescriptor&rDescriptor) 388*02c50d82SAndre Fischer { 389*02c50d82SAndre Fischer if (rDescriptor.get() == NULL) 390*02c50d82SAndre Fischer return false; 391*02c50d82SAndre Fischer else 392*02c50d82SAndre Fischer { 393*02c50d82SAndre Fischer // Take URL, page name, style name, and page object into account 394*02c50d82SAndre Fischer // when comparing two descriptors. When two descriptors are 395*02c50d82SAndre Fischer // identical in any of these values then their are thought of as 396*02c50d82SAndre Fischer // equivalent. Only the Origin has to be the same in both 397*02c50d82SAndre Fischer // descriptors. 398*02c50d82SAndre Fischer return 399*02c50d82SAndre Fischer mpDescriptor->meOrigin == rDescriptor->meOrigin 400*02c50d82SAndre Fischer && ( 401*02c50d82SAndre Fischer (mpDescriptor->msURL.getLength()>0 402*02c50d82SAndre Fischer && mpDescriptor->msURL.equals(rDescriptor->msURL)) 403*02c50d82SAndre Fischer || (mpDescriptor->msPageName.getLength()>0 404*02c50d82SAndre Fischer && mpDescriptor->msPageName.equals(rDescriptor->msPageName)) 405*02c50d82SAndre Fischer || (mpDescriptor->msStyleName.getLength()>0 406*02c50d82SAndre Fischer && mpDescriptor->msStyleName.equals(rDescriptor->msStyleName)) 407*02c50d82SAndre Fischer || (mpDescriptor->mpMasterPage!=NULL 408*02c50d82SAndre Fischer && mpDescriptor->mpMasterPage==rDescriptor->mpMasterPage) 409*02c50d82SAndre Fischer || (mpDescriptor->mpPageObjectProvider.get()!=NULL 410*02c50d82SAndre Fischer && rDescriptor->mpPageObjectProvider.get()!=NULL 411*02c50d82SAndre Fischer && mpDescriptor->mpPageObjectProvider==rDescriptor->mpPageObjectProvider)); 412*02c50d82SAndre Fischer } 413*02c50d82SAndre Fischer } 414*02c50d82SAndre Fischer 415*02c50d82SAndre Fischer 416*02c50d82SAndre Fischer } } // end of namespace sd::sidebar 417