diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2008-11-19 13:34:57 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2008-11-19 13:34:57 +0000 |
commit | b2f3ff63bcc2b5de0cab0e308744c6e4280ad050 (patch) | |
tree | e8ede1b612d2ea02d58420e1202d9501a3d46d5f /sfx2/source | |
parent | 42a11be18928a915e7030068f1a83bb9b81201a2 (diff) |
CWS-TOOLING: integrate CWS fwk94_DEV300
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/appl/app.hrc | 2 | ||||
-rw-r--r-- | sfx2/source/appl/app.src | 2 | ||||
-rw-r--r-- | sfx2/source/doc/SfxDocumentMetaData.cxx | 224 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 57 | ||||
-rw-r--r-- | sfx2/source/doc/objmisc.cxx | 43 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 11 | ||||
-rw-r--r-- | sfx2/source/view/topfrm.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 11 |
9 files changed, 208 insertions, 156 deletions
diff --git a/sfx2/source/appl/app.hrc b/sfx2/source/appl/app.hrc index 68c8fbe427..27869b0d3b 100644 --- a/sfx2/source/appl/app.hrc +++ b/sfx2/source/appl/app.hrc @@ -261,7 +261,7 @@ #define RID_XMLSEC_QUERY_LOSINGSIGNATURE (RID_SFX_APP_START + 186) #define RID_XMLSEC_QUERY_SAVEBEFORESIGN (RID_SFX_APP_START + 187) // FREE -#define RID_XMLSEC_DOCUMENTSIGNED (RID_SFX_APP_START + 189) + // FREE #define RID_XMLSEC_INFO_WRONGDOCFORMAT (RID_SFX_APP_START + 190) /* obsolete diff --git a/sfx2/source/appl/app.src b/sfx2/source/appl/app.src index f376598116..64af7744d7 100644 --- a/sfx2/source/appl/app.src +++ b/sfx2/source/appl/app.src @@ -1100,7 +1100,7 @@ InfoBox RID_XMLSEC_INFO_WRONGDOCFORMAT String RID_XMLSEC_DOCUMENTSIGNED { - Text [ en-US ] = "(Signed)" ; + Text [ en-US ] = " (Signed)" ; }; Image IMG_MISSING_1 diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index fecbd1ce85..98dd3cd31e 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: SfxDocumentMetaData.cxx,v $ - * $Revision: 1.10 $ + * $Revision: 1.10.32.2 $ * * This file is part of OpenOffice.org. * @@ -355,8 +355,12 @@ private: ::rtl::OUString SAL_CALL getMetaText(const char* i_name) const; // throw (css::uno::RuntimeException); /// set text of standard meta data element iff not equal to existing text - void SAL_CALL setMetaText(const char* i_name, - const ::rtl::OUString & i_rValue, bool i_notifyModified = true); + bool SAL_CALL setMetaText(const char* i_name, + const ::rtl::OUString & i_rValue); + // throw (css::uno::RuntimeException); + /// set text of standard meta data element iff not equal to existing text + void SAL_CALL setMetaTextAndNotify(const char* i_name, + const ::rtl::OUString & i_rValue); // throw (css::uno::RuntimeException); /// get text of standard meta data element's attribute ::rtl::OUString SAL_CALL getMetaAttr(const char* i_name, @@ -367,9 +371,9 @@ private: const char* i_name) const; // throw (css::uno::RuntimeException); /// set text of a list of standard meta data elements (multiple occ.) - void SAL_CALL setMetaList(const char* i_name, + bool SAL_CALL setMetaList(const char* i_name, const css::uno::Sequence< ::rtl::OUString > & i_rValue, - AttrVector const* = 0, bool i_notifyModified = true); + AttrVector const* = 0); // throw (css::uno::RuntimeException); }; @@ -660,21 +664,21 @@ SfxDocumentMetaData::getMetaText(const char* i_name) const { checkInit(); - ::rtl::OUString name = ::rtl::OUString::createFromAscii(i_name); + const ::rtl::OUString name( ::rtl::OUString::createFromAscii(i_name) ); DBG_ASSERT(m_meta.find(name) != m_meta.end(), "SfxDocumentMetaData::getMetaText: not found"); css::uno::Reference<css::xml::dom::XNode> xNode = m_meta.find(name)->second; return (xNode.is()) ? getNodeText(xNode) : ::rtl::OUString(); } -void SAL_CALL +bool SAL_CALL SfxDocumentMetaData::setMetaText(const char* i_name, - const ::rtl::OUString & i_rValue, bool i_notifyModified) + const ::rtl::OUString & i_rValue) // throw (css::uno::RuntimeException) { checkInit(); - ::rtl::OUString name = ::rtl::OUString::createFromAscii(i_name); + const ::rtl::OUString name( ::rtl::OUString::createFromAscii(i_name) ); DBG_ASSERT(m_meta.find(name) != m_meta.end(), "SfxDocumentMetaData::setMetaText: not found"); css::uno::Reference<css::xml::dom::XNode> xNode = m_meta.find(name)->second; @@ -685,9 +689,9 @@ SfxDocumentMetaData::setMetaText(const char* i_name, m_xParent->removeChild(xNode); xNode.clear(); m_meta[name] = xNode; - if (i_notifyModified) { - setModified(true); - } + return true; + } else { + return false; } } else { if (xNode.is()) { // update @@ -698,11 +702,10 @@ SfxDocumentMetaData::setMetaText(const char* i_name, if (c->getNodeType() == css::xml::dom::NodeType_TEXT_NODE) { if (!c->getNodeValue().equals(i_rValue)) { c->setNodeValue(i_rValue); - if (i_notifyModified) { - setModified(true); - } + return true; + } else { + return false; } - return; } } } else { // insert @@ -714,9 +717,7 @@ SfxDocumentMetaData::setMetaText(const char* i_name, css::uno::Reference<css::xml::dom::XNode> xTextNode( m_xDoc->createTextNode(i_rValue), css::uno::UNO_QUERY_THROW); xNode->appendChild(xTextNode); - if (i_notifyModified) { - setModified(true); - } + return true; } } catch (css::xml::dom::DOMException & e) { css::uno::Any a(e); @@ -727,6 +728,18 @@ SfxDocumentMetaData::setMetaText(const char* i_name, } } +void SAL_CALL +SfxDocumentMetaData::setMetaTextAndNotify(const char* i_name, + const ::rtl::OUString & i_rValue) + // throw (css::uno::RuntimeException) +{ + ::osl::ClearableMutexGuard g(m_aMutex); + if (setMetaText(i_name, i_rValue)) { + g.clear(); + setModified(true); + } +} + ::rtl::OUString SAL_CALL SfxDocumentMetaData::getMetaAttr(const char* i_name, const char* i_attr) const // throw (css::uno::RuntimeException) @@ -763,10 +776,10 @@ SfxDocumentMetaData::getMetaList(const char* i_name) const return ret; } -void SAL_CALL +bool SAL_CALL SfxDocumentMetaData::setMetaList(const char* i_name, const css::uno::Sequence< ::rtl::OUString> & i_rValue, - AttrVector const* i_pAttrs, bool i_notifyModified) + AttrVector const* i_pAttrs) // throw (css::uno::RuntimeException) { checkInit(); @@ -783,7 +796,7 @@ SfxDocumentMetaData::setMetaList(const char* i_name, // if nothing changed, do nothing // alas, this does not check for permutations, or attributes... - if (i_notifyModified && (0 == i_pAttrs)) { + if ((0 == i_pAttrs)) { if (static_cast<size_t>(i_rValue.getLength()) == vec.size()) { bool isEqual(true); for (sal_Int32 i = 0; i < i_rValue.getLength(); ++i) { @@ -796,18 +809,28 @@ SfxDocumentMetaData::setMetaList(const char* i_name, } } } - if (isEqual) return; + if (isEqual) return false; } } // remove old meta data nodes - for (std::vector<css::uno::Reference<css::xml::dom::XNode> > - ::reverse_iterator it = vec.rbegin(); it != vec.rend(); ) { - m_xParent->removeChild(*it); - ++it; - vec.pop_back(); + { + std::vector<css::uno::Reference<css::xml::dom::XNode> > + ::reverse_iterator it(vec.rbegin()); + try { + for ( ;it != vec.rend(); ++it) + { + m_xParent->removeChild(*it); + } + } + catch (...) + { + // Clean up already removed nodes + vec.erase(it.base(), vec.end()); + throw; + } + vec.clear(); } -// vec.clear(); // not so good in case of exception // insert new meta data nodes into DOM tree for (sal_Int32 i = 0; i < i_rValue.getLength(); ++i) { @@ -832,6 +855,8 @@ SfxDocumentMetaData::setMetaList(const char* i_name, m_xParent->appendChild(xNode); vec.push_back(xNode); } + + return true; } catch (css::xml::dom::DOMException & e) { css::uno::Any a(e); throw css::lang::WrappedTargetRuntimeException( @@ -839,10 +864,6 @@ SfxDocumentMetaData::setMetaList(const char* i_name, "SfxDocumentMetaData::setMetaList: DOM exception"), css::uno::Reference<css::uno::XInterface>(*this), a); } - - if (i_notifyModified) { - setModified(true); - } } // convert property list to string list and attribute list @@ -979,8 +1000,8 @@ void SAL_CALL SfxDocumentMetaData::updateUserDefinedAndAttributes() css::uno::UNO_QUERY_THROW); std::pair<css::uno::Sequence< ::rtl::OUString>, AttrVector> udStringsAttrs = propsToStrings(xPSet); - setMetaList("meta:user-defined", udStringsAttrs.first, - &udStringsAttrs.second, false); + (void) setMetaList("meta:user-defined", udStringsAttrs.first, + &udStringsAttrs.second); // update elements with attributes std::vector<std::pair<const char *, ::rtl::OUString> > attributes; @@ -1378,8 +1399,7 @@ SfxDocumentMetaData::getAuthor() throw (css::uno::RuntimeException) void SAL_CALL SfxDocumentMetaData::setAuthor(const ::rtl::OUString & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); - setMetaText("meta:initial-creator", the_value); + setMetaTextAndNotify("meta:initial-creator", the_value); } @@ -1394,8 +1414,7 @@ void SAL_CALL SfxDocumentMetaData::setGenerator(const ::rtl::OUString & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); - setMetaText("meta:generator", the_value); + setMetaTextAndNotify("meta:generator", the_value); } css::util::DateTime SAL_CALL @@ -1409,8 +1428,7 @@ void SAL_CALL SfxDocumentMetaData::setCreationDate(const css::util::DateTime & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); - setMetaText("meta:creation-date", dateTimeToText(the_value)); + setMetaTextAndNotify("meta:creation-date", dateTimeToText(the_value)); } ::rtl::OUString SAL_CALL @@ -1423,8 +1441,7 @@ SfxDocumentMetaData::getTitle() throw (css::uno::RuntimeException) void SAL_CALL SfxDocumentMetaData::setTitle(const ::rtl::OUString & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); - setMetaText("dc:title", the_value); + setMetaTextAndNotify("dc:title", the_value); } ::rtl::OUString SAL_CALL @@ -1438,8 +1455,7 @@ void SAL_CALL SfxDocumentMetaData::setSubject(const ::rtl::OUString & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); - setMetaText("dc:subject", the_value); + setMetaTextAndNotify("dc:subject", the_value); } ::rtl::OUString SAL_CALL @@ -1453,8 +1469,7 @@ void SAL_CALL SfxDocumentMetaData::setDescription(const ::rtl::OUString & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); - setMetaText("dc:description", the_value); + setMetaTextAndNotify("dc:description", the_value); } css::uno::Sequence< ::rtl::OUString > @@ -1469,8 +1484,11 @@ SfxDocumentMetaData::setKeywords( const css::uno::Sequence< ::rtl::OUString > & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); - setMetaList("meta:keyword", the_value); + ::osl::ClearableMutexGuard g(m_aMutex); + if (setMetaList("meta:keyword", the_value)) { + g.clear(); + setModified(true); + } } css::lang::Locale SAL_CALL @@ -1493,12 +1511,11 @@ void SAL_CALL SfxDocumentMetaData::setLanguage(const css::lang::Locale & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); ::rtl::OUString text = the_value.Language; if (the_value.Country.getLength() > 0) { text += ::rtl::OUString::createFromAscii("-").concat(the_value.Country); } - setMetaText("dc:language", text); + setMetaTextAndNotify("dc:language", text); } ::rtl::OUString SAL_CALL @@ -1512,8 +1529,7 @@ void SAL_CALL SfxDocumentMetaData::setModifiedBy(const ::rtl::OUString & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); - setMetaText("dc:creator", the_value); + setMetaTextAndNotify("dc:creator", the_value); } css::util::DateTime SAL_CALL @@ -1527,8 +1543,7 @@ void SAL_CALL SfxDocumentMetaData::setModificationDate(const css::util::DateTime & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); - setMetaText("dc:date", dateTimeToText(the_value)); + setMetaTextAndNotify("dc:date", dateTimeToText(the_value)); } ::rtl::OUString SAL_CALL @@ -1542,8 +1557,7 @@ void SAL_CALL SfxDocumentMetaData::setPrintedBy(const ::rtl::OUString & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); - setMetaText("meta:printed-by", the_value); + setMetaTextAndNotify("meta:printed-by", the_value); } css::util::DateTime SAL_CALL @@ -1557,8 +1571,7 @@ void SAL_CALL SfxDocumentMetaData::setPrintDate(const css::util::DateTime & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); - setMetaText("meta:print-date", dateTimeToText(the_value)); + setMetaTextAndNotify("meta:print-date", dateTimeToText(the_value)); } ::rtl::OUString SAL_CALL @@ -1573,10 +1586,11 @@ void SAL_CALL SfxDocumentMetaData::setTemplateName(const ::rtl::OUString & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); + ::osl::ClearableMutexGuard g(m_aMutex); checkInit(); if (m_TemplateName != the_value) { m_TemplateName = the_value; + g.clear(); setModified(true); } } @@ -1593,10 +1607,11 @@ void SAL_CALL SfxDocumentMetaData::setTemplateURL(const ::rtl::OUString & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); + ::osl::ClearableMutexGuard g(m_aMutex); checkInit(); if (m_TemplateURL != the_value) { m_TemplateURL = the_value; + g.clear(); setModified(true); } } @@ -1613,10 +1628,11 @@ void SAL_CALL SfxDocumentMetaData::setTemplateDate(const css::util::DateTime & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); + ::osl::ClearableMutexGuard g(m_aMutex); checkInit(); if (!(m_TemplateDate == the_value)) { m_TemplateDate = the_value; + g.clear(); setModified(true); } } @@ -1633,10 +1649,11 @@ void SAL_CALL SfxDocumentMetaData::setAutoloadURL(const ::rtl::OUString & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); + ::osl::ClearableMutexGuard g(m_aMutex); checkInit(); if (m_AutoloadURL != the_value) { m_AutoloadURL = the_value; + g.clear(); setModified(true); } } @@ -1657,10 +1674,11 @@ SfxDocumentMetaData::setAutoloadSecs(::sal_Int32 the_value) ::rtl::OUString::createFromAscii( "SfxDocumentMetaData::setAutoloadSecs: argument is negative"), *this, 0); - ::osl::MutexGuard g(m_aMutex); + ::osl::ClearableMutexGuard g(m_aMutex); checkInit(); if (m_AutoloadSecs != the_value) { m_AutoloadSecs = the_value; + g.clear(); setModified(true); } } @@ -1677,10 +1695,11 @@ void SAL_CALL SfxDocumentMetaData::setDefaultTarget(const ::rtl::OUString & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); + ::osl::ClearableMutexGuard g(m_aMutex); checkInit(); if (m_DefaultTarget != the_value) { m_DefaultTarget = the_value; + g.clear(); setModified(true); } } @@ -1718,7 +1737,7 @@ SfxDocumentMetaData::setDocumentStatistics( const css::uno::Sequence< css::beans::NamedValue > & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); + ::osl::ClearableMutexGuard g(m_aMutex); checkInit(); std::vector<std::pair<const char *, ::rtl::OUString> > attributes; for (sal_Int32 i = 0; i < the_value.getLength(); ++i) { @@ -1743,6 +1762,7 @@ SfxDocumentMetaData::setDocumentStatistics( } } updateElement("meta:document-statistic", &attributes); + g.clear(); setModified(true); } @@ -1768,10 +1788,9 @@ SfxDocumentMetaData::setEditingCycles(::sal_Int16 the_value) ::rtl::OUString::createFromAscii( "SfxDocumentMetaData::setEditingCycles: argument is negative"), *this, 0); - ::osl::MutexGuard g(m_aMutex); ::rtl::OUStringBuffer buf; ::sax::Converter::convertNumber(buf, the_value); - setMetaText("meta:editing-cycles", buf.makeStringAndClear()); + setMetaTextAndNotify("meta:editing-cycles", buf.makeStringAndClear()); } ::sal_Int32 SAL_CALL @@ -1789,31 +1808,34 @@ SfxDocumentMetaData::setEditingDuration(::sal_Int32 the_value) ::rtl::OUString::createFromAscii( "SfxDocumentMetaData::setEditingDuration: argument is negative"), *this, 0); - ::osl::MutexGuard g(m_aMutex); - setMetaText("meta:editing-duration", durationToText(the_value)); + setMetaTextAndNotify("meta:editing-duration", durationToText(the_value)); } void SAL_CALL SfxDocumentMetaData::resetUserData(const ::rtl::OUString & the_value) throw (css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); + ::osl::ClearableMutexGuard g(m_aMutex); - setMetaText("meta:initial-creator", the_value, false); + bool bModified( false ); + bModified |= setMetaText("meta:initial-creator", the_value); ::DateTime now = DateTime(); css::util::DateTime uDT(now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(), now.GetDay(), now.GetMonth(), now.GetYear()); - setMetaText("meta:creation-date", dateTimeToText(uDT), false); - setMetaText("dc:creator", ::rtl::OUString(), false); - setMetaText("meta:printed-by", ::rtl::OUString(), false); - setMetaText("dc:date", dateTimeToText(css::util::DateTime()), false); - setMetaText("meta:print-date", - dateTimeToText(css::util::DateTime()), false); - setMetaText("meta:editing-duration", durationToText(0), false); - setMetaText("meta:editing-cycles", - ::rtl::OUString::createFromAscii("1"), false); + bModified |= setMetaText("meta:creation-date", dateTimeToText(uDT)); + bModified |= setMetaText("dc:creator", ::rtl::OUString()); + bModified |= setMetaText("meta:printed-by", ::rtl::OUString()); + bModified |= setMetaText("dc:date", dateTimeToText(css::util::DateTime())); + bModified |= setMetaText("meta:print-date", + dateTimeToText(css::util::DateTime())); + bModified |= setMetaText("meta:editing-duration", durationToText(0)); + bModified |= setMetaText("meta:editing-cycles", + ::rtl::OUString::createFromAscii("1")); - setModified(true); + if (bModified) { + g.clear(); + setModified(true); + } } @@ -2160,16 +2182,24 @@ SfxDocumentMetaData::createClone() throw (css::uno::RuntimeException) { ::osl::MutexGuard g(m_aMutex); + checkInit(); css::uno::Reference<css::util::XModifiable> xMB(m_xUserDefined, - css::uno::UNO_QUERY_THROW); - return m_isModified || xMB->isModified(); + css::uno::UNO_QUERY); + return m_isModified || (xMB.is() ? xMB->isModified() : sal_False); } void SAL_CALL SfxDocumentMetaData::setModified( ::sal_Bool bModified ) throw (css::beans::PropertyVetoException, css::uno::RuntimeException) { - ::osl::MutexGuard g(m_aMutex); - m_isModified = bModified; + css::uno::Reference<css::util::XModifiable> xMB; + { // do not lock mutex while notifying (#i93514#) to prevent deadlock + ::osl::MutexGuard g(m_aMutex); + checkInit(); + m_isModified = bModified; + xMB.set(m_xUserDefined, css::uno::UNO_QUERY); + DBG_ASSERT(xMB.is(), + "SfxDocumentMetaData::setModified: PropertyBag not Modifiable?"); + } if (bModified) { try { css::uno::Reference<css::uno::XInterface> xThis(*this); @@ -2185,9 +2215,9 @@ void SAL_CALL SfxDocumentMetaData::setModified( ::sal_Bool bModified ) (void) e; } } else { - css::uno::Reference<css::util::XModifiable> xMB(m_xUserDefined, - css::uno::UNO_QUERY_THROW); - xMB->setModified(false); + if (xMB.is()) { + xMB->setModified(false); + } } } @@ -2196,20 +2226,28 @@ void SAL_CALL SfxDocumentMetaData::addModifyListener( const css::uno::Reference< css::util::XModifyListener > & xListener) throw (css::uno::RuntimeException) { + ::osl::MutexGuard g(m_aMutex); + checkInit(); m_NotifyListeners.addInterface(xListener); css::uno::Reference<css::util::XModifyBroadcaster> xMB(m_xUserDefined, - css::uno::UNO_QUERY_THROW); - xMB->addModifyListener(xListener); + css::uno::UNO_QUERY); + if (xMB.is()) { + xMB->addModifyListener(xListener); + } } void SAL_CALL SfxDocumentMetaData::removeModifyListener( const css::uno::Reference< css::util::XModifyListener > & xListener) throw (css::uno::RuntimeException) { + ::osl::MutexGuard g(m_aMutex); + checkInit(); m_NotifyListeners.removeInterface(xListener); css::uno::Reference<css::util::XModifyBroadcaster> xMB(m_xUserDefined, - css::uno::UNO_QUERY_THROW); - xMB->removeModifyListener(xListener); + css::uno::UNO_QUERY); + if (xMB.is()) { + xMB->removeModifyListener(xListener); + } } // ::com::sun::star::xml::sax::XSAXSerializable diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index da0dc6e7a0..399f098155 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -1559,7 +1559,12 @@ void SfxMedium::SetOpenMode( StreamMode nStorOpen, nStorOpenMode = nStorOpen; if( !bDontClose ) - Close(); + { + if ( pImp->xStorage.is() ) + CloseStorage(); + + CloseStreams_Impl(); + } } bDirect = bDirectP; @@ -1691,7 +1696,11 @@ sal_Bool SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource, if( !eError || (eError & ERRCODE_WARNING_MASK) ) { - Close(); + if ( pImp->xStorage.is() ) + CloseStorage(); + + CloseStreams_Impl(); + ::ucbhelper::Content aTempCont; if( ::ucbhelper::Content::create( aSource.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv, aTempCont ) ) { @@ -1872,7 +1881,10 @@ void SfxMedium::Transfer_Impl() if( pOutStreamItem && ( pOutStreamItem->GetValue() >>= rOutStream ) ) { // write directly to the stream - Close(); + if ( pImp->xStorage.is() ) + CloseStorage(); + + CloseStreams_Impl(); INetURLObject aSource( aNameURL ); ::ucbhelper::Content aTempCont; @@ -1993,7 +2005,11 @@ void SfxMedium::Transfer_Impl() xStor->Commit(); // take new unpacked storage as own storage - Close(); + if ( pImp->xStorage.is() ) + CloseStorage(); + + CloseStreams_Impl(); + DELETEZ( pImp->pTempFile ); ::utl::LocalFileHelper::ConvertURLToPhysicalName( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), aName ); SetStorage_Impl( xStor ); @@ -2055,7 +2071,11 @@ void SfxMedium::Transfer_Impl() if ( !eError || (eError & ERRCODE_WARNING_MASK) ) { // free resources, otherwise the transfer may fail - Close(); + if ( pImp->xStorage.is() ) + CloseStorage(); + + CloseStreams_Impl(); + // don't create content before Close(), because if the storage was opened in direct mode, it will be flushed // in Close() and this leads to a transfer command executed in the package, which currently is implemented as // remove+move in the file FCP. The "remove" is notified to the ::ucbhelper::Content, that clears its URL and its @@ -2360,13 +2380,7 @@ void SfxMedium::GetMedium_Impl() sal_Bool bReadOnly = sal_False; aMedium[comphelper::MediaDescriptor::PROP_READONLY()] >>= bReadOnly; if ( bReadOnly ) - { - SFX_ITEMSET_ARG( GetItemSet(), pROItem, SfxBoolItem, SID_DOC_READONLY, sal_False); - BOOL bForceWritable = ( pROItem && !pROItem->GetValue() ); GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) ); - if( bForceWritable ) - SetError( ERRCODE_IO_ACCESSDENIED ); - } //TODO/MBA: what happens if property is not there?! GetContent(); @@ -2894,26 +2908,6 @@ void SfxMedium::SetPhysicalName_Impl( const String& rNameP ) } //---------------------------------------------------------------- -void SfxMedium::MoveStorageTo_Impl( SfxMedium* pMedium ) -{ - if ( pMedium && pMedium != this && pImp->xStorage.is() ) - { - if( pMedium->pImp->pTempFile ) - { - pMedium->pImp->pTempFile->EnableKillingFile( sal_True ); - delete pMedium->pImp->pTempFile; - pMedium->pImp->pTempFile = NULL; - } - - pMedium->Close(); - pMedium->aName = aName; - pMedium->pImp->xStorage = pImp->xStorage; - - CanDisposeStorage_Impl( sal_False ); - } -} - -//---------------------------------------------------------------- void SfxMedium::MoveTempTo_Impl( SfxMedium* pMedium ) { if ( pMedium && pMedium != this && pImp->pTempFile ) @@ -2996,6 +2990,7 @@ void SfxMedium::CompleteReOpen() { pTmpFile->EnableKillingFile( sal_True ); delete pTmpFile; + } pImp->bUseInteractionHandler = bUseInteractionHandler; diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 84f764e03d..4b80f4c358 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: objmisc.cxx,v $ - * $Revision: 1.102 $ + * $Revision: 1.102.104.1 $ * * This file is part of OpenOffice.org. * @@ -535,7 +535,23 @@ sal_Bool SfxObjectShell::SwitchToShared( sal_Bool bShared, sal_Bool bSave ) sal_Bool bOldValue = HasSharedXMLFlagSet(); SetSharedXMLFlag( bShared ); - if ( bSave ) + ::rtl::OUString aOrigURL = GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); + sal_Bool bRemoveEntryOnError = sal_False; + if ( bResult && bShared ) + { + try + { + ::svt::ShareControlFile aControlFile( aOrigURL ); + aControlFile.InsertOwnEntry(); + bRemoveEntryOnError = sal_True; + } + catch( uno::Exception& ) + { + bResult = sal_False; + } + } + + if ( bResult && bSave ) { SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst( this ); @@ -553,17 +569,6 @@ sal_Bool SfxObjectShell::SwitchToShared( sal_Bool bShared, sal_Bool bSave ) // TODO/LATER: Is it possible that the following calls fail? if ( bShared ) { - ::rtl::OUString aOrigURL = GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); - try - { - ::svt::ShareControlFile aControlFile( aOrigURL ); - aControlFile.InsertOwnEntry(); - } - catch( uno::Exception& ) - { - // TODO/LATER: in future the switching should not happen and an error should be shown - } - pImp->m_aSharedFileURL = aOrigURL; GetMedium()->SwitchDocumentToTempFile(); } @@ -578,6 +583,7 @@ sal_Bool SfxObjectShell::SwitchToShared( sal_Bool bShared, sal_Bool bSave ) try { + // aOrigURL can not be used since it contains an old value ::svt::ShareControlFile aControlFile( GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ); aControlFile.RemoveFile(); } @@ -589,6 +595,17 @@ sal_Bool SfxObjectShell::SwitchToShared( sal_Bool bShared, sal_Bool bSave ) else { // the saving has failed! + if ( bRemoveEntryOnError ) + { + try + { + ::svt::ShareControlFile aControlFile( aOrigURL ); + aControlFile.RemoveEntry(); + } + catch( uno::Exception& ) + {} + } + SetSharedXMLFlag( bOldValue ); } } diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 828428c2a3..c37fa706d4 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -649,10 +649,9 @@ sal_Bool SfxObjectShell::DoLoad( SfxMedium *pMed ) EnableSetModified( sal_False ); + pMedium->LockOrigFileOnDemand( sal_True ); if ( GetError() == ERRCODE_NONE && bOwnStorageFormat && ( !pFilter || !( pFilter->GetFilterFlags() & SFX_FILTER_STARONEFILTER ) ) ) { - pMedium->LockOrigFileOnDemand( sal_True ); - uno::Reference< embed::XStorage > xStorage; if ( pMedium->GetError() == ERRCODE_NONE ) xStorage = pMedium->GetStorage(); @@ -1301,9 +1300,9 @@ sal_Bool SfxObjectShell::SaveTo_Impl if( rMedium.GetErrorCode() || pMedium->GetErrorCode() || GetErrorCode() ) return sal_False; + rMedium.LockOrigFileOnDemand( sal_False ); if ( bStorageBasedTarget ) { - rMedium.LockOrigFileOnDemand( sal_False ); if ( rMedium.GetErrorCode() ) return sal_False; diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index eab78c1198..4793f8d074 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -3585,10 +3585,21 @@ css::uno::Reference< css::frame::XUntitledNumbers > SfxBaseModel::impl_getUntitl ::rtl::OUString aResult = impl_getTitleHelper()->getTitle (); if ( m_pData->m_pObjectShell ) { + SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium(); + if ( pMedium ) + { + SFX_ITEMSET_ARG( pMedium->GetItemSet(), pRepairedDocItem, SfxBoolItem, SID_REPAIRPACKAGE, sal_False ); + if ( pRepairedDocItem && pRepairedDocItem->GetValue() ) + aResult += String( SfxResId(STR_REPAIREDDOCUMENT) ); + } + if ( m_pData->m_pObjectShell->IsReadOnlyUI() || m_pData->m_pObjectShell->GetMedium() && m_pData->m_pObjectShell->GetMedium()->IsReadOnly() ) aResult += ::rtl::OUString( String( SfxResId(STR_READONLY) ) ); else if ( m_pData->m_pObjectShell->IsDocShared() ) aResult += ::rtl::OUString( String( SfxResId(STR_SHARED) ) ); + + if ( m_pData->m_pObjectShell->GetDocumentSignatureState() == SIGNATURESTATE_SIGNATURES_OK ) + aResult += String( SfxResId( RID_XMLSEC_DOCUMENTSIGNED ) ); } return aResult; diff --git a/sfx2/source/view/topfrm.cxx b/sfx2/source/view/topfrm.cxx index 2b1ccdfbc9..b1bd3089bc 100644 --- a/sfx2/source/view/topfrm.cxx +++ b/sfx2/source/view/topfrm.cxx @@ -73,7 +73,6 @@ #include <unotools/bootstrap.hxx> #include <sfxresid.hxx> -#include <../appl/app.hrc> // wg. pTopFrames #include "appdata.hxx" @@ -1088,14 +1087,6 @@ String SfxTopViewFrame::UpdateTitle() String aTitle = SfxViewFrame::UpdateTitle(); - // xmlsec05, check with SFX team - if ( GetObjectShell()->GetDocumentSignatureState() == SIGNATURESTATE_SIGNATURES_OK ) - { - aTitle += String::CreateFromAscii( " " ); - aTitle += String( SfxResId( RID_XMLSEC_DOCUMENTSIGNED ) ); - aTitle += String::CreateFromAscii( " " ); - } - ::rtl::OUString aProductName; ::utl::ConfigManager::GetDirectConfigProperty(::utl::ConfigManager::PRODUCTNAME) >>= aProductName; diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 945a9c95e6..5d7f9b9645 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -473,8 +473,11 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) ); pMed->SetOpenMode( nOpenMode, pMed->IsDirect() ); pMed->CompleteReOpen(); - if ( bHasStorage ) - pMed->LockOrigFileOnDemand( sal_True ); + if ( nOpenMode & STREAM_WRITE ) + pMed->LockOrigFileOnDemand( sal_False ); + + // LockOrigFileOnDemand might set the readonly flag itself, it should be set back + pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) ); if ( !pMed->GetErrorCode() ) bOK = sal_True; @@ -774,9 +777,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) { // back to old medium pMedium->ReOpen(); - - if ( bHasStorage ) - pMedium->LockOrigFileOnDemand( sal_True ); + pMedium->LockOrigFileOnDemand( sal_True ); xOldObj->DoSaveCompleted( pMedium ); } |