1 diff --git sd/inc/drawdoc.hxx sd/inc/drawdoc.hxx
2 index d6d4e73..642f51c 100644
5 @@ -232,6 +232,7 @@ private:
6 ::std::auto_ptr<ImpMasterPageListWatcher> mpMasterPageListWatcher;
8 void UpdatePageObjectsInNotes(USHORT nStartPos);
9 + void UpdatePageRelativeURLs(SdPage* pPage, USHORT nPos, sal_Int32 nIncrement);
10 void FillOnlineSpellingList(SdPage* pPage);
11 void SpellObject(SdrTextObj* pObj);
13 @@ -239,6 +240,9 @@ private:
14 DECL_LINK(OnlineSpellingHdl, Timer*);
15 DECL_LINK(OnlineSpellEventHdl, EditStatus*);
18 + void UpdatePageRelativeURLs(const String& rOldName, const String& rNewName);
22 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoModel();
23 diff --git sd/source/core/drawdoc2.cxx sd/source/core/drawdoc2.cxx
24 index d2d630c..d9b399b 100644
25 --- sd/source/core/drawdoc2.cxx
26 +++ sd/source/core/drawdoc2.cxx
28 #include <svx/eeitem.hxx>
29 #include <svx/langitem.hxx>
30 #include <svtools/itempool.hxx>
31 +#include <svx/svdpool.hxx>
32 +#include <svx/flditem.hxx>
35 #include <svx/linkmgr.hxx>
36 @@ -349,6 +351,107 @@ void SdDrawDocument::UpdatePageObjectsInNotes(USHORT nStartPos)
40 +void SdDrawDocument::UpdatePageRelativeURLs(const String& rOldName, const String& rNewName)
42 + if (rNewName.Len() == 0)
45 + SfxItemPool& pPool(GetPool());
46 + USHORT nCount = pPool.GetItemCount(EE_FEATURE_FIELD);
47 + for (USHORT nOff = 0; nOff < nCount; nOff++) {
48 + const SfxPoolItem *pItem = pPool.GetItem(EE_FEATURE_FIELD, nOff);
49 + const SvxFieldItem* pFldItem;
51 + if ((pFldItem = dynamic_cast< const SvxFieldItem * > (pItem)) != 0) {
52 + const SvxFieldData *pData = pFldItem->GetField();
54 + if (pData->ISA(SvxURLField)) {
55 + SvxURLField* pURLField = (SvxURLField*) pData;
57 + if (pURLField->GetFormat() == SVXURLFORMAT_REPR) {
58 + XubString aURL = pURLField->GetURL();
60 + if (aURL.GetChar(0) == 35 && aURL.Search(rOldName, 1) == 1) {
61 + if (aURL.Len() == rOldName.Len() + 1) { // standard page name
62 + aURL.Erase (1, aURL.Len() - 1);
64 + pURLField->SetURL(aURL);
66 + const XubString sNotes = SdResId(STR_NOTES);
67 + if (aURL.Len() == rOldName.Len() + 2 + sNotes.Len() && aURL.Search(sNotes, rOldName.Len() + 2) == rOldName.Len() + 2) {
68 + aURL.Erase (1, aURL.Len() - 1);
72 + pURLField->SetURL(aURL);
82 +void SdDrawDocument::UpdatePageRelativeURLs(SdPage* pPage, USHORT nPos, sal_Int32 nIncrement)
84 + bool bNotes = (pPage->GetPageKind() == PK_NOTES);
86 + SfxItemPool& pPool(GetPool());
87 + USHORT nCount = pPool.GetItemCount(EE_FEATURE_FIELD);
88 + for (USHORT nOff = 0; nOff < nCount; nOff++) {
89 + const SfxPoolItem *pItem = pPool.GetItem(EE_FEATURE_FIELD, nOff);
90 + const SvxFieldItem* pFldItem;
92 + if ((pFldItem = dynamic_cast< const SvxFieldItem * > (pItem)) != 0) {
93 + const SvxFieldData *pData = pFldItem->GetField();
95 + if (pData->ISA(SvxURLField)) {
96 + SvxURLField* pURLField = (SvxURLField*) pData;
98 + if (pURLField->GetFormat() == SVXURLFORMAT_REPR) {
99 + XubString aURL = pURLField->GetURL();
101 + if (aURL.GetChar(0) == 35) {
102 + XubString aHashSlide('#');
103 + aHashSlide += SdResId(STR_PAGE);
105 + if (aURL.CompareTo(aHashSlide, aHashSlide.Len()) == COMPARE_EQUAL) {
106 + XubString aURLCopy = aURL;
107 + const XubString sNotes = SdResId(STR_NOTES);
109 + aURLCopy.Erase(0, aHashSlide.Len());
111 + bool bNotesLink = (aURLCopy.Len() >= sNotes.Len() + 3 && aURLCopy.Search(sNotes, aURLCopy.Len() - sNotes.Len()) == aURLCopy.Len() - sNotes.Len());
113 + if (bNotesLink ^ bNotes)
114 + continue; // no compatible link and page
117 + aURLCopy.Erase(aURLCopy.Len() - sNotes.Len(), sNotes.Len());
119 + sal_Int32 number = aURLCopy.ToInt32();
120 + USHORT realPageNumber = (nPos + 1)/ 2;
122 + if ( number >= realPageNumber ) {
123 + // update link page number
124 + number += nIncrement;
125 + aURL.Erase (aHashSlide.Len() + 1, aURL.Len() - aHashSlide.Len() - 1);
126 + aURL += XubString::CreateFromInt32(number);
131 + pURLField->SetURL(aURL);
141 /*************************************************************************
144 @@ -373,11 +476,14 @@ void SdDrawDocument::MovePage(USHORT nPgNum, USHORT nNewPos)
146 void SdDrawDocument::InsertPage(SdrPage* pPage, USHORT nPos)
148 + bool bLast = (nPos == GetPageCount());
149 FmFormModel::InsertPage(pPage, nPos);
151 ((SdPage*)pPage)->ConnectLink();
153 UpdatePageObjectsInNotes(nPos);
155 + UpdatePageRelativeURLs((SdPage*)pPage, nPos, 1);
158 /*************************************************************************
159 @@ -402,10 +508,13 @@ void SdDrawDocument::DeletePage(USHORT nPgNum)
160 SdrPage* SdDrawDocument::RemovePage(USHORT nPgNum)
162 SdrPage* pPage = FmFormModel::RemovePage(nPgNum);
163 + bool bLast = ((nPgNum+1)/2 == (GetPageCount()+1)/2);
165 ((SdPage*)pPage)->DisconnectLink();
166 ReplacePageInCustomShows( dynamic_cast< SdPage* >( pPage ), 0 );
167 UpdatePageObjectsInNotes(nPgNum);
169 + UpdatePageRelativeURLs((SdPage*)pPage, nPgNum, -1);
173 diff --git sd/source/core/sdpage.cxx sd/source/core/sdpage.cxx
174 index 9968645..474664a 100644
175 --- sd/source/core/sdpage.cxx
176 +++ sd/source/core/sdpage.cxx
177 @@ -2779,7 +2779,9 @@ SdPage* SdPage::getImplementation( const ::com::sun::star::uno::Reference< ::com
179 void SdPage::SetName (const String& rName)
181 + String aOldName = GetName();
182 FmFormPage::SetName (rName);
183 + ((SdDrawDocument*) pModel)->UpdatePageRelativeURLs(aOldName, rName);