[Libreoffice-commits] core.git: 2 commits - include/sfx2 sfx2/source sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Mar 9 15:02:21 UTC 2016
include/sfx2/sfx.hrc | 2
sfx2/source/view/view.src | 10 ++++
sw/qa/extras/rtfexport/data/custom-doc-props.rtf | 10 ++++
sw/qa/extras/rtfexport/rtfexport.cxx | 10 ++++
sw/qa/extras/rtfimport/data/custom-doc-props.rtf | 10 ----
sw/qa/extras/rtfimport/rtfimport.cxx | 10 ----
sw/source/filter/ww8/rtfexport.cxx | 53 +++++++++++++++++++++++
sw/source/filter/ww8/rtfexport.hxx | 2
sw/source/ui/app/app.src | 10 ----
sw/source/uibase/dochdl/swdtflvr.cxx | 5 +-
sw/source/uibase/inc/app.hrc | 4 -
11 files changed, 91 insertions(+), 35 deletions(-)
New commits:
commit 1f7af133d9bade2cf226b65fab501d68113f8cc6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Mar 9 15:38:03 2016 +0100
Move classified copy/paste strings from sw to sfx2
So that other modules can use them as well. The RTF import in
writerfilter is one potential user.
Change-Id: Ib009e1be2aff14d0fcac643c0c6000d2895515b0
diff --git a/include/sfx2/sfx.hrc b/include/sfx2/sfx.hrc
index a0d1ae3..af7fb1e 100644
--- a/include/sfx2/sfx.hrc
+++ b/include/sfx2/sfx.hrc
@@ -154,6 +154,8 @@
#define STR_PASSWD_MIN_LEN1 (RID_SFX_START+129)
#define STR_MODULENOTINSTALLED (RID_SFX_START+130)
#define STR_CLASSIFIED_DOCUMENT (RID_SFX_START+131)
+#define STR_TARGET_DOC_NOT_CLASSIFIED (RID_SFX_START+132)
+#define STR_DOC_CLASSIFICATION_TOO_LOW (RID_SFX_START+133)
#define STR_ACCTITLE_PRODUCTIVITYTOOLS (RID_SFX_START+157)
#define SFX_THUMBNAIL_TEXT (RID_SFX_START+158)
diff --git a/sfx2/source/view/view.src b/sfx2/source/view/view.src
index 26dbbbd..81718cc 100644
--- a/sfx2/source/view/view.src
+++ b/sfx2/source/view/view.src
@@ -96,6 +96,16 @@ String STR_CLASSIFIED_DOCUMENT
Text [ en-US ] = "The classification label of this document is %1." ;
};
+String STR_TARGET_DOC_NOT_CLASSIFIED
+{
+ Text [ en-US ] = "This document must be classified before the clipboard can be pasted." ;
+};
+
+String STR_DOC_CLASSIFICATION_TOO_LOW
+{
+ Text [ en-US ] = "This document has a lower classificaton level than the clipboard." ;
+};
+
PushButton BT_CHECKOUT
{
Pos = MAP_APPFONT( 0 , 0 );
diff --git a/sw/source/ui/app/app.src b/sw/source/ui/app/app.src
index 0b56c96..74c3ce1 100644
--- a/sw/source/ui/app/app.src
+++ b/sw/source/ui/app/app.src
@@ -647,14 +647,4 @@ String STR_SRTERR
Text [ en-US ] = "Cannot sort selection" ;
};
-String STR_TARGET_DOC_NOT_CLASSIFIED
-{
- Text [ en-US ] = "This document must be classified before the clipboard can be pasted." ;
-};
-
-String STR_DOC_CLASSIFICATION_TOO_LOW
-{
- Text [ en-US ] = "This document has a lower classificaton level than the clipboard." ;
-};
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index fb46de91..76ffde6 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -128,6 +128,7 @@
#include <vcl/GraphicNativeMetadata.hxx>
#include <comphelper/lok.hxx>
#include <sfx2/classificationhelper.hxx>
+#include <sfx2/sfxresid.hxx>
#include <memory>
@@ -3231,13 +3232,13 @@ bool lcl_checkClassification(SwDoc* pSourceDoc, SwDoc* pDestinationDoc)
break;
case SfxClassificationCheckPasteResult::TargetDocNotClassified:
{
- ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SW_RES(STR_TARGET_DOC_NOT_CLASSIFIED), VCL_MESSAGE_INFO)->Execute();
+ ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SfxResId(STR_TARGET_DOC_NOT_CLASSIFIED), VCL_MESSAGE_INFO)->Execute();
return false;
}
break;
case SfxClassificationCheckPasteResult::DocClassificationTooLow:
{
- ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SW_RES(STR_DOC_CLASSIFICATION_TOO_LOW), VCL_MESSAGE_INFO)->Execute();
+ ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SfxResId(STR_DOC_CLASSIFICATION_TOO_LOW), VCL_MESSAGE_INFO)->Execute();
return false;
}
break;
diff --git a/sw/source/uibase/inc/app.hrc b/sw/source/uibase/inc/app.hrc
index aab6fd9..b5264d6 100644
--- a/sw/source/uibase/inc/app.hrc
+++ b/sw/source/uibase/inc/app.hrc
@@ -91,10 +91,8 @@
#define STR_ERR_TABLE_MERGE (RC_APP_BEGIN + 137)
#define STR_WRONG_TABLENAME (RC_APP_BEGIN + 138)
#define STR_SRTERR (RC_APP_BEGIN + 139)
-#define STR_TARGET_DOC_NOT_CLASSIFIED (RC_APP_BEGIN + 140)
-#define STR_DOC_CLASSIFICATION_TOO_LOW (RC_APP_BEGIN + 141)
-#define APP_ACT_END STR_DOC_CLASSIFICATION_TOO_LOW
+#define APP_ACT_END STR_SRTERR
#if APP_ACT_END > RC_APP_END
#error Resource-Id Ueberlauf in #file, #line
commit 2e1a6ba26fd0cb251f831dd2a0f60103ca1342e2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Mar 9 14:41:10 2016 +0100
RTF export: write user-defined document properties
Change-Id: I07dfd626f7d248e264fd1724f6f2bd1241be39d0
diff --git a/sw/qa/extras/rtfimport/data/custom-doc-props.rtf b/sw/qa/extras/rtfexport/data/custom-doc-props.rtf
similarity index 100%
rename from sw/qa/extras/rtfimport/data/custom-doc-props.rtf
rename to sw/qa/extras/rtfexport/data/custom-doc-props.rtf
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 60a2293..24faee2 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -989,6 +989,16 @@ DECLARE_RTFEXPORT_TEST(testRedline, "redline.rtf")
CPPUNIT_ASSERT_EQUAL(OUString("Dorothy Jones"), getProperty<OUString>(getRun(getParagraph(2), 2), "RedlineAuthor"));
}
+DECLARE_RTFEXPORT_TEST(testCustomDocProps, "custom-doc-props.rtf")
+{
+ // Custom document properties were not improved, this resulted in a beans::UnknownPropertyException.
+ uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();
+ uno::Reference<beans::XPropertyContainer> xUserDefinedProperties = xDocumentProperties->getUserDefinedProperties();
+ CPPUNIT_ASSERT_EQUAL(OUString("2016-03-08T10:55:18,531376147"), getProperty<OUString>(xUserDefinedProperties, "urn:bails:IntellectualProperty:Authorization:StartValidity"));
+ CPPUNIT_ASSERT_EQUAL(OUString("None"), getProperty<OUString>(xUserDefinedProperties, "urn:bails:IntellectualProperty:Authorization:StopValidity"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 6ee8729..d98b9b9 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2525,16 +2525,6 @@ DECLARE_RTFIMPORT_TEST(testTdf87034, "tdf87034.rtf")
CPPUNIT_ASSERT_EQUAL(OUString("A1B3C4D"), getParagraph(1)->getString());
}
-DECLARE_RTFIMPORT_TEST(testCustomDocProps, "custom-doc-props.rtf")
-{
- // Custom document properties were not improved, this resulted in a beans::UnknownPropertyException.
- uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();
- uno::Reference<beans::XPropertyContainer> xUserDefinedProperties = xDocumentProperties->getUserDefinedProperties();
- CPPUNIT_ASSERT_EQUAL(OUString("2016-03-08T10:55:18,531376147"), getProperty<OUString>(xUserDefinedProperties, "urn:bails:IntellectualProperty:Authorization:StartValidity"));
- CPPUNIT_ASSERT_EQUAL(OUString("None"), getProperty<OUString>(xUserDefinedProperties, "urn:bails:IntellectualProperty:Authorization:StopValidity"));
-}
-
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index 8292557..2c3c88b 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -474,6 +474,58 @@ void RtfExport::WriteInfo()
Strm().WriteChar('}');
}
+void RtfExport::WriteUserProps()
+{
+ Strm().WriteChar('{').WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_USERPROPS);
+
+ SwDocShell* pDocShell(m_pDoc->GetDocShell());
+ uno::Reference<document::XDocumentProperties> xDocProps;
+ if (pDocShell)
+ {
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(pDocShell->GetModel(), uno::UNO_QUERY);
+ xDocProps.set(xDPS->getDocumentProperties());
+ }
+
+ if (xDocProps.is())
+ {
+ // Handle user-defined properties.
+ uno::Reference<beans::XPropertyContainer> xUserDefinedProperties = xDocProps->getUserDefinedProperties();
+ if (xUserDefinedProperties.is())
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(xUserDefinedProperties, uno::UNO_QUERY);
+ uno::Sequence<beans::Property> aProperties = xPropertySet->getPropertySetInfo()->getProperties();
+
+ for (const beans::Property& rProperty : aProperties)
+ {
+ if (rProperty.Name.startsWith("Company"))
+ // We have explicit markup in RTF for this property.
+ continue;
+
+ // Property name.
+ Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_PROPNAME " ");
+ Strm().WriteCharPtr(msfilter::rtfutil::OutString(rProperty.Name, m_eDefaultEncoding).getStr());
+ Strm().WriteChar('}');
+
+ // Property value type.
+ OUString aValue;
+ if (xPropertySet->getPropertyValue(rProperty.Name) >>= aValue)
+ {
+ Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PROPTYPE);
+ OutULong(30);
+ }
+
+ // Property value.
+ Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_STATICVAL " ");
+ Strm().WriteCharPtr(msfilter::rtfutil::OutString(aValue, m_eDefaultEncoding).getStr());
+ Strm().WriteChar('}');
+ }
+ }
+
+ }
+
+ Strm().WriteChar('}');
+}
+
void RtfExport::WritePageDescTable()
{
// Write page descriptions (page styles)
@@ -535,6 +587,7 @@ void RtfExport::ExportDocument_Impl()
WriteRevTab();
WriteInfo();
+ WriteUserProps();
// Default TabSize
Strm().WriteCharPtr(m_pAttrOutput->m_aTabStop.makeStringAndClear().getStr()).WriteCharPtr(SAL_NEWLINE_STRING);
diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx
index 845dfc7..ecef9ee 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -204,6 +204,8 @@ private:
void WriteFootnoteSettings();
void WriteMainText();
void WriteInfo();
+ /// Writes the userprops group: user defined document properties.
+ void WriteUserProps();
/// Writes the writer-specific \pgdsctbl group.
void WritePageDescTable();
/// This is necessary to have the numbering table ready before the main text is being processed.
More information about the Libreoffice-commits
mailing list