renaissance1: #1107215# Previews are updated on model changes (to reflect changes of page numbers etc). Fixed insert position at end of document.
This commit is contained in:
@@ -385,6 +385,32 @@ bool PageCacheManager::InvalidatePreviewBitmap (
|
||||
|
||||
|
||||
|
||||
void PageCacheManager::InvalidateAllPreviewBitmaps (DocumentKey pDocument)
|
||||
{
|
||||
if (pDocument == NULL)
|
||||
return;
|
||||
|
||||
// Iterate over all caches that are currently in use and invalidate the
|
||||
// previews in those that belong to the document.
|
||||
PageCacheContainer::iterator iCache;
|
||||
for (iCache=mpPageCaches->begin(); iCache!=mpPageCaches->end(); ++iCache)
|
||||
if (iCache->first.mpDocument == pDocument)
|
||||
iCache->second->InvalidateCache();
|
||||
|
||||
// Invalidate the previews in the recently used caches belonging to the
|
||||
// given document.
|
||||
RecentlyUsedPageCaches::iterator iQueue (mpRecentlyUsedPageCaches->find(pDocument));
|
||||
if (iQueue != mpRecentlyUsedPageCaches->end())
|
||||
{
|
||||
RecentlyUsedQueue::const_iterator iCache2;
|
||||
for (iCache2=iQueue->second.begin(); iCache2!=iQueue->second.end(); ++iCache2)
|
||||
iCache2->mpCache->InvalidateCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void PageCacheManager::InvalidateAllCaches (void)
|
||||
{
|
||||
// Iterate over all caches that are currently in use and invalidate
|
||||
|
@@ -318,42 +318,7 @@ void Listener::Notify (
|
||||
{
|
||||
case HINT_PAGEORDERCHG:
|
||||
if (&rBroadcaster == mrSlideSorter.GetModel().GetDocument())
|
||||
{
|
||||
// Notify model and selection observer about the page.
|
||||
// The return value of the model call acts as filter as
|
||||
// to which events to pass to the selection observer.
|
||||
if (mrSlideSorter.GetModel().NotifyPageEvent(rSdrHint.GetPage()))
|
||||
{
|
||||
// The page of the hint belongs (or belonged)
|
||||
// to the model.
|
||||
|
||||
// Tell the cache manager that the preview
|
||||
// bitmaps for a deleted page can be removed
|
||||
// from all caches.
|
||||
const SdrPage* pPage = rSdrHint.GetPage();
|
||||
if (pPage!=NULL && ! pPage->IsInserted())
|
||||
cache::PageCacheManager::Instance()->ReleasePreviewBitmap(pPage);
|
||||
|
||||
mrController.GetSelectionManager()
|
||||
->GetSelectionObserver()->NotifyPageEvent(rSdrHint.GetPage());
|
||||
}
|
||||
|
||||
if (rBroadcaster.ISA(SdDrawDocument))
|
||||
{
|
||||
SdDrawDocument& rDocument (static_cast<SdDrawDocument&>(rBroadcaster));
|
||||
if (rDocument.GetMasterSdPageCount(PK_STANDARD)
|
||||
== rDocument.GetMasterSdPageCount(PK_NOTES))
|
||||
{
|
||||
mrController.HandleModelChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case HINT_OBJINSERTED:
|
||||
case HINT_OBJREMOVED:
|
||||
case HINT_OBJCHG:
|
||||
HandleShapeModification(rSdrHint.GetPage());
|
||||
HandleModelChange(rSdrHint.GetPage());
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -641,6 +606,40 @@ void Listener::UpdateEditMode (void)
|
||||
|
||||
|
||||
|
||||
void Listener::HandleModelChange (const SdrPage* pPage)
|
||||
{
|
||||
// Notify model and selection observer about the page. The return value
|
||||
// of the model call acts as filter as to which events to pass to the
|
||||
// selection observer.
|
||||
if (mrSlideSorter.GetModel().NotifyPageEvent(pPage))
|
||||
{
|
||||
// The page of the hint belongs (or belonged) to the model.
|
||||
|
||||
// Tell the cache manager that the preview bitmaps for a deleted
|
||||
// page can be removed from all caches.
|
||||
if (pPage!=NULL && ! pPage->IsInserted())
|
||||
cache::PageCacheManager::Instance()->ReleasePreviewBitmap(pPage);
|
||||
|
||||
mrController.GetSelectionManager()->GetSelectionObserver()->NotifyPageEvent(pPage);
|
||||
}
|
||||
|
||||
// Tell the controller about the model change only when the document is
|
||||
// in a sane state, not just in the middle of a larger change.
|
||||
SdDrawDocument* pDocument (mrSlideSorter.GetModel().GetDocument());
|
||||
if (pDocument != NULL
|
||||
&& pDocument->GetMasterSdPageCount(PK_STANDARD) == pDocument->GetMasterSdPageCount(PK_NOTES))
|
||||
{
|
||||
// A model change can make updates of some text fields necessary
|
||||
// (like page numbers and page count.) Invalidate all previews in
|
||||
// the cache to cope with this. Doing this on demand would be a
|
||||
// nice optimization.
|
||||
cache::PageCacheManager::Instance()->InvalidateAllPreviewBitmaps(pDocument->getUnoModel());
|
||||
|
||||
mrController.HandleModelChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Listener::HandleShapeModification (const SdrPage* pPage)
|
||||
{
|
||||
|
@@ -169,6 +169,11 @@ private:
|
||||
*/
|
||||
void UpdateEditMode (void);
|
||||
|
||||
/** Handle a change in the order of slides or when the set of slides has
|
||||
changed, i.e. a slide has been created.
|
||||
*/
|
||||
void HandleModelChange (const SdrPage* pPage);
|
||||
|
||||
/** Handle a modification to a shape on the given page. When this is a
|
||||
regular page then update its preview. When it is a master page then
|
||||
additionally update the previews of all pages linked to it.
|
||||
|
@@ -107,6 +107,12 @@ public:
|
||||
DocumentKey pDocument,
|
||||
const SdrPage* pPage);
|
||||
|
||||
/** Invalidate the preview bitmaps for all slides that belong to the
|
||||
specified document. This is necessary after model changes that
|
||||
affect e.g. page number fiels.
|
||||
*/
|
||||
void InvalidateAllPreviewBitmaps (DocumentKey pDocument);
|
||||
|
||||
/** Invalidate all the caches that are currently in use and destroy
|
||||
those that are not. This is used for example when the high contrast
|
||||
mode is turned on or off.
|
||||
|
@@ -1407,7 +1407,7 @@ bool StartShowButton::IsEnabled (void) const
|
||||
return false;
|
||||
SfxDispatcher* pDispatcher = pViewShell->GetDispatcher();
|
||||
if (pDispatcher == NULL)
|
||||
return NULL;
|
||||
return false;
|
||||
|
||||
const SfxPoolItem* pState = NULL;
|
||||
const SfxItemState eState (pDispatcher->QueryState(SID_PRESENTATION, pState));
|
||||
@@ -1416,33 +1416,21 @@ bool StartShowButton::IsEnabled (void) const
|
||||
|
||||
|
||||
|
||||
|
||||
void StartShowButton::ProcessClick (const model::SharedPageDescriptor& rpDescriptor)
|
||||
{
|
||||
// mrSlideSorter.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(
|
||||
// rpDescriptor);
|
||||
if (mrSlideSorter.GetViewShell() != NULL
|
||||
&& mrSlideSorter.GetViewShell()->GetDispatcher() != NULL)
|
||||
// Hide the tool tip early, while the slide show still intializes.
|
||||
mrSlideSorter.GetView().GetToolTip().SetPage(model::SharedPageDescriptor());
|
||||
|
||||
Reference< XPresentation2 > xPresentation(
|
||||
mrSlideSorter.GetModel().GetDocument()->getPresentation());
|
||||
if (xPresentation.is())
|
||||
{
|
||||
// Hide the tool tip early, while the slide show still intializes.
|
||||
mrSlideSorter.GetView().GetToolTip().SetPage(model::SharedPageDescriptor());
|
||||
|
||||
Reference< XPresentation2 > xPresentation(
|
||||
mrSlideSorter.GetModel().GetDocument()->getPresentation());
|
||||
if (xPresentation.is())
|
||||
{
|
||||
Sequence<PropertyValue> aProperties (1);
|
||||
aProperties[0].Name = ::rtl::OUString::createFromAscii("FirstPage");
|
||||
const ::rtl::OUString sName (rpDescriptor->GetPage()->GetName());
|
||||
aProperties[0].Value = Any(sName);
|
||||
xPresentation->startWithArguments(aProperties);
|
||||
}
|
||||
|
||||
/*
|
||||
// Request the start of the slide show.
|
||||
mrSlideSorter.GetViewShell()->GetDispatcher()->Execute(
|
||||
SID_PRESENTATION,
|
||||
SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
|
||||
*/
|
||||
Sequence<PropertyValue> aProperties (1);
|
||||
aProperties[0].Name = ::rtl::OUString::createFromAscii("FirstPage");
|
||||
const ::rtl::OUString sName (rpDescriptor->GetPage()->GetName());
|
||||
aProperties[0].Value = Any(sName);
|
||||
xPresentation->startWithArguments(aProperties);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1501,8 +1489,15 @@ DuplicateButton::DuplicateButton (SlideSorter& rSlideSorter)
|
||||
|
||||
bool DuplicateButton::IsEnabled (void) const
|
||||
{
|
||||
ViewShell* pViewShell = mrSlideSorter.GetViewShell();
|
||||
if (pViewShell == NULL)
|
||||
return false;
|
||||
SfxDispatcher* pDispatcher = pViewShell->GetDispatcher();
|
||||
if (pDispatcher == NULL)
|
||||
return false;
|
||||
|
||||
const SfxPoolItem* pState = NULL;
|
||||
const SfxItemState eState (mrSlideSorter.GetViewShell()->GetDispatcher()->QueryState(
|
||||
const SfxItemState eState (pDispatcher->QueryState(
|
||||
SID_DUPLICATE_PAGE,
|
||||
pState));
|
||||
return (eState & SFX_ITEM_DISABLED) == 0;
|
||||
@@ -1527,10 +1522,13 @@ void DuplicateButton::ProcessClick (const model::SharedPageDescriptor& rpDescrip
|
||||
}
|
||||
// Duplicate the selected pages. Insert the new pages right
|
||||
// after the current selection and select them
|
||||
if (mrSlideSorter.GetViewShell() != NULL)
|
||||
if (mrSlideSorter.GetViewShell() != NULL
|
||||
&& mrSlideSorter.GetViewShell()->GetDispatcher() != NULL)
|
||||
{
|
||||
mrSlideSorter.GetViewShell()->GetDispatcher()->Execute(
|
||||
SID_DUPLICATE_PAGE,
|
||||
SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1466,7 +1466,7 @@ void GridImplementation::CalculateLogicalInsertPosition (
|
||||
{
|
||||
nIndex = mnPageCount;
|
||||
nRow = mnRowCount-1;
|
||||
nColumn = mnPageCount%mnColumnCount;
|
||||
nColumn = ::std::min(::std::min(mnPageCount, mnColumnCount), nColumn);
|
||||
bIsAtRunEnd = true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user