summaryrefslogtreecommitdiff
path: root/include/comphelper/embeddedobjectcontainer.hxx
blob: af548adbb578120759ddcc04e3c4eaa91e330024 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#ifndef INCLUDED_COMPHELPER_EMBEDDEDOBJECTCONTAINER_HXX
#define INCLUDED_COMPHELPER_EMBEDDEDOBJECTCONTAINER_HXX

#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <comphelper/comphelperdllapi.h>

#include <rtl/ustring.hxx>
#include <memory>

namespace comphelper
{
    class EmbeddedObjectContainer;
    /** Helper interface to give access to some common object which replace the SfxObjectShell
    */
    class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI IEmbeddedHelper
    {
    public:
        virtual EmbeddedObjectContainer& getEmbeddedObjectContainer() const = 0;
        virtual css::uno::Reference < css::embed::XStorage > getStorage() const = 0;
        virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const = 0;
        virtual bool isEnableSetModified() const = 0;
        virtual OUString getDocumentBaseURL() const = 0;

    protected:
        ~IEmbeddedHelper() {}
    };

struct EmbedImpl;
class COMPHELPER_DLLPUBLIC EmbeddedObjectContainer
{
    std::unique_ptr<EmbedImpl>  pImpl;

    css::uno::Reference < css::embed::XEmbeddedObject > Get_Impl( const OUString&,
            const css::uno::Reference < css::embed::XEmbeddedObject >& xCopy,
            OUString const* pBaseURL);

public:
    // add an embedded object to the container storage
    bool StoreEmbeddedObject(
        const css::uno::Reference<css::embed::XEmbeddedObject>& xObj, OUString& rName, bool bCopy,
        const OUString& rSrcShellID, const OUString& rDestShellID );

    // add an embedded object that has been imported from the container storage - should only be called by filters!
    void                AddEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, const OUString& );

                        EmbeddedObjectContainer();
                        EmbeddedObjectContainer( const css::uno::Reference < css::embed::XStorage >& );
                        EmbeddedObjectContainer( const css::uno::Reference < css::embed::XStorage >&,
                                                 const css::uno::Reference < css::uno::XInterface >& );
                        ~EmbeddedObjectContainer();

    void                SwitchPersistence( const css::uno::Reference < css::embed::XStorage >& );
    bool                CommitImageSubStorage();
    void                ReleaseImageSubStorage();

    OUString     CreateUniqueObjectName();

    // get a list of object names that have been added so far
    css::uno::Sequence < OUString > GetObjectNames();

    // check for existence of objects at all
    bool            HasEmbeddedObjects();

    // check existence of an object - either by identity or by name
    bool            HasEmbeddedObject( const OUString& );
    bool            HasEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >& );
    bool            HasInstantiatedEmbeddedObject( const OUString& );

    // get the object name of an object - this is the persist name if the object has persistence
    OUString        GetEmbeddedObjectName( const css::uno::Reference < css::embed::XEmbeddedObject >& );

    // retrieve an embedded object by name that either has been added already or is available in the container storage
    css::uno::Reference<css::embed::XEmbeddedObject> GetEmbeddedObject(const OUString&, OUString const* pBaseURL = nullptr);

    // create an object from a ClassId
    css::uno::Reference < css::embed::XEmbeddedObject >
                        CreateEmbeddedObject( const css::uno::Sequence < sal_Int8 >&, OUString&,
                                              OUString const* pBaseURL = nullptr );

    css::uno::Reference < css::embed::XEmbeddedObject >
                        CreateEmbeddedObject( const css::uno::Sequence < sal_Int8 >&,
                        const css::uno::Sequence < css::beans::PropertyValue >&, OUString&,
                        OUString const* pBaseURL = nullptr );

    // insert an embedded object into the container - objects persistent representation will be added to the storage
    bool            InsertEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, OUString& );

    // load an embedded object from a MediaDescriptor and insert it into the container
    // a new object will be created from the new content and returned
    css::uno::Reference < css::embed::XEmbeddedObject >
                        InsertEmbeddedObject( const css::uno::Sequence < css::beans::PropertyValue >&, OUString& rName, OUString const* pBaseURL = nullptr);

    // create an embedded link based on a MediaDescriptor and insert it into the container
    // a new object will be created from the new content and returned
    css::uno::Reference < css::embed::XEmbeddedObject >
                        InsertEmbeddedLink( const css::uno::Sequence < css::beans::PropertyValue >&, OUString& );

    // create an object from a stream that contains its persistent representation and insert it as usual (usually called from clipboard)
    // a new object will be created from the new content and returned
    css::uno::Reference < css::embed::XEmbeddedObject >
                        InsertEmbeddedObject( const css::uno::Reference < css::io::XInputStream >&, OUString& );

    // copy an embedded object into the storage, open the new copy and return it
    css::uno::Reference <css::embed::XEmbeddedObject> CopyAndGetEmbeddedObject(
        EmbeddedObjectContainer& rSrc, const css::uno::Reference <css::embed::XEmbeddedObject>& xObj, OUString& rName,
        const OUString& rSrcShellID, const OUString& rDestShellID );

    // move an embedded object from one container to another one
    bool MoveEmbeddedObject( EmbeddedObjectContainer& rSrc, const css::uno::Reference < css::embed::XEmbeddedObject >&, OUString& );

    // remove an embedded object from the container and from the storage; if object can't be closed
    // #i119941, bKeepToTempStorage: use to specify whether store the removed object to temporary storage+
    bool            RemoveEmbeddedObject( const OUString& rName, bool bKeepToTempStorage = true);
    bool            RemoveEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, bool bKeepToTempStorage = true);

    // close and remove an embedded object from the container without removing it from the storage
    bool            CloseEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >& );

    // move an embedded object to another container (keep the persistent name)
    bool            MoveEmbeddedObject( const OUString& rName, EmbeddedObjectContainer& );

    // get the stored graphical representation for the object
    css::uno::Reference < css::io::XInputStream > GetGraphicStream( const css::uno::Reference < css::embed::XEmbeddedObject >&, OUString* pMediaType=nullptr );

    // get the stored graphical representation by the object name
    css::uno::Reference < css::io::XInputStream > GetGraphicStream( const OUString& aName, OUString* pMediaType=nullptr );

    // add a graphical representation for an object
    bool            InsertGraphicStream( const css::uno::Reference < css::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& rMediaType );

    // try to add a graphical representation for an object in optimized way ( might fail )
    bool            InsertGraphicStreamDirectly( const css::uno::Reference < css::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& rMediaType );

    // remove a graphical representation for an object
    bool            RemoveGraphicStream( const OUString& rObjectName );

    // copy the graphical representation from different container
    bool            TryToCopyGraphReplacement( EmbeddedObjectContainer& rSrc,
                                                    const OUString& aOrigName,
                                                    const OUString& aTargetName );

    void            CloseEmbeddedObjects();
    bool            StoreChildren(bool _bOasisFormat,bool _bObjectsOnly);
    bool            StoreAsChildren( bool _bOasisFormat
                                        ,bool _bCreateEmbedded
                                        ,const css::uno::Reference < css::embed::XStorage >& _xStorage);

    static css::uno::Reference< css::io::XInputStream > GetGraphicReplacementStream(
                                            sal_Int64 nViewAspect,
                                            const css::uno::Reference < css::embed::XEmbeddedObject >&,
                                            OUString* pMediaType );

    /** call setPersistentEntry for each embedded object in the container
    *
    * \param _xStorage The storage where to store the objects.
    * \param _bClearModifedFlag If <TRUE/> then the modified flag will be set to <FALSE/> otherwise nothing happen.
    * \return <FALSE/> if no error occurred, otherwise <TRUE/>.
    */
    bool             SetPersistentEntries(const css::uno::Reference< css::embed::XStorage >& _xStorage,bool _bClearModifedFlag = true);

    bool getUserAllowsLinkUpdate() const;
    void setUserAllowsLinkUpdate(bool bNew);
};

}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
pan>Armin Le Grand Also simplify parent/child relationships, get rid of double data (SdrPage/Parent infos in SdrObjects, also in SdrObjList). This is all not needed - when a SdrObject is inserted to a SdrPage, get SdrPage by traveling over parents (no double info, member as soon as inserted, ...). More cleanups/reworks included, will need some more cleanups, too. Stabilizing: SetRectsDirty/DefaultStyleSheet Had to correct the SetRectsDirty stuff for 3D due to going down the hierarchy while the 2D implementation goes the other direction -> endless loops. Added special handling for 3D stuff for now (will be chnaged again when SnapRect is no longer needed at SdrObject level). Also had to adapt how the DefaultStyleSheet is set at incarnated SdrObjects - better: their properties. Since we now always have a SdrModel, it is possible to correctly initialize with the correct default StyleSheet from that SdrModel. This needs to be done after ForceDefaultAttributes and in a way that again deletes Items that are set in the StyleSheet. This leads to an error in CppunitTest_sd_import_tests where I checked tdf100491 - it is okay and thus I change the control instance of the imported, XML-dumped file. The less hard attributes, the better for Styles in general. Cleanup of comments for last two commits Corrected SvxShape::getParent() Needed to get the direct parent, so test for SdrObject first (to get SdrObjGroup/E3DScene), for SdrPage second Fixed CppunitTest_sc_subsequent_export_test Several problems arose. The used SdrCaptionObj was Cloned, but the clone not inserted to a SdrPage. This leads to not being able to access a UNO API imlementation of the SdrPage (SvxPage) on lower levels. It worked before due to SdrObject having a SdrPage* additionally to being added to a SdrPage - this is exactly the main cleanup this change does. Looked for why it is cloned, could see no reasons. The SdrCaptionObj exists during all im/export, not difference to other SdrObjects (that do not get cloned). It is not changed in any way. It *might* be to suppress a crash that happened due to UNO API Service emfio/emfio not being available in the UnitTest scenario. Interestingly it did not crash with the cloned SdrCaptionObj, but the Graphic exported was probably wrong. Fixed by no longer Cloning the SdrCaptionObj and adding emfio/emfio UNO API Service. d139f821a5b39535a3e7b9c6261df7e18f8ae8ac 910e7f4bc628a715fda7545dffaf3369d5e76ea0 ca1de01b723051e09ac37d7ec7bba978beea41c5 3a76da1471dfe75e69847f64a6a3519ad21c8c9c Change-Id: I986586e326b563acebf00d931a7084c6eb09e5f8 Reviewed-on: https://gerrit.libreoffice.org/54689 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de> 2018-03-07uitest: fix small bug when trying to select different sheet in calcMarkus Mohrhard Change-Id: I83e2b8dc1b0da9f28475994493e3776c898a5729 Reviewed-on: https://gerrit.libreoffice.org/50853 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> 2017-10-23loplugin:includeform: scStephan Bergmann Change-Id: I2ed763e0584a188032c80fde60890de3c6985cbd 2017-09-22Bin leftover SAL_DEBUGTor Lillqvist Change-Id: I452909cc1f0529ecb24b1f705a86a0a8bc1a3c9f 2017-06-05clang-tidy performance-unnecessary-value-paramNoel Grandin Change-Id: I6ed8c54c7c45931d91709cc818f2483c70197192 Reviewed-on: https://gerrit.libreoffice.org/38400 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2017-04-25tools: svstream.hxx needs only errcode.hxx & not errinf.hxxChris Sherlock Change-Id: Ia28e35ae5af4f601e9a586a3deffbcd61702b0ca Reviewed-on: https://gerrit.libreoffice.org/36896 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com> 2017-04-09uitest: add state about currently visible rangeMarkus Mohrhard Change-Id: Ie07ef2379086f84f9596771bc91683fa3e9bcd32 Reviewed-on: https://gerrit.libreoffice.org/36304 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> 2017-03-26uitest: add ability to open autofilter dialogMarkus Mohrhard Change-Id: If03b2699975756ab650488abe032aefa8880a6b4 Reviewed-on: https://gerrit.libreoffice.org/35692 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com> 2016-12-21uitest: add selected area to gridwin stateMarkus Mohrhard Change-Id: I27e17640cc426dc3a63c605e6a294c3f90f5350c Reviewed-on: https://gerrit.libreoffice.org/32279 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> 2016-08-23convert SdrIterMode to scoped enumNoel Grandin Change-Id: Iaa4631039e6b96627d8e547f21136f107e157d8a 2016-07-19clang-tidy performance-unnecessary-value-param in scStephan Bergmann Change-Id: I1941c050a385e3a1020c5d2495471f5805c4c180 2016-06-18uitest: loplugin:stringconstantMarkus Mohrhard Change-Id: Ib63a978bd488f41602d982789699ba3f3ca2dcf0 2016-06-18uitest: add way to deselect OLE objectMarkus Mohrhard Change-Id: I34515de0b149147e40c23df6fef1339d0b69d469 2016-06-18uitest: allow activating OLE objectsMarkus Mohrhard Change-Id: I960f5d644afb9392f8b3fe1d2f393c499af57bdb 2016-06-18uitest: allow to select charts in calcMarkus Mohrhard Change-Id: I7fd899d7abda968e9c849e46714208a650b3cfdb 2016-06-18uitest: provide charts as children of calc's grid windowMarkus Mohrhard 2016-06-18uitest: allow selecting different tabs in gridwinMarkus Mohrhard Change-Id: Id8104eac183b4f7129d7f23092c52b58376ed492 2016-06-18uitest: warn when we can not handle the select typeMarkus Mohrhard Change-Id: I7c3055f84edd2bbab0799cf2c61269355ba82055 2016-06-18uitest: provide some more state information about gridwinMarkus Mohrhard Change-Id: Ic5c481c7d7f84b7e6a155d2b3b2c427349b1db9d 2016-06-18uitest: support extending the select cell rangeMarkus Mohrhard Change-Id: Ia3093e06cc2168f415bd8477b57a57e0fe897e4d 2016-06-18uitest: add wrapper for calc's gridwindowMarkus Mohrhard It already supports selecting cell ranges. Change-Id: I8c3e4a42dea8956e2429b82b50ff8506c1774bbb