Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _SVTOOLS_EMBEDHLP_HXX
21 : #define _SVTOOLS_EMBEDHLP_HXX
22 :
23 : #include "svtools/svtdllapi.h"
24 : #include <com/sun/star/uno/Reference.hxx>
25 : #include <com/sun/star/embed/XEmbeddedObject.hpp>
26 : #include <com/sun/star/embed/Aspects.hpp>
27 : #include <com/sun/star/io/XInputStream.hpp>
28 : #include <vcl/graph.hxx>
29 : #include <tools/mapunit.hxx>
30 : #include <rtl/ustring.hxx>
31 :
32 : namespace comphelper
33 : {
34 : class EmbeddedObjectContainer;
35 : }
36 :
37 : class Rectangle;
38 : class OutputDevice;
39 : class String;
40 : namespace svt
41 : {
42 : struct EmbeddedObjectRef_Impl;
43 : class SVT_DLLPUBLIC EmbeddedObjectRef
44 : {
45 : EmbeddedObjectRef_Impl* mpImp;
46 : ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject > mxObj;
47 :
48 : SVT_DLLPRIVATE SvStream* GetGraphicStream( sal_Bool bUpdate ) const;
49 : /* SVT_DLLPRIVATE */ void GetReplacement( sal_Bool bUpdate );
50 : SVT_DLLPRIVATE void Construct_Impl();
51 :
52 : EmbeddedObjectRef& operator = ( const EmbeddedObjectRef& );
53 :
54 : public:
55 3690 : const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& operator ->() const { return mxObj; }
56 6756 : const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& GetObject() const { return mxObj; }
57 :
58 : static void DrawPaintReplacement( const Rectangle &rRect, const String &rText, OutputDevice *pOut );
59 : static void DrawShading( const Rectangle &rRect, OutputDevice *pOut );
60 : static sal_Bool TryRunningState( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& );
61 : static void SetGraphicToContainer( const Graphic& rGraphic,
62 : comphelper::EmbeddedObjectContainer& aContainer,
63 : const ::rtl::OUString& aName,
64 : const ::rtl::OUString& aMediaType );
65 :
66 : static ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetGraphicReplacementStream(
67 : sal_Int64 nViewAspect,
68 : const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&,
69 : ::rtl::OUString* pMediaType )
70 : throw();
71 :
72 : // default constructed object; needs further assignment before it can be used
73 : EmbeddedObjectRef();
74 :
75 : // assign a previously default constructed object
76 : void Assign( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& xObj, sal_Int64 nAspect );
77 :
78 : // create object for a certain view aspect
79 : EmbeddedObjectRef( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& xObj, sal_Int64 nAspect );
80 :
81 : ~EmbeddedObjectRef();
82 : EmbeddedObjectRef( const EmbeddedObjectRef& );
83 :
84 : // assigning to a container enables the object to exchange graphical representations with a storage
85 : void AssignToContainer( comphelper::EmbeddedObjectContainer* pContainer, const ::rtl::OUString& rPersistName );
86 : comphelper::EmbeddedObjectContainer* GetContainer() const;
87 :
88 : sal_Int64 GetViewAspect() const;
89 : void SetViewAspect( sal_Int64 nAspect );
90 : Graphic* GetGraphic( ::rtl::OUString* pMediaType=0 ) const;
91 :
92 : // the original size of the object ( size of the icon for iconified object )
93 : // no conversion is done if no target mode is provided
94 : Size GetSize( MapMode* pTargetMapMode = NULL ) const;
95 :
96 : void SetGraphic( const Graphic& rGraphic, const ::rtl::OUString& rMediaType );
97 : void SetGraphicStream(
98 : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInGrStream,
99 : const ::rtl::OUString& rMediaType );
100 :
101 2288 : void UpdateReplacement() { GetReplacement( sal_True ); }
102 : void UpdateReplacementOnDemand();
103 : void Lock( sal_Bool bLock = sal_True );
104 : sal_Bool IsLocked() const;
105 : void Clear();
106 3742 : sal_Bool is() const { return mxObj.is(); }
107 :
108 : sal_Bool IsChart() const;
109 :
110 : // #i104867#
111 : // Provides a graphic version number for the fetchable Graphic during this object's lifetime. Internally,
112 : // that number is incremented at each change of the Graphic. This mechanism is needed to identify if a
113 : // remembered Graphic (e.g. primitives) has changed compared to the current one, but without actively
114 : // fetching the Graphic what would be too expensive e.g. for charts
115 : sal_uInt32 getGraphicVersion() const;
116 : void SetDefaultSizeForChart( const Size& rSizeIn_100TH_MM );//#i103460# charts do not necessaryly have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this method
117 : };
118 : }
119 :
120 : #endif
121 :
122 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|