diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-08-23 17:46:30 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-08-25 15:31:15 +0200 |
commit | 9b40796fd3e8f724d69a343e0444220b69a6d6ab (patch) | |
tree | 777eeff0e42ce26e6011cf01c014dcba144f29cc /include | |
parent | 8170245a9d9b9aeff913e0b3477fc2a9d508af80 (diff) |
tdf#50097: DOCX: export form controls as MSO ActiveX controls
* Use the same structure for export what MSO uses
** Position and size information are exported as VML shape properties
** Different handling of inline and floating controls (pict or object)
** Do some changes on VML shape export to match how MSO exports these controls
** Write out activeX.xml and activeX.bin to store control properties
** Use persistStorage storage type defined in activeX.xml
* Drop grabbaging of activex.XML and activeX.bin
* Cleanup control related test code
Signed-off-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/41256
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit c0cc02e2934aeb12dda44818955e5964496c186a)
Change-Id: I38bb2b2ffd2676c5459b61ec2549c31348bab41c
This test intended to be an export test
Change-Id: Ib233bd603185efdb85ed30f3d00c28512d57a0ac
Reviewed-on: https://gerrit.libreoffice.org/41355
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit a7e8c5304b740cb4e03e25b7217ce6071c29c09b)
Fix two issues in ActiveX DOCX import / export code
* Inline anchored VML shape had wrong vertical position
** In MSO inline shapes are positioned to the top of the baseline
* During export all shape ids were the same (shape_0)
** VML shapes used to be exported only as fallback,
I guess that's why it did not cause any issue before.
** Override the shapeid generator with a new one, which
actually generates unique shapeids.
Reviewed-on: https://gerrit.libreoffice.org/41319
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit 2d1fe7fb67ec1ff1b96912c0945d17d54aecb12e)
Change-Id: I752f39d092d0b61d91824141655dae662dbeafbc
DOCX: Fix an other test case of ActiveX control export
When LO control is anchored to the end of the run, it
is exported into a new run.
Reviewed-on: https://gerrit.libreoffice.org/41472
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit b129421764ae78a1422812169fce8eb4914a6b22)
Change-Id: I9269fd1b34924780aad61c452d1e2094dc8e4aad
Reviewed-on: https://gerrit.libreoffice.org/41484
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/filter/msfilter/escherex.hxx | 3 | ||||
-rw-r--r-- | include/oox/export/vmlexport.hxx | 35 | ||||
-rw-r--r-- | include/oox/ole/olehelper.hxx | 35 |
3 files changed, 69 insertions, 4 deletions
diff --git a/include/filter/msfilter/escherex.hxx b/include/filter/msfilter/escherex.hxx index 746bb2a6d5e0..7948716a67fc 100644 --- a/include/filter/msfilter/escherex.hxx +++ b/include/filter/msfilter/escherex.hxx @@ -1048,7 +1048,8 @@ public: /** Creates and returns a new shape identifier, updates the internal shape counters and registers the identifier in the DGG cluster table. */ - inline sal_uInt32 GenerateShapeId() { return mxGlobal->GenerateShapeId( mnCurrentDg, mbEscherSpgr ); } + virtual sal_uInt32 GenerateShapeId() { return mxGlobal->GenerateShapeId( mnCurrentDg, mbEscherSpgr ); } + /** Returns the graphic provider from the global object that has been passed to the constructor. diff --git a/include/oox/export/vmlexport.hxx b/include/oox/export/vmlexport.hxx index e9971e0c685a..6ef32469e2af 100644 --- a/include/oox/export/vmlexport.hxx +++ b/include/oox/export/vmlexport.hxx @@ -82,6 +82,7 @@ class OOX_DLLPUBLIC VMLExport : public EscherEx /// Anchoring. sal_Int16 m_eHOri, m_eVOri, m_eHRel, m_eVRel; + bool m_bInline; // css::text::TextContentAnchorType_AS_CHARACTER /// Parent position. const Point* m_pNdTopLeft; @@ -101,11 +102,31 @@ class OOX_DLLPUBLIC VMLExport : public EscherEx /// Remember style, the most important shape attribute ;-) OStringBuffer *m_pShapeStyle; + /// Remember the generated shape id. + OString m_sShapeId; + /// Remember which shape types we had already written. bool *m_pShapeTypeWritten; + /// It seems useless to write out an XML_ID attribute next to XML_id which defines the actual shape id + bool m_bSkipwzName; + + /// Use '#' mark for type attribute (check Type Attribute of VML shape in OOXML documentation) + bool m_bUseHashMarkForType; + + /** There is a shapeid generation mechanism in EscherEx, but it does not seem to work + * so override the existing behavior to get actually unique ids. + */ + bool m_bOverrideShapeIdGeneration; + + /// Prefix for overriden shape id generation (used if m_bOverrideShapeIdGeneration is true) + OString m_sShapeIDPrefix; + + /// Counter for generating shape ids (used if m_bOverrideShapeIdGeneration is true) + sal_uInt64 m_nShapeIDCounter; + public: - VMLExport( ::sax_fastparser::FSHelperPtr const & pSerializer, VMLTextExport* pTextExport = nullptr ); + VMLExport( ::sax_fastparser::FSHelperPtr const & pSerializer, VMLTextExport* pTextExport = nullptr); virtual ~VMLExport() override; const ::sax_fastparser::FSHelperPtr& @@ -116,11 +137,16 @@ public: /// Export the sdr object as VML. /// /// Call this when you need to export the object as VML. - void AddSdrObject( const SdrObject& rObj, sal_Int16 eHOri = -1, + OString AddSdrObject( const SdrObject& rObj, sal_Int16 eHOri = -1, sal_Int16 eVOri = -1, sal_Int16 eHRel = -1, sal_Int16 eVRel = -1, const Point* pNdTopLeft = nullptr, const bool bOOxmlExport = false ); + OString AddInlineSdrObject( const SdrObject& rObj, const bool bOOxmlExport = false ); virtual void AddSdrObjectVMLObject( const SdrObject& rObj) override; static bool IsWaterMarkShape(const OUString& rStr); + + void SetSkipwzName(bool bSkipwzName) { m_bSkipwzName = bSkipwzName; } + void SetHashMarkForType(bool bUseHashMarkForType) { m_bUseHashMarkForType = bUseHashMarkForType; } + void OverrideShapeIDGen(bool bOverrideShapeIdGeneration, const OString sShapeIDPrefix = OString()); protected: /// Add an attribute to the generated <v:shape/> element. /// @@ -131,6 +157,9 @@ protected: using EscherEx::StartShape; using EscherEx::EndShape; + /// Override shape ID generation when m_bOverrideShapeIdGeneration is set to true + virtual sal_uInt32 GenerateShapeId() override; + /// Start the shape for which we just collected the information. /// /// Returns the element's tag number, -1 means we wrote nothing. @@ -154,7 +183,7 @@ private: private: /// Create an OString representing the id from a numerical id. - static OString ShapeIdString( sal_uInt32 nId ); + OString ShapeIdString( sal_uInt32 nId ); /// Add flip X and\or flip Y void AddFlipXY( ); diff --git a/include/oox/ole/olehelper.hxx b/include/oox/ole/olehelper.hxx index 4e2a2d8e62fc..dbbf1a110d1a 100644 --- a/include/oox/ole/olehelper.hxx +++ b/include/oox/ole/olehelper.hxx @@ -29,6 +29,7 @@ #include <rtl/ustring.hxx> #include <sal/types.h> #include <tools/ref.hxx> +#include <memory> namespace com { namespace sun { namespace star { namespace awt { class XControlModel; } @@ -52,6 +53,8 @@ namespace oox { namespace ole { + class ControlModelBase; + class EmbeddedControl; #define OLE_GUID_STDFONT "{0BE35203-8F91-11CE-9DE3-00AA004BB851}" @@ -134,6 +137,38 @@ namespace OleHelper bool bWithGuid ); } +class OOX_DLLPUBLIC OleFormCtrlExportHelper final +{ + std::unique_ptr<::oox::ole::EmbeddedControl> mpControl; + ::oox::ole::ControlModelBase* mpModel; + ::oox::GraphicHelper maGrfHelper; + css::uno::Reference< css::frame::XModel > mxDocModel; + css::uno::Reference< css::awt::XControlModel > mxControlModel; + + OUString maName; + OUString maTypeName; + OUString maFullName; + OUString maGUID; +public: + OleFormCtrlExportHelper( const css::uno::Reference< css::uno::XComponentContext >& rxCtx, const css::uno::Reference< css::frame::XModel >& xDocModel, const css::uno::Reference< css::awt::XControlModel >& xModel ); + ~OleFormCtrlExportHelper(); + + OUString getGUID() + { + OUString sResult; + if ( maGUID.getLength() > 2 ) + sResult = maGUID.copy(1, maGUID.getLength() - 2 ); + return sResult; + } + const OUString& getFullName() { return maFullName; } + const OUString& getTypeName() { return maTypeName; } + const OUString& getName() { return maName; } + bool isValid() { return mpModel != nullptr; } + void exportName( const css::uno::Reference< css::io::XOutputStream >& rxOut ); + void exportCompObj( const css::uno::Reference< css::io::XOutputStream >& rxOut ); + void exportControl( const css::uno::Reference< css::io::XOutputStream >& rxOut, const css::awt::Size& rSize, bool bAutoClose = false ); +}; + // ideally it would be great to get rid of SvxMSConvertOCXControls // however msfilter/source/msfilter/svdfppt.cxx still uses // SvxMSConvertOCXControls as a base class, unfortunately oox depends on |