1 |
From 070f5923eac7a93b64d2f168d91a3983b80a22c0 Mon Sep 17 00:00:00 2001 |
2 |
From: Armin Le Grand <alg@apache.org> |
3 |
Date: Thu, 7 Aug 2014 09:59:26 +0000 |
4 |
Subject: [PATCH] Resolves: #i125386# secured user request and changed some |
5 |
bools to bitfield |
6 |
|
7 |
(cherry picked from commit 5e3cbe056c19bea5018dbf1fd4b2bc8f8b030ff3) |
8 |
|
9 |
Conflicts: |
10 |
comphelper/inc/comphelper/embeddedobjectcontainer.hxx |
11 |
comphelper/source/container/embeddedobjectcontainer.cxx |
12 |
sfx2/source/appl/linkmgr2.cxx |
13 |
svtools/source/misc/embedhlp.cxx |
14 |
|
15 |
(cherry picked from commit d005acae3aa315921f2c331612131626c470bd22) |
16 |
|
17 |
Conflicts: |
18 |
include/comphelper/embeddedobjectcontainer.hxx |
19 |
|
20 |
Change-Id: I7e9b20a87ca6afe8cb91c577860a6c6b72368ee9 |
21 |
Reviewed-on: https://gerrit.libreoffice.org/10882 |
22 |
Reviewed-by: David Tardon <dtardon@redhat.com> |
23 |
Tested-by: David Tardon <dtardon@redhat.com> |
24 |
--- |
25 |
.../source/container/embeddedobjectcontainer.cxx | 36 +++++++++++++++++----- |
26 |
include/comphelper/embeddedobjectcontainer.hxx | 3 ++ |
27 |
sfx2/source/appl/linkmgr2.cxx | 12 +++++++- |
28 |
svtools/source/misc/embedhlp.cxx | 29 +++++++++++------ |
29 |
4 files changed, 62 insertions(+), 18 deletions(-) |
30 |
|
31 |
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx |
32 |
index c3b4338..4fef6c0 100644 |
33 |
--- a/comphelper/source/container/embeddedobjectcontainer.cxx |
34 |
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx |
35 |
@@ -85,7 +85,10 @@ struct EmbedImpl |
36 |
uno::WeakReference < uno::XInterface > m_xModel; |
37 |
//EmbeddedObjectContainerNameMap maTempObjectContainer; |
38 |
//uno::Reference < embed::XStorage > mxTempStorage; |
39 |
- bool bOwnsStorage; |
40 |
+ |
41 |
+ /// bitfield |
42 |
+ bool mbOwnsStorage : 1; |
43 |
+ bool mbUserAllowsLinkUpdate : 1; |
44 |
|
45 |
const uno::Reference < embed::XStorage >& GetReplacements(); |
46 |
}; |
47 |
@@ -116,7 +119,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer() |
48 |
{ |
49 |
pImpl = new EmbedImpl; |
50 |
pImpl->mxStorage = ::comphelper::OStorageHelper::GetTemporaryStorage(); |
51 |
- pImpl->bOwnsStorage = true; |
52 |
+ pImpl->mbOwnsStorage = true; |
53 |
+ pImpl->mbUserAllowsLinkUpdate = true; |
54 |
pImpl->mpTempObjectContainer = 0; |
55 |
} |
56 |
|
57 |
@@ -124,7 +128,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer( const uno::Reference < embed:: |
58 |
{ |
59 |
pImpl = new EmbedImpl; |
60 |
pImpl->mxStorage = rStor; |
61 |
- pImpl->bOwnsStorage = false; |
62 |
+ pImpl->mbOwnsStorage = false; |
63 |
+ pImpl->mbUserAllowsLinkUpdate = true; |
64 |
pImpl->mpTempObjectContainer = 0; |
65 |
} |
66 |
|
67 |
@@ -132,7 +137,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer( const uno::Reference < embed:: |
68 |
{ |
69 |
pImpl = new EmbedImpl; |
70 |
pImpl->mxStorage = rStor; |
71 |
- pImpl->bOwnsStorage = false; |
72 |
+ pImpl->mbOwnsStorage = false; |
73 |
+ pImpl->mbUserAllowsLinkUpdate = true; |
74 |
pImpl->mpTempObjectContainer = 0; |
75 |
pImpl->m_xModel = xModel; |
76 |
} |
77 |
@@ -141,11 +147,11 @@ void EmbeddedObjectContainer::SwitchPersistence( const uno::Reference < embed::X |
78 |
{ |
79 |
ReleaseImageSubStorage(); |
80 |
|
81 |
- if ( pImpl->bOwnsStorage ) |
82 |
+ if ( pImpl->mbOwnsStorage ) |
83 |
pImpl->mxStorage->dispose(); |
84 |
|
85 |
pImpl->mxStorage = rStor; |
86 |
- pImpl->bOwnsStorage = false; |
87 |
+ pImpl->mbOwnsStorage = false; |
88 |
} |
89 |
|
90 |
sal_Bool EmbeddedObjectContainer::CommitImageSubStorage() |
91 |
@@ -201,7 +207,7 @@ EmbeddedObjectContainer::~EmbeddedObjectContainer() |
92 |
{ |
93 |
ReleaseImageSubStorage(); |
94 |
|
95 |
- if ( pImpl->bOwnsStorage ) |
96 |
+ if ( pImpl->mbOwnsStorage ) |
97 |
pImpl->mxStorage->dispose(); |
98 |
|
99 |
delete pImpl->mpTempObjectContainer; |
100 |
@@ -1378,7 +1384,7 @@ sal_Bool EmbeddedObjectContainer::StoreAsChildren(sal_Bool _bOasisFormat,sal_Boo |
101 |
xStream = GetGraphicStream( xObj, &aMediaType ); |
102 |
} |
103 |
|
104 |
- if ( !xStream.is() ) |
105 |
+ if ( !xStream.is() && getUserAllowsLinkUpdate() ) |
106 |
{ |
107 |
// the image must be regenerated |
108 |
// TODO/LATER: another aspect could be used |
109 |
@@ -1667,6 +1673,20 @@ sal_Bool EmbeddedObjectContainer::SetPersistentEntries(const uno::Reference< emb |
110 |
} |
111 |
return bError; |
112 |
} |
113 |
+ |
114 |
+bool EmbeddedObjectContainer::getUserAllowsLinkUpdate() const |
115 |
+{ |
116 |
+ return pImpl->mbUserAllowsLinkUpdate; |
117 |
+} |
118 |
+ |
119 |
+void EmbeddedObjectContainer::setUserAllowsLinkUpdate(bool bNew) |
120 |
+{ |
121 |
+ if(pImpl->mbUserAllowsLinkUpdate != bNew) |
122 |
+ { |
123 |
+ pImpl->mbUserAllowsLinkUpdate = bNew; |
124 |
+ } |
125 |
+} |
126 |
+ |
127 |
} |
128 |
|
129 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
130 |
diff --git a/include/comphelper/embeddedobjectcontainer.hxx b/include/comphelper/embeddedobjectcontainer.hxx |
131 |
index 616ca0f..270ef1b 100644 |
132 |
--- a/comphelper/inc/comphelper/embeddedobjectcontainer.hxx |
133 |
+++ b/comphelper/inc/comphelper/embeddedobjectcontainer.hxx |
134 |
@@ -177,6 +177,9 @@ public: |
135 |
* \return <FALSE/> if no error occurred, otherwise <TRUE/>. |
136 |
*/ |
137 |
sal_Bool SetPersistentEntries(const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& _xStorage,bool _bClearModifedFlag = true); |
138 |
+ |
139 |
+ bool getUserAllowsLinkUpdate() const; |
140 |
+ void setUserAllowsLinkUpdate(bool bNew); |
141 |
}; |
142 |
|
143 |
} |
144 |
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx |
145 |
index e1e4606..878479f 100644 |
146 |
--- a/sfx2/source/appl/linkmgr2.cxx |
147 |
+++ b/sfx2/source/appl/linkmgr2.cxx |
148 |
@@ -328,7 +328,17 @@ void LinkManager::UpdateAllLinks( |
149 |
{ |
150 |
int nRet = QueryBox( pParentWin, WB_YES_NO | WB_DEF_YES, SfxResId( STR_QUERY_UPDATE_LINKS ).toString() ).Execute(); |
151 |
if( RET_YES != nRet ) |
152 |
- return ; // nothing should be updated |
153 |
+ { |
154 |
+ SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist(); |
155 |
+ |
156 |
+ if(pShell) |
157 |
+ { |
158 |
+ comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer(); |
159 |
+ rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false); |
160 |
+ } |
161 |
+ |
162 |
+ return ; // nothing should be updated |
163 |
+ } |
164 |
bAskUpdate = false; // once is enough |
165 |
} |
166 |
|
167 |
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx |
168 |
index fb5f3f2..3aa1f12 100644 |
169 |
--- a/svtools/source/misc/embedhlp.cxx |
170 |
+++ b/svtools/source/misc/embedhlp.cxx |
171 |
@@ -601,19 +601,30 @@ SvStream* EmbeddedObjectRef::GetGraphicStream( bool bUpdate ) const |
172 |
if ( !xStream.is() ) |
173 |
{ |
174 |
RTL_LOGFILE_CONTEXT_TRACE( aLog, "getting stream from object" ); |
175 |
- // update wanted or no stream in container storage available |
176 |
- xStream = GetGraphicReplacementStream( mpImp->nViewAspect, mxObj, &mpImp->aMediaType ); |
177 |
+ bool bUserAllowsLinkUpdate(true); |
178 |
+ const comphelper::EmbeddedObjectContainer* pContainer = GetContainer(); |
179 |
|
180 |
- if ( xStream.is() ) |
181 |
+ if(pContainer) |
182 |
{ |
183 |
- if ( mpImp->pContainer ) |
184 |
- mpImp->pContainer->InsertGraphicStream( xStream, mpImp->aPersistName, mpImp->aMediaType ); |
185 |
+ bUserAllowsLinkUpdate = pContainer->getUserAllowsLinkUpdate(); |
186 |
+ } |
187 |
|
188 |
- SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream ); |
189 |
- if ( pResult && bUpdate ) |
190 |
- mpImp->bNeedUpdate = sal_False; |
191 |
+ if(bUserAllowsLinkUpdate) |
192 |
+ { |
193 |
+ // update wanted or no stream in container storage available |
194 |
+ xStream = GetGraphicReplacementStream(mpImp->nViewAspect, mxObj, &mpImp->aMediaType); |
195 |
|
196 |
- return pResult; |
197 |
+ if(xStream.is()) |
198 |
+ { |
199 |
+ if (mpImp->pContainer) |
200 |
+ mpImp->pContainer->InsertGraphicStream(xStream,mpImp->aPersistName,mpImp->aMediaType); |
201 |
+ |
202 |
+ SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream ); |
203 |
+ if (pResult && bUpdate) |
204 |
+ mpImp->bNeedUpdate = sal_False; |
205 |
+ |
206 |
+ return pResult; |
207 |
+ } |
208 |
} |
209 |
} |
210 |
|
211 |
-- |
212 |
1.9.3 |
213 |
|